Simple Coding Help - No Promise.

I am getting Errors in it. Kindly rectify this Renko chart

//------------------------------------------------------------------------------
//
// Plot renko chart. Error in plotting will occur if the box and/or reversal
// values are too small causing the number of renko bars exceeding the
// underlying stock normal price bars
//
//------------------------------------------------------------------------------

// Renko Chart
// Graham Kavanagh 13 Aug 2004 ver C
// 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) );
Brick = Param( "Brick Size", 0.1, 0.01, 1.00, 0.01 );
reverse = 2;

// Convert the closing price to rising and falling rounded bricks
CF = ceil(C/Brick);
CR = floor(C/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 <= RKC[j] - 1 && down[j] ) // Continue down
{
num = RKC[j] - CF;
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 >= RKC[j] + Reverse && down[j] ) // Change down to up
{
num = CR - 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 >= RKC[j] + 1 && up[j] ) // Continue Up
{
num = CR - 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 <= RKC[j] - Reverse && up[j] ) // Change up to down
{
num = RKC[j] - CF;
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, "", colorGrey50,styleCandle);
// plot chart
//plotOHLC( rO, rH, rL, rC, "Renko Price " , colorBlack, styleCandle);
GraphXSpace=5;

Title = Name() + " - {{INTERVAL}} {{DATE}} - Renko Chart : Last Value = " + RKC * Brick + ", Brick Size = " + Brick;
 

Romeo1998

Well-Known Member
bro there is no option to select period of ema , kindly add that
Dear friend,
use this code :)
modified the code given by novicetraders :)
Code:
SetChartOptions(0,chartShowArrows|chartShowDates,0);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_BEGIN("MTF EMA");
_SECTION_BEGIN("EMA 5 MIN");
EM5=ParamToggle("EMA5","Off|On",1);

if(EM5)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in5Minute);
m5= EMA(Close,p) ;
Plot(TimeFrameExpand(m5, in5Minute), "", ParamColor( "5 Min Color", colorRed ), styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 15 MIN");
EM15=ParamToggle("EMA15","Off|On",1);

if(EM15)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in15Minute);
m15= EMA(Close,p) ;
Plot(TimeFrameExpand(m15, in15Minute), "", ParamColor( "15 Min Color", colorBlue ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA Hourly");
EMH=ParamToggle("EMAH","Off|On",1);

if(EMH)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly);
mH= EMA(Close,p) ;
Plot(TimeFrameExpand(mH, inHourly), "", ParamColor( "Hourly Color", colorGreen ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 2Hourly");
EM2H=ParamToggle("EMA2H","Off|On",1);

if(EM2H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*2);
m2H= EMA(Close,p) ;
Plot(TimeFrameExpand(m2H, inHourly*2), "", ParamColor( "2Hour Color", colorYellow ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 4Hourly");
EM4H=ParamToggle("EMA4H","Off|On",1);

if(EM4H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*4);
m4H= EMA(Close,p) ;
Plot(TimeFrameExpand(m4H, inHourly*4), "", ParamColor( "4Hour Color", colorOrange ),styleStaircase|styleThick);
TimeFrameRestore();
}
_SECTION_END();
_SECTION_END();
 
Last edited:

toocool

Well-Known Member
Dear friend,
use this code :)
modified the code given by novicetraders :)
Code:
SetChartOptions(0,chartShowArrows|chartShowDates,0);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

_SECTION_BEGIN("MTF EMA");
_SECTION_BEGIN("EMA 5 MIN");
EM5=ParamToggle("EMA5","Off|On",1);

if(EM5)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in5Minute);
m5= EMA(Close,p) ;
Plot(TimeFrameExpand(m5, in5Minute), "", ParamColor( "5 Min Color", colorRed ), styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 15 MIN");
EM15=ParamToggle("EMA15","Off|On",1);

if(EM15)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(in15Minute);
m15= EMA(Close,p) ;
Plot(TimeFrameExpand(m15, in15Minute), "", ParamColor( "15 Min Color", colorBlue ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA Hourly");
EMH=ParamToggle("EMAH","Off|On",1);

if(EMH)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly);
mH= EMA(Close,p) ;
Plot(TimeFrameExpand(mH, inHourly), "", ParamColor( "Hourly Color", colorGreen ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 2Hourly");
EM2H=ParamToggle("EMA2H","Off|On",1);

if(EM2H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*2);
m2H= EMA(Close,p) ;
Plot(TimeFrameExpand(m2H, inHourly*2), "", ParamColor( "2Hour Color", colorYellow ),styleLine|styleThick);
TimeFrameRestore();
}
_SECTION_END();

_SECTION_BEGIN("EMA 4Hourly");
EM4H=ParamToggle("EMA4H","Off|On",1);

if(EM4H)
{
p=Param("Periods",5,1,1000,1);
TimeFrameSet(inHourly*4);
m4H= EMA(Close,p) ;
Plot(TimeFrameExpand(m4H, inHourly*4), "", ParamColor( "4Hour Color", colorOrange ),styleStaircase|styleThick);
TimeFrameRestore();
}
_SECTION_END();
_SECTION_END();

error bro not working
 
Hi,
Can somebody write an AFL to plot only the opening candle and volume of past days on certain timeframe? I.e. AFL would give all opening 3 min or 5 min or 15 min candles with their volume.

Thank you.
 

Similar threads