i am trying to write a pine script code on Tradingview, the aim is to adjust the renko box size automatically (something like ATR, but tradingview's ATR feature doesnt do what i want), i am thinking to make the box size 5% of the current price (or of the previous close, this makes more sense because the value would be concrete).
below is the code for the regular renko, what i am struggling is to make 'box_size' variable equal to a specific percentage of the previous close.
//@version=3
study("Renko", shorttitle = "Renko")
src = input(title = "Source (close or open or hl2 or hlc3 or ohlc4)", type =
string, defval = "close")
box_size = 0.5
renko_tickerid = renko(tickerid, src, "Traditional", box_size)
renko_close = security(renko_tickerid, period, close)
renko_open = security(renko_tickerid, period, open)
renko_high = security(renko_tickerid, period, high)
renko_low = security(renko_tickerid, period, low)
plotcandle(renko_open, renko_high, renko_low, renko_close, color = renko_open < renko_close ? green : red)
appreciate any guidance in advance.