#property copyright "© 2006-2008 BJF Trading Group" #property link "www.iticsoftware.com" #property show_inputs #define major 1 #define minor 0 extern int RepeatN = 3; //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void init() { } void deinit() { } void start() { for (int i=0; i < RepeatN; i++) { fDeleteOrders(); } } void fDeleteOrders() { int cnt = OrdersTotal(); for (int i=cnt-1; i >= 0; i--) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; if (OrderSymbol() != Symbol()) continue; int type = OrderType(); if (type == OP_BUYSTOP || type == OP_SELLSTOP || type == OP_BUYLIMIT || type == OP_SELLLIMIT) { DeleteOrder(OrderTicket()); } } } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #include #include int SleepOk = 1000; int SleepErr = 3000; bool DeleteOrder(int ticket) { Print("DeleteOrder ", ticket); bool res = OrderDelete(ticket); if (res) { Sleep(SleepOk); return (res); } int code = GetLastError(); Print("DeleteOrder failed: ", ErrorDescription(code), " (", code, ")"); Sleep(SleepErr); return (false); }