Indicator · Pine Script v6 · On the chart

MTF MA Bands

by InNoobWeTrust

The indicator calculates and plots up to five multi-timeframe moving average bands directly on the price chart.

View on GitHub

Repaints

GitHub stars4on the repository
Pine versionv6current
Lines of code187
Settings30inputs
LicenceNone statedfile: MPL-2.0
Last update2 days ago28 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

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

mtf_ma_bands.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",overlay = true)

//=============================================================================
// 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))
//-----------------------------------------------------------------------------}

// 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)
//-----------------------------------------------------------------------------}

// 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))
//-----------------------------------------------------------------------------}

// 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)

Overview

Each band is constructed from moving averages computed across user-defined timeframes, such as current chart, 5-minute, 30-minute, 4-hour, and daily intervals. Traders can select between Simple, Exponential, or Weighted Moving Averages, as well as adjust lengths, timeframes, and band fill colors for each layer. Higher timeframe values fetched via security calls update dynamically during open higher-timeframe bars, causing repainting on current intraday bars.

Details

Published by

InNoobWeTrust on GitHub

Draws

On the price chart

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

  • Signals can change on the live bar or after it closes (repainting)

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 30 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
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

947 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 12 days ago · GPL-3.0 GitHub repository of Adaptive Laguerre Filter
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

NVDA Trend Ribbon

by longsurf-ai
280 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 3 days ago · MIT GitHub repository of NVDA Trend Ribbon
257 stars

Donald SPX - Options Trading is an overlay indicator designed for intraday SPX analysis. It plots a 200-period Weighted Moving Average (WMA) on the price chart while evaluating multi-timeframe market structure across Daily, 15-minute, 5-minute, and 2-minute ba

Indicator v5 Moving averagesTrend Repaints
Updated 7 weeks ago · None stated GitHub repository of Donald SPX - Options Trading
228 stars

This indicator computes moving average and RSI bias signals across the current timeframe and four higher timeframes. It sums biases from the MA and RSI to derive an overall bullish or bearish signal. The results appear in a configurable table that displays eac

Indicator v6 TrendMoving averages
Updated 3 months ago · None stated GitHub repository of Multi-Timeframe Analysis Template

More Trend 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