BarsTrue Function

Author: Optuma Team Last updated: Jan 21, 2020 22:41

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:

BARSTRUE