Bentrix Docs
HomePricingDashboard

Moving Average Ribbon

Moving averagesoverlay8 linesin every package

Several moving averages of the same price at evenly stepped lengths, drawn together: the first at the starting length and each next one longer by the step, at most sixteen.

It measures how averages of many horizons are ordered and spaced at once. Readings: the lines fanned out in order of length, or bunched and crossing each other. The averages are the standard ones of the chosen kind; the EMA is TA-Lib's, seeded by the simple average of its first window.

01The study, live

Live figureScroll to zoom, drag the bars to pan.
bar —O — H — L — C —Ribbon { index: 0 } —Ribbon { index: 1 } —Ribbon { index: 2 } —Ribbon { index: 3 } —Ribbon { index: 4 } —Ribbon { index: 5 } —Ribbon { index: 6 } —Ribbon { index: 7 } —first value at —

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. MA Ribbon has no value on the first 19 — the bars it needs before it can answer — and its first value stands on bar 20. As states rather than moments: every line of the ribbon is above the next longer on 32 bars; every line of the ribbon is below the next longer on 73 bars.

02Its parts, named

Ribbon (7)one of the study's linesRibbon (8)one of the study's linesWarm-upno value on the first 19 bars: thestudy needs them before it cananswerRibbon (4)one of the study's linesRibbon (3)one of the study's linesRibbon (6)one of the study's linesRibbon (2)one of the study's lines
Computed by Bentrix’s own code over the sample bars. It is drawn on once, as you reach the figure.

03What you see

A fan of averages of one kind — by default each a few bars longer than the last — drawn together. When they lie in order and apart, the fan opens; when they tangle, it closes.

04Where it comes from

Drawing several averages of stepped periods together is a long-standing chart habit; the best-known named version is Daryl Guppy's Multiple Moving Average, described in his 2004 book, which uses a short and a long group of EMAs.

05The formula

Linet(j)=MA(P, Start+j·Step)t,j=0,1,…,Count−1
MA(P,n)the chosen kind of moving average of the price over n bars
Startthe period of the first line
Stephow many bars longer each next line is
Countthe number of lines

There is no new formula: the ribbon is Count moving averages of one kind, the first with period Start and each next one Step bars longer. With the defaults that is eight EMAs of 20, 30, 40, … 90 bars.

06A worked example

With Count 8, Start 20 and Step 10, the periods are 20, 30, 40, 50, 60, 70, 80, 90.

Suppose on some bar the eight averages read, shortest first, 104.2, 103.6, 103.1, 102.4, 101.9, 101.5, 101.0, 100.6. They are in perfect order — each shorter average above each longer one — and the ribbon is 104.2 − 100.6 = 3.6 wide.

Twenty bars later they read 102.1, 102.3, 102.2, 102.0, 101.9, 101.8, 101.6, 101.4: the order is broken at the short end and the width is 0.9. Nothing else is computed; the ribbon is read from order and width.

On real closes — 20, 21, 23, 22, 24, 25, 24, 26 — with Count 3, Start 2, Step 1 and simple averages, the periods are 2, 3 and 4 and the three averages read 25.00, 25.00 and 24.75 on the last bar: in order, and 0.25 wide.

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("Moving Average Ribbon", overlay = true)
start = input.int(20, "First length")
step = input.int(10, "Step")
// Eight exponential averages, each `step` bars longer than the one before it. Each starts from the simple
// average of its first `length` closes, then takes a share of every new close.
ema1 = ta.ema(close, start)
ema2 = ta.ema(close, start + step)
ema3 = ta.ema(close, start + 2 * step)
ema4 = ta.ema(close, start + 3 * step)
ema5 = ta.ema(close, start + 4 * step)
ema6 = ta.ema(close, start + 5 * step)
ema7 = ta.ema(close, start + 6 * step)
ema8 = ta.ema(close, start + 7 * step)
plot(ema1, "MA 1")
plot(ema2, "MA 2")
plot(ema3, "MA 3")
plot(ema4, "MA 4")
plot(ema5, "MA 5")
plot(ema6, "MA 6")
plot(ema7, "MA 7")
plot(ema8, "MA 8")

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

An ordered, widening ribbon — shortest on top in a rise — is read as prices of every recent horizon agreeing in direction.

A tangled ribbon is read as the horizons disagreeing: a sideways market.

The ribbon compressing after a move is read as the move's momentum fading across horizons.

Order. All lines stacked in order of period, shortest nearest price, is read as a trend that holds across every horizon in the ribbon. It fails as timing: perfect order appears only after the move has run long enough to turn the slowest line.

Width. A widening ribbon is read as the move speeding up, a narrowing one as it slowing. A ribbon squeezed into a braid is read as no trend. It fails in a slow drift, where the ribbon is orderly and narrow at once.

Price entering the ribbon. Read as a pullback whose depth can be judged by how many lines it passes. It fails when the ribbon is narrow — price then passes through all of it in one bar.

09In different markets and timeframes

A ribbon shows a trend's age and health across horizons, so it is most useful in markets that trend for long stretches. In a range it is a braid. On low timeframes the slowest line needs a long history to be reliable.

10With other studies

It is its own companion: the reading is the order and width of the lines. It is set beside the ADX to tell an orderly narrow ribbon (a slow drift) from a strong trend.

11What it does not tell you

!

A ribbon is many averages of the same prices; it says the same thing as two of them, more vividly.

12Inputs and defaults

MA Ribbon (8, ema)settings card
1Count8
2Averageema
3Start20
4Step10
5Applied priceClose
6TimeframeChart
7Wait for the candle to closeOn
  1. 1
    Count — 8How many averages are drawn. More lines make the fan easier to see and the chart busier.
  2. 2
    Average — emaThe kind of average every line uses. EMAs fan out sooner than SMAs.
  3. 3
    Start — 20The period of the shortest average.
  4. 4
    Step — 10How much longer each next average is. A larger step spreads the ribbon over a wider span of periods and widens it.
  5. 5
    Applied price — CloseAny of the seven prices, and several at once, each its own line with its own look.
  6. 6
    Timeframe — ChartThe chart's own by default; any higher one, read on the last closed candle. A finer one is never offered.
  7. 7
    Wait for the candle to close — OnThe value of a higher timeframe is taken only from a candle that has finished.

The settings in use

  • In use8 lines from 20 by steps of 10 is the default; Guppy's own sets are 3, 5, 8, 10, 12, 15 and 30, 35, 40, 45, 50, 60.

13Limits and common misreadings

Eight lines are one piece of information seen eight times: they are all averages of the same closes.

The slowest line sets the warm-up: with the defaults the full ribbon needs 90 bars.

14Conditions an alert or a strategy can watch

every line of the ribbon is above the next longer stateevery line of the ribbon is below the next longer 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

Play a trend's start and end and watch the order of the lines change.

Open the laboratory

17In Bentrix

  • From the menu: a chart's Indicators button › Moving averages › MA Ribbon, or type MA Ribbon 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": "ma_ribbon"}).

The study, as a chart files it

This is a new MA Ribbon’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": "custom",
  "kind": "ma_ribbon",
  "settings": {
    "count": 8,
    "ma": "ema",
    "shape": "ribbon",
    "start": 20,
    "step": 10
  }
}

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": "custom",
      "kind": "ma_ribbon",
      "settings": {
        "count": 8,
        "ma": "ema",
        "shape": "ribbon",
        "start": 20,
        "step": 10
      }
    }
  }
}

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": "custom", "kind": "ma_ribbon", "settings": {"count": 8, "ma": "ema", "shape": "ribbon", "start": 20, "step": 10}}, 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": "custom", "kind": "ma_ribbon", "settings": { "count": 8, "ma": "ema", "shape": "ribbon", "start": 20, "step": 10 } }, 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"] = "custom", ["kind"] = "ma_ribbon", ["settings"] = new Dictionary<string, object?> { ["count"] = 8, ["ma"] = "ema", ["shape"] = "ribbon", ["start"] = 20, ["step"] = 10 } }, 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": "custom", "kind": "ma_ribbon", "settings": map[string]any{"count": 8, "ma": "ema", "shape": "ribbon", "start": 20, "step": 10}}, 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", "custom", "kind", "ma_ribbon", "settings", obj("count", 8, "ma", "ema", "shape", "ribbon", "start", 20, "step", 10))).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", "custom"}, {"kind", "ma_ribbon"}, {"settings", Json::Object{{"count", 8}, {"ma", "ema"}, {"shape", "ribbon"}, {"start", 20}, {"step", 10}}}}).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" => "custom", "kind" => "ma_ribbon", "settings" => Dict{String,Any}("count" => 8, "ma" => "ema", "shape" => "ribbon", "start" => 20, "step" => 10)); 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 = "custom", kind = "ma_ribbon", settings = list(count = 8, ma = "ema", shape = "ribbon", start = 20, step = 10)), 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": "custom", "kind": "ma_ribbon", "settings": {"count": 8, "ma": "ema", "shape": "ribbon", "start": 20, "step": 10}})).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 1 × the period at the start of the history.
lineWhat it is
Ribbon { index: 0 }Ribbon { index: 0 }
Ribbon { index: 1 }Ribbon { index: 1 }
Ribbon { index: 2 }Ribbon { index: 2 }
Ribbon { index: 3 }Ribbon { index: 3 }
Ribbon { index: 4 }Ribbon { index: 4 }
Ribbon { index: 5 }Ribbon { index: 5 }
Ribbon { index: 6 }Ribbon { index: 6 }
Ribbon { index: 7 }Ribbon { index: 7 }

In a strategy

Filed under a key of your choice in a strategy document’s studies — here ma_ribbon: {"ma_ribbon": {"applied": "close", "convention": "custom", "kind": "ma_ribbon", "settings": {"count": 8, "ma": "ema", "shape": "ribbon", "start": 20, "step": 10}}} — its rules can name:

WriteWhat it is
{"cond": "ma_ribbon:ribbon.aligned_up"}a condition it declares itself
{"cond": "ma_ribbon:ribbon.aligned_down"}a condition it declares itself

Its lines named ribbon are more than one line of that name, so a strategy reaches them through the conditions above rather than by name.

19Sources

  1. Murphy, John J. Technical Analysis of the Financial Markets. New York Institute of Finance, 1999, ch. 9.
  2. Guppy, Daryl. Trend Trading. Wrightbooks, 2004.

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