Skip to content
StatePath
Tool Atlasmarket.moving_average

Tool

Moving Average

market.moving_average

MarketTrend

Inputs

No typed inputs.

Outputs

Buffer (time series)

A single smoothed price line, one value per bar, plotted on the same scale as price.

A moving average smooths price into a single trend line by averaging the last N bars. Traders use it to see the underlying direction without the bar-to-bar noise, and to spot when price pulls back to or crosses the line.

Moving Average overview diagramMA

How it works

Over a rolling window (the period, default 14 bars) it averages the chosen price (close by default) into one value per bar. The mode picks how those bars are weighted: a simple average treats them equally, while exponential and Hull variants weight recent bars more so the line turns faster.

Modes

Mode options

SMA (Simple)sma

Averages the last N bars with equal weight. The smoothest, slowest-turning line.

SMA (Simple) diagramSMA

When to use: Use when you want a stable view of the trend and don't mind extra lag.

EMA (Exponential)ema

Weights recent bars more heavily, so the line tracks price with less lag than SMA.

EMA (Exponential) diagramEMA

When to use: Use when you want a responsive trend line that reacts faster to turns.

WMA (Linear-Weighted)wma

Weights bars linearly, newest gets the most weight. Sits between SMA and EMA in responsiveness.

WMA (Linear-Weighted) diagramWMA

When to use: Use when you want recent bars to count more, but a smoother shape than EMA.

DEMA (Double EMA)dema

A double-exponential construction that subtracts lag, hugging price closer than EMA.

DEMA (Double EMA) diagramDEMA

When to use: Use when EMA still lags too much and you want the line nearer to price.

TEMA (Triple EMA)tema

A triple-exponential construction that removes even more lag than DEMA, tracking price very closely.

TEMA (Triple EMA) diagramTEMA

When to use: Use when you want the least-lagging average and can tolerate more wiggle.

HMA (Hull)hma

The Hull moving average is built to be both smooth and very responsive, turning quickly with little lag.

HMA (Hull) diagramHMA

When to use: Use when you want fast turns and a smooth line, accepting occasional overshoot.

Source options

Openopen

Average each bar's open price.

Open diagram

When to use: Use open when that price best reflects the move you trade.

Highhigh

Average each bar's high price.

High diagram

When to use: Use high when that price best reflects the move you trade.

Lowlow

Average each bar's low price.

Low diagram

When to use: Use low when that price best reflects the move you trade.

Closeclose

Average each bar's close price. The usual choice.

Close diagram

When to use: Use close when that price best reflects the move you trade (the default).

HL2 (Median Price)hl2

Average the median price, the midpoint of each bar's high and low.

HL2 (Median Price) diagram

When to use: Use the median when you want to ignore where price opened and closed.

HLC3 (Typical Price)hlc3

Average the typical price, the mean of each bar's high, low, and close.

HLC3 (Typical Price) diagram

When to use: Use the typical price when you want close to count alongside the bar's range.

OHLC4 (Average Price)ohlc4

Average the OHLC4 price, the mean of each bar's open, high, low, and close.

OHLC4 (Average Price) diagram

When to use: Use the average price for the smoothest, most balanced input across the whole bar.

Configuration

modeenum

Which averaging method to use: sma (simple, equal weight), ema (exponential, recent-weighted), wma (linear-weighted), dema / tema (double / triple EMA, less lag), or hma (Hull, very responsive).

Choices:smaemawmadematemahma
periodscalar

How many bars to average over. Larger = smoother and slower; smaller = faster and noisier. 14 is a common default.

period diagram
sourceenum

Which price each bar contributes: open, high, low, close, hl2 (median), hlc3 (typical), or ohlc4 (average). Close is the usual choice.

Choices:openhighlowclosehl2hlc3ohlc4

Connects to

Feeds into

Examples

  • Wire close and a 50-period EMA into calc.cross to fire when price crosses the average.
  • Filter: only take longs when a fast MA sits above a slow MA (stack the trend).

Common mistakes

  • Using too short a period, which makes the line whippy and produces constant false crosses.
  • Treating every cross of the line as a signal in a sideways market, where price chops back and forth across it.

See also