- Desktop
- Scripting
- Formulas and Scripting Functions
- BarIndex Function
BarIndex Function
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() > 100Here’s how the BarIndex() displays in a Show View:

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)
Your privacy choices
We use cookies and similar technologies to make the site work, see how it's used, and improve it. Analytics and advertising cookies only run with your consent — see our Privacy Policy for details.