Afl code to list oldest data point for ticker

Hello - I have a watchlist of tickers. I would like to create an exploration listing the oldest data point for the tickers in the watchlist. Ideas please.

The top row of the result list would show the symbol with oldest date of all tickers.

/// output oldest date of a set of tickers
/// @link

SetSortColumns( 2 );

bi = BarIndex();

Filter = bi == bi[0];

EDIT: Since multiple roads lead to Rome here is another version

SetSortColumns( 3 );

rev_dt = Reverse(Datetime());

Filter = Status( "lastbarinrange" );

AddColumn( rev_dt, "Oldest DateTime", formatDateTime, -1, -1, 120 );

I was not clear. I need the oldest ticker data for each ticker on the watchlist. Some tickers will have longer history, so an older date will be identified.

The first code set seems to provide the oldest single date for all of the tickers which the second code set seems to provide the youngest. So, I was not clear. For example, one of my tickers goes back to 10/02/1989 and another to 11/03/2003. I would like to identify these dates for the entire watchlist. Thanks for the help!

1 Like
SetSortColumns( 3 );

lowdt = Lowest(DateTime());

Filter = Status( "lastbarinrange" );

AddColumn( lowdt, "Oldest DateTime", formatDateTime, -1, -1, 120 );
1 Like

Have you actually tried the sample codes?!
BOTH ones identify oldest dates as of your quote.

So instead of guessing you should rather apply first.

In the 2nd code you have to look at the THIRD column not the 2nd one!

I used your suggest first code section. I get same date for each ticker. See image below.

Here is what I get with second section of code.

Here is another version. The 4th version. Imagine that... we take extra time to show you four different versions!

// set range to all quotes to output oldest!

dt    = DateTime();
fbr   = Status( "firstbarinrange" );
fdr   = ValueWhen( fbr, dt );

Filter = Status( "lastbarinrange" );

AddColumn( fdr, "First Date/Time", formatDateTime, -1, -1, 120 );

As for your picture. Can't confirm that. Which AB version? Works here as expected with 6.20.


Some things to check…

Are your database settings limiting the number of bars to load?

Do you see different first dates in the quote editor window?



You have activated “Pad and align all data…” in backtest settings tab “General”! Deactivate it!

Yep, I had Pad and Align. It works now. Didn’t know this would cause problem. Thank you and others for the help.