shitizbansal247

New Member
problem i have encountered:

I want the price of an index two days back(two trading days) and that too for the 3rd bar (time frame is 5 minute bars)
for eg- if today is 11 aug, i want the close value of minus-3rd bar (i.e. 9:45a.m. on a 5 minute scale) on the date of 9aug.

DSM

Well-Known Member
Trust this is of help....

problem i have encountered:

I want the price of an index two days back(two trading days) and that too for the 3rd bar (time frame is 5 minute bars)
for eg- if today is 11 aug, i want the close value of minus-3rd bar (i.e. 9:45a.m. on a 5 minute scale) on the date of 9aug.

mastermind007

Well-Known Member
problem i have encountered:

I want the price of an index two days back(two trading days) and that too for the 3rd bar (time frame is 5 minute bars)
for eg- if today is 11 aug, i want the close value of minus-3rd bar (i.e. 9:45a.m. on a 5 minute scale) on the date of 9aug.

Lookup
- search the array for bar with specified date/time Date/Time
(AFL 3.40)

SYNTAX Lookup( array, datetime, mode = 0 )
RETURNS NUMBER
FUNCTION The function searches for the bar with specified datetime and returns the value from the same position of the input array.
Parameter 'mode' decides how search is performed in case when exact match is not found:

mode = 0 - find exact match, otherwise return Null
mode = -1 - find exact match, otherwise return nearest predecesor (if datetime is past last bar it will return last bar value)
mode = -2 - find exact match, otherwise return nearest predecessor EXCEPT the very last bar (if searched datetime is past last bar it will return Null)
mode = 1 - find exact match, otherwise return nearest successor (if datetime is before first bar it will return first bar value)
mode = 2 - find exact match, otherwise return nearest successor EXCEPT the very first bar (if searched datetime is before first bar it will return Null)
This function uses very fast binary search and it is many times faster than previous AFL-based methods such as FindValueAtDateTime() presented in the past. Any call to FindValueAtDateTime ( input, dt, value ) can be now replaced with Lookup( input, value ) (here is no need to pass dt- datetime).

NOTE: This function does not affect QuickAFL required bars, therefore it will only search bars that are actually loaded in arrays. For indicators it may mean that it won't be able to find value if it is invisible, unless you use SetBarsRequired() function to ensure that more bars are loaded.

EXAMPLE InputDate = "2011-04-05";
Title = "Close value at (or before) " + InputDate + " is " + Lookup( Close, _DT( InputDate ), -1 );

SEE ALS

shitizbansal247

New Member
thanks.. but its not working for me

Last edited: