Indicator · Pine Script v6 · Own pane

Madrid MA Ribbon Bar v2

by theonetrade

Madrid MA Ribbon Bar v2 calculates 20 moving averages with periods ranging from 5 to 100 in steps of 5, using either exponential or simple moving averages.

View on GitHub

GitHub stars34on the repository
Pine versionv6current
Lines of code109
Settings1inputs
LicenceMIT
Last update2 weeks ago8 Nov 2026

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

109 lines of Pine Script v6 from assets/indicator/bit-exact/madrid_ma_ribbon_bar_v2_n4rW85zV.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.

madrid_ma_ribbon_bar_v2_n4rW85zV.pine
//@version=6
// Madrid : 26/Feb/2015 21:41: Moving Average Ribbon Bar: 2.0
// MMARB
// Madrid : 250630:0830 : Updated to PSV6
//
// This is based on the Madrid Moving Average Ribbon study, 
// it displays the output in a bar format to better identify
// entry points, up/down trends and reversals
//


indicator(title = 'Madrid MA Ribbon Bar v2', shorttitle = 'MMARB', precision = 0)

exponential = input(true, title = 'Exponential MA')

src = close

ema_1 = ta.ema(src, 05)
sma_1 = ta.sma(src, 05)
ma05 = exponential ? ema_1 : sma_1
ema_2 = ta.ema(src, 10)
sma_2 = ta.sma(src, 10)
ma10 = exponential ? ema_2 : sma_2
ema_3 = ta.ema(src, 15)
sma_3 = ta.sma(src, 15)
ma15 = exponential ? ema_3 : sma_3
ema_4 = ta.ema(src, 20)
sma_4 = ta.sma(src, 20)
ma20 = exponential ? ema_4 : sma_4
ema_5 = ta.ema(src, 25)
sma_5 = ta.sma(src, 25)
ma25 = exponential ? ema_5 : sma_5
ema_6 = ta.ema(src, 30)
sma_6 = ta.sma(src, 30)
ma30 = exponential ? ema_6 : sma_6
ema_7 = ta.ema(src, 35)
sma_7 = ta.sma(src, 35)
ma35 = exponential ? ema_7 : sma_7
ema_8 = ta.ema(src, 40)
sma_8 = ta.sma(src, 40)
ma40 = exponential ? ema_8 : sma_8
ema_9 = ta.ema(src, 45)
sma_9 = ta.sma(src, 45)
ma45 = exponential ? ema_9 : sma_9
ema_10 = ta.ema(src, 50)
sma_10 = ta.sma(src, 50)
ma50 = exponential ? ema_10 : sma_10
ema_11 = ta.ema(src, 55)
sma_11 = ta.sma(src, 55)
ma55 = exponential ? ema_11 : sma_11
ema_12 = ta.ema(src, 60)
sma_12 = ta.sma(src, 60)
ma60 = exponential ? ema_12 : sma_12
ema_13 = ta.ema(src, 65)
sma_13 = ta.sma(src, 65)
ma65 = exponential ? ema_13 : sma_13
ema_14 = ta.ema(src, 70)
sma_14 = ta.sma(src, 70)
ma70 = exponential ? ema_14 : sma_14
ema_15 = ta.ema(src, 75)
sma_15 = ta.sma(src, 75)
ma75 = exponential ? ema_15 : sma_15
ema_16 = ta.ema(src, 80)
sma_16 = ta.sma(src, 80)
ma80 = exponential ? ema_16 : sma_16
ema_17 = ta.ema(src, 85)
sma_17 = ta.sma(src, 85)
ma85 = exponential ? ema_17 : sma_17
ema_18 = ta.ema(src, 90)
sma_18 = ta.sma(src, 90)
ma90 = exponential ? ema_18 : sma_18
ema_19 = ta.ema(src, 95)
sma_19 = ta.sma(src, 95)
ma95 = exponential ? ema_19 : sma_19
ema_20 = ta.ema(src, 100)
sma_20 = ta.sma(src, 100)
ma100 = exponential ? ema_20 : sma_20

change_1 = ta.change(ma05)
change_2 = ta.change(ma05)
change_3 = ta.change(ma05)
leadMAColor = ta.change(ma05) >= 0 and ma05 > ma100 ? color.lime : change_1 < 0 and ma05 > ma100 ? color.maroon : change_2 <= 0 and ma05 < ma100 ? color.red : change_3 >= 0 and ma05 < ma100 ? color.green : color.gray
maColor(ma, maRef) =>
    change1 = ta.change(ma)
    change2 = ta.change(ma)
    change3 = ta.change(ma)
    ta.change(ma) >= 0 and ma05 > maRef ? color.lime : change1 < 0 and ma05 > maRef ? color.maroon : change2 <= 0 and ma05 < maRef ? color.red : change3 >= 0 and ma05 < maRef ? color.green : color.gray


plot(05, color = leadMAColor, style = plot.style_columns, title = 'MMA05', linewidth = 2, histbase = 00)
plot(10, color = maColor(ma10, ma100), style = plot.style_columns, title = 'MMA10', linewidth = 2, histbase = 05)
plot(15, color = maColor(ma15, ma100), style = plot.style_columns, title = 'MMA15', linewidth = 2, histbase = 10)
plot(20, color = maColor(ma20, ma100), style = plot.style_columns, title = 'MMA20', linewidth = 2, histbase = 15)
plot(25, color = maColor(ma25, ma100), style = plot.style_columns, title = 'MMA25', linewidth = 2, histbase = 20)
plot(30, color = maColor(ma30, ma100), style = plot.style_columns, title = 'MMA30', linewidth = 2, histbase = 25)
plot(35, color = maColor(ma35, ma100), style = plot.style_columns, title = 'MMA35', linewidth = 2, histbase = 30)
plot(40, color = maColor(ma40, ma100), style = plot.style_columns, title = 'MMA40', linewidth = 2, histbase = 35)
plot(45, color = maColor(ma45, ma100), style = plot.style_columns, title = 'MMA45', linewidth = 2, histbase = 40)
plot(50, color = maColor(ma50, ma100), style = plot.style_columns, title = 'MMA50', linewidth = 2, histbase = 45)
plot(55, color = maColor(ma55, ma100), style = plot.style_columns, title = 'MMA55', linewidth = 2, histbase = 50)
plot(60, color = maColor(ma60, ma100), style = plot.style_columns, title = 'MMA60', linewidth = 2, histbase = 55)
plot(65, color = maColor(ma65, ma100), style = plot.style_columns, title = 'MMA65', linewidth = 2, histbase = 60)
plot(70, color = maColor(ma70, ma100), style = plot.style_columns, title = 'MMA70', linewidth = 2, histbase = 65)
plot(75, color = maColor(ma75, ma100), style = plot.style_columns, title = 'MMA75', linewidth = 2, histbase = 70)
plot(80, color = maColor(ma80, ma100), style = plot.style_columns, title = 'MMA80', linewidth = 2, histbase = 75)
plot(85, color = maColor(ma85, ma100), style = plot.style_columns, title = 'MMA85', linewidth = 2, histbase = 80)
plot(90, color = maColor(ma90, ma100), style = plot.style_columns, title = 'MMA90', linewidth = 2, histbase = 85)
plot(95, color = maColor(ma90, ma100), style = plot.style_columns, title = 'MMA95', linewidth = 2, histbase = 90)
plot(100, color = maColor(ma90, ma100), style = plot.style_columns, title = 'MMA100', linewidth = 2, histbase = 95)

Overview

Madrid MA Ribbon Bar v2 evaluates the slope and position of each moving average relative to the 100-period baseline, assigning specific colors to represent bullish, bearish, and momentum shifts. The script plots these values as colored stacked columns in a separate pane, providing a visual representation of overall trend structure, entry points, and trend reversals.

Details

Published by

theonetrade on GitHub

Draws

Separate pane below the chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

Topics

algorithmic-tradingbacktestingbitcoinccxtcrypto-tradingllm-agentoffline-backtestingopen-source-tradingpine-scriptpine-to-pythonpinescriptpynecorepythonquantquantitative-financestrategy-backtestingtechnical-analysistrading-indicatorstrading-strategiestradingview

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
Exponential MAbooltrueexponential
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.

Similar Pine Scripts

Beep Boop

by magic8bot
408 stars

This indicator calculates a modified MACD oscillator and signal line alongside a trend EMA filter, plotting the output as a stylized column histogram in a separate pane. Instead of plotting true MACD distance, it quantifies positive and negative histogram mome

Indicator v4 Oscillators & momentumTrend
Updated 3 years ago · MIT GitHub repository of Beep Boop
228 stars

Multi-Timeframe Analysis Suite calculates trend direction and momentum conditions across five user-selected timeframes using moving averages, RSI, and Stochastic oscillators. It evaluates moving average slope and oscillator levels to compute trend alignment, m

Indicator v6 Screeners & dashboardsTrend
Updated 4 months ago · None stated GitHub repository of Multi-Timeframe Analysis Suite

KamaFama

by Mastaaa1987
141 stars

KamaFama is an indicator that translates a Freqtrade trading strategy into Pine Script for visualization. It combines Kaufman Adaptive Moving Average (KAMA), MAMA/FAMA calculations derived via Hilbert Transform, Williams %R, and correlation trend filters to ev

Indicator v6 Moving averagesOscillators & momentum
Updated 2 months ago · MIT GitHub repository of KamaFama

MultiIndicator

by capissimo
114 stars

MultiIndicator combines multiple technical indicators into a single separate pane to save chart space. It calculates and displays market regime detection based on ordinary least squares regression, a Holt exponential smoothing crossover, normalized RSI, ADX, a

Indicator v4 Oscillators & momentumTrend
Updated 2 years ago · None stated GitHub repository of MultiIndicator
99 stars

Calculates the Archer Moving Averages Trends (AMAT) indicator by comparing fast and slow Exponential Moving Averages (EMAs) alongside their slope directions. A bullish trend (+1) is identified when the fast EMA exceeds the slow EMA with both rising, while a be

Indicator v6 TrendMoving averages
Updated 8 weeks ago · Apache-2.0 GitHub repository of Archer Moving Averages Trends (AMAT)

Colored fill

by be-thomas
65 stars

This indicator plots two simple moving averages of close, one over five bars and one over twenty bars, in a separate pane. It shades the area between the two plots green when the shorter average is above the longer average and red when it is below. There are n

Indicator v4 Moving averagesTrend
Updated 4 weeks ago · GPL-3.0 GitHub repository of Colored fill

More Moving averages scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers