Hi, I'm a beginner, need coders' help. The following codes are the results of copy and paste job from other EA / Scripts (with minor changes) but honestly I don't really understand.
My intention is to set an exit signal to basket close all the open and pending orders at server time 23:00:00, doesn't care whether the open trades are in loss / profit / magic # / symbol types etc. and I just want to clear everything to become ZERO open and pending orders so that the EA can start a total fresh on next new trading day.
The following codes do not work at all with errors and warnings, I do not know where it goes wrong, kindly help to rectify it, thanks.
My intention is to set an exit signal to basket close all the open and pending orders at server time 23:00:00, doesn't care whether the open trades are in loss / profit / magic # / symbol types etc. and I just want to clear everything to become ZERO open and pending orders so that the EA can start a total fresh on next new trading day.
The following codes do not work at all with errors and warnings, I do not know where it goes wrong, kindly help to rectify it, thanks.
Inserted Code
//This exitSignal block is my existing EA's codes :- string exitSignal(int ticket, string symbol, datetime ordertime, double orderprice, double netProfit) { if(operation) { switch(mode) { if(TimeHour(TimeCurrent())==23) closeAll(); //(I coded here, very likely are wrong codes) break; } } return(Output); } //+------------------------------------------------------------------+ //This block is the result of copy and paste job from //other EA / Scripts (with minor changes) void closeAll() { if (OrdersTotal()==0) return; bool result=false; for (int i=OrdersTotal()-1; i>=0; i--) { if (!OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) continue; while(IsTradeContextBusy()) Sleep(100); if (OrderType()<=1) //Close Open Trades { result=OrderClose(OrderTicket(), OrderLots(), OrderClosePrice(), 1000, clrNONE); if (result) i++; } if (OrderType()>=2) //Delete Pending Orders { result=OrderDelete(OrderTicket(), clrNONE); if (result) i++; } } }