Bentrix Docs
HomePricingDashboard

Smoothed Moving Average SMMA

Moving averagesoverlayone linein every package

Smoothed Moving Average, Wilder's — a heavily damped average, arithmetically the same as an EMA of period 2N−1.

It measures a slow centre that ignores most single-bar movement, which is why it is the building block of the Alligator and of Wilder's own indicators. Read for direction and slope rather than for crossings, which it gives late.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
bar —O — H — L — C —SMMA —first value at —
Show where:

Computed by Bentrix’s own code over the same synthetic bars on every page — an illustration of how the study behaves, not a market.

What this figure shows

The figure is computed over 300 sample bars. SMMA has no value on the first 19 — the bars it needs before it can answer — and its first value stands on bar 20. Of the 281 bars that have a value, the close is above the line on 153 and below it on 128. Counting the conditions the study declares on these bars: price crosses above the line 6 times; price crosses below the line 6 times. Press a condition under the figure to see each place marked. As states rather than moments: price is above the line on 153 bars; price is below the line on 128 bars.

02Its parts, named

Warm-upno value on the first 19 bars: thestudy needs them before it cananswerThe linethe study's value, one for each barThe bars it readseach bar's close, unless you chooseanother price
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

A very smooth, slow average — the one inside RSI, ATR and ADX.

SMMA is one line drawn over the candles. Beside a simple or an exponential average of the same period it is visibly slower: it stays further from price in a trend and bends later at a turn, with almost no small wiggles of its own.

04Where it comes from

J. Welles Wilder used this smoothing in the indicators of his 1978 book; it is often called Wilder's smoothing or the running moving average.

05The formula

SMMAt=(N−1)SMMAt−1+PtN
Ptthe applied price of bar t — the close by default
Nthe period, in bars
SMMAt−1the average one bar before

It is an exponential average with α=1/N — so an SMMA of 14 behaves like an EMA of 27.

06A worked example

Take eight closes — 20, 21, 23, 22, 24, 25, 24, 26 — and a period of 3.

The first value is the simple average of the first three closes: (20 + 21 + 23) / 3 = 21.33. After that each bar keeps two thirds of the old value and takes one third of the new close:

  • bar 4: (2 × 21.33 + 22) / 3 = 21.56
  • bar 5: (2 × 21.56 + 24) / 3 = 22.37
  • bar 6: (2 × 22.37 + 25) / 3 = 23.25

and it ends at 24.33, while the EMA of the same period ends at 24.98 and the SMA at 25.00. The smoothed average is the slowest of the three: the newest close takes 1/3 of the weight here, against 1/2 in the EMA.

07Built in Assay

The same study written in Assay, Bentrix’s script language, and drawn by Bentrix itself as the script’s graph: each block is one step of the formula. On the ladder the steps stand in the script’s order, one a row; on the board each wire carries a value from the block that gives it to the block that reads it, left to right. The script computes exactly what the study computes — Bentrix checks the two against each other, candle by candle.

THE SCRIPT’S GRAPH
//@version=6
indicator("Smoothed Moving Average", overlay = true)
length = input.int(20, "Length")
// The first value is the simple average of the first `length` closes.
seed = ta.sma(close, length)
// After that, each bar keeps `length - 1` parts of the line and adds one part of the new close.
var float smma = na
smma := na(smma[1]) ? seed : (smma[1] * (length - 1) + close) / length
plot(smma, "SMMA")

Paste it into the Assay IDE to put it on a chart, or to change it. Looking at the graph is free in every package; editing it as blocks is Plus.

08Readings — what traders look for

Mostly used inside other studies; on a chart it is read as a slow trend line. The Alligator's three lines are SMMAs.

A slow background line. Price far from the SMMA is read as an extended move; price weaving around a flat SMMA as a market without direction. It fails as a timing tool: by the time a slow line turns, most of the move that turned it is over.

09In different markets and timeframes

The smoothed average is for the background: it changes direction only when a move has lasted. In trends it is a steady reference well behind price; in ranges it goes nearly flat and price swings across it. It needs a long history before its first values settle — on a freshly loaded intraday chart the leftmost stretch is not yet reliable.

10With other studies

It is Wilder's smoothing, so it is read mostly through the studies built on it: the RSI's average gains and losses, the ATR, the directional lines, and the three lines of the Alligator.

11What it does not tell you

!

Its slowness hides short swings entirely; a turn of the SMMA comes late.

12Inputs and defaults

SMMA (20, 0)settings card
1Period20
2Shift0
3Applied priceClose
4TimeframeChart
5Wait for the candle to closeOn
  1. 1
    Period — 20The N of the formula: the newest price takes 1/N of the weight. An SMMA of N moves like an EMA of 2N − 1, so a small-looking period is already a slow line.
  2. 2
    Shift — 0Draws every line that many candles to the right (a negative number: to the left). The values are not changed, only where they stand.
  3. 3
    Applied price — CloseAny of the seven prices, and several at once, each its own line with its own look.
  4. 4
    Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
  5. 5
    Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.

What each input changes

  • ShiftDraws the line that many candles to the right, or to the left with a negative number. Its values do not change — only the candle each one stands on — so a shifted average is compared with a later price than the one it was computed at.
  • In useA period N behaves like an EMA of 2N − 1, so 7 to 14 already gives a slow line; the Alligator uses 13, 8 and 5.

13Limits and common misreadings

Its period means something different. SMMA 14 is not comparable to EMA 14 or SMA 14; it is close to EMA 27.

The start depends on the seed. Like the EMA, its first values depend on how it was started and settle after a few periods.

14Conditions an alert or a strategy can watch

price crosses above the line eventprice crosses below the line eventprice is above the line stateprice is below the line state

Event: the bar it happens on an event happens on one barState: every bar while it holds a state holds on every bar while it lasts

These are the conditions the study itself declares — the same rules the alert editor and the strategy engine read, and the ones the figure's chips show.

15Practise it in the laboratory

Put SMMA 14 and EMA 27 on one chart and see how closely they agree.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Moving averages › SMMA, or type SMMA in its search.
  • Its settings: the settings card opens when it is added; its legend's name opens it again.

18From an agent or a program

Two tools reach it. study_values computes it over a workbench’s candles up to the clock — no chart needed — and study_attach puts it on a chart, where it is drawn and saved with the chart ({"chart": "<chart uri>", "kind": "smma"}).

The study, as a chart files it

This is a new SMMA’s entry — its kind, its calculation, the price it reads and its settings. Change a setting here to read it with other inputs.

{
  "applied": "close",
  "convention": "mt5",
  "kind": "smma",
  "settings": {
    "period": 20,
    "shape": "period"
  }
}

An agent

An agent calls the MCP tool with it:

{
  "name": "study_values",
  "arguments": {
    "bench": "bentrix://lab/\u2026/bench/\u2026",
    "symbol": "EURUSD",
    "timeframe": "H1",
    "limit": 5,
    "study": {
      "applied": "close",
      "convention": "mt5",
      "kind": "smma",
      "settings": {
        "period": 20,
        "shape": "period"
      }
    }
  }
}

A program

A program does the same in its language — bench and market as in the built-in indicators guide:

Python

values = client.study.values(bench, market, "H1", {"applied": "close", "convention": "mt5", "kind": "smma", "settings": {"period": 20, "shape": "period"}}, limit=5)
print("times:", values["times"])
for line in values["lines"]:
    print("line:", line["line"])
    print("  newest values:", line["values"])

JSJavaScript

const values = await client.study.values({ bench, symbol: market, timeframe: "H1", study: { "applied": "close", "convention": "mt5", "kind": "smma", "settings": { "period": 20, "shape": "period" } }, limit: 5 });
console.log("times:", values.times);
for (const line of values.lines) {
  console.log("line:", line.line);
  console.log("  newest values:", line.values);
}

C#C#

var values = await client.Study.Values(bench, market, "H1", new Dictionary<string, object?> { ["applied"] = "close", ["convention"] = "mt5", ["kind"] = "smma", ["settings"] = new Dictionary<string, object?> { ["period"] = 20, ["shape"] = "period" } }, limit: 5);
Console.WriteLine($"times: {values!["times"]!}");
foreach (var line in values!["lines"]!.AsArray())
{
    Console.WriteLine($"line: {line!["line"]!}");
    Console.WriteLine($"  newest values: {line!["values"]!}");
}

GOGo

values := must(client.Study.Values(ctx, mcp.StudyValuesArgs{Bench: bench, Symbol: market, Timeframe: "H1", Study: map[string]any{"applied": "close", "convention": "mt5", "kind": "smma", "settings": map[string]any{"period": 20, "shape": "period"}}, Limit: mcp.Ptr[int64](5)}))
fmt.Println("times:", at(values, "times"))
for _, line := range at(values, "lines").([]any) {
	fmt.Println("line:", at(line, "line"))
	fmt.Println("  newest values:", at(line, "values"))
}

Java

Object values = client.study.values(new Bentrix.StudyApi.ValuesArgs(bench, market, "H1", obj("applied", "close", "convention", "mt5", "kind", "smma", "settings", obj("period", 20, "shape", "period"))).limit(5L));
System.out.println("times:" + " " + at(values, "times"));
for (Object line : (List<Object>) at(values, "lines")) {
    System.out.println("line:" + " " + at(line, "line"));
    System.out.println("  newest values:" + " " + at(line, "values"));
}

C++C++

auto values = client.study.values_(StudyApi::ValuesArgs(bench, market, "H1", Json::Object{{"applied", "close"}, {"convention", "mt5"}, {"kind", "smma"}, {"settings", Json::Object{{"period", 20}, {"shape", "period"}}}}).limit(5));
std::cout << "times:" << " " << values["times"].dump() << std::endl;
for (const Json &line : values["lines"].arr()) {
    std::cout << "line:" << " " << line["line"].dump() << std::endl;
    std::cout << "  newest values:" << " " << line["values"].dump() << std::endl;
}

Julia

values = client.study.values(bench, market, "H1", Dict{String,Any}("applied" => "close", "convention" => "mt5", "kind" => "smma", "settings" => Dict{String,Any}("period" => 20, "shape" => "period")); limit = 5)
println("times:", " ", values["times"])
for line in values["lines"]
    println("line:", " ", line["line"])
    println("  newest values:", " ", line["values"])
end

RR

values <- client$study$values(bench, market, "H1", list(applied = "close", convention = "mt5", kind = "smma", settings = list(period = 20, shape = "period")), limit = 5)
cat("times:", format(values$times), "\n")
for (line in values$lines) {
  cat("line:", format(line$line), "\n")
  cat("  newest values:", format(line$values), "\n")
}

RRust

let values = client.study().values(mcp::StudyValuesArgs::new(bench.clone(), market.clone(), "H1", serde_json::json!({"applied": "close", "convention": "mt5", "kind": "smma", "settings": {"period": 20, "shape": "period"}})).limit(5))?;
println!("times: {}", values["times"]);
for line in values["lines"].as_array().into_iter().flatten() {
    println!("line: {}", line["line"]);
    println!("  newest values: {}", line["values"]);
}

Reading the answer

  • times — the candles’ open times, in milliseconds since 1970 (UTC), oldest first.
  • lines — one entry per line, in this order, each with its line name and its values; values[i] belongs to the candle at times[i].
  • The last value is the candle at the clock’s, which may still be forming: it changes until that candle closes, as on the chart. Nothing after the clock is ever computed.
  • null is a candle with no value yet — the warm-up, about 2 × the period at the start of the history.
lineWhat it is
Mainline

In a strategy

Filed under a key of your choice in a strategy document’s studies — here smma: {"smma": {"applied": "close", "convention": "mt5", "kind": "smma", "settings": {"period": 20, "shape": "period"}}} — its rules can name:

WriteWhat it is
smmaits main line, as a value in a compare
{"cond": "smma:price.cross_up"}a condition it declares itself
{"cond": "smma:price.cross_down"}a condition it declares itself
{"cond": "smma:price.above"}a condition it declares itself
{"cond": "smma:price.below"}a condition it declares itself

19Sources

  1. Wilder, J. Welles Jr. New Concepts in Technical Trading Systems. Trend Research, 1978.

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed