Higher Time Frame EMAs and 1% volatility indicator
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ft74

//@version=5
indicator(title="Higher Time Frame EMA", shorttitle="HTFEMA", overlay=true)



HTF = input('30', title="Higher Timeframe for EMA")

len1 = input(5, title="EMA1 Length")
col1 = input(color.new(color.red,65), title="EMA1 Color")
smooth1 = input(defval=true, title="EMA1 Smooth")

len2 = input(10, title="EMA2 Length")
col2 = input(color.new(color.yellow,80), title="EMA2 Color")
smooth2 = input(defval=true, title="EMA2 Smooth")

len3 = input(60, title="EMA3 Length")
col3 = input(color.rgb(0,255,255,80), title="EMA3 Color")
smooth3 = input(defval=true, title="EMA3 Smooth")

len4 = input(223, title="EMA4 Length")
col4 = input(color.new(color.purple,60), title="EMA4 Color")
smooth4 = input(defval=true, title="EMA4 Smooth")

ema1 = ta.ema(close, len1)
emaSmooth1 = request.security(syminfo.tickerid, HTF, ema1, barmerge.gaps_on, barmerge.lookahead_on)
emaStep1 = request.security(syminfo.tickerid, HTF, ema1, barmerge.gaps_off, barmerge.lookahead_on)

ema2 = ta.ema(close, len2)
emaSmooth2 = request.security(syminfo.tickerid, HTF, ema2, barmerge.gaps_on, barmerge.lookahead_on)
emaStep2 = request.security(syminfo.tickerid, HTF, ema2, barmerge.gaps_off, barmerge.lookahead_on)

ema3 = ta.ema(close, len3)
emaSmooth3 = request.security(syminfo.tickerid, HTF, ema3, barmerge.gaps_on, barmerge.lookahead_on)
emaStep3 = request.security(syminfo.tickerid, HTF, ema3, barmerge.gaps_off, barmerge.lookahead_on)

ema4 = ta.ema(close, len4)
emaSmooth4 = request.security(syminfo.tickerid, HTF, ema4, barmerge.gaps_on, barmerge.lookahead_on)
emaStep4 = request.security(syminfo.tickerid, HTF, ema4, barmerge.gaps_off, barmerge.lookahead_on)


plot(series = smooth1 ? emaSmooth1 : emaStep1,
     title = "HTF EMA1",
     color = col1,
     linewidth = 10, 
     style = plot.style_line
     )
 
plot(series = smooth2 ? emaSmooth2 : emaStep2,
     title = "HTF EMA2",
     color = col2,
     linewidth = 10, 
     style = plot.style_line
     )

plot(series = smooth3 ? emaSmooth3 : emaStep3,
     title = "HTF EMA3",
     color = col3,
     linewidth = 10, 
     style = plot.style_line
     )

plot(series = smooth4 ? emaSmooth4 : emaStep4,
     title = "HTF EMA4",
     color = col4,
     linewidth = 10, 
     style = plot.style_line
     )

line100 = line.new(bar_index[1]+2, close, bar_index+2, close, extend=extend.right, color=color.white)
line.delete(line100[1])
label100 = label.new(bar_index+2, close, "0%", textalign=text.align_left, style=label.style_none, textcolor=color.white)
label.delete(label100[1])

line101=line.new(bar_index[1]+2,close*1.01,bar_index+2, close*1.01,extend=extend.right, color=color.white)
line.delete(line101[1])
label101 = label.new(bar_index+2, close*1.01, "+1%", textalign=text.align_left, style=label.style_none, textcolor=color.white)
label.delete(label101[1])

line99=line.new(bar_index[1]+2,close*0.99,bar_index+2, close*0.99,extend=extend.right, color=color.white)
line.delete(line99[1])
label99 = label.new(bar_index+2, close*0.99, "-1%", textalign=text.align_left, style=label.style_none, textcolor=color.white)
label.delete(label99[1])

