robertebuck:
Hi i have created an expert adviser that places pending orders after each new bar and closes any previous pending orders. However I would like my adviser to stop placing pending orders once a pending order price is met and i am unsure how to go about doing this. I was hoping somebody may have some helpful advice about how to do this?
Thanks
int openBuy; int openSell; void countOpenOrders() { openBuy = 0; openSell = 0; for(int i=OrdersTotal()-1; i >= 0; i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) { if(OrderType() == OP_BUY) openBuy ++; if(OrderType() == OP_SELL) openSell++; } }You can count your open order like this and insert a condition to place pending orders only if openBuy == 0 && openSell == 0.
I believe the code you have given me only works for MTQL4 i am however using MTQl5. I should have made that clear in my original post.
robertebuck:
I believe the code you have given me only works for MTQL4 i am however using MTQl5. I should have made that clear in my original post.
Even if the syntax may differ a little you can use the logic. Hit F1 if you do not know how or pay five bucks for someone who puts you the snippet together.
I believe the code you have given me only works for MTQL4 i am however using MTQl5. I should have made that clear in my original post.
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 have created an expert adviser that places pending orders after each new bar and closes any previous pending orders. However I would like my adviser to stop placing pending orders once a pending order price is met and i am unsure how to go about doing this. I was hoping somebody may have some helpful advice about how to do this?
Thanks