MQL5 pending order expiriance every friday

 

Hi


It looked verry easy to my but now i get error:

               TimeToStruct(TimeCurrent(),myTime);
               if(myTime.day_of_week!=5)

                 {
                  // HERAUSFINDEN WIE DATUM VOM FOLGENDE FREITAG GEHT
                  request.type_time=ORDER_TIME_SPECIFIED_DAY;

                  if(myTime.day_of_week == 1)request.expiration=TimeCurrent()+354600;
                  if(myTime.day_of_week == 2)request.expiration=TimeCurrent()+259200;
                  if(myTime.day_of_week == 3)request.expiration=TimeCurrent()+172800;
                  if(myTime.day_of_week == 4)request.expiration=TimeCurrent()+86400;
                  if(myTime.day_of_week == 6)request.expiration=TimeCurrent()+432000;
                  if(myTime.day_of_week == 0)request.expiration=TimeCurrent()+518400;
                 }
               else request.type_time=ORDER_TIME_DAY;

Time current + days til friday should give me the date of friday - what did i get wrong ??

 
Baumann Andrea:

It looked verry easy to my but now i get error:

Time current + days til friday should give me the date of friday - what did i get wrong ??

  1. What error, there are no mind readers here.
  2. Now+86400 is not Friday, it is Friday current time. Perhaps you want beginning of the day+86400
    #define HR2400 86400
    #define SECONDS uint
    SECONDS    time(datetime when=0){
          return SECONDS(when == 0 ? TimeCurrent() : when) % HR2400;               }
    datetime   date(datetime when=0){
          return datetime( (when == 0 ? TimeCurrent() : when) - time(when) );      }