BarIndex Function

Author: Optuma Team Last updated: Aug 13, 2020 21:58

The BarIndex() function is a progressive count of the number of bars on a chart, with the first bar having a Bar Index value of 0. It can be used in a scan to filter out new listings, e.g. to ignore codes with less than 100 days of data:

BARINDEX() > 100

Here’s how the BarIndex() displays in a Show View:

BARINDEX

To show the last X number of bars in a different colour use the following under Custom Bar Colours (showing last 12 weeks, or 60 bars on a daily chart):

//Get last BarIndex value;
B1 = LAST(BARINDEX());

//Subtract number of trading days;
BARINDEX() >= (B1-60)

BARINDEX