CopyTime to Which day of the week

 

Hi,


i need to find our which day of the week was a previous candle in an EA MT5 start and finish time


datetime timeC[];

ArraySetAsSeries(timeC,true);

CopyTime(NULL,0,0,1000,timeC); 


string t=timeC[500];

Print(EnumToString((ENUM_DAY_OF_WEEK)t));  //???????


looking for a result like Monday,tuesday,....

Please Help!

 
amjad.b.barhoumeh: Print(EnumToString((ENUM_DAY_OF_WEEK)t));  //??????? looking for a result like Monday,tuesday,....

T is a datetime (seconds from 1970.) ENUM_DAY_OF_WEEK is an enumeration (SUNDAY, etc.) You can't cast one to the other.

Use TimeDayOfWeek
          Migrating from MQL4 to MQL5 - MQL5 Articles № 18

 
amjad.b.barhoumeh:

Hi,


i need to find our which day of the week was a previous candle in an EA MT5 start and finish time


datetime timeC[];

ArraySetAsSeries(timeC,true);

CopyTime(NULL,0,0,1000,timeC); 


string t=timeC[500];

Print(EnumToString((ENUM_DAY_OF_WEEK)t));  //???????


looking for a result like Monday,tuesday,....

Please Help!

Thank you for your quick response, how do you suggest i do it? i just want to get the day name where the candle is was on the chart from timeC[500] position ?

 
amjad.b.barhoumeh:

Thank you for your quick response, how do you suggest i do it? i just want to get the day name where the candle is was on the chart from timeC[500] position ?

Here's how I would do it...

#include <Tools\DateTime.mqh>
void OnStart()
{
   datetime timeC[];
   ArraySetAsSeries(timeC,true);
   CopyTime(_Symbol,PERIOD_D1,0,1000,timeC); 
   CDateTime time;
   time.DateTime(timeC[500]);
   printf("%s is a %s",TimeToString(time.DateTime(),TIME_DATE),time.DayName());
}
 
nicholishen:

Here's how I would do it...

Thank you so much great help :)

Reason: