Indicator · Pine Script v5 · On the chart

7 in 1

by g-moe· code credited to goodgains

The 7 in 1 indicator plots multiple customizable moving averages directly on the price chart to reduce indicator clutter.

View on GitHub

GitHub stars3on the repository
Pine versionv5runs as is
Lines of code182
Settings34inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago27 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

182 lines of Pine Script v5 from Tradingview/7-in-1.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

7-in-1.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © goodgains


//@version=5
indicator("7 in 1", overlay = true)

// @keywords: 7-in-1, multiple-moving-averages, six-moving-averages, moving-average-bundle, ema-stack, sma-ema, multitimeframe-ma, mtf-moving-average, anchored-vwap, session-vwap, vwap, ohlc-source, earnings-vwap, dividend-vwap, weekly-vwap, monthly-vwap, yearly-vwap, price-source-ma, fibonacci-ema, ma-suite

// settings
use_ma1     = input.bool(true, title = 'MA 1', group = 'Settings', inline = 'ma1')
ma_1_type    = input.string('EMA', title = '', options = ['SMA', 'EMA'], group = 'Settings', inline = 'ma1')
ma_1_val  = input.int(9, title = '', group = 'Settings', inline = 'ma1')
ma1_res   = input.string("Normal MA", title = '', 
 options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], 
 group = 'Settings', inline = 'ma1')
color_ma1   = input.color(color.blue, title = '', group = 'Settings', inline = 'ma1') 

use_ma2     = input.bool(true, title = 'MA 2', group = 'Settings', inline = 'ma2')
ma_2_type    = input.string('EMA', title = '', options = ['SMA', 'EMA'], group = 'Settings', inline = 'ma2')
ma_2_val  = input.int(13, title = '', group = 'Settings', inline = 'ma2')
ma2_res   = input.string("Normal MA", title = '', 
 options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], 
 group = 'Settings', inline = 'ma2')
color_ma2   = input.color(color.orange, title = '', group = 'Settings', inline = 'ma2') 

use_ma3     = input.bool(true, title = 'MA 3', group = 'Settings', inline = 'ma3')
ma_3_type    = input.string('EMA', title = '', options = ['SMA', 'EMA'], group = 'Settings', inline = 'ma3')
ma_3_val  = input.int(21, title = '', group = 'Settings', inline = 'ma3')
ma3_res   = input.string("Normal MA", title = '', 
 options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], 
 group = 'Settings', inline = 'ma3')
color_ma3   = input.color(color.yellow, title = '', group = 'Settings', inline = 'ma3') 

use_ma4     = input.bool(true, title = 'MA 4', group = 'Settings', inline = 'ma4')
ma_4_type    = input.string('EMA', title = '', options = ['SMA', 'EMA'], group = 'Settings', inline = 'ma4')
ma_4_val  = input.int(55, title = '', group = 'Settings', inline = 'ma4')
ma4_res   = input.string("Normal MA", title = '', 
 options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], 
 group = 'Settings', inline = 'ma4')
color_ma4   = input.color(color.purple, title = '', group = 'Settings', inline = 'ma4')

use_ma5     = input.bool(true, title = 'MA 5', group = 'Settings', inline = 'ma5')
ma_5_type    = input.string('EMA', title = '', options = ['SMA', 'EMA'], group = 'Settings', inline = 'ma5')
ma_5_val  = input.int(100, title = '', group = 'Settings', inline = 'ma5')
ma5_res   = input.string("Normal MA", title = '', 
 options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], 
 group = 'Settings', inline = 'ma5')
color_ma5   = input.color(color.lime, title = '', group = 'Settings', inline = 'ma5') 

use_ma6     = input.bool(true, title = 'MA 6', group = 'Settings', inline = 'ma6')
ma_6_type    = input.string('EMA', title = '', options = ['SMA', 'EMA'], group = 'Settings', inline = 'ma6')
ma_6_val  = input.int(200, title = '', group = 'Settings', inline = 'ma6')
ma6_res   = input.string("Normal MA", title = '', 
 options = ["Normal MA","Open","High","Low","Close","hl2","hlc3","ohlc4","hlcc4","Multitimeframe MA","Chart","1 Minute","3 Minutes","5 Minutes","15 Minutes","30 Minutes","45 Minutes","1 Hour","2 Hours","3 Hours","4 Hours","Day","Week","Month"], 
 group = 'Settings', inline = 'ma6')
color_ma6   = input.color(color.new(#311b92,0), title = '', group = 'Settings', inline = 'ma6') 

use_vwap     = input.bool(true, title = 'VWAP', group = 'Settings', inline = 'ma7')
anchor    = input.string('Session', title = '', options=["Session", "Week", "Month", "Quarter", "Year", "Decade", "Century", "Earnings", "Dividends", "Splits"], group = 'Settings', inline = 'ma7')
source_vwap  = input.source(hlc3, title = '', group = 'Settings', inline = 'ma7')
color_vwap   = input.color(color.silver, title = '', group = 'Settings', inline = 'ma7') 



ma_function(source, length, type) =>
    if type == 'RMA'
        ta.rma(source, length)
    else if type == 'SMA'
        ta.sma(source, length)
    else if type == 'EMA'
        ta.ema(source, length)
    else if type == 'WMA'
        ta.wma(source, length)
    else if type == 'HMA'
        if(length<2)
            ta.hma(source,2)
        else
            ta.hma(source, length)
    else 
        ta.vwma(source, length)
    
sh(string type) =>
    if type == "Only Show Smoothed MA "
        false
    else
        true

type_nor(type)=>
    if (type == "Open") or (type == "High") or (type == "Low") or (type == "Close") or (type == "Normal MA")
        true
    else
        false 

tf(res)=>

    if (res == "1 Minute")
        '1'
    else if (res == "3 Minutes")
        '3'
    else if (res == "5 Minutes")
        '5'
    else if (res == "15 Minutes")
        '15'
    else if (res == "30 Minutes")
        '30'
    else if (res == "45 Minutes")
        '45'
    else if (res == "1 Hour")
        '60'
    else if (res == "2 Hours")
        '120'
    else if (res == "3 Hours")
        '180'
    else if (res == "4 Hours")
        '240'
    else if (res == "Day")
        'D'
    else if (res =="Week" )
        'W'
    else if (res == "Month")
        'M'
    else
        timeframe.period
 
pr(res)=>
    switch res
        "Open" => open
        "High" => high
        "Low" => low
        "Close" => close
        "hlc3" => hlc3
        "ohlc4" => ohlc4
        "hlcc4" => hlcc4
        =>close

ma_1 = use_ma1 ? (type_nor(ma1_res)?ma_function(pr(ma1_res), ma_1_val, ma_1_type):request.security(syminfo.tickerid,tf(ma1_res) , ma_function(close, ma_1_val, ma_1_type))):na
ma_2 = use_ma2 ?(type_nor(ma2_res)?ma_function(pr(ma2_res), ma_2_val, ma_2_type):request.security(syminfo.tickerid, tf(ma2_res), ma_function(close, ma_2_val, ma_2_type))):na
ma_3 = use_ma3 ?(type_nor(ma3_res)?ma_function(pr(ma3_res), ma_3_val, ma_3_type):request.security(syminfo.tickerid, tf(ma3_res), ma_function(close, ma_3_val, ma_3_type))):na
ma_4 = use_ma4 ?(type_nor(ma4_res)?ma_function(pr(ma4_res), ma_4_val, ma_4_type): request.security(syminfo.tickerid, tf(ma4_res), ma_function(close, ma_4_val, ma_4_type))):na
ma_5 = use_ma5 ?(type_nor(ma5_res)?ma_function(pr(ma5_res), ma_5_val, ma_5_type):request.security(syminfo.tickerid, tf(ma5_res), ma_function(close, ma_5_val, ma_5_type))):na
ma_6 = use_ma6 ?(type_nor(ma6_res)?ma_function(pr(ma6_res), ma_6_val, ma_6_type):request.security(syminfo.tickerid,tf(ma6_res) , ma_function(close, ma_6_val, ma_6_type))):na


plot(ma_1, 'MA 1', color = color_ma1, style = plot.style_line, display = use_ma1 ? display.all : display.none)
plot(ma_2, 'MA 2', color = color_ma2, style = plot.style_line, display = use_ma2 ? display.all : display.none)
plot(ma_3, 'MA 3', color = color_ma3, style = plot.style_line, display = use_ma3 ? display.all : display.none)
plot(ma_4, 'MA 4', color = color_ma4, style = plot.style_line, display = use_ma4 ? display.all : display.none)
plot(ma_5, 'MA 5', color = color_ma5, style = plot.style_line, display = use_ma5 ? display.all : display.none)
plot(ma_6, 'MA 6', color = color_ma6, style = plot.style_line, display = use_ma6 ? display.all : display.none)





// vwap calculate
new_earnings = request.earnings(syminfo.tickerid, earnings.actual, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
new_dividends = request.dividends(syminfo.tickerid, dividends.gross, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)
new_split = request.splits(syminfo.tickerid, splits.denominator, barmerge.gaps_on, barmerge.lookahead_on, ignore_invalid_symbol=true)

isNewPeriod = switch anchor
    "Earnings"  => not na(new_earnings)
    "Dividends" => not na(new_dividends)
    "Splits"    => not na(new_split)
    "Session"   => timeframe.change("D")
    "Week"      => timeframe.change("W")
    "Month"     => timeframe.change("M")
    "Quarter"   => timeframe.change("3M")
    "Year"      => timeframe.change("12M")
    "Decade"    => timeframe.change("12M") and year % 10 == 0
    "Century"   => timeframe.change("12M") and year % 100 == 0
    => false

isEsdAnchor = anchor == "Earnings" or anchor == "Dividends" or anchor == "Splits"
if na(source_vwap[1]) and not isEsdAnchor
    isNewPeriod := true

float vwapValue = na
[_vwap, _stdevUpper, _] = ta.vwap(source_vwap, isNewPeriod, 1)
vwapValue := _vwap

plot(vwapValue, title = 'VWAP', color = color_vwap, style = plot.style_circles, display = use_vwap ? display.all : display.none)

Overview

Traders can toggle each moving average on or off, selecting between Simple Moving Average (SMA) and Exponential Moving Average (EMA) types. Each moving average line offers full control over its length, plot color, source price calculation, or higher timeframe resolution ranging from minute to monthly bars. This allows for multi-timeframe trend analysis and moving average ribbon visualization.

Details

Published by

g-moe on GitHub

Code credit

goodgains, as written in the script's header

Draws

On the price 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.

Settings

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

SettingTypeDefaultVariable
MA 1booltrueuse_ma1
ma_1_typestringEMAma_1_type
ma_1_valint9ma_1_val
ma1_resstringNormal MAma1_res
color_ma1colorcolor.bluecolor_ma1
MA 2booltrueuse_ma2
ma_2_typestringEMAma_2_type
ma_2_valint13ma_2_val
ma2_resstringNormal MAma2_res
color_ma2colorcolor.orangecolor_ma2
MA 3booltrueuse_ma3
ma_3_typestringEMAma_3_type
Show all 34 settings
SettingTypeDefaultVariable
ma_3_valint21ma_3_val
ma3_resstringNormal MAma3_res
color_ma3colorcolor.yellowcolor_ma3
MA 4booltrueuse_ma4
ma_4_typestringEMAma_4_type
ma_4_valint55ma_4_val
ma4_resstringNormal MAma4_res
color_ma4colorcolor.purplecolor_ma4
MA 5booltrueuse_ma5
ma_5_typestringEMAma_5_type
ma_5_valint100ma_5_val
ma5_resstringNormal MAma5_res
color_ma5colorcolor.limecolor_ma5
MA 6booltrueuse_ma6
ma_6_typestringEMAma_6_type
ma_6_valint200ma_6_val
ma6_resstringNormal MAma6_res
color_ma6colorcolor.new(#311b92,0)color_ma6
VWAPbooltrueuse_vwap
anchorstringSessionanchor
source_vwapsourcehlc3source_vwap
color_vwapcolorcolor.silvercolor_vwap
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 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