Search code examples
pine-scriptpine-script-v5

How get average value of all 15minutes candle within 4 hour candle


There are 16 15minutes candles in 4hour candle. How get average value of all 15minutes candle within a 4 hour candle.


Solution

  • //@version=5
    indicator("My script", overlay = true)
    lower = request.security_lower_tf(syminfo.tickerid, '15', close)
    avg = lower.avg()
    
    if barstate.islast
        label.new(bar_index, high, str.tostring(avg,format.mintick), color=color.aqua)