if(OrderType()==OP_BUYSTOP||OP_BUYLIMIT||OP_SELLSTOP||OP_SELLLIMIT)
if this even compiles, it's equivalent to OrderType()=OP_BUYSTOP or true or true or truefor(i=0;i<OrdersTotal();i++) { OrderSelect(i,SELECT_BY_POS,MODE_TRADES);
You must count down in the presence of multiple orders (multiple charts.) Always test return codes. Must RefreshRates() between multiple server callsfor(pos=OrdersTotal()-1; pos >= 0; pos--) if( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair. if (OrderType() <= OP_SELL) OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),3,Red); else OrderDelete(OrderTicket()); RefreshRates(); }
Thanks for your great response. Tried several things, but not one of them worked.
i first got errors that magic.number not exist and that pos is not a variable or something. so i needed some tweaks but never got this to work.
could u add a full completed script. thanks for the great help!

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 all,
i used the following script to close all open orders.
but i would love to apply this on all charts at once
i tried modifying other scripts but couldn't get it to work.
anybody got a clever idea?