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.
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.
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")