Skip to main content

bars_since

Syntax Format

bars_since(condition)

Overview

The bars_since function provides the number of bars since the moment the given condition was met = was true. The condition is considered to be false if the condition is falsenil, or zero. This function can be used in scripts, when checking the data after a certain event has occurred.

Parameters

ParameterTypePurpose
conditionseries or numeric or booleanCondition value for the current bar

Returns: series[integer].

Example

condition = open = close

bar_count = bars_since(condition) -- calculates the number of bars since the open and close bar prices were the same