Rolling Min/Max Node

The Rolling Min/Max node gives the lowest or highest value of a series over its last N bars: the peak RSI of the last 10 bars, the narrowest candle of the last 7. What it reads from Current Price, and why price levels belong in Price History.

NodeBy AlgoLiftUpdated 4 min read
On this page 7How it worksNot for price levelsExample: break of an NR7 barSettingsUse something else whenWhen it doesn't behaveGoing further

Some rules are about extremes. Was RSI overbought at any point in the last ten bars? Is this the narrowest candle of the week? The Rolling Min/Max node answers them for any series you give it: pick a window, pick Max or Min, and it returns the highest or lowest value inside that window.

Takes
One series: an indicator, a level, price action, a memory or another modifier
Gives
The highest or lowest value of its last N bars
Reach for it
A rule is about the peak or trough of an indicator or a derived value

How it works

The window is the last N bars, and it includes the bar your rules are reading. So Max over 10 bars of RSI is the highest RSI among the latest completed bar and the nine before it, and "RSI was above 70 somewhere in the last ten bars" is that value compared Greater Than 70. Empty values inside the window are skipped.

Because the current bar is inside its own window, the current value can never be strictly above its rolling Max or strictly below its rolling Min. At best it ties. Write the comparison with that in mind (the first symptom below is exactly this).

The input has to be a series the engine builds before the first bar: an indicator or one of its outputs, a price-action output, an external data source, a level (Price History, Pivot Levels, Event Day or Bands), a Distance in standard deviations, a Since or Capture, a Crossover on the Bar close clock, or another modifier. Math nodes, Constants and State Machines won't connect. One caution: Swing Points, Market Structure, Order Block, Fair Value Gap and Multi-Bar Formation keep their own memory through history, and the engine runs a backtest in monthly pieces, so a modifier over one of them reads an empty value for the first bars of each month. The builder warns when you wire one. Current Price connects too, but read the next part before you use it.

Not for price levels

Wire Current Price into this node, set Max and 20, and you'd expect the 20-bar high. You get something else. A modifier can't hold the live price, so Current Price arrives as the close of each completed bar, and the node returns the highest close of the last 20 bars. That sits below the 20-bar high whenever a wick reached above the closes, which is most of the time, so a breakout above it fires early, sometimes in the middle of a range.

The older recipe put a Bars Ago after it to end the window a bar sooner, which also made it a bar stale. Don't rebuild it. A level made of bar prices is one Price History node: its defaults already read the highest high of the last 20 completed bars, it never includes the bar being traded, and you choose the field (high, low, open, close, volume or range). Keep Rolling Min/Max for values that aren't bar prices.

Example: break of an NR7 bar

You trade ES 15m and like the old NR7 setup: when a bar is the narrowest of the last seven, the market is coiled, and a break of that bar's high tends to travel.

Add Candle Metrics and use its Full Range output, the bar's high minus its low in points. Wire it into a Rolling Min/Max set to Min, Period 7. In a Comparison, put Full Range on a and the rolling minimum on b, and choose Less Than or Equal. It's true when the latest completed bar is the narrowest of the seven.

For the trigger, add a Crossover with Current Price on A and a one-bar Price History reading the high on B, direction Above, clock Intrabar: price breaking the NR7 bar's high. AND the two through a Logic node into a long Entry. The NR7 condition is judged on the completed bar, so the entry gets exactly one bar to break it.

Settings

Period
Default 14
Bars in the window, 1 to 999, the bar your rules are reading included.
Type
Default Max
Max for the highest value in the window, Min for the lowest.

Use something else when

The highest high or lowest low of the last N bars
It reads the field you name over completed bars, leaves the forming bar out, and also tells you how many bars ago the extreme printed.
A channel drawn on the chart
Donchian draws the highest high and lowest low as bands you can see. For a level a rule reads, Price History is still the better node.
How often something happened, not only whether
"RSI above 70 on at least 3 of the last 20 bars" is a Since and its count of the last N bars.

When it doesn't behave

My “narrowest bar” rule never fires

Full Range Less Than its own 7-bar minimum can't happen, because the minimum includes the bar you're testing. Use Less Than or Equal, as in the example. If you mean strictly narrower than each of the bars before it, end the window a bar earlier: a Bars Ago Modifier (Value 1) on a 6-bar minimum, and Less Than against that. When both sides are bar prices the builder spots this and says so. For indicators and derived values like this one it can't, so it's on you.

My 20-bar breakout fires inside the range

You're probably comparing price with a Rolling Max of Current Price, which is the highest close, not the highest high. Price can clear it while the range's real top is still overhead. Replace it with a Price History reading the highest high.

Going further

Compare a stretch with the one before it. A Max of RSI over 10 bars, beside a Bars Ago 10 of that same Max, sets this stretch's peak momentum against the previous stretch's. A lower peak while price is still making highs is the textbook fading rally.

The window length is sweepable, and so is Max against Min, though flipping Max to Min turns one idea into a different one rather than tuning it. Sweep the period in coarse steps around a length you can justify (seven bars for NR7 has decades of folklore behind it; nine doesn't).

Or ask the copilot