datetime last=0; int retval; for(int i = 0; i <= OrdersTotal(); i++) { OrderSelect(i, SELECT_BY_POS, MODE_HISTORY); if(OrderMagicNumber() == MagicNumber && OrderSymbol() == Symbol()) { // ????? if(OrderCloseTime()>last){ last=OrderCloseTime(); retval=OrderTicket(); } } }//z
I corrected my code snippet, glad you understood it. FYI, the OrdersTotal should be changed to OrdersHistoryTotal for those who wish to use this code.
thank you for the help here. I will put it to good use ;-)
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
I know I have asked this before, but I could not find it in my past threads. I also did a search for something like it and could not find a reference.
I know that I need to basically do a command where I do something like the following:
In the section where the ??? are, what do I need to be able to get the most recently closed trade?
My idea is to use the above code to first maintain a count value of closed trades (this part I can handle). If the count is different then I want to use the above code to figure out which trade closed (this is the part I need help with). This way I can grab the ticket number of the most recently closed trade.