PureBytes Links
Trading Reference Links
|
The code below posted by Graham Kavanagh seems to give the same result as
MetaStock values.
Cheers,
Gordon Sutherland
_SECTION_BEGIN("Kaji Chart");
/*AFL Library
Details:
Formula Name: Kagi Chart
Author/Uploader: Graham Kavanagh - gkavanag@xxxxxxxxxxxxxx
Date/Time added: 2002-11-29 05:12:31
Description:
Kagi swing chart with change based on share price. Swing ranges from 3 to
5%.
Place in indicator builder.
Formula: */
//KAGI Chart (or Swing) for Amibroker Indicator window.
//Reverse swing is 3%.
//Graham Kavanagh 16 Nov 2002
SetBarsRequired(100000,100000);
Close = IIf( C<10, round(C*10)/10, IIf( C>=10 AND C<50, int(C) +
round(round(frac(C)*10)/5)*5/10, int(C)));
Reverse = LastValue(IIf(C<50,0.05,IIf(C>=50 AND C<100,0.04,0.03)));
EnableScript("jscript");
<%
Close = VBArray( AFL( "Close" ) ).toArray();
KC = new Array();
// initialize first element
j = 0;
KC[j] = Close[0];
down = 1; // By default the first bar is a down bar.
up = 0;
swap = 0;
// perform the loop that produces Kagi Chart
for( i = 1; i < Close.length; i++ )
{
Reverse =AFL("Reverse"); // percent reversal
requirement
if( Close[i] <= KC[j] && down) //continue down
{
KC[j] = Close[i];
}
else
{
if( Close[i] >= KC[j]*(1 + Reverse) && down) //Change direction to up
{
j++;
swap = 1;
KC[j] = Close[i];
}
}
if( Close[i] >= KC[j] && up) //Continue up
{
KC[j] = Close[i];
}
else
{
if( Close[i] <= KC[j]*(1 - Reverse) && up) //Change direction to down
{
j++;
KC[j] = Close[i];
swap = 1;
}
}
if( swap )
{
swap = 0;
if( up )
{
up = 0;
down = 1;
}
else
{
up = 1;
down = 0;
}
}
}
delta = Close.length - j-1; //to get all of chart
AFL.Var("KC") = KC;
AFL.Var("delta") = delta;
AFL.Var("Reverse") = Reverse;
%>
KC = Ref( KC, -delta );
C = KC;
L = LLV(C,2);
H = HHV(C,2);
MyColor =
IIf(C>Ref(H,-2),colorBlue,
IIf(C<Ref(L,-2),colorRed,
colorBlack));
Graph0BarColor = MyColor;
Graph0Style = 512+4096;
GraphXSpace = 5;
Graph0 = C;
Graph0Name = "Kagi Chart";
Graph1BarColor = 1;
Graph1Style = 16+2048+4096;
Graph1 = Reverse*100;
Graph1Name = "Reverse %";
_SECTION_END();
-----Original Message-----
From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of imorf69
Sent: Tuesday, 30 October 2007 4:21 p.m.
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Kagi indicator
Thanks, runs.
But doesn't really look the same as my friend's Bullcharts Kagi
indicator. His steps are far wider and flatter, and encompass whole
swings, whereas this appears to step for every candle. Changing the
paramater doesn't seem to help much.
Any suggestions?
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
Please note that this group is for discussion between users only.
To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/
For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/amibroker/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/amibroker/join
(Yahoo! ID required)
<*> To change settings via email:
mailto:amibroker-digest@xxxxxxxxxxxxxxx
mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx
<*> 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/
|