Indicator · Pine Script v6 · On the chart

EMA High/Low/Median Ribbon

by iyoshikawa· code credited to Yellow_Yoshi

The script is an indicator that plots multiple moving averages on the price chart.

View on GitHub

GitHub stars1on the repository
Pine versionv6current
Lines of code174
Settings40inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago31 May 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

174 lines of Pine Script v6 from EMA_HLM.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

EMA_HLM.txt
// This Pine Script™ source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © Yellow_Yoshi
// @version=6
indicator("EMA High/Low/Median Ribbon", overlay=true)

// ─────────────────────────────────────────────
// INPUTS
// ─────────────────────────────────────────────

// ── HMA 9 Settings ──
grp_hma9          = "HMA 9"
show_hma9         = input.bool(true, "Show HMA 9", group=grp_hma9)
hma9_offset       = input.float(0, "Offset Width (points)", minval=0, step=0.5, group=grp_hma9)
hma9_bull_col     = input.color(color.new(#00FF00, 0), "Bullish Color", group=grp_hma9)
hma9_bear_col     = input.color(color.new(#FF0000, 0), "Bearish Color", group=grp_hma9)
hma9_fill_col     = input.color(color.new(#00FF00, 85), "Band Fill Color", group=grp_hma9)
hma9_fill_show    = input.bool(true, "Show Band Fill", group=grp_hma9)

// ── EMA 16 Settings (HLCC/4) ──
grp_ema16         = "EMA 16 (HLCC/4)"
show_ema16        = input.bool(true, "Show EMA 16", group=grp_ema16)
ema16_offset      = input.float(0, "Offset Width (points)", minval=0, step=0.5, group=grp_ema16)
ema16_bull_col    = input.color(color.new(#0099FF, 0), "Bullish Color", group=grp_ema16)
ema16_bear_col    = input.color(color.new(#FF6600, 0), "Bearish Color", group=grp_ema16)
ema16_fill_col    = input.color(color.new(#0099FF, 85), "Band Fill Color", group=grp_ema16)
ema16_fill_show   = input.bool(true, "Show Band Fill", group=grp_ema16)

// ── HMA 21 Settings ──
grp_hma21         = "HMA 21"
show_hma21        = input.bool(true, "Show HMA 21", group=grp_hma21)
hma21_offset      = input.float(0, "Offset Width (points)", minval=0, step=0.5, group=grp_hma21)
hma21_bull_col    = input.color(color.new(#00CCFF, 0), "Bullish Color", group=grp_hma21)
hma21_bear_col    = input.color(color.new(#FF3333, 0), "Bearish Color", group=grp_hma21)
hma21_fill_col    = input.color(color.new(#00CCFF, 85), "Band Fill Color", group=grp_hma21)
hma21_fill_show   = input.bool(true, "Show Band Fill", group=grp_hma21)

// ── EMA 34 Settings ──
grp_ema34         = "EMA 34"
ema34_len         = input.int(34, "EMA 34 Length", minval=1, group=grp_ema34)
show_ema34        = input.bool(true, "Show EMA 34", group=grp_ema34)
ema34_offset      = input.float(0, "Offset Width (points)", minval=0, step=0.5, group=grp_ema34)
ema34_bull_col    = input.color(color.new(#99FF00, 0), "Bullish Color", group=grp_ema34)
ema34_bear_col    = input.color(color.new(#FF0099, 0), "Bearish Color", group=grp_ema34)
ema34_fill_col    = input.color(color.new(#99FF00, 85), "Band Fill Color", group=grp_ema34)
ema34_fill_show   = input.bool(true, "Show Band Fill", group=grp_ema34)

// ── EMA 50 Settings ──
grp_ema50         = "EMA 50"
show_ema50        = input.bool(true, "Show EMA 50", group=grp_ema50)
ema50_offset      = input.float(0, "Offset Width (points)", minval=0, step=0.5, group=grp_ema50)
ema50_bull_col    = input.color(color.new(#FFFF00, 0), "Bullish Color", group=grp_ema50)
ema50_bear_col    = input.color(color.new(#FF00FF, 0), "Bearish Color", group=grp_ema50)
ema50_fill_col    = input.color(color.new(#FFFF00, 85), "Band Fill Color", group=grp_ema50)
ema50_fill_show   = input.bool(true, "Show Band Fill", group=grp_ema50)

// ── Background Settings ──
grp_bg            = "Background"
show_hma_crossover_bg = input.bool(true, "Show HMA 9/21 Crossover BG", group=grp_bg)
show_rsi_momentum_bg  = input.bool(true, "Show RSI Momentum BG", group=grp_bg)
rsi_bull_bg_col   = input.color(color.new(#00FF00, 90), "RSI Bullish BG", group=grp_bg)
rsi_bear_bg_col   = input.color(color.new(#FF0000, 90), "RSI Bearish BG", group=grp_bg)
rsi_neutral_bg_col = input.color(color.new(#808080, 95), "RSI Neutral BG", group=grp_bg)

// ── RSI Settings for Background ──
grp_rsi           = "RSI Momentum"
rsi_period        = input.int(14, "RSI Period", minval=2, group=grp_rsi)
rsi_fast_len      = input.int(5, "RSI Fast Length", minval=2, group=grp_rsi)
rsi_slow_len      = input.int(21, "RSI Slow Length", minval=2, group=grp_rsi)
rsi_thresh        = input.int(10, "RSI Difference Threshold", minval=1, group=grp_rsi)

// ─────────────────────────────────────────────
// CALCULATIONS
// ─────────────────────────────────────────────

// ── HMA 9 Calculation ──
hma9_base  = ta.hma(hl2, 9)
hma9_upper = hma9_base + hma9_offset
hma9_lower = hma9_base - hma9_offset
hma9_color = close > hma9_base ? hma9_bull_col : hma9_bear_col
hma9_fill_color = hma9_offset > 0 and hma9_fill_show ? (close > hma9_base ? color.new(hma9_fill_col, 85) : color.new(hma9_bear_col, 85)) : na

// ── EMA 16 Calculation (HLCC/4) ──
hlcc4 = (high + low + close + close) / 4
ema16_base  = ta.ema(hlcc4, 16)
ema16_upper = ema16_base + ema16_offset
ema16_lower = ema16_base - ema16_offset
ema16_color = close > ema16_base ? ema16_bull_col : ema16_bear_col
ema16_upper_color = close > ema16_upper ? ema16_bull_col : ema16_bear_col
ema16_lower_color = close > ema16_lower ? ema16_bull_col : ema16_bear_col
ema16_fill_color = ema16_offset > 0 and ema16_fill_show ? (close > ema16_base ? color.new(ema16_fill_col, 85) : color.new(ema16_bear_col, 85)) : na

// ── HMA 21 Calculation ──
hma21_base  = ta.hma(hl2, 21)
hma21_upper = hma21_base + hma21_offset
hma21_lower = hma21_base - hma21_offset
hma21_color = close > hma21_base ? hma21_bull_col : hma21_bear_col
hma21_fill_color = hma21_offset > 0 and hma21_fill_show ? (close > hma21_base ? color.new(hma21_fill_col, 85) : color.new(hma21_bear_col, 85)) : na

// ── EMA 34 Calculation ──
ema34_base  = ta.ema(hl2, ema34_len)
ema34_upper = ema34_base + ema34_offset
ema34_lower = ema34_base - ema34_offset
ema34_color = close > ema34_base ? ema34_bull_col : ema34_bear_col
ema34_upper_color = close > ema34_upper ? ema34_bull_col : ema34_bear_col
ema34_lower_color = close > ema34_lower ? ema34_bull_col : ema34_bear_col
ema34_fill_color = ema34_offset > 0 and ema34_fill_show ? (close > ema34_base ? color.new(ema34_fill_col, 85) : color.new(ema34_bear_col, 85)) : na

// ── EMA 50 Calculation ──
ema50_base  = ta.ema(hl2, 50)
ema50_upper = ema50_base + ema50_offset
ema50_lower = ema50_base - ema50_offset
ema50_color = close > ema50_base ? ema50_bull_col : ema50_bear_col
ema50_fill_color = ema50_offset > 0 and ema50_fill_show ? (close > ema50_base ? color.new(ema50_fill_col, 85) : color.new(ema50_bear_col, 85)) : na

// ── HMA 9/21 Crossover Detection ──
hma9_above_21 = hma9_base > hma21_base
hma9_below_21 = hma9_base < hma21_base
crossover_bull = hma9_above_21 and hma9_below_21[1]  // 9 crosses above 21
crossover_bear = hma9_below_21 and hma9_above_21[1]  // 9 crosses below 21
hma_crossover_bg = show_hma_crossover_bg ? (crossover_bull ? color.new(hma9_bull_col, 80) : crossover_bear ? color.new(hma9_bear_col, 80) : na) : na

// ── RSI Momentum Background Calculation ──
rsi_val = ta.rsi(close, rsi_period)
rsi_fast = ta.ema(rsi_val, rsi_fast_len)
rsi_slow = ta.ema(rsi_val, rsi_slow_len)
diff_curr = rsi_fast - rsi_slow

// Determine RSI momentum direction
is_rsi_bullish = diff_curr > rsi_thresh
is_rsi_bearish = diff_curr < -rsi_thresh
is_rsi_neutral = not is_rsi_bullish and not is_rsi_bearish

rsi_momentum_bg = show_rsi_momentum_bg ? (is_rsi_bullish ? rsi_bull_bg_col : is_rsi_bearish ? rsi_bear_bg_col : rsi_neutral_bg_col) : na

// ── Combined Background Logic ──
// Priority: HMA Crossover > RSI Momentum
final_bg_color = show_hma_crossover_bg and (crossover_bull or crossover_bear) ? hma_crossover_bg : rsi_momentum_bg

// ─────────────────────────────────────────────
// PLOTTING
// ─────────────────────────────────────────────

// ── Background Coloring ──
bgcolor(final_bg_color, title="Background Signals")

// ── HMA 9 Plotting ──
p_hma9_upper = plot(show_hma9 ? hma9_upper : na, "HMA 9 Upper", hma9_color, 1)
              plot(show_hma9 ? hma9_base : na, "HMA 9 Center", hma9_color, 2)
p_hma9_lower = plot(show_hma9 ? hma9_lower : na, "HMA 9 Lower", hma9_color, 1)
fill(p_hma9_upper, p_hma9_lower, hma9_fill_color, title="HMA 9 Band Fill")

// ── EMA 16 Plotting ──
p_ema16_upper = plot(show_ema16 ? ema16_upper : na, "EMA 16 Upper", ema16_upper_color, 1)
               plot(show_ema16 ? ema16_base : na, "EMA 16 Center", ema16_color, 2)
p_ema16_lower = plot(show_ema16 ? ema16_lower : na, "EMA 16 Lower", ema16_lower_color, 1)
fill(p_ema16_upper, p_ema16_lower, ema16_fill_color, title="EMA 16 Band Fill")

// ── HMA 21 Plotting ──
p_hma21_upper = plot(show_hma21 ? hma21_upper : na, "HMA 21 Upper", hma21_color, 1)
               plot(show_hma21 ? hma21_base : na, "HMA 21 Center", hma21_color, 2)
p_hma21_lower = plot(show_hma21 ? hma21_lower : na, "HMA 21 Lower", hma21_color, 1)
fill(p_hma21_upper, p_hma21_lower, hma21_fill_color, title="HMA 21 Band Fill")

// ── EMA 34 Plotting ──
p_ema34_upper = plot(show_ema34 ? ema34_upper : na, "EMA 34 Upper", ema34_upper_color, 1)
               plot(show_ema34 ? ema34_base : na, "EMA 34 Center", ema34_color, 2)
p_ema34_lower = plot(show_ema34 ? ema34_lower : na, "EMA 34 Lower", ema34_lower_color, 1)
fill(p_ema34_upper, p_ema34_lower, ema34_fill_color, title="EMA 34 Band Fill")

// ── EMA 50 Plotting ──
p_ema50_upper = plot(show_ema50 ? ema50_upper : na, "EMA 50 Upper", ema50_color, 1)
               plot(show_ema50 ? ema50_base : na, "EMA 50 Center", ema50_color, 2)
p_ema50_lower = plot(show_ema50 ? ema50_lower : na, "EMA 50 Lower", ema50_color, 1)
fill(p_ema50_upper, p_ema50_lower, ema50_fill_color, title="EMA 50 Band Fill")

Overview

EMA High/Low/Median Ribbon displays HMA 9, EMA 16, HMA 21, EMA 34 and EMA 50 lines with separate bullish and bearish colors plus optional band fills for each. Users toggle visibility of lines and fills while adjusting offset widths. The script draws directly on the price chart without a separate pane and provides color coded trend visualization.

Details

Published by

iyoshikawa on GitHub

Code credit

Yellow_Yoshi, as written in the script's header

Type

Indicator, Pine Script v6

Draws

On the price chart

Category

Moving averages

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.

Settings

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

SettingTypeDefaultVariable
Show HMA 9booltrueshow_hma9
Offset Width (points)float0hma9_offset
Bullish Colorcolorcolor.new(#00FF00, 0)hma9_bull_col
Bearish Colorcolorcolor.new(#FF0000, 0)hma9_bear_col
Band Fill Colorcolorcolor.new(#00FF00, 85)hma9_fill_col
Show Band Fillbooltruehma9_fill_show
Show EMA 16booltrueshow_ema16
Offset Width (points)float0ema16_offset
Bullish Colorcolorcolor.new(#0099FF, 0)ema16_bull_col
Bearish Colorcolorcolor.new(#FF6600, 0)ema16_bear_col
Band Fill Colorcolorcolor.new(#0099FF, 85)ema16_fill_col
Show Band Fillbooltrueema16_fill_show
Show all 40 settings
SettingTypeDefaultVariable
Show HMA 21booltrueshow_hma21
Offset Width (points)float0hma21_offset
Bullish Colorcolorcolor.new(#00CCFF, 0)hma21_bull_col
Bearish Colorcolorcolor.new(#FF3333, 0)hma21_bear_col
Band Fill Colorcolorcolor.new(#00CCFF, 85)hma21_fill_col
Show Band Fillbooltruehma21_fill_show
EMA 34 Lengthint34ema34_len
Show EMA 34booltrueshow_ema34
Offset Width (points)float0ema34_offset
Bullish Colorcolorcolor.new(#99FF00, 0)ema34_bull_col
Bearish Colorcolorcolor.new(#FF0099, 0)ema34_bear_col
Band Fill Colorcolorcolor.new(#99FF00, 85)ema34_fill_col
Show Band Fillbooltrueema34_fill_show
Show EMA 50booltrueshow_ema50
Offset Width (points)float0ema50_offset
Bullish Colorcolorcolor.new(#FFFF00, 0)ema50_bull_col
Bearish Colorcolorcolor.new(#FF00FF, 0)ema50_bear_col
Band Fill Colorcolorcolor.new(#FFFF00, 85)ema50_fill_col
Show Band Fillbooltrueema50_fill_show
Show HMA 9/21 Crossover BGbooltrueshow_hma_crossover_bg
Show RSI Momentum BGbooltrueshow_rsi_momentum_bg
RSI Bullish BGcolorcolor.new(#00FF00, 90)rsi_bull_bg_col
RSI Bearish BGcolorcolor.new(#FF0000, 90)rsi_bear_bg_col
RSI Neutral BGcolorcolor.new(#808080, 95)rsi_neutral_bg_col
RSI Periodint14rsi_period
RSI Fast Lengthint5rsi_fast_len
RSI Slow Lengthint21rsi_slow_len
RSI Difference Thresholdint10rsi_thresh
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

948 stars

The Adaptive Laguerre Filter calculates a smoothed, dynamically adjusted trendline plotted directly on the main price chart. It dynamically adjusts its damping factor (alpha) based on recent price range variations and median percentile calculations over a spec

Indicator v4 TrendMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter

This overlay indicator plots a Supertrend from an ATR length and factor, four exponential moving averages, and a selectable VWAP or TWAP taken from a chosen timeframe on the price chart. It also shows MACD and stochastic with adjustable lengths, smoothing, ver

Indicator v5 Oscillators & momentumMoving averages
Updated 1 year ago · MPL-2.0 GitHub repository of Momentum Setup: Vijay Thakare Option Buying Scalping Setup
330 stars

This script plots three moving averages on the price chart: a fast EMA or SMA with 10 periods, a slow EMA or SMA with 20 periods, and a trend EMA or SMA with 100 periods. It signals trend changes by drawing a white cross when the fast moving average crosses ab

Indicator v4 TrendMoving averages
Updated 2 months ago · None stated GitHub repository of 3 EMA/SMA + Cross [Alorse]
318 stars

This indicator plots four customizable moving averages directly on the main price chart using default lengths of 3, 8, 21, and 50 periods. It fills the space between adjacent averages in green or maroon depending on trend alignment. Additionally, it computes B

Indicator v5 Moving averagesTrend
Updated 2 months ago · MIT GitHub repository of Multiple Moving Averages
285 stars

Mean Reversion Study is an indicator that identifies trade setups combining exponential moving averages, RSI extremes, and engulfing candlestick patterns. It highlights bullish setups when a bullish engulfing candle forms below the EMA while RSI is oversold, a

Indicator v4 Mean reversionCandlestick patterns
Updated 3 years ago · None stated GitHub repository of Mean Reversion Study

NVDA Trend Ribbon

by longsurf-ai
277 stars

This indicator plots three exponential moving averages and ATR volatility envelopes on the price chart. It compares the fast and slow EMAs to shade a trend ribbon and marks confirmed upward and downward crossovers with triangle labels. Settings change the thre

Indicator v6 TrendMoving averages
Updated yesterday · MIT GitHub repository of NVDA Trend Ribbon

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers