Moving average settings: choosing length, EMA or SMA and source
Moving average settings explained: how to pick 9, 20, 50, 100 or 200 bars, EMA versus SMA, source and offset, and how to set them in SuperCharting.
Moving average settings come down to four choices: the length, the type (EMA or SMA), the source and the timeframe it sits on. Lengths of 9, 20, 50, 100 and 200 are the common ones, and the type matters less than most traders expect. Pick the length for the job you want the line to do, such as filtering the trend or marking pullbacks, then keep it fixed so your readings stay comparable. This page explains how to choose and where each setting lives in SuperCharting. The types themselves are covered in moving averages: EMA and SMA.
Length: what 9, 20, 50, 100 and 200 are used for
The length is the number of bars in the average. Longer means smoother and later.
| Length | Typical use | On a 1D chart it spans |
|---|---|---|
| 9 or 10 | Short-term momentum, fast crossovers | about 2 weeks |
| 20 | Pullback support in a trend, middle of Bollinger Bands | about 1 month |
| 50 | Medium trend, swing-trade support | about 2.5 months |
| 100 | Slower trend line | about 5 months |
| 200 | Long-term trend filter | about 10 months |
The fastest lengths mostly add noise on their own. Many traders use two or three together, for example 20 and 50, or 50 and 200, and read the gap and slope between them.
The built-in SMA and EMA open with a Length of 9, not 20 or 200, so you need to change it. The Moving average ribbon is the quick alternative: it draws four averages at once with defaults of 20, 50, 100 and 200.
How much lag each length adds
An average of n bars is centred about (n - 1) / 2 bars behind the latest bar when price is rising or falling at a steady speed. If price climbs 10 points a bar, a 20-bar average sits about 95 points below it, a 50-bar about 245 points below and a 200-bar about 995 points below. Longer lengths do not just look smoother. They stay further from price and turn much later, which is why a 200 average is a filter and not an entry tool.
EMA or SMA
An EMA of length n has the same average lag as an SMA of length n in a steady trend. The difference is in how they treat the past.
- The SMA weights every bar in the window equally and drops the oldest bar completely when a new one arrives. A big spike therefore makes the SMA jump when it enters, and jump again when it leaves n bars later.
- The EMA gives the newest bar a weight of 2 / (n + 1), which is 9.5% at length 20 against 5% for the SMA. Older bars fade gradually and never fully leave.
So the EMA reacts a little more to the latest bar and has no "cliff" effect. The SMA is steadier and easy to compute by hand. For a 200 filter the choice rarely matters. For a 20 pullback line the EMA is the common pick, and many 200-day traders prefer the SMA because that is what most others watch. Choose one per purpose and keep it. If you want fast lines with less lag, the library also has Hull, DEMA and TEMA averages.
Source and offset
- Source: Close is the default and is what most traders use. The list also has Open, High, Low, (H + L)/2, (H + L + C)/3, (O + H + L + C)/4, (H + L + C + C)/4 and Volume, and you can pick another indicator's plot. An average of the highs and an average of the lows make a channel. An average of volume tells you whether today's volume is above normal.
- Offset: shifts the line forward (positive) or backward (negative) by that many bars, from -500 to 500. It does not change the values. Displaced averages use it, such as a 20 EMA shifted 5 bars.
Which timeframe to put it on
An average counts bars, so a 50 means different things on different charts. A 50 on 5m is about four hours of price, a 50 on 1h is about a week of trading on NSE:NIFTY, and a 50 on 1D is about ten weeks. Intraday traders often watch a 20 or 50 EMA on 5m to 15m for pullbacks and use the 200 on 1h or 1D for the larger trend. Swing traders usually work from 1D averages. The built-in SMA and EMA average the bars of the chart they sit on, so a 200 on a 1h chart is a 200-hour line, not a daily one.
An average also needs history to settle. An EMA starts from the first bar it has, so its early values lean on that start. A chart can load up to 40,000 bars, which is far more than a 200-length average needs.
How to set a moving average in SuperCharting
- Open a chart, for example NSE:RELIANCE on the 1D interval.
- Click Indicators, type "ema" (or "sma") and click Exponential moving average or Simple moving average.
- Hover the legend line and click the gear for Settings.
- On Inputs, set Length (for example 50), Source and Offset.
- Under Smoothing, Type is None by default. Choose SMA, EMA, SMMA (RMA), WMA, VWMA or SMA + Bollinger Bands, and set its Length, to draw an average of the average.
- On Style, give each average its own colour and thickness so the lengths are easy to tell apart.
- Click Ok. Repeat for a second length, such as a 200 SMA.
To get several averages in one step, add the Moving average ribbon instead. Each of its four lines has its own type (SMA, EMA, SMMA (RMA), WMA or VWMA), source and length. A custom set can be saved in an indicator template so every new chart starts with it.
If you want the type switchable from one place, this script plots three lengths and lets you flip them between EMA and SMA with one box:
//@version=6
indicator("Moving average set", "MA set", overlay = true)
useEma = input.bool(true, "Use EMA (off = SMA)")
len1 = input.int(20, "Length 1", minval = 1)
len2 = input.int(50, "Length 2", minval = 1)
len3 = input.int(200, "Length 3", minval = 1)
srcIn = input.source(close, "Source")
f(len) => useEma ? ta.ema(srcIn, len) : ta.sma(srcIn, len)
plot(f(len1), "MA 1", color.blue)
plot(f(len2), "MA 2", color.orange, 2)
plot(f(len3), "MA 3", color.red, 2)
Save it in the Script Editor and add it from My scripts in the Indicators dialog.
Testing a choice
A setting is only worth keeping if it holds up on more than the chart in front of you. The Strategies chip has Two moving averages crossover, and its two lengths can be changed in Settings. Run it on several symbols, such as XAUUSD 4h and NSE:NIFTY 1D, with Commission and Slippage set on the Properties tab, and compare the Strategy Tester reports. Past results do not guarantee future results. When you reach for a faster average to "catch the move earlier", remember it will also be wrong more often; a trend-following line such as Supertrend or the gap measure in MACD shows the same trade-off.
Frequently asked questions
What is the best moving average setting?
There is no single best one. 20, 50 and 200 are the most watched, which is part of why they are useful: many traders react to the same lines. Choose the length for your timeframe and the job, then test it.
Which is better for day trading, EMA or SMA?
Day traders commonly use the EMA on 5m to 15m charts because it responds a little more to the latest bar. The difference at the same length is small, so consistency matters more than the choice.
Why do my 200 SMA values differ from another site?
Different history, session times or source (for example hlc3 instead of close) change the values. Check that the source and length match first.
Can I change the colour of each average?
Yes. Open Settings, go to the Style tab and set the colour, line thickness and style for each plotted average.