Indicator · Pine Script v6 · Own pane

MTF MA Bands + RSI

by InNoobWeTrust

This indicator calculates and plots multi-timeframe moving average bands alongside a Relative Strength Index in a separate pane.

View on GitHub

GitHub stars4on the repository
Pine versionv6current
Lines of code228
Settings35inputs
LicenceNone statedfile: MPL-2.0
Last updatetoday28 Oct 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

228 lines of Pine Script v6 from .innoobwetrust/life_hacks/tradingview/mtf_ma_bands+rsi.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

mtf_ma_bands+rsi.pine
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © InNoobWeTrust

//@version=6
indicator("MTF MA bands + RSI", overlay=false)

//=============================================================================
// MTF MA bands
//=============================================================================

// Types
//-----------------------------------------------------------------------------{
enum MaType
    sma = 'SMA'
    wma = 'WMA'
    ema = 'EMA'

type MaTf
    bool enable
    string tf
    MaType t
    int len
    float ma
    float ma_filled
    float h_ma
    float h_ma_filled
    float l_ma
    float l_ma_filled
    color clr
    color band_clr
//-----------------------------------------------------------------------------}

// Const
//-----------------------------------------------------------------------------{
const int TF_SIZE = 7
//-----------------------------------------------------------------------------{

// Helper functions
//-----------------------------------------------------------------------------{
ma(MaType t, src, int len) =>
    switch t
        MaType.sma => ta.sma(src, len)
        MaType.wma => ta.wma(src, len)
        MaType.ema => ta.ema(src, len)

ma_tf(series string tf, MaType t, src, int len) =>
    request.security(syminfo.tickerid, tf, ma(t, src, len))


// Smoothing MA Calculation
rsi_ma(source, length, MAtype) =>
    switch MAtype
        "SMA"                   => ta.sma(source, length)
        "SMA + Bollinger Bands" => ta.sma(source, length)
        "EMA"                   => ta.ema(source, length)
        "SMMA (RMA)"            => ta.rma(source, length)
        "WMA"                   => ta.wma(source, length)
        "VWMA"                  => ta.vwma(source, length)
//-----------------------------------------------------------------------------}

// Input
//-----------------------------------------------------------------------------{
ma1_grp = '► MA1'
ma1_enable = input.bool(true, 'Enable', group = ma1_grp)
ma1_type = input.enum(MaType.ema, 'MA type', group = ma1_grp)
ma1_len = input.int(34, 'Length', group = ma1_grp)
ma1_color = input.color(color.new(#FFD921,50), 'Color', group = ma1_grp)
ma1_band_color = input.color(color.new(#FFD921,80), 'Band Color', group = ma1_grp)
ma1_tf = input.timeframe('', 'Timeframe', group = ma1_grp)

ma2_grp = '► MA2'
ma2_enable = input.bool(true, 'Enable', group = ma2_grp)
ma2_type = input.enum(MaType.ema, 'MA type', group = ma2_grp)
ma2_len = input.int(34, 'Length', group = ma2_grp)
ma2_color = input.color(color.new(#DDA059,50), 'Color', group = ma2_grp)
ma2_band_color = input.color(color.new(#DDA059,80), 'Band Color', group = ma2_grp)
ma2_tf = input.timeframe('5', 'Timeframe', group = ma2_grp)

ma3_grp = '► MA3'
ma3_enable = input.bool(true, 'Enable', group = ma3_grp)
ma3_type = input.enum(MaType.ema, 'MA type', group = ma3_grp)
ma3_len = input.int(34, 'Length', group = ma3_grp)
ma3_color = input.color(color.new(#AA585B,50), 'Color', group = ma3_grp)
ma3_band_color = input.color(color.new(#AA585B,80), 'Band Color', group = ma3_grp)
ma3_tf = input.timeframe('30', 'Timeframe', group = ma3_grp)

ma4_grp = '► MA4'
ma4_enable = input.bool(true, 'Enable', group = ma4_grp)
ma4_type = input.enum(MaType.ema, 'MA type', group = ma4_grp)
ma4_len = input.int(34, 'Length', group = ma4_grp)
ma4_color = input.color(color.new(#B52121,50), 'Color', group = ma4_grp)
ma4_band_color = input.color(color.new(#B52121,80), 'Band Color', group = ma4_grp)
ma4_tf = input.timeframe('240', 'Timeframe', group = ma4_grp)

ma5_grp = '► MA5'
ma5_enable = input.bool(true, 'Enable', group = ma5_grp)
ma5_type = input.enum(MaType.ema, 'MA type', group = ma5_grp)
ma5_len = input.int(34, 'Length', group = ma5_grp)
ma5_color = input.color(color.new(#6B3710,50), 'Color', group = ma5_grp)
ma5_band_color = input.color(color.new(#6B3710,80), 'Band Color', group = ma5_grp)
ma5_tf = input.timeframe('D', 'Timeframe', group = ma5_grp)

rsi_grp = '► RSI'
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group=rsi_grp)
rsiSourceInput = input.source(close, "Source", group=rsi_grp)
rsiTf = input.timeframe("", "Timeframe",group=rsi_grp)

// Smoothing MA inputs
rsi_smoothing_grp = "► Smoothing RSI MA"
maTypeInput = input.string("SMA", "Type", options = ["None", "SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = rsi_smoothing_grp, display = display.data_window)
maLengthInput = input.int(14, "Length", group = rsi_smoothing_grp, display = display.data_window, active = maTypeInput != "None")
var enableMA = maTypeInput != "None"
//-----------------------------------------------------------------------------}

// Calculation
//-----------------------------------------------------------------------------{

// Constructor
newMa(int idx) =>
    enable = switch idx
        0 => ma1_enable
        1 => ma2_enable
        2 => ma3_enable
        3 => ma4_enable
        4 => ma5_enable
    tf = switch idx
        0 => ma1_tf
        1 => ma2_tf
        2 => ma3_tf
        3 => ma4_tf
        4 => ma5_tf
    t = switch idx
        0 => ma1_type
        1 => ma2_type
        2 => ma3_type
        3 => ma4_type
        4 => ma5_type
    len = switch idx
        0 => ma1_len
        1 => ma2_len
        2 => ma3_len
        3 => ma4_len
        4 => ma5_len
    clr = switch idx
        0 => ma1_color
        1 => ma2_color
        2 => ma3_color
        3 => ma4_color
        4 => ma5_color
    band_clr = switch idx
        0 => ma1_band_color
        1 => ma2_band_color
        2 => ma3_band_color
        3 => ma4_band_color
        4 => ma5_band_color
    ma = enable ? ma_tf(tf,t,close,len) : na
    ma_filled = ta.valuewhen(not na(ma), ma, 0)
    h_ma = enable ? ma_tf(tf,t,high,len) : na
    h_ma_filled = ta.valuewhen(not na(h_ma), h_ma, 0)
    l_ma = enable ? ma_tf(tf,t,low,len) : na
    l_ma_filled = ta.valuewhen(not na(l_ma), l_ma, 0)
    MaTf.new(enable,tf,t,len,ma,ma_filled,h_ma,h_ma_filled,l_ma,l_ma_filled,clr,band_clr)

// EMA data
MaTf[] ma_data = array.new<MaTf>()
ma_data.push(newMa(0))
ma_data.push(newMa(1))
ma_data.push(newMa(2))
ma_data.push(newMa(3))
ma_data.push(newMa(4))

// RSI
rsi = request.security(syminfo.tickerid, rsiTf, ta.rsi(rsiSourceInput,rsiLengthInput))

// Smoothing MA
smoothingMA = enableMA ? rsi_ma(rsi, maLengthInput, maTypeInput) : na
//-----------------------------------------------------------------------------}

// Plot
//-----------------------------------------------------------------------------{

// MA1
ma1 = ma_data.get(0)
ma1_plt = plot(ma1.ma_filled,'MA1',ma1.clr,force_overlay = true)
ma1_h_plt = plot(ma1.h_ma_filled,'MA1 high',ma1.band_clr,force_overlay = true)
ma1_l_plt = plot(ma1.l_ma_filled,'MA1 low',ma1.band_clr,force_overlay = true)
fill(ma1_h_plt,ma1_l_plt,ma1.band_clr)

// MA2
ma2 = ma_data.get(1)
ma2_plt = plot(ma2.ma_filled,'MA2',ma2.clr,force_overlay = true)
ma2_h_plt = plot(ma2.h_ma_filled,'MA2 high',ma2.band_clr,force_overlay = true)
ma2_l_plt = plot(ma2.l_ma_filled,'MA2 low',ma2.band_clr,force_overlay = true)
fill(ma2_h_plt,ma2_l_plt,ma2.band_clr)

// MA3
ma3 = ma_data.get(2)
ma3_plt = plot(ma3.ma_filled,'MA3',ma3.clr,force_overlay = true)
ma3_h_plt = plot(ma3.h_ma_filled,'MA3 high',ma3.band_clr,force_overlay = true)
ma3_l_plt = plot(ma3.l_ma_filled,'MA3 low',ma3.band_clr,force_overlay = true)
fill(ma3_h_plt,ma3_l_plt,ma3.band_clr)

// MA4
ma4 = ma_data.get(3)
ma4_plt = plot(ma4.ma_filled,'MA4',ma4.clr,force_overlay = true)
ma4_h_plt = plot(ma4.h_ma_filled,'MA4 high',ma4.band_clr,force_overlay = true)
ma4_l_plt = plot(ma4.l_ma_filled,'MA4 low',ma4.band_clr,force_overlay = true)
fill(ma4_h_plt,ma4_l_plt,ma4.band_clr)

// MA5
ma5 = ma_data.get(4)
ma5_plt = plot(ma5.ma_filled,'MA4',ma5.clr,force_overlay = true)
ma5_h_plt = plot(ma5.h_ma_filled,'MA4 high',ma5.band_clr,force_overlay = true)
ma5_l_plt = plot(ma5.l_ma_filled,'MA4 low',ma5.band_clr,force_overlay = true)
fill(ma5_h_plt,ma5_l_plt,ma5.band_clr)

// RSI
rsiPlot = plot(rsi, "RSI", color=#7E57C2)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
midLinePlot = plot(50, color = na, editable = false, display = display.none)
fill(rsiPlot, midLinePlot, 100, 70, top_color = color.new(color.green, 0), bottom_color = color.new(color.green, 100),  title = "Overbought Gradient Fill")
fill(rsiPlot, midLinePlot, 30,  0,  top_color = color.new(color.red, 100), bottom_color = color.new(color.red, 0),      title = "Oversold Gradient Fill")

// Smoothing MA plots
plot(smoothingMA, "RSI-based MA", color=color.yellow, display = enableMA ? display.all : display.none, editable = enableMA)

Overview

MTF MA Bands + RSI evaluates up to five distinct moving average layers across user-defined timeframes, ranging from the chart resolution to daily intervals. Users can customize each moving average length, color, and calculation method using simple, weighted, or exponential smoothing, as well as RSI smoothing types. It provides visual momentum and trend context without automated trade signals. Unconfirmed higher-timeframe values will repaint on the live bar.

Details

Published by

InNoobWeTrust on GitHub

Type

Indicator, Pine Script v6

Draws

Separate pane below the chart

Category

Moving averages, Oscillators & momentum

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

dotfiles

Settings

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

SettingTypeDefaultVariable
Enablebooltruema1_enable
MA typeenumMaType.emama1_type
Lengthint34ma1_len
Colorcolorcolor.new(#FFD921,50)ma1_color
Band Colorcolorcolor.new(#FFD921,80)ma1_band_color
Timeframetimeframema1_tf
Enablebooltruema2_enable
MA typeenumMaType.emama2_type
Lengthint34ma2_len
Colorcolorcolor.new(#DDA059,50)ma2_color
Band Colorcolorcolor.new(#DDA059,80)ma2_band_color
Timeframetimeframe5ma2_tf
Show all 35 settings
SettingTypeDefaultVariable
Enablebooltruema3_enable
MA typeenumMaType.emama3_type
Lengthint34ma3_len
Colorcolorcolor.new(#AA585B,50)ma3_color
Band Colorcolorcolor.new(#AA585B,80)ma3_band_color
Timeframetimeframe30ma3_tf
Enablebooltruema4_enable
MA typeenumMaType.emama4_type
Lengthint34ma4_len
Colorcolorcolor.new(#B52121,50)ma4_color
Band Colorcolorcolor.new(#B52121,80)ma4_band_color
Timeframetimeframe240ma4_tf
Enablebooltruema5_enable
MA typeenumMaType.emama5_type
Lengthint34ma5_len
Colorcolorcolor.new(#6B3710,50)ma5_color
Band Colorcolorcolor.new(#6B3710,80)ma5_band_color
TimeframetimeframeDma5_tf
RSI Lengthint14rsiLengthInput
SourcesourceclosersiSourceInput
TimeframetimeframersiTf
TypestringSMAmaTypeInput
Lengthint14maLengthInput
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 Derivative Oscillator calculates a double-exponentially smoothed Relative Strength Index (RSI) and subtracts its Simple Moving Average (SMA) to form the main oscillator line. A secondary signal line is plotted using an SMA of the main oscillator values. Th

Indicator v4 Oscillators & momentumMoving averages
Updated 10 days ago · GPL-3.0 GitHub repository of Derivative Oscillator

Beep Boop

by magic8bot
409 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

MACD

by Alorse
330 stars

This indicator calculates and plots the standard Moving Average Convergence Divergence oscillator in a separate pane. It computes the difference between a fast and slow moving average, derives a signal line through smoothing, and plots a histogram representing

Indicator v4 Oscillators & momentumMoving averages
Updated 2 months ago · None stated GitHub repository of MACD

MACD-V

by harryguiacorn
219 stars

MACD-V is a volatility-normalized momentum indicator based on research by Alex Spiroglou. It calculates the standard MACD histogram and normalizes it by dividing by the Average True Range (ATR). Plotted in a separate pane as a colored histogram, it includes us

Indicator v5 Oscillators & momentumVolatility & bands
Updated 1 year ago · None stated GitHub repository of MACD-V
218 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 3 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 6 weeks ago · MIT GitHub repository of KamaFama

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