Salam Mohsen ...
This is my own function, I used it in one of my EAs successfully ...
void LastClosedTrade(){ int cnt, total; total = OrdersHistoryTotal(); for(cnt=0;cnt<total; cnt++){ if(OrderSelect(cnt,SELECT_BY_POS,MODE_HISTORY)==true) if(OrderSymbol()==Symbol() && OrderMagicNumber()==MagicNumber && OrderProfit()!=0){ LastOrderType = OrderType(); LastOrderLots = OrderLots(); LastOrderProfit = OrderProfit(); LastOrderStopLoss = OrderStopLoss(); LastOrderTakeProfit = OrderTakeProfit(); } } }
It gives you the following ...
LastOrderType, LastOrderLots, LastOrderProfit, LastOrderStopLoss and LastOrderTakeProfit.
You can cancel any of those who you don't need but remember, you have to declare these variables globally (before start function).
Salam Mohsen ...
This is my own function, I used it in one of my EAs successfully ...
It gives you the following ...
LastOrderType, LastOrderLots, LastOrderProfit, LastOrderStopLoss and LastOrderTakeProfit.
You can cancel any of those who you don't need but remember, you have to declare these variables globally (before start function).
I found this helpful.
Thanks.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi
How can i get profit of last deal?