Understanding Lookup Function

Hi Experts ,

I have tried and read the help about look up fuction .
I could understand mode 0 and mode 1 ,
I could not understand mode -1 and mode -2 .... Can some give me some examples , so that i can use these fuctions with complete understanding.

Thanks in advance,
kaeswar

mode -1, and -2 are predecessor.
That means if bar is not found, it will return the closest bar before that time.

Example:
Lets say you are looking for 2025-01-09 16:30:00 in 5min interval,
but the last bar in DB yesterday is 2025-01-09 16:00:00
Now, there is no new data after that as next day is holiday.

mode -1: if data is present for symbol, it is guaranteed that you will not receive NULL but some bar( input array), so in this case value at last bar 2025-01-09 16:00:00 is received.

mode -2: Here, you date search is past the last bar for the symbol, so it will return NULL.

But if today is not holiday and some data is received in DB, then both mode -1,-2 will point to the bar number at 2025-01-09 16:00:00

2 Likes

See below to help you understand what's happening - it's a good way to learn.

3 Likes

Thanks for the Quick Explanation , it is useful, thanks again nsm51

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.