Using better code for identifying session
Hello
I haven an EA that runs 24 hours a day and takes into account the 3 main timezone session.
Here is what I usE to identify the current time zone and so it is then used to find the start bar of the session:
Is there a way to do this thats uses more efficient coding?
Bearing in mind I still quite a novice so examples would be useful
Hi
Thanks for the reply, I have reattached the "cleared up" version of the code:
extern int London_ST = 8;// 7 FOR SUMMER extern int London_ET = 17;// 16 FOR SUMMER extern int NewYork_ST = 13;// 12 FOR SUMMER extern int Asia_ST = 22;//21 FOR SUMMER extern int Asia_ET = 9;//8 FOR SUMMER //+------------------------------------------------------------------+ int Brokentime(){ if(DayOfWeek()==0){ daystarttime= iTime(Symbol(),PERIOD_D1,1)+(Asia_ET*3600); } //+------------------------------------------------------------------+ if(DayOfWeek()==1){ if(TimeHour(TimeCurrent())>=0 && TimeHour(TimeCurrent())<London_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,2)+(Asia_ET*3600); } if(TimeHour(TimeCurrent())>=London_ST && TimeHour(TimeCurrent())<Asia_ET){ daystarttime = iTime(Symbol(),PERIOD_D1,2)+(Asia_ET*3600); } if(TimeHour(TimeCurrent())>=Asia_ET && TimeHour(TimeCurrent())<NewYork_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,2)+(London_ET*3600); } if(TimeHour(TimeCurrent())>=NewYork_ST && TimeHour(TimeCurrent())<London_ET){ daystarttime = iTime(Symbol(),PERIOD_D1,2)+((Asia_ST-1)*3600); } if(TimeHour(TimeCurrent())>=London_ET && TimeHour(TimeCurrent())<Asia_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,2)+((Asia_ST-1)*3600); } if(TimeHour(TimeCurrent())>=Asia_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,0)+(Asia_ET*3600); } } //+------------------------------------------------------------------+ if(DayOfWeek()>=2){ if(TimeHour(TimeCurrent())>=0 && TimeHour(TimeCurrent())<London_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,1)+(Asia_ET*3600); } if(TimeHour(TimeCurrent())>=London_ST && TimeHour(TimeCurrent())<Asia_ET){ daystarttime = iTime(Symbol(),PERIOD_D1,1)+(London_ET*3600); } if(TimeHour(TimeCurrent())>=Asia_ET && TimeHour(TimeCurrent())<NewYork_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,1)+(London_ET*3600); } if(TimeHour(TimeCurrent())>=NewYork_ST && TimeHour(TimeCurrent())<London_ET){ daystarttime = iTime(Symbol(),PERIOD_D1,1)+(Asia_ST*3600); } if(TimeHour(TimeCurrent())>=London_ET && TimeHour(TimeCurrent())<Asia_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,1)+(Asia_ST*3600); } if(TimeHour(TimeCurrent())>=Asia_ST){ daystarttime = iTime(Symbol(),PERIOD_D1,0)+(Asia_ET*3600);} } }
Thanks again
Antony
Hi
Thanks for the reply, I have reattached the "cleared up" version of the code:
No problem, I was thinking of using arrays?
Hello
I haven an EA that runs 24 hours a day and takes into account the 3 main timezone session.
Here is what I usE to identify the current time zone and so it is then used to find the start bar of the session:
Is there a way to do this thats uses more efficient coding?
Bearing in mind I still quite a novice so examples would be useful
Thanks
Antony