PureBytes Links
Trading Reference Links
|
<span
>I created the
attached DLL a while back and found the results to be accurate. The
exploration (and BP calcs) makes calls to the QP2 DLL so if you do not have
Quotes Plus just remark them out.
<span
>
<span
>Even though
Tomasz has included the ability to chart X’s and O’s, the scaling
differences caused a problem. The code below will chart candlesticks with
the appropriate color (see beginning remarks in the AFL). The solid line
will also show the level where the traditional PnF chart would be.
<span
>
<span
>There is also an
attempt to create the BPNYSE, but I did not test completely and I haven’t
taken the time to test recently either.
<span
>
<span
>If there are any
questions please let me know.
<span
>
<span
>Regards,
<span
>Peter
<span
>
<span
>
<span
>// This DLL is invoked by calling
xocalcPnF(boxsize[0=traditional],reversal)<font size=2
color=black face="Courier New">
<span
>// There will be 3 values returned by the
DLL: PnFBuySell, PnFCol and PnFVal<font size=2
color=black face="Courier New">
<span
>// For PnFBuySell: 1=Buy / 0=Sell<font
size=2 color=black face="Courier New">
<span
>// For PnFCol: 1=X / 0=O<font
size=2 color=black face="Courier New">
<span
>// For PnFVal: This is the value that
would be expressed on a traditional PnF chart.<font
size=2 color=black face="Courier New">
xo=<font
size=2 face="Courier New">xocalcPnF<font
color=black>(<span
>0,<font
color=fuchsia>3<span
>);<font size=2
color=black face="Courier New">
Color=<font
size=2 face="Courier New">IIf<span
>(PnFBuySell == <span
>1
AND PnFCol == <font
color=fuchsia>1<span
>, colorBlue,<font
size=2 color=black face="Courier New">
<font
size=2 face="Courier New">IIf<span
>(PnFBuySell == <span
>1
AND PnFCol == <font
color=fuchsia>0<span
>, colorYellow,<font
size=2 color=black face="Courier New">
<font
size=2 face="Courier New">IIf<span
>(PnFBuySell == <span
>0
AND PnFCol == <font
color=fuchsia>1<span
>, colorOrange,<font
size=2 color=black face="Courier New">
<font
size=2 face="Courier New">IIf<span
>(PnFBuySell == <span
>0
AND PnFCol == <font
color=fuchsia>0<span
>, colorRed,<font
color=fuchsia>1<span
>))));<font size=2
color=black face="Courier New">
Plot(PnFVal,<font
color=fuchsia>"PnF"<font
color=black>,Color,<span
>1+<font
color=fuchsia>4<span
>);<font size=2
color=black face="Courier New">
Plot(<span
>C,<span
>"C"<span
>,Color,<span
>64);<font size=2 color=black
face="Courier New">
Filter=<span
>C><font
size=2 color=fuchsia face="Courier New">0<font size=2 color=black
face="Courier New">;<font
size=2 color=black face="Courier New">
AddColumn(<span
>C,<span
>"Close"<span
>);<font size=2
color=black face="Courier New">
AddColumn(PnFBuySell,<font
color=fuchsia>"Buy/Sell"<font
color=black>);<font
size=2 color=black face="Courier New">
AddColumn(PnFCol,<font
color=fuchsia>"<st1:place
w:st="on">Col"<span
>);<font size=2
color=black face="Courier New">
AddColumn(PnFVal,<font
color=fuchsia>"Val"<font
color=black>);<font
size=2 color=black face="Courier New">
AddColumn(MarketID<font
color=black>(<span
>0),<font
color=fuchsia>"ID"<font
color=black>);<font
size=2 color=black face="Courier New">
AddTextColumn(MarketID<font
color=black>(<span
>1),<font
color=fuchsia>"Market"<font
color=black>);<font
size=2 color=black face="Courier New">
<span
>//AddColumn(GetExtraData("HasOptions"),"Optionable");<font
size=2 color=black face="Courier New">
AddColumn(<span
>C>MA<span
>(C,<font
color=fuchsia>50<span
>),"10Wk"<span
>);<font size=2
color=black face="Courier New">
AddColumn(<span
>C>MA<span
>(C,<font
color=fuchsia>150<span
>),"30Wk"<span
>);<font size=2
color=black face="Courier New">
AddColumn(EMA<font
color=black>(C,<font
color=fuchsia>5<span
>)>EMA<span
>(C,<font
color=fuchsia>15<span
>),"5-15"<span
>);<font size=2
color=black face="Courier New">
AddColumn(RelStrength<font
color=black>(<span
>"!DJI"<span
>),"RS");<font
size=2 color=black face="Courier New">
AddColumn(IndustryID<font
color=black>(),<span
>"IID"<span
>);<font size=2
color=black face="Courier New">
AddTextColumn(IndustryID<font
color=black>(<span
>1),<font
color=fuchsia>"Industry"<font
color=black>);<font
size=2 color=black face="Courier New">
AddColumn(SectorID<font
color=black>(),<span
>"SID"<span
>);<font size=2
color=black face="Courier New">
AddTextColumn(SectorID<font
color=black>(<span
>1),<font
color=fuchsia>"Sector"<font
color=black>);<font
size=2 color=black face="Courier New">
AddColumn((Ref<font
color=black>(C,-<font
color=fuchsia>1<span
>)-L)/(<span
>H-L)*<font
color=fuchsia>100<span
>,"Range"<font
color=black>);<font
size=2 color=black face="Courier New">
x=<font
size=2 face="Courier New">IIf<span
>(MarketID<span
>()==<span
>3,AddToComposite<font
color=black>(PnFBuySell,<font
color=fuchsia>"%BPNYSEcalc"<font
color=black>,<span
>"X"<span
>),0);<font
size=2 color=black face="Courier New">
y=<font
size=2 face="Courier New">IIf<span
>(MarketID<span
>()==<span
>3
AND (PnFBuySell==<font
color=fuchsia>0<span
> OR
PnFBuySell==1<font
color=black>),AddToComposite<font
color=black>(<span
>1,<font
color=fuchsia>"%BPNYSEcalc"<font
color=black>,<span
>"V"<span
>),0);<font
size=2 color=black face="Courier New">
<span
>/*x=MarketID()==3;<font
size=2 color=green face="Courier New">
y=MarketID()==3 AND (PnFBuySell==0 OR
PnFBuySell==1);
AddColumn(x,"X");
AddColumn(y,"Y");*/<font
size=2 color=black face="Courier New">
Buy=<font
size=2 color=fuchsia face="Courier New">0<font size=2 color=black
face="Courier New">;<font
size=2 color=blue face="Courier New">
<font size=3
face="Times New Roman">
From:<font size=2
face=Tahoma> john gibb
[mailto:jgibb1@xxxxxxxxxxxxx]
Sent: Wednesday, June 30, 2004
10:06 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: Re: [amibroker] Bullish
Percent Index Code #1
Hi Graham,
I use only EOD data and you mention "real time
basis", so I might not be the best to give you feedback.
However, for me and some symbols, the blue staircase doesn't
line up on the lowest lows and highest highs. (see attached, applied to the
QQQs)
Should it?
-john
----- Original Message -----
From: "Graham" <<a
href=""><span
>gkavanagh@xxxxxxxxxxxxx<font
size=2 face=Arial>>
To: <<a
href=""><span
>amibroker@xxxxxxxxxxxxxxx<font
size=2 face=Arial>>
Sent: Tuesday, June 29, 2004 8:43 PM
Subject: [amibroker] Bullish Percent Index Code #1
Here is stage 1 of the code on the road to producing BPI
figures. This is
just the forming of the boxed values of price data. It applies only to each
stock and so far just a plot to see if the P&F values can be created on a
real time basis.
Looking for comments back after you have had a chance to work out what I
have done, and what the results look like. Any suggestions on how to tidy up
the code, any errors/omissions, appreciated as sometimes I can take a long
road as an idea meanders through my head.
The PF values appear as a blue staircase line on backdrop of the price
chart.
Copy the code below to IB window
Cheers,
Graham
<font size=2
face=Arial>http://e-wire.net.au/~eb_kavan/
//
Bullish Percent Index
// Buy Signals generated via P&F
// Graham Kavanagh 30 Jun 2004
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;
}
Plot( C, "", colorBlack, styleBar);
Plot( toprice(PFC), "", colorBlue, styleStaircase);
//Plot( toprice(Lx), "", colorRed, styleStaircase);
//Plot( toprice(Hx), "", colorGreen, styleStaircase);
Title = Name()+" "+Date()+ " PFC = " + pfc + ", Rise =
" + rise + ", Fall =
" + fall;
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
<font
size=2 face=Arial>http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
Check AmiBroker web page at:
<span
>http://www.amibroker.com/
Check
group FAQ at: <a
href=""><font
size=2 face=Arial>http://groups.yahoo.com/group/amibroker/files/groupfaq.html<font
size=2 face=Arial>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
<a
href=""><span
>http://groups.yahoo.com/group/amibroker/
<*>
To unsubscribe from this group, send an email to:
<a
href=""><span
>amibroker-unsubscribe@xxxxxxxxxxxxxxx
<*>
Your use of Yahoo! Groups is subject to:
<a
href=""><span
>http://docs.yahoo.com/info/terms/
Check
AmiBroker web page at:<span
>
http://www.amibroker.com/
Check group FAQ at: <a
href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Check AmiBroker web page at:
http://www.amibroker.com/
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
Yahoo! Groups Sponsor
ADVERTISEMENT
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 the Yahoo! Terms of Service.
Attachment:
PnF.zip
Attachment:
Description: "Description: Zip compressed data"
|