Hi!
I’ve been searching for examples of this code but can’t find it.
In PRT-charts it is possible to get the Renko boxes in % price movements. For example, 0.1 % is set as default. In the examples that I found of automated trading strategies or indicators using Renko, they are all written with a boxsize in pips. I can’t figure out how to code a boxsize in % of price. Is there a friendly soul that knows how and would like to share?
The below code is plotting renko boxes with a dynamic size in percentage of the current Close:
percent = 0.1
boxsize = close*(percent/100)
once renkoMax = ROUND(close / boxSize) * boxSize
once renkoMin = renkoMax - boxSize
IF close crosses over renkoMax + boxSize THEN
WHILE close > renkoMax + boxSize
renkoMax = renkoMax + boxSize
renkoMin = renkoMin + boxSize
iclose = renkomax
WEND
ELSIF close crosses under renkoMin - boxSize THEN
WHILE close < renkoMin - boxSize
renkoMax = renkoMax - boxSize
renkoMin = renkoMin - boxSize
iclose = renkomin
WEND
ENDIF
if iclose=renkomax then
r=0
g=255
else
r=255
g=0
endif
RETURN renkomax coloured(r,g,0) as "UP Box", renkomin coloured(r,g,0) as "DOWN Box"
Choose the percent value in line 1 by adjusting the “percent” variable.
If you want the box size to be set only at first bar and therefore fixed for the rest of the history, change the line boxsize with:
ONCE boxsize = close*(percent/100)
Thank you Nicolas! Great code! This have helped me understand the Renko better.