adjusting for daylight savings time in M1 T6

Posted By: SBGuy

adjusting for daylight savings time in M1 T6 - 05/06/21 15:09


I'm creating a 1-minute bar .t6 file from a US data source that only specifies the time in New York market hours: 9:30-16:00 ET. However .t6 files require timestamps to be in UTC zone.

Is there anyway to check to see if the particular M1 bar is in daylight savings time, so I can +4 or +5 hours accordingly to get UTC time?

checking (dst(ET,0)) doesn't work because the 2nd argument is a bar offset, and there are no bars yet in main(). If I do it in run(), the first asset does not evaluate dst() correctly, subsequent assets do evaluate dst() correctly. Strange.

I looked at the sample CSVtoHistory.c sample script and it hardcodes any hour adjustment. Surely that's not a good solution if my historical data crossed DST periods.

There used to be a HistoryZone system variable, but it appears to be removed in recent releases.

Any ideas?

Many thanks!
Posted By: AndrewAMD

Re: adjusting for daylight savings time in M1 T6 - 05/06/21 15:31

Set the Now variable, and then use offset = NOW.

https://zorro-project.com/manual/en/date.htm
https://zorro-project.com/manual/en/month.htm
Posted By: SBGuy

Re: adjusting for daylight savings time in M1 T6 - 05/06/21 15:51

Dude! You're awesome! That worked.

But just to be safe I need to set Now back to the actual current UTC time right - like this?

Code
	var adj = 5.0;
	Now = dataVar(34,i,0);
	if (dst(ET,NOW)) {	
		adj = 4.0;
		printf("[%s] DST ACTIVE !!!\n",myAsset);
	}
	printf("adj = %.0f\n",adj);
	Now = wdate(NOW);

	for (i=records-1; i>=0; i--)	{
		var mytime = dataVar(34,i,0) + adj/24.0;
		dataSet(34,i,0,mytime);		
	}

© 2024 lite-C Forums