|
Navigation: Function Reference > Stream Functions > TEStream.offsetDaysAgo() TEStream.offsetDaysAgo() |
Top Previous Next |
TEStream.offsetDaysAgo( offset: Integer; numDays: Integer ) : Integer;
Returns the positive integer offset to the bar numDays days ago that has a timestamp equal to or less than the bar at offset. If an out-of-data condition is reached before the requested bar is found, then -1 is returned.
So, for example, offsetDaysAgo( -1, 4 ) would determine the time stamp of the prior bar (i.e., -1 was passed) and then try to find the offset to the same time stamp 4 trading days prior.
If numDays is 0 (i.e., get the bar from zero days ago) then offset will be returned.
Parameters
offset |
integer value (0 or negative offset into the stream) |
numDays |
integer value. number of days back |
myStream := Symbol.close;
offsetToBar := myStream.offsetDaysAgo(-2, 2);
//-- assuming close(-2) is the 9:30am bar then
//-- this function would return the positive offset
//-- to the 9:30am bar from 2 trading days ago
debugPrint( format('Offset to desired bar is -%d', [offsetToBar]) );
myValue := myStream.getValue(-offsetToBar);