This is sample code only, but does what you need. There are several ways to do this, but here is probably the easiest.
Try adding magic numbers to your trading EA, and call last closed trade in trade history.
closedProfit will return if last order was +profit or -profit.
double mymagicnumber = 55;
double closedProfit = 0;
int hstTotal = OrdersHistoryTotal();
for(i=0;i<hstTotal;i++)
{ OrderSelect(i, SELECT_BY_POS, MODE_HISTORY );
if ( OrderSymbol()==Symbol() && ( (OrderMagicNumber() == mymagicnumber)))
{closedProfit = closedProfit + OrderProfit();
}
}
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi!I've been learning meta 4 language and i'd like to know if there's a quick way for the program check if the last order was a winning order or not?
can any one help me please?
thank you