-
Finish your loop setting a bool if there is; then test it. If any (not all) of the open orders are not in your range, you open a new order.
-
{for (int x=0; x <= OrdersTotal(); x++){ OrderResult=OrderSelect(x,SELECT_BY_POS,MODE_TRADES);
Check your return codes, and report your errors (including market prices and your variables). Don't look at GLE/LE unless you have an error. Don't just silence the compiler (MT5/MT4+strict), it is trying to help you.
What are Function return values ? How do I use them ? - MQL4 programming forum 2012.05.20
Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles 25 March 2014 - If there are n orders, their positions are [0 … n-1]. You try and fail to select n but continue anyway.
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,
My objective is that if there is an existing open order at a price between (PB1-PBDip1) and (PB1+PBDip1) then the loop should not open another order.
When i test this code it keeps opening new orders every second irrespective of existing open order price
Kindly guide