Skip to content

Instantly share code, notes, and snippets.

@mamirjamali
Created January 4, 2023 09:03
Show Gist options
  • Save mamirjamali/57839555c122c04347dc4cf255c63f61 to your computer and use it in GitHub Desktop.
Save mamirjamali/57839555c122c04347dc4cf255c63f61 to your computer and use it in GitHub Desktop.
Stop EA based on daily profit
double DailyProfit()
{
double profit = 0;
int i, hstTotal = OrdersHistoryTotal();
for (i = 0; i < hstTotal; i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) == TRUE)
{
if (OrderType() > 1)
continue;
if (TimeToStr(TimeCurrent(), TIME_DATE) == TimeToStr(OrderCloseTime(), TIME_DATE))
{
profit += OrderProfit() + OrderSwap() + OrderCommission();
}
}
}
return (profit);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment