PureBytes Links
Trading Reference Links
|
function
pfsig(box)
{
global Buy, Sell, Cover, Short;
Buy
= Sell
= Short
= Cover
= 0;
j = 0;
Lo[0] =
Box * ceil(L[0]/Box) ;
Hi[0] = Lo[0] + box;
direction = 0;
range = 0;
reverse = 3;
for(
i = 1 ; i
< BarCount ; i++ )
{
if(direction[j]
== 0)
{
if(L[i] <= Lo[j] - Box)
{
diff = Lo[j] - L[i];
n= floor(diff/box);
Lo[j] = Lo[j] - n* box;
}
else
{
if(H[i] >= Lo[j] + Reverse*Box)
{
diff = H[i] - Lo[j];
n = floor(diff/box);
j++;
direction[j] = 1;
Hi[j] = Lo[j-1] + n* Box;
Lo[j] = Lo[j-1] + Box;
Buy[i] = 1;
}
}
}
else
{
if(H[i] >= Hi[j] + Box)
{
diff = H[i] - Hi[j];
n= floor(diff/box);
Hi[j] = Hi[j] + n*box;
}
else
{
if(L[i] <= Hi[j] - Reverse * Box )
{
diff = Hi[j] - L[i];
n= floor(diff/box);
j++;
direction[j] = 0;
Lo[j] = Hi[j-1] - n*box;
Hi[j] = Hi[j-1] - Box;
Sell[i] = 1;
}
}
}
}
return (
Buy
&& Sell && Short && Cover);
}
SetBarsRequired(100000,100000);
pfsig (0.001);
Plot(C,"", IIf(Buy, colorBrightGreen,IIf(Short,colorRed, 39)),styleBar);
PlotShapes(Buy*shapeUpArrow,colorBrightGreen,0,L);
PlotShapes(Sell*shapeDownArrow,colorRed,0,H);
onelkm wrote:
I wanted to apply buys and sells to a nice P&F chart that Graham did
a while back. I tried to use some of the examples in Howard Bandy's
book plus other posts on this board to add the buys and sells. At
this point I am stumped and would really appreciate any help to get
the code running. It does produce results, but they are wrong.
Thanks
Larry
__._,_.___
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
__,_._,___
|
|