Disliked{quote} Hi BestTraderEv, my broker's crypto symbols is running 24/7, but not 24/5, therefore I'll give a "instruction codes" on Friday before 23:30 (server time) to switch the EA loaded chart to BTCUSD so that there are tick activity during the day 0 or 6. The problem is I've been trying many times on ChartSetSymbolPeriod but failed. Kindly help to provide me the "instruction codes" to put into my EA, thanks.Ignored
Option1: In the OnInit() function (if you are switching your computer Off on Friday, and then On on Saturday and on Sunday),
Option2: In the OnTimer() function (which will work always, only you should then use TimeLocal() if neccesary).
Otherwise there shouldn't be any problem.
Inserted Code
void OnInit() { EventSetTimer(1); // set timer event to 1 second } void OnTimer() { int dd = DayOfWeek(); string symbolForWeekdays = "EURUSD"; ENUM_TIMEFRAMES tfForWeekdays = PERIOD_D1; if(dd>=1 && dd<=5 && _Symbol != symbolForWeekdays) if(ChartSetSymbolPeriod(ChartID(),symbolForWeekdays,tfForWeekdays )) { Print("Chart has been changed to Weekdays: "+_Symbol+" "+EnumToString(tfForWeekdays)); } string symbolForWeekends = "BTCUSD"; ENUM_TIMEFRAMES tfForWeekends = PERIOD_D1; if((dd==0 || dd==6 ) && _Symbol != symbolForWeekends) if(ChartSetSymbolPeriod(ChartID(),symbolForWeekdays,tfForWeekends )) { Print("Chart has been changed to Weekend: "+_Symbol+" "+EnumToString(tfForWeekdays)); } } void OnDeinit(const int reason) { EventKillTimer(); }
And, yes, another option would be to have the EA do it just before Market Close on Friday.
PS. Ooops, sorry, DayOfWeek is int (int DayOfWeek(); ) - not datetime!
If you're looking for the Holy Grail - NEVER STOP!
1