Still stuck with this issue. Can someone offer guidance on what can I look into to understand the issue at hand?
Still stuck with this issue. Can someone offer guidance on what can I look into to understand the issue at hand?
Why are you setting price to bid every time?
Should you not select bid or ask depending one whether it is a sell or buy?
if(OrderSelect(ticket)== false) continue; if(OrderGetInteger(ORDER_MAGIC)!=EAmagic) continue;
Where do you filter on symbols?
Only if you use a unique Magic for each symbol.
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/symbol 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 (2013)
PositionClose is not working - MQL5 programming forum (2020)
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles (2011)
Limit one open buy/sell position at a time - General - MQL5 programming forum (2022)
You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.
Only if you use a unique Magic for each symbol.
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/symbol 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 (2013)
PositionClose is not working - MQL5 programming forum (2020)
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles (2006)
Orders, Positions and Deals in MetaTrader 5 - MQL5 Articles (2011)
Limit one open buy/sell position at a time - General - MQL5 programming forum (2022)
You need one Magic Number for each symbol/timeframe/strategy. Trade current timeframe, one strategy, and filter by symbol requires one MN.
Well its for the OP to say whether its a unique magic ID per symbol or not
- Tobias Johannes Zimmer #: Shouldn't it be if order select == true continue ?
No. If you succeed in selecting the order, you want to process it. If you do not select the order, you want to continue to the next index. I prefer positive logic only:
uLong ticket; for(int orderIndex = 0; orderIndex < OrdersTotal(); orderIndex++) if( OrderSelect( ticket=OrderGetTicket(orderIndex) ) && OrderGetInteger(ORDER_MAGIC)==EAmagic // && symbol match, etc. ){ // Process
-
if(OrderSelect(ticket)== false) continue;
You should be able to read your code out loud and have it make sense. You would never write if( (2+2 == 4) == true) would you? if(2+2 == 4) is sufficient. So don't write if(bool == true), just use if(bool) or if(!bool). Code becomes self documenting when you use meaningful variable names, like bool isLongEnabled where as Long_Entry sounds like a trigger price or a ticket number and “if long entry” is an incomplete sentence.

- 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 all.
I have been working on a function that acts on the pending orders inside a multi symbol EA. When I run the code it works great if I use only 1 pair but when I enable multi symbol it only acts on the latest opened pending Order.
I tried using m_order.select from COrderInfo and directly OrderSelect(ticket) and both show same behaviour - only works on latest.
Please help!