Time Filter

 

Hi

how can I add a filter to my Hedge expert 

Time filter start form 04:00 to 16:00 if there order found after time ended the expert still work and take orders as hedging until to take profit


Regards

Bassam

 
Bassam Salman:

Hi

how can I add a filter to my Hedge expert 

Time filter start form 04:00 to 16:00 if there order found after time ended the expert still work and take orders as hedging until to take profit


Regards

Bassam

You can create a function and check this in OnTick().

Example of such a function:

bool isAllowTrading(){
   //Result is true between 04:00:00 ~ 16:00:00 GMT, otherwise false
   bool result = false;
   MqlDateTime DtStruct;
   bool success = TimeToStruct(TimeCurrent(),DtStruct);
   if((DtStruct.hour > 3) &&
      (DtStruct.hour < 17)) result = true;
   return result;
}