Zeal Terminal Open in Zeal Terminal

Pine Script v5 · Indicator

Moving Average Ribbon

A Pine Script v5 indicator built on SMA or WMA or RMA or HMA or EMA (close, 20). It draws 4 lines on the price chart. It declares 2 alerts. 6 settings; defaults include Average type EMA, Source close and Length 1 20.

Generated from the script's code by a template: every clause is a fact read from the source. Not written by a person or a model, and not taken from the author's description.

Does Moving Average Ribbon repaint?
No
No repainting patterns were found in the source, and a live tick-by-tick replay matched history on 300 of 300 bars.
How many settings does Moving Average Ribbon have?
6
Defaults include Average type EMA, Source close, Length 1 20.
What alerts does Moving Average Ribbon have?
2
Ribbon stacked up; Ribbon stacked down.
Does Moving Average Ribbon run in Pine Script v6?
Yes
Every plotted value identical on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. The v6 script can be downloaded below.
Does Moving Average Ribbon draw on the price chart?
Yes
It is declared with overlay = true.

BTCUSDT · 1D · default settings

  • MA 1
  • MA 2
  • MA 3
  • MA 4
Prerendered with the defaults. Change anything and run it here. The script runs in your browser.
Settings (6)
40,00060,00080,000100,000120,000AprJulOct2025AprJulOct2026AprJulOct
Binance BTCUSDT 1D candles, 26 Jan 2024 to 21 Oct 2026, 1,000 bars, default settings. Lines and shading are what the script draws.
MA 1
82,813.50
on the last bar
MA 2
80,839.40
on the last bar
MA 3
77,373.10
on the last bar
MA 4
76,126.60
on the last bar

The value of each line the script plots, on the last of 1,000 bars, with the default settings.

Review

What a careful reader of this script would point out, found by checking the source and the backtest.

Nothing to point out.

Settings

Every input the script declares, with its default and what it feeds. Bounds are the ones the script enforces.

SettingDefaultType and rangeFeeds
Average typeEMAstring · options ["SMA", "EMA", "WMA", "RMA", "HMA"]ma1 ma2 ma3 ma4
Sourceclosesourcema1 ma2 ma3 ma4
Length 120int · min 1ma1
Length 250int · min 1ma2
Length 3100int · min 1ma3
Length 4200int · min 1ma4

What it calculates

  • SMA / WMA / RMA / HMA / EMASource (close), Length 1 (20) · chosen by Average typema1 · line 17
  • SMA / WMA / RMA / HMA / EMASource (close), Length 2 (50) · chosen by Average typema2 · line 23
  • SMA / WMA / RMA / HMA / EMASource (close), Length 3 (100) · chosen by Average typema3 · line 29
  • SMA / WMA / RMA / HMA / EMASource (close), Length 4 (200) · chosen by Average typema4 · line 35

Signal flow

How price data and settings reach what is drawn. Each box is a name in the script, or several computed the same way; each arrow is a value one of them reads. Hover a box for its members.

closecloseprice datamaTypeAverage typesetting · EMAlen1Length 1setting · 20len2Length 2setting · 50len3Length 3setting · 100len4Length 4setting · 200ma1SMA / WMA / RMA / HMA /…→ ma1 · by Average typema2SMA / WMA / RMA / HMA /…→ ma2 · by Average typema3SMA / WMA / RMA / HMA /…→ ma3 · by Average typema4SMA / WMA / RMA / HMA /…→ ma4 · by Average typestacked, inversestacked · inverse2 conditionsplot:45MA 1plotplot:46MA 2plotplot:47MA 3plotplot:48MA 4plotalertcondition:50Ribbon stacked upalertconditionalertcondition:51Ribbon stacked downalertcondition

What it draws

OutputCallValueBy defaultLine
MA 1plotma1Shown45
MA 2plotma2Shown46
MA 3plotma3Shown47
MA 4plotma4Shown48

Alerts

AlertCallMessageLine
Ribbon stacked upalertconditionMoving averages are stacked in rising order50
Ribbon stacked downalertconditionMoving averages are stacked in falling order51

Does it repaint?

No

No repainting patterns in the source, and the live replay matched history.

300/300bars identical at close when replayed liveThe last 300 bars, from 26 Dec 2025, were fed to the engine as live ticks, four per bar, and compared with the historical run. On 0 of them the colour changed while the bar was forming before it settled.
  • ClearHigher-timeframe dataThe script requests no other symbol or timeframe.
  • ClearFuture-bar referencesNo negative history offsets such as close[-1].
  • ClearIntrabar recalculationNo varip or realtime-only state. Values move while a bar forms and settle when it closes, as every indicator's do.

The checks read the source; the replay runs it. Together they catch the common causes, not every possible one.

Other markets

The same script with default settings on 8 Binance markets, each the most recent 1,000 bars.

MarketMA 1MA 2MA 3MA 4
BTCUSDT 1D82,813.5080,839.4077,373.1076,126.60
BTCUSDT 4h82,948.8082,622.0082,752.8082,130.00
ETHUSDT 1D2,498.612,482.292,363.942,317.10
ETHUSDT 4h2,446.312,450.702,489.412,512.36
SOLUSDT 1D108.71106.84100.1998.08
SOLUSDT 4h106.06106.28108.29108.87
BNBUSDT 1D743.50733.58703.47688.68
BNBUSDT 4h737.48735.20741.10742.19

Each line's value on the last bar.

Similar scripts

Indicators and strategies built from the same calculations.

ScriptSharesType
Smoothed Heikin Ashi Trend on Chart - TraderHalai BACKTEST by TraderHalaisma ema hma rmav5 strategy
Optimized Keltner Channels SL-TP Strategy for BTC by chanu_lev10ksma ema rmav4 strategy
Forex SWING Trader by SoftKill21wma ema smav4 strategy
RMI + Triple HMRSI + Double EVWRSI + TERSI + CMO Strategy by burgercrisisrma hma emav4 strategy
Soheil PKO's 5 min Hitman Scalp - 3MA + Laguerre RSI + ADX [Pt] by PtGamblerema sma rmav5 strategy

Upgrade and export

Written in Pine Script v5. The clean-v5 step types the settings and moves when = into if blocks, which v6 requires; it is run before and after like any upgrade.

  • No v6-only features. v6 is not needed to run this script.

Clean v5

Verified

Nothing to change.

Does it run in Pine Script v6?

Yes

Every plotted value identical on BTCUSDT 1D, 1,000 bars, in Zeal Terminal's engine. Both versions were run on Zeal Terminal's engine, and the results are identical. It differs from the v5 version by 1 edit.

Download the v6 script

⋯// © Zeal Terminal-//@version=5+//@version=6indicator("Moving Average Ribbon", shorttitle = "MA Ribbon", overlay = true)⋯

Where it runs

EngineCompilesRunsMatches TradingView
Zeal Terminal · OpenPineScript v2Yes 11 msYes 1,000 bars in 33 msNot measured
PineTSNot testedNot testedNot measured

“Matches TradingView” needs this script's own output exported from TradingView and compared bar by bar, which has not been done for this script. The engine is built on OpenPineScript, whose conformance results are in its conformance report.

Source

Written by Zeal Terminal and published under the Mozilla Public License 2.0.

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/// © Zeal Terminal//@version=5indicator("Moving Average Ribbon", shorttitle = "MA Ribbon", overlay = true) // Four moving averages of one type. The ribbon fans out in a trend and// tangles in a range.maType = input.string("EMA", "Average type", options = ["SMA", "EMA", "WMA", "RMA", "HMA"])src    = input.source(close, "Source")len1   = input.int(20,  "Length 1", minval = 1)len2   = input.int(50,  "Length 2", minval = 1)len3   = input.int(100, "Length 3", minval = 1)len4   = input.int(200, "Length 4", minval = 1) // The type is a setting, so one branch runs on every bar and each average// keeps its own history.ma1 = switch maType    "SMA" => ta.sma(src, len1)    "WMA" => ta.wma(src, len1)    "RMA" => ta.rma(src, len1)    "HMA" => ta.hma(src, len1)    => ta.ema(src, len1)ma2 = switch maType    "SMA" => ta.sma(src, len2)    "WMA" => ta.wma(src, len2)    "RMA" => ta.rma(src, len2)    "HMA" => ta.hma(src, len2)    => ta.ema(src, len2)ma3 = switch maType    "SMA" => ta.sma(src, len3)    "WMA" => ta.wma(src, len3)    "RMA" => ta.rma(src, len3)    "HMA" => ta.hma(src, len3)    => ta.ema(src, len3)ma4 = switch maType    "SMA" => ta.sma(src, len4)    "WMA" => ta.wma(src, len4)    "RMA" => ta.rma(src, len4)    "HMA" => ta.hma(src, len4)    => ta.ema(src, len4) stacked = ma1 > ma2 and ma2 > ma3 and ma3 > ma4inverse = ma1 < ma2 and ma2 < ma3 and ma3 < ma4 plot(ma1, "MA 1", color = #4dd0e1, linewidth = 2)plot(ma2, "MA 2", color = #26a69a)plot(ma3, "MA 3", color = #ffb74d)plot(ma4, "MA 4", color = #ef5350, linewidth = 2) alertcondition(stacked and not stacked[1], "Ribbon stacked up", "Moving averages are stacked in rising order")alertcondition(inverse and not inverse[1], "Ribbon stacked down", "Moving averages are stacked in falling order")