- Desktop
- Scripting
- Formulas and Scripting Functions
- BarsTrue Function
BarsTrue Function
The BarsTrue() function will return results showing how many times condition X has been true over the last Y bars (ie days on a daily chart, or weeks on a weekly chart). For example, how many days have been higher (CLOSE() IsUp) over the last 20 days?
BARSTRUE(CLOSE() IsUp, LOOKBACK=20)To turn it in to a boolean true/false statement add a condition, such as BARSTRUE(CLOSE() IsUp, LOOKBACK=20) > 10
Here’s the above 2 formulas in a watchlist column, and the time series below the chart in a Show View:

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.