Daylight savings anomaly inconsistency
Forums › ProRealTime English forum › ProOrder support › Daylight savings anomaly inconsistency
- This topic has 5 replies, 2 voices, and was last updated 3 years ago by Philstrading.
-
-
04/29/2021 at 9:23 AM #168348
hi
So Ive included the code and an ITF file for runing checks.
Here the switching is not consistently on sundays. I appear to have data – timezone is europe/London utc +01:00
I included the graphing, but I’m not altogether sure why I’m getting days other than a sunday for the Switch
Any assistance would be appreciated.. there is some additional code tried behind comments
I’ve tried on FX and Dax – time change code not too important as that canbe anything, but it should be switching on Sundays in line with the daylights saivngs but is inconsistently sundays…
Daylight Savings123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778DEFPARAM CumulateOrders = FalseDEFPARAM PreLoadBars = 2000//-------------------------------------------------------------------------------------//March settings//-------------------------------------------------------------------------------------If normaltime=1 thenstartT = 040000 //Starting TIMEendT = 123000 //Ending TIMEtd1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= 040000 //FridaytdCond = td1 OR td2 OR td3 OR td4 OR td5tdclose = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 200000 //Friday close off 9pmendifif changedtime=1 thenstartT = 040000 //Starting TIMEendT = 123000 //Ending TIMEtd1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= 040000 //FridaytdCond = td1 OR td2 OR td3 OR td4 OR td5tdclose = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 200000 //Friday close off 9pmendiftimeframe (daily)If openmonth=3 thendaycount=daycount+1endifif OpenMonth=3 and OpenDayOfWeek=0 thensunday=Sunday+1endifIf OpenMonth=3 and sunday=2 then//clocks go forward in America to pen = 1-30pm GMTchangedtime=1normaltime=0endifIf OpenMonth=3 and sunday>=4 and 31-daycount<7 then//or OpenMonth=3 and sunday=5 and 31-daycount=0 thennormaltime=1changedtime=0daycount=0sunday=0endif//-------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------//Oct Nov Settings//-------------------------------------------------------------------------------------If openmonth=10 thendaycount=daycount+1endifif OpenMonth=10 and opendayofweek=0 thensunday=Sunday+1endifIf OpenMonth=10 and sunday>=4 and 31-daycount<7 then//or OpenMonth=10 and sunday=5 and 31-daycount=0 thenchangedtime=1//1-30pm again as 1-30pm will be 2-30pm USnormaltime=0daycount=0sunday=0endifIf openmonth=11 and opendayofweek=0 thennormaltime=1changedtime=0sunday=0daycount=0endifgraph changedtime coloured (255,0,0)graph normaltime coloured (0,0,255)//graph daycounttimeframe (4 hours, updateonclose)Myamount=1If not onmarket thenbuy myamount perpoint at marketendifIf not tdcond and onmarket thensell at marketendif04/30/2021 at 10:17 PM #168498No takers then
Fixed anyways.
I’ll put it up for good measure, though I’m still confused why I need days <=4 when March 2019 has 5 Sundays starting on 3rd.. so yet to see if it causes an isue by looking back.. Any comment on that be useful -still to backtest some years to check for consistency and cant really tell why its a week early if I put <4 when it falls on Sunday 3rd March in 2019, so a long wait for testing live so looking back best bet.. any resolve on why day<4 doesnt work when Sunday falls on 3rd be appreciated..Probably to do with how day is counted on sundays….Line 50 on my code for “weekcount” – foreseen issue possibly if Sunday lands on 4th and its a 4 week month so still looking to tweak it but its woking, just the resolve on <=4 when it lands on 3rd… getting there
Daylight Saving123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109//In the UK the clocks go forward 1 hour at 1am on the last Sunday in March, and back 1 hour at 2am on the last Sunday in October.//Daylight Saving Time (DST) in the USA starts on the 2nd Sunday in March (go forward an hour) and ends on the 1st Sunday in November.(turn clocks back)//2nd Sunday (US) changes again last Sunday in March (UK)//Last Sunday in Ocober UK changes 1st Sunday in November (US)DEFPARAM CumulateOrders = FalseDEFPARAM PreLoadBars = 5000timeframe (15 minutes, updateonclose)//-------------------------------------------------------------------------------------//March settings//-------------------------------------------------------------------------------------live=0If live=0 thenif normaltime=1 thenstartT = 040000 //Starting TIMEendT = 123000 //Ending TIMEtd1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= 040000 //FridaytdCond = td1 OR td2 OR td3 OR td4 OR td5tdclose = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 200000 //Friday close off 9pmelsif changedtime=1 thenstartT = 040000 //Starting TIMEendT = 123000 //Ending TIMEtd1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= 040000 //FridaytdCond = td1 OR td2 OR td3 OR td4 OR td5tdclose = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 200000 //Friday close off 9pmendifendiftimeframe (daily)if not openmonth=3 or not openmonth=10 thensunday=0weekcount=0endifif openmonth=3 and OpenDayOfWeek=0 thensunday=Sunday+1endifIf openmonth=3 and sunday=2 then//clocks go forward in America to pen = 1-30pm GMTchangedtime=1normaltime=0endifIf openmonth=3 and day<=4 and opendayofweek=0 thenweekcount=5elsif openmonth=3 and weekcount<>5 thenweekcount=4endifIf openmonth=3 and weekcount=5 and sunday=5 thennormaltime=1changedtime=0sunday=0weekcount=0elsif openmonth=3 and weekcount=4 and sunday=4 thennormaltime=1changedtime=0sunday=0weekcount=0endif//-------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------//Oct Nov Settings//-------------------------------------------------------------------------------------if OpenMonth=10 and opendayofweek=0 thensunday =Sunday+1endifIf openmonth=10 and day<=4 and opendayofweek=0 thenweekcount=5endifif OpenMonth=10 and weekcount<>5 thenweekcount=4endifIf OpenMonth=10 and weekcount=5 and sunday=5 thenchangedtime=1//1-30pm again as 1-30pm will be 2-30pm USnormaltime=0sunday=0weekcount=0endifif OpenMonth=10 and weekcount=4 and sunday=4 thenchangedtime=1//1-30pm again as 1-30pm will be 2-30pm USnormaltime=0sunday=0weekcount=0endifIf openmonth=11 and opendayofweek=0 thennormaltime=1changedtime=0sunday=0weekcount=0endifgraph changedtime coloured (255,0,0)graph normaltime coloured (0,0,255)graph daytimeframe (15 minutes, updateonclose)Myamount=1If not onmarket thenbuy myamount perpoint at marketendifIf not tdclose and onmarket thensell at marketendif05/02/2021 at 10:30 AM #168556this is the way I account for the time change. Yours is better in that it’s open ended, whereas mine uses the actual dates 2010-2024, but I’d be curious to know if it gives you a different result.
I only use it for american indices to adjust their opening and closing times on GMT but you can change the Tradetime numbers to whatever…
1234567//adjustment for American Daylight Savings timeDLS =(Date >= 20100314 and date <=20100328) or (Date >= 20101031 and date <=20101107) or (Date >= 20110313 and date <=20110327) or (Date >= 20111030 and date <=20111106) or (Date >= 20120311 and date <=20120325) or (Date >= 20121028 and date <=20121104) or (Date >= 20130310 and date <=20130331) or (Date >= 20131027 and date <=20131103) or (Date >= 20140309 and date <=20140330) or (Date >= 20141026 and date <=20141102) or (Date >= 20150308 and date <=20150329) or (Date >= 20151025 and date <=20151101) or (Date >= 20160313 and date <=20160327) or (Date >= 20161030 and date <=20161106) or (Date >= 20170312 and date <=20170326) or (Date >= 20171030 and date <=20171105) or (Date >= 20180311 and date <=20180325) or (Date >= 20181028 and date <=20181104) or (Date >= 20190310 and date <=20190331) or (Date >= 20191027 and date <=20191103) or (Date >= 20200308 and date <=20200329) or (Date >= 20201025 and date <=20201101) or (Date >= 20210314 and date <=20210328) or (Date >= 20211031 and date <=20211107) or (Date >= 20220313 and date <=20220327) or (Date >= 20221030 and date <=20221106) or (Date >= 20230312 and date <=20230326) or (Date >= 20231029 and date <=20231105) or (Date >= 20240310 and date <=20240331) or (Date >= 20241027 and date <=20241103)If DLS thenTradetime = time >=133000 and time <200000elsif not DLS thenTradetime = time >=143000 and time <210000endif06/14/2021 at 2:42 PM #171746I’ll take a look at that, however I found when graphing the results were anomalous, and often differed, so I’ve yet to see how it operates and its a long winded way to write it but I wrote the below code.. The code appeared to graph correctly when backtested across the years..
I will take a look at your code and graph it to see as its a lot shorter of course.. too ended up inputed specific years….
Daylight savings123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120DEFPARAM CumulateOrders = False // Cumulating positions deactivatedDefparam preloadbars=1300If normaltime=1 thenStartT=143000EndT=144000EndTend=144100td1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= EndT //Fridaytdcond= td1 or td2 or td3 or td4 or td5td6 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= EndTend //Mondaytd7 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= EndTend //Tuesdaytd8 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= EndTend //Wednesdaytd9 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= EndTend //Thursdaytd10 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= EndTend //Fridaytdclose2= td6 or td7 or td8 or td9 or td10//---------------------------------------------------------tdclose = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 210000 //Friday close off 9pmendifif changedtime=1 thenStartT=133000EndT=134000EndTend=134100td1 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= startT AND OpenTime <= endT //Mondaytd2 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= startT AND OpenTime <= endT //Tuesdaytd3 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= startT AND OpenTime <= endT //Wednesdaytd4 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= startT AND OpenTime <= endT //Thursdaytd5 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= startT AND OpenTime <= EndT //Fridaytdcond= td1 or td2 or td3 or td4 or td5td6 = 1 AND OpenDayOfWeek = 1 AND OpenTime >= EndTend //Mondaytd7 = 1 AND OpenDayOfWeek = 2 AND OpenTime >= EndTend //Tuesdaytd8 = 1 AND OpenDayOfWeek = 3 AND OpenTime >= EndTend //Wednesdaytd9 = 1 AND OpenDayOfWeek = 4 AND OpenTime >= EndTend //Thursdaytd10 = 1 AND OpenDayOfWeek = 5 AND OpenTime >= EndTend //Fridaytdclose2= td6 or td7 or td8 or td9 or td10//---------------------------------------------------------tdclose = 1 AND OpenDayOfWeek = 5 AND OpenTime >= 200000 //Friday close off 9pmendiftimeframe (daily)once normaltime=1//depending on when started. Reverse for daylight saving opposingonce changedtime=0IF year=2013 or year=2019 or year=2024 or year=2030 or year=2041 thenmarch5week=1elsemarch5week=0endifIF year=2021 or year=2027 or year=2032 or year=2038 or year=2049 thenoct5week=1elseoct5week=0endifif not openmonth=3 or not openmonth=10 thensunday=0weekcount=0endif//-------------------------------------------------------------------------------------//March settings//-------------------------------------------------------------------------------------if openmonth=3 and OpenDayOfWeek=0 thensunday=Sunday+1endifIf openmonth=3 and sunday=2 then//clocks go forward in America to pen = 1-30pm GMTchangedtime=1normaltime=0endifIf march5week=0 and openmonth=3 and day<=3 and opendayofweek=0 thenweekcount=5endifif march5week=1 and openmonth=3 and day<=4 and opendayofweek=0 thenweekcount=5endifif march5week=0 and openmonth=3 and weekcount=0 thenweekcount=4endifIf openmonth=3 and weekcount=5 and sunday=5 thennormaltime=1changedtime=0sunday=0weekcount=0elsif openmonth=3 and weekcount=4 and sunday=4 thennormaltime=1changedtime=0sunday=0weekcount=0endif//-------------------------------------------------------------------------------------//-------------------------------------------------------------------------------------//Oct Nov Settings//-------------------------------------------------------------------------------------if OpenMonth=10 and opendayofweek=0 thensunday =Sunday+1endifIf oct5week=0 and openmonth=10 and day<=3 and opendayofweek=0 thenweekcount=5endifif oct5week=1 and openmonth=10 and day<=4 and opendayofweek=0 thenweekcount=5endifif oct5week=0 and OpenMonth=10 and weekcount=0 thenweekcount=4endifIf OpenMonth=10 and weekcount=5 and sunday=5 thenchangedtime=1//1-30pm again as 1-30pm will be 2-30pm USnormaltime=0sunday=0weekcount=0elsif OpenMonth=10 and weekcount=4 and sunday=4 thenchangedtime=1//1-30pm again as 1-30pm will be 2-30pm USnormaltime=0sunday=0weekcount=0endifIf openmonth=11 and opendayofweek=0 thennormaltime=1changedtime=0sunday=0weekcount=0endif06/14/2021 at 2:42 PM #171747Without recoding it that way then it didnt graph correctly…
06/14/2021 at 2:44 PM #171748Sorry thats some of the program timecode there
-
AuthorPosts
Find exclusive trading pro-tools on