Rolling Max¶
Math · Rolling
Highest value in the trailing N bars.
Rolling Max reports the highest value of a series over the trailing N bars. As price moves, it traces the recent peak — the highest high of the last 20 bars, say. It's the building block behind breakout levels, channel tops, and trailing references: "the highest price we've seen in the window" is exactly the line a breakout trades through.
How it works¶
Each bar the block outputs the maximum of the source over the Window (bars) (default 14). Feed it Bars (uses close) or any series. The output steps up when a new high enters the window and steps down (or holds) as old highs age out the back. Rolling Max of the high is the upper line of a Donchian Channel.
When to use it¶
Use Rolling Max to build breakout and trailing levels. A close crossing above the rolling max of the last N highs is an N-bar breakout. The rolling max of price is a trailing resistance line; in a long, a rolling max can anchor a trailing reference. Combine it with Rolling Min for a hand-built channel, or compare price to it with a Crosses Above for a clean breakout trigger.
Example¶
An N-bar breakout: take the Rolling Max of price over 20 bars and feed it as B into a Crosses Above with price as A — true when price breaks to a new 20-bar high. Route to a Buy Signal, gate with ADX / DMI, and backtest in the Tester.
Tips & gotchas¶
- The breakout primitive — rolling max of highs = the upper Donchian line.
- Steps with the window — a new extreme bumps it up; old extremes age out.
- Pair with Rolling Min for a custom channel.
- Window sets sensitivity — short = frequent (minor) breakouts, long = rare (major) ones.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| In | series / bars |
Source series. BARS input uses close. |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| max | series |
Line · sub-pane | Per-bar rolling max. |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Window (bars) | number · 2–500 | 14 |
Bars in the rolling window. |
Reference auto-generated from the block catalog · category Math.