All indicators

Moving Average

By LuxAlgoApr 13, 2020

Static chart image

The Moving Average build is a single configurable average that smooths a chosen price source over a set lookback — 20 bars by default — and plots the result on the chart. A type selector covers the common variants — SMA (default), EMA, WMA, RMA (SMMA), HMA, ALMA, VWMA, DEMA, TEMA, KAMA, LSMA, McGinley Dynamic, and Hamming — each following its standard published formula with no added logic; an optional second moving average with cross alerts covers crossover work.

How to Trade the Moving Average?

  • Price above a rising MA 1: the elementary trend filter; the slope carries most of the information.
  • Price crossing MA 1: the simplest trend-change trigger — responsive but whipsaw-prone around a flat average.
  • MA 1 crossing MA 2 (with Show MA 2 enabled): the classic fast/slow crossover — later entries, fewer false starts.
  • Distance from the average: stretch on either side gauges how extended the current swing is.

Moving Average Settings

  • MA 1 Type (default SMA): calculation used for the primary average.
  • MA 1 Length (default 20): bars in the MA 1 calculation.
  • MA 1 Source (default close): price series MA 1 is calculated on.
  • Show MA 2 (default disabled): displays the second moving average.
  • MA 2 Type (default SMA): calculation used for MA 2.
  • MA 2 Length (default 50): bars in the MA 2 calculation.
  • MA 2 Source (default close): price series MA 2 is calculated on.
  • ALMA Offset (default 0.85): ALMA type only — nearer 1 favors responsiveness, nearer 0 smoothness.
  • ALMA Sigma (default 6): ALMA type only — larger widens the Gaussian window.
  • LSMA Offset (default 0): LSMA type only — bar offset applied to the regression value.

Alerts

Price Cross Above MA 1 and Price Cross Below MA 1 fire when the source crosses MA 1, while MA 1 Cross Above MA 2 and MA 1 Cross Below MA 2 cover the two-line crossover; both evaluate even while the MA 2 plot is hidden.

Frequently Asked Questions

Which moving average type should I use?

Match the type to the job: SMA as the transparent reference, EMA or HMA for faster signal work, KAMA or McGinley on instruments that alternate between trend and chop. Switching types changes timing at the margin — it does not remove the lag trade-off.

How do I build a crossover setup?

Enable Show MA 2 and keep MA 1 faster than MA 2 — the 20/50 defaults already are — then read MA 1 crossing above MA 2 as bullish and below as bearish. The two MA-cross alert conditions cover automation.

What is the main limitation of moving averages?

Lag is structural: every average summarizes past prices, so crosses confirm turns after they begin, and sideways tape whips price across any average repeatedly. An average describes trend rather than predicting it.

Free indicator

Get free access to this indicator on the platforms below.

TradingView
NinjaTrader
MetaTrader 4/5

The Library is free. Quant makes it yours.

Pull any concept or indicator into Quant: rebuild it, retune it, or turn it into a backtested strategy of your own.