Search code examples
pine-scriptpine-script-v5algorithmic-tradingpine-script-v4

How to plot shape at the end of time on the Renko candle Chart


I want to plot shapes at the end of the Renko Candle close at 30min timeframe. But It only plots at the start of the time interval.

//@version=5
indicator(title='Renko Brick Close', overlay=true)

res = input('30')
isnew = ta.change(time(res)) != 0

plotshape(isnew)

How to plot shape at the end of that period and not on the beginning. Is it possible to do that without request.security and offset?


Solution

  • Use barstate.isconfirmed it will only plot a shape once the candle has closed

    for example, this would plot an arrow either up or down on every candle other than the real time candle

    closeup = close > open
    closedown = close < open
    
    plotshape(closeup and barstate.isconfirmed, 'close up', shape.arrowup, location = location.belowbar)
    plotshape(closedown and barstate.isconfirmed, 'close down', shape.arrowdown, location = location.abovebar)