Super Multi Trend [Salty]
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © markmiotke

//@version=5
indicator('Super Multi Trend [Salty]', overlay=false)
// # 3 indicators:
//   1st is the relationship of 8:13:21 EMAs, to show when they are stacked bullish, bearish, or neutral to help gauge momentum.
//   2nd adds in the relationship of the 34 EMA High and 34 EMA Low, to get the trend of the 34 EMA (high, close, low) Wave.
//   3rd is the relationship of 5:8:13:21:34:55 EMAs, to show when they are stacked bullish, bearish, or neutral to help gauge momentum and trend strength using more EMAs and colors.
//      Lighter colors indicate higher levels of bullishness or lesser levels of bearishness. Yellow indicates neutral or choppy price action.
// These relationships are shown for the current symbol, and optionally for 3 additional symbols if desired.  To hide unwanted rows uncheck them on the Setting Style Tab and uncheck Show Market Lables. 

BrightGreen = #7CFC00
LightPink = #FFB9D2
DarkGreen = #397934
DarkRed = #B22222

//Super Multi Trend Default Colors
C_VeryBullish = BrightGreen
C_Bullish = color.green
C_SlightlyBullish = DarkGreen
C_Sideways = color.yellow
C_SlightlyBearish = LightPink
C_Bearish = color.red
C_VeryBearish = DarkRed

C_Blank = color.new(color.black, 100)  //Transp = 100 is invisible
C_Label = color.new(color.black, 0)

sizeOption = input.string(title='Label Size', options=['Auto', 'Huge', 'Large', 'Normal', 'Small', 'Tiny'], defval='Normal')

bShowMarketTickers = input(title='Show Market Lables', defval=true)

var string i_Tickers = input.string('SPY_QQQ_DIA', 'Market Tickers', options=['SPY_QQQ_DIA', 'ES1!_NQ1!_YM1!', 'SPX_NDX_DJI', 'User Specified Tickers'])
var string userTicker1 = input.string('XLY', 'User Specified Ticker1')
var string userTicker2 = input.string('AMZN', 'User Specified Ticker2')
var string userTicker3 = input.string('TSLA', 'User Specified Ticker3')

Ticker_1 = i_Tickers == 'SPY_QQQ_DIA' ? 'SPY' : i_Tickers == 'ES1!_NQ1!_YM1!' ? 'ES1!' : i_Tickers == 'SPX_NDX_DJI' ? 'SPX' : userTicker1
Ticker_2 = i_Tickers == 'SPY_QQQ_DIA' ? 'QQQ' : i_Tickers == 'ES1!_NQ1!_YM1!' ? 'NQ1!' : i_Tickers == 'SPX_NDX_DJI' ? 'NDX' : userTicker2
Ticker_3 = i_Tickers == 'SPY_QQQ_DIA' ? 'DIA' : i_Tickers == 'ES1!_NQ1!_YM1!' ? 'YM1!' : i_Tickers == 'SPX_NDX_DJI' ? 'DJI' : userTicker3

labelSize = sizeOption == 'Huge' ? size.huge : sizeOption == 'Large' ? size.large : sizeOption == 'Small' ? size.small : sizeOption == 'Tiny' ? size.tiny : sizeOption == 'Auto' ? size.auto : size.normal

Simple_Trend() =>

    EMA34High = ta.ema(high, 34)
    EMA34Low = ta.ema(low, 34)
    EMA8 = ta.ema(close, 8)
    EMA21 = ta.ema(close, 21)
    EMA13 = ta.ema(close, 13)

    stacked81321 = EMA8 > EMA13 and EMA13 > EMA21 ? 1 : EMA8 < EMA13 and EMA13 < EMA21 ? -1 : 0

    WaveState = EMA8 > EMA13 and EMA13 > EMA21 and EMA21 > EMA34High ? 1 : EMA8 < EMA13 and EMA13 < EMA21 and EMA21 < EMA34Low ? -1 : 0
    [stacked81321, WaveState]

Super_Trend() =>

    EMA5 = ta.ema(close, 5)
    EMA8 = ta.ema(close, 8)
    EMA13 = ta.ema(close, 13)
    EMA21 = ta.ema(close, 21)
    EMA34 = ta.ema(close, 34)
    EMA55 = ta.ema(close, 55)

    stacked5813213455 = EMA5 >= EMA8 and EMA8 >= EMA13 and EMA13 >= EMA21 and EMA21 > EMA34 and EMA34 > EMA55 ? 3 : EMA5 < EMA8 and EMA8 >= EMA13 and EMA13 >= EMA21 and EMA21 > EMA34 and EMA34 > EMA55 ? 1 : EMA8 < EMA13 and EMA13 >= EMA21 and EMA21 > EMA34 and EMA34 > EMA55 ? 2 : EMA5 <= EMA8 and EMA8 <= EMA13 and EMA13 <= EMA21 and EMA21 < EMA34 and EMA34 < EMA55 ? -3 : EMA5 > EMA8 and EMA8 <= EMA13 and EMA13 <= EMA21 and EMA21 < EMA34 and EMA34 < EMA55 ? -1 : EMA8 > EMA13 and EMA13 <= EMA21 and EMA21 < EMA34 and EMA34 < EMA55 ? -2 : 0

    [stacked5813213455]

text_gen(prefix, ticker, flag) =>
    flag_text = flag == 3 ? 'BullStrong' : flag == 2 ? 'BullWeak' : flag == 1 ? 'Bullish' : flag == -3 ? 'BearStrong' : flag == -2 ? 'BearWeak' : flag == -1 ? 'Bearish' : 'S/W'
    prefix + '(' + ticker + ') : ' + flag_text

flag_color(flag) =>
    flag == 3 ? C_VeryBullish : flag == 2 ? C_SlightlyBullish : flag == 1 ? C_Bullish : flag == -1 ? C_Bearish : flag == -3 ? C_VeryBearish : flag == -2 ? C_SlightlyBearish : C_Sideways


//15 t1_81321
//14 t1_wave
//13 t1_SuperTrend//
[t1_81321, t1_wave] = request.security(Ticker_1, '', Simple_Trend())
[t1_SuperTrend] = request.security(Ticker_1, '', Super_Trend())

var t1_81321_label = bShowMarketTickers ? label.new(x=na, y=15, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na
label.set_x(t1_81321_label, bar_index)
label.set_tooltip(t1_81321_label, text_gen('8:13:21', Ticker_1, t1_81321))
label.set_text(t1_81321_label, Ticker_1 + ' (8:13:21)')
label.set_textcolor(t1_81321_label, C_Label)
plotshape(series=15, title='8:13:21 : Ticker #1', style=shape.square, location=location.absolute, color=flag_color(t1_81321))

var t1_wave_label = bShowMarketTickers ? label.new(x=na, y=14, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na
label.set_x(t1_wave_label, bar_index)
label.set_tooltip(t1_wave_label, text_gen('Wave', Ticker_1, t1_wave))
label.set_text(t1_wave_label, Ticker_1 + ' (Wave)')
label.set_textcolor(t1_wave_label, C_Label)
plotshape(series=14, title='Wave : Ticker #1', style=shape.square, location=location.absolute, color=flag_color(t1_wave))

var t1_SuperTrend_label = bShowMarketTickers ? label.new(x=na, y=13, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na
label.set_x(t1_SuperTrend_label, bar_index)
label.set_tooltip(t1_SuperTrend_label, text_gen('SuperTrend', Ticker_1, t1_SuperTrend))
label.set_text(t1_SuperTrend_label, Ticker_1 + ' (SuperTrend)')
label.set_textcolor(t1_SuperTrend_label, flag_color(t1_SuperTrend))
plotshape(series=13, title='SuperTrend : Ticker #1', style=shape.square, location=location.absolute, color=flag_color(t1_SuperTrend))

//11 t2_81321
//10 t2_wave
//9 t2_SuperTrend
[t2_81321, t2_wave] = request.security(Ticker_2, '', Simple_Trend())
[t2_SuperTrend] = request.security(Ticker_2, '', Super_Trend())
var t2_81321_label = bShowMarketTickers ? label.new(x=na, y=11, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na

label.set_x(t2_81321_label, bar_index)
label.set_tooltip(t2_81321_label, text_gen('8:13:21', Ticker_2, t2_81321))
label.set_text(t2_81321_label, Ticker_2 + ' (8:13:21)')
label.set_textcolor(t2_81321_label, C_Label)
plotshape(series=11, title='8:13:21 : Ticker #2', style=shape.square, location=location.absolute, color=flag_color(t2_81321))

var t2_wave_label = bShowMarketTickers ? label.new(x=na, y=10, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na

label.set_x(t2_wave_label, bar_index)
label.set_tooltip(t2_wave_label, text_gen('Wave', Ticker_2, t2_wave))
label.set_text(t2_wave_label, Ticker_2 + ' (Wave)')
label.set_textcolor(t2_wave_label, C_Label)
plotshape(series=10, title='Wave : Ticker #2', style=shape.square, location=location.absolute, color=flag_color(t2_wave))

var t2_SuperTrend_label = bShowMarketTickers ? label.new(x=na, y=9, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na

label.set_x(t2_SuperTrend_label, bar_index)
label.set_tooltip(t2_SuperTrend_label, text_gen('SuperTrend', Ticker_2, t2_SuperTrend))
label.set_text(t2_SuperTrend_label, Ticker_2 + ' (SuperTrend)')
label.set_textcolor(t2_SuperTrend_label, flag_color(t2_SuperTrend))
plotshape(series=9, title='SuperTrend : Ticker #2', style=shape.square, location=location.absolute, color=flag_color(t2_SuperTrend))

//7 t3_81321
//6 t3_wave
//5 t3_SuperTrend
[t3_81321, t3_wave] = request.security(Ticker_3, '', Simple_Trend())
[t3_SuperTrend] = request.security(Ticker_3, '', Super_Trend())

var t3_81321_label = bShowMarketTickers ? label.new(x=na, y=7, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na
label.set_x(t3_81321_label, bar_index)
label.set_tooltip(t3_81321_label, text_gen('8:13:21', Ticker_3, t3_81321))
label.set_text(t3_81321_label, Ticker_3 + ' (8:13:21)')
label.set_textcolor(t3_81321_label, C_Label)
plotshape(series=7, title='8:13:21 : Ticker #3', style=shape.square, location=location.absolute, color=flag_color(t3_81321))

var t3_wave_label = bShowMarketTickers ? label.new(x=na, y=6, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na
label.set_x(t3_wave_label, bar_index)
label.set_tooltip(t3_wave_label, text_gen('Wave', Ticker_3, t3_wave))
label.set_text(t3_wave_label, Ticker_3 + ' (Wave)')
label.set_textcolor(t3_wave_label, C_Label)
plotshape(series=6, title='8:13:21 : Ticker #3', style=shape.square, location=location.absolute, color=flag_color(t3_wave))

var t3_SuperTrend_label = bShowMarketTickers ? label.new(x=na, y=5, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left) : na
label.set_x(t3_SuperTrend_label, bar_index)
label.set_tooltip(t3_SuperTrend_label, text_gen('SuperTrend', Ticker_3, t3_SuperTrend))
label.set_text(t3_SuperTrend_label, Ticker_3 + ' (SuperTrend)')
label.set_textcolor(t3_SuperTrend_label, flag_color(t3_SuperTrend))
plotshape(series=5, title='SuperTrend : Ticker #3', style=shape.square, location=location.absolute, color=flag_color(t3_SuperTrend))

//3 main_81321
//2 main_wave
//1 main_SuperTrend
[main_81321, main_wave] = Simple_Trend()
[main_SuperTrend] = Super_Trend()
var main_81321_label = label.new(x=na, y=3, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left)
label.set_x(main_81321_label, bar_index)
label.set_tooltip(main_81321_label, text_gen('8:13:21', syminfo.ticker, main_81321))
label.set_text(main_81321_label, syminfo.ticker + " (8:13:21)")
label.set_textcolor(main_81321_label, C_Label)
plotshape(series=3, title='8:13:21 : Main', style=shape.square, location=location.absolute, color=flag_color(main_81321))

var main_wave_label = label.new(x=na, y=2, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left)
label.set_x(main_wave_label, bar_index)
label.set_tooltip(main_wave_label, text_gen('Wave', syminfo.ticker, main_wave))
label.set_text(main_wave_label, syminfo.ticker + ' (Wave)')
label.set_textcolor(main_wave_label, C_Label)
plotshape(series=2, title='Wave : Main', style=shape.square, location=location.absolute, color=flag_color(main_wave))

var main_SuperTrend_label = label.new(x=na, y=1, xloc=xloc.bar_index, yloc=yloc.price, style=label.style_label_left, color=#00000000, size=labelSize, textalign=text.align_left)
label.set_x(main_SuperTrend_label, bar_index)
label.set_tooltip(main_SuperTrend_label, text_gen('SuperTrend', syminfo.ticker, main_SuperTrend))
label.set_text(main_SuperTrend_label, syminfo.ticker + ' (SuperTrend)')
label.set_textcolor(main_SuperTrend_label, flag_color(main_SuperTrend))
plotshape(series=1, title='SuperTrend Main', style=shape.square, location=location.absolute, color=flag_color(main_SuperTrend))

//Add Blank rows for spacing
//Row 16 Blank
plotshape(16, 'Blank 16', location=location.absolute, color=C_Blank, show_last=1)
//Row 12 Blank
plotshape(12, 'Blank 12', location=location.absolute, color=C_Blank, show_last=1)
//Row 8 Blank
plotshape(8, 'Blank 8', location=location.absolute, color=C_Blank, show_last=1)
//Row 4 Blank
plotshape(4, 'Blank 4', location=location.absolute, color=C_Blank, show_last=1)
//Row 0 Blank	 
plotshape(0, 'Blank 0', location=location.absolute, color=C_Blank, show_last=1)












