Try this. Apologies - for some reason SRC button seems not to be working for me just now.
int myLosingOrders = 0;
int fnLosingOrdersCheck()
{
iOrders = OrdersHistoryTotal()-1;
for (i = iOrders; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if (OrderSymbol() == Symbol()
&& OrderMagicNumber() == myMagicNumber
&& TimeDayOfYear(OrderOpenTime()) == DayOfYear()
&& TimeYear(OrderOpenTime()) == Year()
&& OrderProfit() < 0)
{
myLosingOrders++;
}
}
return(myLosingOrders);
}
CB
Try this. Apologies - for some reason SRC button seems not to be working for me just now.
int myLosingOrders = 0;
int fnLosingOrdersCheck()
{
iOrders = OrdersHistoryTotal()-1;
for (i = iOrders; i>=0; i--)
{
OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
if (OrderSymbol() == Symbol()
&& OrderMagicNumber() == myMagicNumber
&& TimeDayOfYear(OrderOpenTime()) == DayOfYear()
&& TimeYear(OrderOpenTime()) == Year()
&& OrderProfit() < 0)
{
myLosingOrders++;
}
}
return(myLosingOrders);
}
CB
Thanks
Works perfectly!!
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I would like my EA to count the loosing trades from my trade history based on magic number and date. I can then have the EA stop trading for the remainder of the session when some number of loosing trades is reached.
Basically if someone can show me a code snippet that would return a aggregate count of the loosing trades based on magic number and date I would be elated.
Thanks
Will