Backtesting using Renko Chart
Author: francistan
Creation Date: 2/25/2013 8:00 AM
profile picture

francistan

#1
Hi Folks!

I've been trying to figure out myself how to do a complete backtesting system that uses Renko Charts. However, I can't seem to get the desired outcome.

Hope that there's someone who can help.

Thank you very much!

Francis
profile picture

Eugene

#2
Francis, your question is missing the vital piece: what exactly have you done to not get the desired result?

Start right here:

WealthScript Programming Guide > Backtesting with ChartStyles.Trending.

These downloadable Strategies will help you get started:

Renko Basic {Rev A}
ActiveTrader 2007-04 | Adaptive Renko (although it's not classic Renko, still might give some food for thought)
profile picture

Cone

#3
The thing to keep in mind is that the script always gets all of the price data - not just the data shown in the ChartStyle. So, when developing a system and actually trading, I'd recommend looking at the Renko chart with the OHLC overlay by right clicking the chart for Chart Style Settings and Overlay OHLC chart.

Next, the Renko ChartStyle includes an object that your script can work with for the actual Renko "columns". The documentation is in the WealthScript Programming Guide > Backtesting with ChartStyles.Trending, but you might be able to get by using the Renko Basic [Rev. A} strategy and modify it if required. If you don't have it, just use the "Strategy Download" feature (found in Wealth-Lab's Open Strategy dialog, Ctrl+O).
profile picture

francistan

#4
Thank you very much, Eugene and Cone!

Will do the work and feedback soon. :)
profile picture

kbellare

#5
I'm running the sample Renko BRicks (Rev A) strategy.

1) How do i display the Renko bricks on the chart? My chart is the traditional candlestick and ChartStyleSettings only shows me 2 options - FillCandleSticks and ShowOutlines (see attached screenshot).

2) Also, there appears to be only 1 brick size in the TRenko object (renkoPriceUnits in code below). How do i set different sizes for the Reveral brick and the Trending brick? e.g. 3*ATR and 2*ATR?

3) Finally, how do i make the Renko brick size adaptive by simply passing the ATR series as a parameter to TRenko object? It seems to accept integer, not a data series.


CODE:
Please log in to see this code.
profile picture

Eugene

#6
1) Switch the chart style to Renko first. Then the chart style settings will show "Overlay HLC chart".

2) Cone will correct me if I'm wrong but this is not supported by TRenko. Earlier in this thread I gave a pointer to the Adaptive Renko Strategy that allows both brick sizes to be customized by setting an ATR multiple:

ActiveTrader 2007-04 | Adaptive Renko

I guess this is what you're after. Your task is to create another Mult that would apply to DOWN_line:
CODE:
Please log in to see this code.


3) That was a good one. :) Renko bricks are fixed by design. "By simply passing" means that someone has to program that capability first!

And someone of our customers did it - ATR bricks named Flexible Renko can be found in Community ChartStyles library.
profile picture

kbellare

#7
I'm trying to identify historic Support/Resistence levels in the Renko columns (using the Renko Basic RevA example strategy), but couldn't find documentation on renko.Column object and methods (e.g. how do i get the High, Low of a column, how do i access the pervious and next columns so i can compare their directions - upward or downward?)

-> Pl advise how to correct this pseudo-code below so i'm using the correct Renko Column methods ..


CODE:
Please log in to see this code.

profile picture

Eugene

#8
The Column class is thoroughly documented in the WealthScript Programming Guide > Backtesting with ChartStyles.Trending > Column Class (Reference). All "Trending" chart styles share it, including TRenko.
profile picture

kbellare

#9
Thanks, I'm using the Column Class with TRenko. Couple of issues i'm running into -

1) I'm confused about the column.DirectionUp property is assigned a value and how it represents a trend
- it doesn't coincide with the column color - e.g. DirectionUp == true even when the column is red at the bar.
- also, the column is printed on the chart after the price crosses the threshold, so the DirectionUp is not known at that bar. Example, Column for bars 10-14 will be drawn only when price crosses threshold at bar14. So, at bar 12, DirectionUp is not known in a backtest - how is the value to DirectionUp assigned?


2) Some reversal columns (i.e. a red column following green column or vice versa) start in the middle instead of the end of previous column - What does that signify? The middle point doesn't seem like the Open of the next bar, so not sure what to interpret it as.
profile picture

Eugene

#10
1) DirectionUp perfectly coincides with the column color. Just strike Ctrl-Y and select "Overlay HLC chart" to make sure that "Renko Basic [Rev A]" is working as designed.
profile picture

kbellare

#11
I did that, but see a disconnect.
profile picture

Eugene

#12
For example?
profile picture

Cone

#13
QUOTE:
So, at bar 12, DirectionUp is not known in a backtest - how is the value to DirectionUp assigned?
"Up/Down" is assigned when a price movement occurs (always on a closing basis) of the Renko amount in the opposition direction from the last Renko level.

Follow the "Renko Basic [Rev A] strategy with the "Long Only" parameter = 1. Use the HLC overlay. You can see that we chose to draw the blocks starting from the bar that last changed the Renko price to the new Renko level. Perhaps it would have been more intuitive to have drawn the continuation of blocks after a Renko price change, but it's just a visual effect and frankly isn't worth changing at this point.

To see the value of DirectionUp at each bar, just add this snippet at the top of the loop after the Renko rkoColumn = renko.Columns[bar]; assignment.
CODE:
Please log in to see this code.
Note that the strategy always buys on the bar after DirectionUp changes to "U" and sells on the bar after it changes to "D".
profile picture

kbellare

#14
I annotated as you advised, and as you see in the attached image, some green Columns with rising bars are annotated "Down". Shouldn't every green column have UpDirection==true and red column have UpDirection==false?

How do i detect Column direction and reversals? Also, rkoColumn.Reversal is flagged a few columns after the actual reversal, so i can't use that flag either.

- Pl advise
Kiran

profile picture

Cone

#15
It's because the Renko settings in the script do not match those of the ChartStyle. Right click the chart > Chart Style Settings > Renko Price Units -> this number much match the "Reverse Amount" Strategy Parameter, which is used by the script. After you make an adjustment to either setting, make sure to press "Go" (or F5) to run the script.
profile picture

kbellare

#16
I ensured the Chart Style Renko Price Units match the setting in the script - see attached image is for Renko Units 2.5
It still shows a delay in the Direction reversal - red columns still say Up for several bars after the reversal - see attached image.
As a result i exit positions too late.

- Pl advise how to get around this.

profile picture

Eugene

#17
That screenshot would make better sense if you overlaid it with you Renko settings (strike Ctrl-Y) to make sure the chart matches the script as Cone suggested. 2.25 isn't equal to 2.5 as in your message.

P.S. By the way, don't use JPG for screen captures. As you can see they come out blurry and dithered. Use PNG and I bet you'll see a difference:

profile picture

Cone

#18
The image is correct for reasons I explained before. The Renko "column" is relative to the close of the last bar touching it. You'll see all the bars still indicating that the trend is "Up" from the last close that created an Up column until the close that created the Down column, which is drawn (for better or worse) from the last close of the Up column.

Keep in mind this is not a true Renko chart. The HLC overlay gives you a picture of all the bars that are ignored too. The ONLY bars that are considered for Renko are the ones AT THE END of the column. In other words, you too should ignore all bars except the ones that are on the right edge of the columns.
profile picture

kbellare

#19
There seems to be an issue with the Renko Column High and Low parameters - i'm plotting rkoColumn.High (green dashed line in image) and rkoColumn.Low (red dashed line) and they overlap on most bars - i did adjust the RenkoPriceUnits in the ChartStyleSetting to the one used in the script - 5.79 in this case.
-> They should be bordering the top and bottom of each Renko column, shouldn't they? Why do they overlap?



profile picture

kbellare

#20
Is there some other way to extract the column High and Low levels, if there's a bug with High/Low? These are important for any Renko strategy. Column.ReverseLevel parameter doesn't help because it isn't the same as High/Low.
profile picture

Cone

#21
To me, it looks like a mistake in the script used to plot those values. The script below generally plots the values that I expect, but I'm seeing some transitions that don't look correct to me at first glance. I'd have to spend some time studying it though; it's been a long time since I've thought about Renko charts.

CODE:
Please log in to see this code.

This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).