I am with a group of people who use Renko blocks as one of the indicators for a trading system, which currently we trade manually. I would like to automate this, but I would like to have an automated Renko that looks exactly like the PRT one so that I can check my automated system against the charts, and so that manual entries would be exactly the same as my automated ones, in backtesting, at least. I looked on the forums for code that reproduce it, failed to find any, and wrote my own. It seems to work in that the blocks move in step with the PRT ones, but it isn’t initialising in the same way, so my blocks are sometimes x points higher or lower than PRT’s, still moving the same amount in step, but with an offset of x. It seems to vary dependent on how many units are loaded, or simply when I load it.
Do you know how PRT calculates its initial values for Renko? Is it possible to do what I’m trying to do?
Many thanks.
still moving the same amount in step, but with an offset of x. It seems to vary dependent on how many units are loaded, or simply when I load it.
That’s the thing with Renko charts. You will get a completely different chart just depending on when you start it.
In real life this shouldn’t matter for your strategy because if it is truly robust then it can cope no matter when you start building your Renko blocks.
I think that the below code version can start the same way as the version of the platform, with a round number, therefore the bricks construction is synchronized with the platform.
boxsize = 5
boxsize = boxsize*pointsize
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"
Vonasi, thank you for your reply. Before I get to the strategy, it matters to me to get my indicator looking the same as the chart so that I can convince my fellow traders that my backtesting matches their spreadsheet results, so can be believed.
Nicholas, thank you for the most beautiful code that I have seen in my life! It is a perfect match indeed, and what’s more, my Renko is in colour!!! 🙂