TradeZoro
Notifications

Cookbook

Bars since last cross

Count bars since a signal.

//@zscript 1
indicator("Bars since cross")
fast = ta.ema(close, 9)
slow = ta.ema(close, 21)
n = ta.barssince(ta.cross(fast, slow))
plot(n, "Bars since last cross", style=plot.style_columns, color=#00adb5)
-2.288.3619.0029.6440.28
Sample bars, not market data. Bars since cross.

How it works

ta.barssince(condition) counts bars since the condition was last true.

Education only. Not financial advice. Examples are teaching samples, not trading results.

Zscript is coming soon

The manual opens when Zscript launches.

Back to home