Flexible Renko

Modified on 2010/11/18 10:52 by Eugene — Categorized as: ChartStyles

The FlexRenko ChartStyle developed by user dansmo is a chart style which is similar to the usual Renko style but the calculation of the brick size can be switched from a fixed value to a volatility adjusted method using the ATR(14).

Right-click the chart and select "Chart Style Settings" - or simply hit Ctrl-Y on your keyboard - to invoke the dialog where you can set which method to use and which factor to take for calculation of the brick size.

As of version 2010.12 of the library, FlexRenko uses the 14-day ATR as a basis for the calculation of the brick size on intraday charts. (Previously, the ChartStyle used the intraday ATR, making the chart to depend heavily on recent intraday volatility.) The change is designed to keep the brick size constant during the trading session and make the chart's look & feel resemble the traditional Renko chart. Note: for an intraday chart to start drawing FlexRenko bricks, the equivalent of at least 15 Daily bars must be loaded; otherwise you'll see an empty chart.

Example with FlexRenko using Price based calculation of 1,0 Dollars.

Example with FlexRenko using Price based calculation of 1,0 Dollars.

Example with FlexRenko using ATR based calculation where ATR is weighted with a factor of 2,00.

Example with FlexRenko using ATR based calculation where ATR is weighted with a factor of 2,00.


You can call the FlexRenko method and use it in a bar chart to get all the necessary information. Here´s an example that will paint the bar chart red/green if there are up/down bricks.

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using WealthLab.ChartStyles.Community;

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { //use these to change the settings for the Renko Chart: bool _Price = true; bool _ATR = false; double _Factor = 1; //**************************************************** //create an instance of FlexRenko FlexRenko fr = new FlexRenko(); //call the calculate Renkos Method fr.calculateRenkos(Bars,_Price, _ATR, _Factor);

//get all the available Renko information in the Renko class stored for every bar Dictionary<int, FlexRenko.Renko> renkoDict = fr.getRenko(); //available variables in the Renko class are: /* public int firstBrickInBar; public int numBricks; public bool isDownBrick; public bool isUpBrick; public List <double> brickHigh = new List<double>(); public List <double> brickLow = new List<double>(); */ DataSeries brickHighSeries = new DataSeries(Bars, "brick High"); DataSeries brickLowSeries = new DataSeries(Bars, "brick Low"); double brickHigh = 0; double brickLow = 0; bool lastBrickUp = false; bool isUpBrick = false; bool isDownBrick = false; for(int bar = 1; bar <= Bars.Count - 1; bar++) { int numBricks = 0; int firstBrick = 0; int brickNumber; //get the current bar´s values from the renko dicitonary if(renkoDict.ContainsKey(bar)) { numBricks = renkoDict[bar].numBricks; isUpBrick = renkoDict[bar].isUpBrick; isDownBrick = renkoDict[bar].isDownBrick; firstBrick = renkoDict[bar].firstBrickInBar; }

//draw the number of bricks to the chart if(numBricks > 0) AnnotateBar("#"+numBricks, bar, true, Color.Black); //paint the background according to current brick if(isUpBrick && !isDownBrick) lastBrickUp = true; else if(!isUpBrick && isDownBrick) lastBrickUp = false;

if(lastBrickUp) SetPaneBackgroundColor(PricePane, bar, Color.LightGreen); else SetPaneBackgroundColor(PricePane, bar, Color.LightCoral); } PlotSeries(PricePane, brickHighSeries, Color.Green, WealthLab.LineStyle.Solid, 2); PlotSeries(PricePane, brickLowSeries, Color.Red, WealthLab.LineStyle.Solid, 2); } } }