PureBytes Links
Trading Reference Links
|
Hi all
To anyone still interested in trying this out here is revised AFL for
creating the composite ticker ~BullPercent. I will post the chart AFLs in
next 2 emails
Cheers,
Graham
http://e-wire.net.au/~eb_kavan/
// Bullish Percent Index
// Buy Signals generated via P&F
// Graham Kavanagh 01 Jul 2004
// Select your group of stocks and run Scan in AA window
SetBarsRequired(100000,100000);
function ToBox( Price )
{
Boxes =
Min( Price, 0.25 )/0.0625 +
Max( ( Min( Price, 1 )-0.25 ) ,0 )/0.125 +
Max( ( Min( Price, 5 )-1 ) ,0 )/0.25 +
Max( ( Min( Price, 20 )-5 ) ,0 )/0.5 +
Max( ( Min( Price, 100 )-20 ) ,0 )/1 +
Max( ( Min( Price, 200 )-100 ) ,0 )/2 +
Max( ( Min( Price, 500 )-200 ) ,0 )/4 +
Max( ( Min( Price, 1000 )-500 ) ,0 )/5 +
Max( ( Min( Price, 25000 )-1000 ) ,0 )/50 +
Max( ( Price-25000 ) ,0 )/500 ;
return Boxes;
}
// round boxes down for High and up for Low
Lx = ceil(ToBox(L));
Hx = floor(ToBox(H));
// set variable values for locating peak/troughs of columns
Bar = BarIndex();
BarDate = DateNum();
BarTurn = 0;
DateTurn = 0;
DateEnd = 0;
BarEnd = 0;
fall = 1;
rise = 0;
PFC[0] = Lx[0];
reverse = 3;
dirn = -1; // -1=down, 1=up
for( i = 1; i < BarCount; i++ )
{
if( Lx[i]<=(PFC[i-1]-1) && V[i]>0 && dirn==-1) //continue down
{
PFC[i] = Lx[i];
DateEnd[i] = BarDate[i];
BarEnd[i] = Bar[i];
fall[i] = 1;
rise[i] = 0;
}
else
{
if( Hx[i]>=(PFC[i-1]+Reverse) && Lx[i]>PFC[i-1] && V[i]>0 && dirn==-1)
//Change direction to up
{
dirn = 1;
PFC[i] = Hx[i];
BarTurn[i] = Bar[i];
DateTurn[i] = BarDate[i];
DateEnd[i] = BarDate[i];
BarEnd[i] = Bar[i];
fall[i] = 0;
rise[i] = 1;
}
else
{
if( Hx[i]>=(PFC[i-1]+1) && V[i]>0 && dirn==1) //Continue up
{
PFC[i] = Hx[i];
DateEnd[i] = BarDate[i];
BarEnd[i] = Bar[i];
fall[i] = 0;
rise[i] = 1;
}
else
{
if( Lx[i]<=(PFC[i-1]-Reverse) && Hx[i]<PFC[i-1] && V[i]>0 && dirn==1)
//Change direction to down
{
dirn = -1;
PFC[i] = Lx[i];
BarTurn[i] = Bar[i];
DateTurn[i] = BarDate[i];
DateEnd[i] = BarDate[i];
BarEnd[i] = Bar[i];
fall[i] = 1;
rise[i] = 0;
}
else
{
PFC[i] = PFC[i-1];
rise[i] = rise[i-1];
fall[i] = fall[i-1];
}
}
}
}
}
//Convert boxes to prices for check plotting
b1=0 + 0.25 / 0.0625;
b2=b1 + (1-0.25) / 0.125;
b3=b2 + (5-1) / 0.25;
b4=b3 + (20-5) / 0.5;
b5=b4 + (100-20) / 1;
b6=b5 + (200-100) / 2;
b7=b6 + (500-200) / 4;
b8=b7 + (1000-500) / 5;
b9=b8 + (25000-100) / 50;
function ToPrice( Value )
{
Price =
Min( Value, b1 ) * 0.0625 +
Min( Max( Value-b1, 0 ), b2-b1 ) * 0.125 +
Min( Max( Value-b2, 0 ), b3-b2 ) * 0.25 +
Min( Max( Value-b3, 0 ), b4-b3 ) * 0.5 +
Min( Max( Value-b4, 0 ), b5-b4 ) * 1 +
Min( Max( Value-b5, 0 ), b6-b5 ) * 2 +
Min( Max( Value-b6, 0 ), b7-b6 ) * 4 +
Min( Max( Value-b7, 0 ), b8-b7 ) * 5 +
Min( Max( Value-b8, 0 ), b9-b8 ) * 50 +
Max( Value-b9, 0 ) * 500 ;
return Price;
}
bullsig = PFC > ValueWhen( rise AND Ref(fall,1), PFC ) AND rise;
// Plot( C, "", colorBlack, styleBar);
// Plot( toprice(PFC), "", colorBlue, styleStaircase);
// Plot( toprice(Lx), "", colorRed, styleStaircase);
// Plot( toprice(Hx), "", colorGreen, styleStaircase);
// PlotShapes( shapeStar*bullsig, colorBlack, 0, toprice(PFC), 5 );
// Title = Name()+" "+Date()+ " PFC = " + pfc + ", Rise = " + rise + ", Fall
= " + fall;
Buy=1;
AddToComposite( bullsig, "~BullPercent", "C" );
AddToComposite( 1, "~BullPercent", "V" );
------------------------ Yahoo! Groups Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/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/
|