if(OrderSymbol()==0||OrderSymbol()==1) break;
??????
OrderSymbol() is a string.
DOHHHHHH
Thanks Keith, it must be the quarantine;)
I have tried this and unfortunately it still does not work 100%
It returns me the GBPCAD order highlighted when I am expecting the last USDCHF
Any reasons?
for (int Counter=OrdersTotal()-1; Counter >= 0; Counter--) { OrderSelect(Counter, SELECT_BY_POS,MODE_TRADES); if(OrderType()==0||OrderType()==1) break; } string LastLiveOrd=OrderComment(); datetime LastDateLive=OrderOpenTime();
MacGiamma:
I have tried this and unfortunately it still does not work 100%
It returns me the GBPCAD order highlighted when I am expecting the last USDCHF
Any reasons?
When you return the list of orders, there's no guarantee of chronological order, so you need to confirm it yourself?
Something like this...
datetime lastorder=0; for(int i=0;i<OrdersTotal();i++) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderOpenTime()>lastorder) lastorder=OrderOpenTime();
It works like a charm!!!
Tx Andrew
MacGiamma: It works like a charm!!!
Magic number only allows an EA to identify its trades from all others. Using OrdersTotal/OrdersHistoryTotal
(MT4) or PositionsTotal (MT5), directly and/or no Magic number filtering on your OrderSelect /
Position select loop means your code is incompatible with every EA (including itself on other charts and manual trading.) Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 programming forum
PositionClose is not working - MQL5 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
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 Everybody,
I am trying to retrieve the details of the last open order (i.e. not pending) , but the code below does not seem to work.
Any hints?
Thanks
MG