Bars since condition
Bars since its condition last fired: 0 on the firing bar, then up one each bar.
BarsSinceCondition takes one input, a condition, normally another indicator's output. A bar counts as a fire whenever that condition is not None, so 0 and False count as fires too. On a fire the indicator returns 0, then the number of bars since that fire on each later bar until the next fire. Before the first fire it returns None, which draws as no line.
How to read it
- The line sits in its own pane below the price, in whole bars.
- A 0 marks the bar where the condition fired; the line then climbs by one each bar until the next fire.
- Before the first fire the line is empty, not zero.
What it outputs
- Bars since fire
- Bars since the condition last fired: 0 on the firing bar, then 1, 2, 3 on each bar after. Empty until the first fire.
Pitfalls
- The test is only for None, so a condition that returns False or 0 on quiet bars fires on every bar. Quiet bars must return None.
- It counts data rows, not clock minutes. A missing minute in the bar data is not counted, so the number matches elapsed time only on continuous bars.