0% found this document useful (0 votes)
480 views3 pages

Renko Chart BST - Afl

This document contains code for generating a Renko chart custom indicator in MetaTrader 4. It defines the brick size parameter, converts price data into rounded bricks, and generates the Renko chart values and plot. The code loops through the price bars, tracking the direction and calculating the rounded open, close, high and low values in bricks for each bar to create the Renko chart.

Uploaded by

udhaya kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
480 views3 pages

Renko Chart BST - Afl

This document contains code for generating a Renko chart custom indicator in MetaTrader 4. It defines the brick size parameter, converts price data into rounded bricks, and generates the Renko chart values and plot. The code loops through the price bars, tracking the direction and calculating the rounded open, close, high and low values in bricks for each bar to create the Renko chart.

Uploaded by

udhaya kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

// Renko Chart

// Graham Kavanagh 13 Aug 2004 ver C - MODIFIED BY M.J.JEEVAN LAL


// Custom Indicator, date axis does not apply

//SetBarsRequired(10000,10000);

// Brick size is dependant on what you want, if too small will not produce a chart
due to insufficient x-axis bars
//Brick = LastValue( ATR(100) );
//Brick = LastValue( Max(0.02*C, 0.05) );
SetChartOptions(0,chartShowArrows|chartShowDates);
Brick = Param( "Brick Size", 5, 0.01, 10, 0.01 );
reverse =Param( "Reverse ", 1, 0, 10, 1 );

// Convert the closing price to rising and falling rounded bricks


CF = ceil(H/Brick);
CR = floor(L/Brick);

// initialize first element


j = 0;
RKC[j] = CF[0];
RKO[j] = CF[0] + 1;

down[j] = 1; // By default the first bar is a down bar.


up[j] = 0;

// Loop to produce the Renko values in number of bricks

for( i=1; i<BarCount-1; i++ )


{
if( CF[i] <= RKC[j] - 1 && down[j] ) // Continue down
{
num = RKC[j] - CF[i];
for( x=1; x<=num; x++ )
{
j++;
up[j] = 0;
down[j] = 1;
RKC[j] = RKC[j-1] - 1;
RKO[j] = RKC[j] + 1;
}
}
else
{
if( CR[i] >= RKC[j] + Reverse && down[j] ) // Change down to up
{
num = CR[i] - RKC[j];
j++;
up[j] = 1;
down[j] = 0;
RKC[j] = RKC[j-1] + 2;
RKO[j] = RKC[j] - 1;
for( x=2; x<=num; x++ )
{
j++;
up[j] = 1;
down[j] = 0;
RKC[j] = RKC[j-1] + 1;
RKO[j] = RKC[j] - 1;
}
}
else
{
if( CR[i] >= RKC[j] + 1 && up[j] ) // Continue Up
{
num = CR[i] - RKC[j];
for( x=1; x<=num; x++ )
{
j++;
Up[j] = 1;
Down[j] = 0;
RKC[j] = RKC[j-1] + 1;
RKO[j] = RKC[j] - 1;
}
}
else
{
if( CF[i] <= RKC[j] - Reverse && up[j] ) // Change up to down
{
num = RKC[j] - CF[i];
j++;
Up[j] = 0;
Down[j] = 1;
RKC[j] = RKC[j-1] - 2;
RKO[j] = RKC[j] + 1;
for( x=2; x<=num; x++ )
{
j++;
up[j] = 0;
down[j] = 1;
RKC[j] = RKC[j-1] - 1;
RKO[j] = RKC[j] + 1;
}
}
}
}
}
}

// move the chart to right end of chart space, ie last brick on last bar position
delta = BarCount-1 - j;

RKC = Ref( RKC, -delta );


RKO = Ref( RKO, -delta );

Up = Ref( Up, -delta );


Down = Ref( Down, -delta );

/*
rC = RKC * Brick;// + (Up-down)*Brick/2;
rO = RC - (Up-down)*Brick;
rH = Max(rC,rO);
rL = Min(rC,rO);
*/
C = RKC * Brick;// + (Up-down)*Brick/2;
O = C - (Up-down)*Brick;
H = Max(C,O);
L = Min(C,O);

Plot( C, "", ParamColor( "Renko Color", colorBlack ),ParamStyle("Renko


Style",styleCandle,maskAll));

_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} \n Op=> %g, \n Cl=> %g \n",


O, C ) );

// plot chart
//PlotOHLC( rO, rH, rL, rC, "Renko Price " , colorBlack, styleCandle);
/*
Buy=Up;
PlotShapes(shapeUpArrow*Buy,colorGreen, 0, L );
Sell=Down;
PlotShapes(shapeDownArrow*Sell,colorRed, 0, H );

*/

You might also like