Skip to content
Algo Trade Analytics Docs

ta.barssince() - Pine Script Function

Counts the number of bars since the last time the condition was true.

ta.barssince(condition) → series int
NameTypeDescription
conditionseries boolThe condition to check for.

Number of bars since condition was true.

  • If the condition has never been met prior to the current bar, the function returns na.
//@version=6
indicator("ta.barssince")// get number of bars since last color.green bar
plot(ta.barssince(close >= open))