Moving Average Node

The Moving Average node smooths any series with a simple or exponential average: a signal line for RSI, a baseline for ATR. How it averages, what it can read, and when Price History or the SMA and EMA indicators fit better.

NodeBy AlgoLiftUpdated 4 min read
On this page 6How it worksExample: a signal line for RSISettingsUse something else whenWhen it doesn't behaveGoing further

The SMA and EMA indicators average price. Plenty of things worth averaging aren't price: an RSI that zigzags, an ATR you'd like to compare with its usual level, a MACD histogram that needs calming down. The Moving Average node averages whatever series you wire into it, simple or exponential, over the period you pick.

Takes
One series: an indicator, a price, a level, price action, a memory or another modifier
Gives
Its simple or exponential average over N bars
Reach for it
You want a smoother version of a series, or a baseline to compare it with

How it works

SMA is the plain average of the last N values, the bar your rules are reading included. EMA leans toward recent bars: each new value pulls it 2 ÷ (N + 1) of the way from where it was, so a 9-period EMA moves a fifth of the gap every bar. The EMA starts from the SMA of its first full window, so both types need N bars of history before they give you anything.

The trade-off is the usual one. The EMA turns sooner, the SMA is steadier, and both lag the thing they smooth. A longer period means a calmer line and a later signal.

Both need real values to average. An SMA whose window contains a single missing value comes out empty, and an EMA that runs into one does too. That matters for inputs that only exist some of the time, such as a price-action level that's empty whenever there's nothing to report.

The input must be a series the engine can build before the first bar: an indicator or one of its outputs, Current Price (which a modifier reads as the close of each completed bar), 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.

Example: a signal line for RSI

Say you trade NQ 5m and time entries with RSI(14). Raw RSI zigzags enough that "RSI turning up" triggers on every small bounce. A signal line helps: a short EMA of the RSI itself, so a turn only counts once RSI pushes back through its own recent average.

Wire RSI into a Moving Average set to EMA, Period 9. Then add a Crossover with RSI on A and the average on B, direction Above, on the Bar close clock. To keep it to oversold bounces, add a Comparison: RSI Less Than a Constant of 40. AND the two through a Logic node into a long Entry.

The entry now fires on the bar RSI climbs back through its 9-bar EMA while still in the lower part of its range, and ignores the twitches in between.

Settings

Period
Default 10
Bars averaged, from 1 to 999.
Type
Default SMA
SMA or EMA.

Use something else when

An average of price
Averaging Current Price here gives an average of closes, which the indicators already do, along with DEMA, TEMA, Hull and KAMA if you want a different curve.
The average volume or range of the last N bars
Price History averages a bar field directly (volume, range or any of the four prices) over completed bars, with no indicator in between.
The average daily range
A moving average averages bars, not sessions. A Price History reading the range of each completed session, averaged across the last 10, is the average daily range.

When it doesn't behave

My volume filter fires at every open

"Volume above 1.5 times its 20-bar average" compares the open's heavy bars with an average full of quiet ones, so the open always looks unusual and lunch never does. Compare like with like: a Price History on the This time of day window gives the average volume of this bar's clock slot over past sessions.

The average is empty for long stretches

Its input has gaps. A level from price action is empty while there's nothing to measure, and any window that contains an empty value can't be averaged. Average something that always has a value, or compare the level directly instead of smoothing it.

It won't take a Math node as its input

A modifier needs a series the engine builds before the first bar, and a Math node's result only exists as the strategy runs. Averages are linear, though, so you can average each input and do the arithmetic after. The SMA of (A minus B) is exactly SMA(A) minus SMA(B), and the EMA version agrees once both averages have warmed up.

Going further

A volatility regime filter is one of the most useful things to build with it. Wire ATR(14) into a Moving Average (SMA, 50) and compare ATR Greater Than its average: true while volatility is expanding, false while it's contracting. Breakout systems often want the first state, mean reversion the second.

Period and Type can both be swept. SMA against EMA is a real difference in shape, but usually a small one in results, and testing both doubles your search. Pick the type for a reason, sweep the period in coarse steps, and click the paintbrush on the node to draw the average on the results chart before trusting any number it produces.

Or ask the copilot