Depends on the language used, depends on type of account used.
You specified: None.
mql4. Live account.
Then it's
OrdersTotal();
that still does not answer the question on how to select open positions and not open orders
- MT4 only has orders. It has no concept of positions.
-
Using OrdersTotal directly and/or no Magic number filtering on your
OrderSelect 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 and MetaTrader 4 - MQL4 programming forum
MagicNumber: "Magic" Identifier of the Order - MQL4 Articles
I want to loop over the open positions in my account and not the open orders
for(int i=OrdersTotal()-1; i>=0; i--) if(OrderSelect(i,SELECT_BY_POS) && OrderType()<2)
nicholi shen:
sorry, that did not cut it either.
Show your code.
There is only one OrderSelect() and one OrdersTotal() in MQL4.
In MQL4 only OrdersTotal
for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS)) continue; if(OrderType() != ORDER_TYPE_BUY_LIMIT && OrderType() != ORDER_TYPE_BUY_STOP && OrderType() != ORDER_TYPE_SELL_LIMIT && OrderType() != ORDER_TYPE_SELL_STOP) continue; /* work */ }And check in search
Konstantin Nikitin:
In MQL4 only OrdersTotal
for(int i=OrdersTotal()-1; i>=0; i--) { if(!OrderSelect(i,SELECT_BY_POS)) continue; if(OrderType() != ORDER_TYPE_BUY_LIMIT && OrderType() != ORDER_TYPE_BUY_STOP && OrderType() != ORDER_TYPE_SELL_LIMIT && OrderType() != ORDER_TYPE_SELL_STOP) continue; /* work */ }
And check in search
This will not execute
/*work*/
if the order is OP_BUY or OP_SELL
Is that what you intended?
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
I want to loop over the open positions in my account and not the open orders. How is that done as
OrdersTotal()
gives the total number of working orders plus the open positions.
Thanks