LastBattle

Single Timeframe Moving Average

Provides Moving average of 200 and 50 at the specific timeframe regardless of what interval you're looking at.
Saving the need to change it manually each time you switch the interval.

In this chart, I am looking at 4H interval with EMA of 50/200 of daily timeframe.

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(title="Single Timeframe Moving Average", shorttitle="Single TF MA", overlay=true)

len_sma_long = input(200, minval=1, title="Long Simple Moving Average")
len_sma_short = input(50, minval=1, title="Short Simple Moving Average")
resCustom = input(title="Time interval (W, D, [min])", type=string, defval="D")

sma_long = security(tickerid, resCustom, sma(close, len_sma_long))
sma_short = security(tickerid, resCustom, sma(close, len_sma_short))
src = security(tickerid, resCustom, close)

s2 = cross(sma_long, sma_short) ? src : na
plot(sma_long, color=green)
plot(sma_short, color=red)

plotshape(cross(sma_long, sma_short) ? sma_long  : na, style=shape.xcross, text="ALERT")