Here is a code which can be saved as a script file in the Scripts Folder.
To execute the script, drage and drop the script on the current chart, this will close all open trades and also pending orders of all symbols.
int start()
{ double total; int cnt; while(OrdersTotal()>0) { // close opened orders first total = OrdersTotal(); for (cnt = total ; cnt >=0 ; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { switch(OrderType()) { case OP_BUY : RefreshRates(); OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_BID),3,Violet);break; case OP_SELL : RefreshRates(); OrderClose(OrderTicket(),OrderLots(),MarketInfo(OrderSymbol(),MODE_ASK),3,Violet); break; } } } // and close pending total = OrdersTotal(); for (cnt = total ; cnt >=0 ; cnt--) { if(OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES)) { switch(OrderType()) { case OP_BUYLIMIT :OrderDelete(OrderTicket()); break; case OP_SELLLIMIT :OrderDelete(OrderTicket()); break; case OP_BUYSTOP :OrderDelete(OrderTicket()); break; case OP_SELLSTOP :OrderDelete(OrderTicket()); break; } } } } return(0); }
No comments:
Post a Comment