Skip to content

BarsTrue Function

By Optuma Team · Updated 2020-01-21

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

Choose which categories of cookies you allow. Strictly-necessary cookies are always on. You can change this any time via the "Cookie Settings" link in the footer.

  • Functional

    Remember preferences like dismissed banners and your dark-mode choice.

  • Analytics

    Help us understand how the site is used so we can improve it.

  • Marketing

    Measure our advertising and help us reach people who may be interested in Optuma.