ta.barssince() - Pine Script Function
ta.barssince()
Section titled “ta.barssince()”Overview
Section titled “Overview”Counts the number of bars since the last time the condition was true.
Syntax
Section titled “Syntax”ta.barssince(condition) → series intParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| condition | series bool | The condition to check for. |
Returns
Section titled “Returns”Number of bars since condition was true.
Remarks
Section titled “Remarks”- If the condition has never been met prior to the current bar, the function returns na.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("ta.barssince")// get number of bars since last color.green barplot(ta.barssince(close >= open))