hour() and lhour()

Posted By: boatman

hour() and lhour() - 10/03/16 04:13

I noticed in the manual that if BarZone is set to the local time, that hour() and lhour() are equivalent. I don't think this is the case. I think that hour() actually always refers to the UTC hour.

The following script:

Code:
function run()
{
	StartDate = 20150101;
	BarZone = ET;
	BarPeriod = 1440;
	BarOffset = 9*60;
	vars Close = series(priceClose());
	printf("\nhour: %d, lhour: %d, Close: %f", hour(), lhour(ET), Close[0]);
}



generates the following example output:

Code:
hour: 13, lhour: 9, Close: 1.109865
hour: 13, lhour: 9, Close: 1.115435
hour: 13, lhour: 9, Close: 1.116505
hour: 13, lhour: 9, Close: 1.120315
hour: 13, lhour: 9, Close: 1.119425
hour: 13, lhour: 9, Close: 1.114395
hour: 13, lhour: 9, Close: 1.108410
hour: 13, lhour: 9, Close: 1.108720
hour: 13, lhour: 9, Close: 1.107920
hour: 13, lhour: 9, Close: 1.118925
hour: 13, lhour: 9, Close: 1.118165
Chart... ok



which to me suggests that hour() is returning the UTC hour, while lhour(ET) is returning the ET hour, even though BarZone is set.
Posted By: jcl

Re: hour() and lhour() - 10/03/16 17:13

The BarZone determines when the bar starts and ends. hour() and lhour() is the UTC and local time at the end of a bar. You let a bar end at 9:00 ET. At that time lhour is always 9 and UTC is 13 or 14, dependent on daylight saving.
Posted By: boatman

Re: hour() and lhour() - 10/04/16 11:10

Thanks - that makes sense.
© 2024 lite-C Forums