Hi
I would like to call a function that will only run if there is no open market orders.
It is OK if there are pending orders open but I do not want to call my function if there are any open in the market orders.
How can I check if there are open/none in the market orders?
OrdersTotal() returns market and pending orders, but I only want to know if there are any market orders open. Thx in advance
Sorry for the bother I think I worked it out
bool GetAnyOpenMarketOrders() { bool openMarketOrderFound = false; for(int i = OrdersTotal() -1; i >= 0; i--) { if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES) == true) if((OrderType() == OP_BUY) || (OrderType() == OP_SELL)) openMarketOrderFound = true; } return(openMarketOrderFound); }
Sorry for the bother I think I worked it out
Congratulations. However I suggest you to check the used symbol (if you run your ea on several symbols) and also eventually the magic number (if you run more than one EA on a symbol).
Oops, yes sorry & thx will do next time.
Yes of course, only left it very simple to get it working then add all the appropriate checks.
Hi
I would like to call a function that will only run if there is no open market orders.
It is OK if there are pending orders open but I do not want to call my function if there are any open in the market orders.
How can I check if there are open/none in the market orders?
OrdersTotal() returns market and pending orders, but I only want to know if there are any market orders open. Thx in advance
A solution can be...
//---------------------------------- EXISTEN POSICIONES ABIERTAS ------------------------------ bool existePosicAbierta(string simb= NULL) { bool resp= false; resp= simb==NULL? PositionsTotal()>0: PositionSelect(simb); return(resp); }
A solution can be...
- 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
I would like to call a function that will only run if there is no open market orders.
It is OK if there are pending orders open but I do not want to call my function if there are any open in the market orders.
How can I check if there are open/none in the market orders?
OrdersTotal() returns market and pending orders, but I only want to know if there are any market orders open. Thx in advance