Struggling to get the Moving average value displayed correctly from the HL candle. Want to see the moving average value @ HL candle
Script output Screenshot-Please see this also
//@version=5
indicator("My script", overlay = true)
Period = 6
smalength = 20
float pivotLow = na
pivotLow := ta.pivotlow(6, 6)
valuewhen_5 = ta.valuewhen(pivotLow, low[Period], 1)
valuewhen_6 = ta.valuewhen(pivotLow, low[Period], 0)
higherlow = na(pivotLow) ? na : valuewhen_5 < valuewhen_6 ? pivotLow : na
plotshape(higherlow, title='HL', style=shape.triangleup, location=location.belowbar, color=color.new(color.green, 50), text='HL', textcolor=color.new(color.green, 50), offset=-Period)
plot(ta.sma(close[0], smalength))
var label bbmbcfmlableHL = na
if (not na(higherlow))
smavalue = ta.valuewhen(higherlow, ta.sma(close, smalength),0)
bbmbcfmlableHL := label.new(x=bar_index, y=high, color=color.orange, textcolor=color.blue, text=str.tostring(smavalue))