Daily SMA In Lower Timeframe public version
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © signalp1

//@version=5
//change to make it public
indicator("Daily SMA In Lower Timeframe")

out50 = ta.sma(close, 50)
s50 = request.security(syminfo.tickerid, "1D", out50)
out100 = ta.sma(close, 100)
s100 = request.security(syminfo.tickerid, "1D", out100)
out200 = ta.sma(close, 200)
s200 = request.security(syminfo.tickerid, "1D", out200)

isInRange(cl,s)=>cl*1.05>s and cl*0.95<s

if(barstate.islast)
    if(isInRange(close[0],s50[0]))
        line.new(bar_index -78, s50, bar_index, s50,extend=extend.right,color=color.blue)
        label.new(bar_index-78,s50,text="50SMA",color=color.aqua)
    if(isInRange(close[0],s100[0]))
        line.new(bar_index -78, s100, bar_index, s100,extend=extend.right,color=color.green)
        label.new(bar_index-78,s100,text="100SMA",color=color.aqua)
    if(isInRange(close[0],s200[0]))
        line.new(bar_index -78, s200, bar_index, s200,extend=extend.right,color=color.red)
        label.new(bar_index-78,s200,text="200SMA",color=color.aqua)
    

