How to close order on next day certain time

 

Hello,

I want to close order on next day certain time, I have a mql4 files which close on the same day certain time.

Which part I must change? How to change to next day certain time. Thank you

      if(istradinghours(close_time_hour,24,0,0))

   {

      if(CountOpenOrders(OP_BUY)+CountOpenOrders(OP_SELL)+CountOpenOrders(OP_BUYSTOP)+CountOpenOrders(OP_SELLSTOP)>0)

      {

         CloseTrades(OP_BUY);    

         CloseTrades(OP_SELL);    

         CloseTrades(OP_BUYSTOP);    

         CloseTrades(OP_SELLSTOP);  

         return;  

      }

   }  


bool istradinghours(int starthour, int endhour, int startminute=0, int endminute=0, int shift = 0)

{

   int nowtime = (Hour()+shift)*60 + Minute();

   if (nowtime < 0)

      nowtime += 1440;

   if (nowtime >= 1440)

      nowtime -= 1440;

   int starttime = starthour*60 + startminute;

   int endtime = endhour*60 + endminute;



   if (starttime <= endtime)

   {

      if ((nowtime < starttime) || (nowtime >= endtime))

         return(false);

   }

   else

   {

      if ((nowtime < starttime) && (nowtime >= endtime))

         return(false);

   }

   return(true);

   }


How to insert SRC? I can't find SRC menu

 
U can use my Function
bool myCloseTradingTime(string StartTimeCek,string StopTimeCek,int GMT_Offset=0){
bool UseTimeLocal=False;
if(GMT_Offset==99){UseTimeLocal=True;GMT_Offset=0;}
datetime start0, stop0, start1, stop1;
   start0   = StrToTime(StringConcatenate(Year(),".",Month(),".",Day()," ",StartTimeCek))+GMT_Offset*3600;
   stop0    = StrToTime(StringConcatenate(Year(),".",Month(),".",Day()," ",StopTimeCek))+GMT_Offset*3600;
   start1=start0;stop1=stop0;
   if(stop0<=start0){stop1+=86400;start0-=86400;}
   if((((TimeCurrent()>=start0&&TimeCurrent()<stop0)||(TimeCurrent()>=start1&&TimeCurrent()<stop1))&&UseTimeLocal==False)||
      (((TimeLocal()>=start0&&TimeLocal()<stop0)||(TimeLocal()>=start1&&TimeLocal()<stop1))&&UseTimeLocal==True)){return(true);}
   return(false);}
exp to use

i want close all my open order in Hour 3 and 15 Minute and cek for 1 minute broker time
the code is
myCloseTradingTime("03:15:00","03:15:59",0);
 
houseofmiracle: How to insert SRC? I can't find SRC menu
When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your (original) post.
          General rules and best pratices of the Forum. - General - MQL5 programming forum
          Messages Editor
 

@whroeder1 : Sorry, I can't edit my post, is only "to pocket" and "reply"

@Abi Manyu : Thank you for your help, is it close on the same day? What part need to change for close on next day / certain day?

 
houseofmiracle:

@whroeder1 : Sorry, I can't edit my post, is only "to pocket" and "reply"

@Abi Manyu : Thank you for your help, is it close on the same day? What part need to change for close on next day / certain day?

I edited it for you.

Reason: