Identifying the day of the week from a specific candle

 

Hi!


I am trying to backtest an strategy and i don't want to enter any position on fridays.


I try using this code to get the day of the week of the candle,but get the following error.


MqlDateTime herenow[];

CopyTime(_Symbol,_Period,0,0,herenow);


'CopyTime' - no one of the overloads can be applied to the function call


 

All calls to CopyTime() take a datetime array argument not a MqlDateTime structure (and certainly not an array of them!).  If you want the result in an MqlDateTime struct, CopyTime() into the datetime array and then convert each element; see TimeToStruct()

 
mohammad7521 :

Example: if the current day of the week is Friday, just exit the procedure:

   MqlDateTime STime;
   TimeToStruct(TimeCurrent(),STime);
   if(STime.day_of_week==5)
      return;
 
Scott:

All calls to CopyTime() take a datetime array argument not a MqlDateTime structure (and certainly not an array of them!).  If you want the result in an MqlDateTime struct, CopyTime() into the datetime array and then convert each element; see TimeToStruct()

Thanks!
 
Vladimir Karputov:

Example: if the current day of the week is Friday, just exit the procedure:


Thanks Very Much!

Reason: