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 false
, nil,
or zero
. This function can be used in scripts, when checking the data after a certain event has occurred.
Parameters
Parameter | Type | Purpose |
---|---|---|
condition | series or numeric or boolean | Condition 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