20813

Multi Timeframe EMA

Improved Version of
Changes:
- smoothed the lines of the higher timeframes
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.

Want to use this script on a chart?
study("Multi Timeframe EMA", shorttitle="MTF_EMA",overlay=true)
len = input(20, title="Length", type=integer)
src = input(close, title="Source", type=source)
show5m = input(true, title="show 5m", type=bool)
show15m = input(true, title="show 15m", type=bool)
show30m = input(true, title="show 30m", type=bool)
show1h = input(true, title="show 1h", type=bool)
show2h = input(true, title="show 2h", type=bool)
show4h = input(true, title="show 4h", type=bool)
show1D = input(true, title="show 1D", type=bool)

emaCurrent = ema(src,len)
ema5m = security(ticker,"5",ema(src,len))
ema15m = security(ticker,"15",ema(src,len))
ema30m = security(ticker,"30",ema(src,len))
ema1h = security(ticker,"60",ema(src,len))
ema2h = security(ticker,"120",ema(src,len))
ema4h = security(ticker,"240",ema(src,len))
ema1D = security(ticker,"D",ema(src,len))

plot(emaCurrent, color=red, title="ema current")

plot(show5m ? sma(ema5m,5) : na, color=interval < 5 and not isdaily and not isweekly and not ismonthly  ? #aaaaaa : na, title="ema 5m")
plot(show15m ? sma(ema15m,15) : na, color=interval < 15 and not isdaily and not isweekly and not ismonthly  ? #999999 : na, title="ema 15m")
plot(show30m ? sma(ema30m,30) : na, color=interval < 30 and not isdaily and not isweekly and not ismonthly  ? #888888 : na, title="ema 30m")
plot(show1h ? sma(ema1h,60) : na, color=interval < 60 and not isdaily and not isweekly and not ismonthly  ? #777777 : na, title="ema 1h")
plot(show2h ? sma(ema2h,120) : na, color=interval < 120 and not isdaily and not isweekly and not ismonthly  ? #666666 : na, title="ema 2h")
plot(show4h ? sma(ema4h,240) : na, color=interval < 240 and not isdaily and not isweekly and not ismonthly ? #555555 : na, title="ema 4h")
plot(show1D ? sma(ema1D,480) : na, color=not isdaily and not isweekly and not ismonthly ? #444444 : na, title="ema 1D")