Tool
In Last N Bars
condition.in_last_n_bars
Inputs
The boolean line to remember, one true/false per bar — typically the output of another condition, a cross, or a pattern detector.
Outputs
A boolean that is true on each bar where the input was true at least once within the last n bars, and false otherwise.
In Last N Bars remembers a true/false signal and fires true if it was true at any point within the last few bars. It turns a one-bar event into a short-lived window, so a trigger that flashed a couple of bars ago still counts.
How it works
You wire a boolean line into `value` and set `n`. On each bar the node looks back over the most recent n bars (including the current one) and outputs true if the input was true on any of them, false if it was false throughout. Larger n keeps the memory alive longer.
Configuration
How many bars back the node remembers a true value. 1 means this bar only (a pass-through); larger values widen the window so an older trigger still counts. Keep it small to stay tight to the event, larger to be forgiving of timing.
Connects to
Examples
- Confirmation grace: wire a fast-EMA cross into value with n 3 so a second condition can still confirm the cross two bars after it fired.
- Event memory: feed a breakout flag into value with n 5 to keep a “just broke out” state alive for a handful of bars.
Common mistakes
- Wiring a number line in instead of a boolean — this node expects a true/false input; convert a number with a To Boolean or a threshold first.
- Setting n very large so the window almost never resets, leaving the gate stuck on true long after the event is stale.