My pinescript should print colored arrows above and below the seventh close on one side SMA.
If I only have 3 conditions, then it works… But I want to check 7 closes.
I tried making a for loop but my skills not so good.
indicator(title = "5SMA", shorttitle = "5SMA", overlay = true)
// Get SMA value
i_sma = ta.sma(close,5)
// Check green or red close conditions
smaGreen = close[0] > i_sma and
close[1] > i_sma and
close[2] > i_sma and
close[3] > i_sma and
close[4] > i_sma and
close[5] > i_sma and
close[6] > i_sma
smaRed = close[0] < i_sma and
close[1] < i_sma and
close[2] < i_sma and
close[3] < i_sma and
close[4] < i_sma and
close[5] < i_sma and
close[6] < i_sma
//Draw signals
plotshape(smaGreen, "Green", shape.arrowup, location.abovebar, color.green)
plotshape(smaRed, "Below", shape.arrowdown, location.belowbar, color.red)```