[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: Weekly indicators on daily charts



PureBytes Links

Trading Reference Links

Sorry for sending revisions before anyone has a chance to respond. 

I have amended it in the loops and hopefully this may be better. 
I have made the bricks similar in position as the boxes in P&F charts. They
straddle the price so that the brick mid point is the actual price of the
brick close. 
The title is also added and this gives the actual brick closing price.

One thing you will need to do is make the brick size suit your stocks. I
leave that to you :)

If no corrections are necessary to the logic or construction I will post
this to the library over the weekend.

Cheers,
Graham
http://e-wire.net.au/~eb_kavan/

// 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.02) );
reverse = 1;

// 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[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] + 1;
			RKO[j] = RKC[j] - 1;			
			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( 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] - 1;
				 	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);

// plot chart
PlotOHLC( rO, rH, rL, rC, "Brick size = " + brick + "Renko Price =" ,
colorBlack, styleCandle);
GraphXSpace=5;

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



 



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~-> 

Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/