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

[amibroker] Corrected Gann/Fib Projection Formula



PureBytes Links

Trading Reference Links

I just had a brain fart and figured out what the problem was with the 
Gann/Fib Projection formula.  I have posted the corrected code below.

David K.

//* S&C Fibonacci and Gann Projections - Sept 2004 *//

Change=Param("Zig %",0.80,0.10,20,0.10);

Gannincrement=0.0625;

procedure Plotshapeat(x,y,shape,shift)
{
PlotShapes(IIf(BarIndex()==x,shape,0),colorRed,0,y,shift);
}
procedure Plotbluedot(x,y)
{
PlotShapes(IIf(BarIndex()==x,shapeSmallCircle,0),colorBlue,0,y,0);
	
for(i=-2;i<=2;i++)
{
if(i !=0)
{
ygann=(sqrt(y)+i*gannincrement)^2;
PlotShapes(IIf(BarIndex()
==x,shapeSmallCircle,0),colorOrange,0,ygann,0);
	}
}
}


bi=BarIndex();

sbi=SelectedValue(bi);

GraphXSpace=2;

Plot(Zig(C,Change),"ZigZag",colorBrightGreen,1);

Plot(C,"Price", IIf(bi>sbi,colorLightGrey,colorBlack),styleBar);

upshift=15;

if(SelectedValue(PeakBars(C,Change)<TroughBars(C,Change)))
{

pt1=PeakBars(C,Change,1)==0;
pt2=TroughBars(C,Change,1)==0;
}

else
{

pt1=TroughBars(C,Change,1)==0;
pt2=PeakBars(C,Change,1)==0;

upshift= -upshift;
}


bpt1=SelectedValue(ValueWhen(pt1,bi));
bpt2=SelectedValue(ValueWhen(pt2,bi));
bpt3=SelectedValue(ValueWhen(pt1,bi,2));
bpt4=SelectedValue(ValueWhen(pt2,bi,2));
bpt5=SelectedValue(ValueWhen(pt1,bi,3));
bpt6=SelectedValue(ValueWhen(pt2,bi,3));

Plotshapeat(bpt1,C,shapeDigit1,upshift);
Plotshapeat(bpt2,C,shapeDigit2,-upshift);
Plotshapeat(bpt3,C,shapeDigit3,upshift);
Plotshapeat(bpt4,C,shapeDigit4,-upshift);
Plotshapeat(bpt5,C,shapeDigit5,upshift);
Plotshapeat(bpt6,C,shapeDigit6,-upshift);

Level=SelectedValue(ValueWhen(pt1,C));
Plotbluedot(round(bpt1+1.618*(bpt1-bpt2)),Level);
Plotbluedot(round(bpt1+0.382*(bpt1-bpt2)),Level);

Plotbluedot(round(bpt1+0.50*(bpt2-bpt3)),Level);
Plotbluedot(round(bpt1+1.732*(bpt2-bpt3)),Level);

Plotbluedot(round(bpt1+0.618*(bpt4-bpt5)),Level);
Plotbluedot(round(bpt1+2*(bpt4-bpt5)),Level);

Plotbluedot(round(bpt2+0.6707*(bpt4-bpt2)),Level);
Plotbluedot(round(bpt2+2.618*(bpt4-bpt2)),Level);

Plotbluedot(round(bpt2+1*(bpt6-bpt2)),Level);
Plotbluedot(round(bpt2+3*(bpt6-bpt2)),Level);




------------------------ 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/