I coded this function several years ago ... It worked perfect for me to detect last closed trade (History) in case the profit was in loss ...
You can change it according to your needs. You just need to do minor changes ...
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()==MagicNo && OrderProfit()!=0){ LastOrderType = OrderType(); LastOrderLots = OrderLots(); LastOrderProfit = 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 All,
Could anybody give me an idea about
how to detect the last running transaction order status
whether it is still running or has been closed(because it reach the TP or SL) ?
where will i start from to reach this result ?
Many thanks in advance.
my apologize for my bad english. :)