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

[amibroker] Re: Zig zag retracements: how to display just the ones I want?



PureBytes Links

Trading Reference Links

I guess I found it for metastock:


ZigPerc:= Input("Zig-Zag Percentage", .1, 99, 1);
{basic peak and trough level calculation}
P1:=ValueWhen(1,Peak(1,Zig(C,ZigPerc,%),ZigPerc),
Peak(1,Zig(H,ZigPerc,%),ZigPerc));
P2:=ValueWhen(1,Trough(1,Zig(C,ZigPerc,%),ZigPerc),
Trough(1,Zig(L,ZigPerc,%),ZigPerc));

{Fibonacci retracement levels calculation}
P3 := P2 + (P1-P2)*0.236;
P4 := P2 + (P1-P2)*0.382;
P5 := P2 + (P1-P2)*0.5;
P6 := P2 + (P1-P2)*0.618;
P7 := P2 + (P1-P2)*0.764;

{Plotting the levels}
P2; {through}
P3; {23.6% (76.4%) retracement}
P4; {38.2% (61.8%) retracement}
P5; {50.0% retracement}
P6; {61.8% (38.2%) retracement}
P7; {76.4% (23.6%) retracement}
P1; {peak}







--- In amibroker@xxxxxxxxxxxxxxx, "awbe2005" <awbe2005@xxx> wrote:
>
> Hello everybody,
> this is the code I took from the library:
> 
> 
> //////////////////////////////////////////////////////////////////
> Per = Param("Period", 5.9618, .1, 20, .001);
> Period = Param("Look back", 10, 1, BarCount-1);
> ShowRet = ParamToggle("Show Retracement values", "No|Yes",1);
> Price = ParamList("Price to follow:", "Close|High|Low", 0);
> if(Price=="Close") ZigP = Zig(C, per);
> else if(Price=="High") ZigP = Zig(H, per);
> else ZigP = Zig(L, per);
> 
> //////////////////////////////////////////////////////////////////
> Plot(C, "", IIf(O>=C, colorDarkRed, colorDarkGreen), ParamStyle("Price
> Style",styleHidden,maskPrice));
> Plot(ZigP, "Zig", colorGold, styleThick);
> //////////////////////////////////////////////////////////////////
> 
> xs1 = GetXSupport(ZigP, .01, 1);
> xr1 = GetXResistance(ZigP, .01, 1);
> ys1 = GetYSupport(ZigP, .01, 1);
> yr1 = GetYResistance(ZigP, .01, 1);
> 
> if(xs1 < xr1)
> {
> x = LineArray(xs1, ys1, BarCount - 1, LastValue(ZigP));
> Down = (yr1 - LastValue(ZigP)) / (yr1 - ys1);
> DnBars = BarCount - 1 - xr1;
> Plot(x, "", colorRed, styleDots);
> PlotText(StrFormat("%.3f (%.0f)", Down, DnBars), (xs1 + BarCount -1)/2,
> (ys1+LastValue(ZigP))/2, colorBlack);
> }
> else
> {
> x = LineArray(xr1, yr1, BarCount - 1, LastValue(ZigP));
> Up = (LastValue(ZigP) - ys1) / (yr1 - ys1);
> UpBars = BarCount - 1 - xs1;
> Plot(x, "", colorRed, styleDots);
> PlotText(StrFormat("%.3f (%.0f)", Up, UpBars), (xr1 + BarCount -1)/2,
> (yr1+LastValue(ZigP))/2, colorBlack);
> }
> Plot( 1, "", IIf( xs1 > xr1, colorGreen,
> colorRed),styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );
> if(ShowRet)
> for(i=2; i<=Period+1; i++)
> {
> xs0 = GetXSupport(ZigP, .01, i);
> xs1 = GetXSupport(ZigP, .01, i-1);
> ys0 = GetYSupport(ZigP, .01, i);
> ys1 = GetYSupport(ZigP, .01, i-1);
> 
> xr0 = GetXResistance(ZigP, .01, i);
> xr1 = GetXResistance(ZigP, .01, i-1);
> yr0 = GetYResistance(ZigP, .01, i);
> yr1 = GetYResistance(ZigP, .01, i-1);
> 
> xs = LineArray(xs0, ys0, xs1, ys1, 0);
> Plot(xs, "", colorGold, styleLine|styleDashed);
> xr = LineArray(xr0, yr0, xr1, yr1, 0);
> Plot(xr, "", colorGold, styleLine|styleDashed);
> if(xs1 < xr1)
> {
> Up = (yr1 - ys1) / (yr0 - ys1);
> Down = (yr0 - ys1) / (yr0 - ys0);
> UpBars = xr1 - xs1;
> DnBars = xs1 - xr0;
> }
> else
> {
> Up = (yr1 - ys0) / (yr0 - ys0);
> Down = (yr1 - ys1) / (yr1 - ys0);
> UpBars = xr1 - xs0;
> DnBars = xs1 - xr1;
> }
> PlotText(StrFormat("%.3f (%.0f)", Up, UpBars), (xr1 + xr0)/2,
> (yr1+yr0)/2,
> colorBlack);
> PlotText(StrFormat("%.3f (%.0f)", Down, DnBars), (xs1 + xs0)/2,
> (ys1+ys0)/2,
> colorBlack);
> //Plot(LineArray(xs0, ys0, BarCount-1, ys0), "", colorGreen,
> styleDashed);
> //Plot(LineArray(xr0, yr0, BarCount-1, yr0), "", colorRed, styleDashed);
> 
> }
> 
> str = StrFormat(" (Bars to END=%.0f)\n", BarCount - 1 - BarIndex());
> Title =FullName()+" ("+Name()+") - "+Date()+" - Open: "+O+", Hi:
> "+H+", Lo:
> "+L+", Close: "+C+StrFormat(" (%.2f %.2f%%)", C-Ref(C, -1),
> SelectedValue(ROC(C, 1)))+str;
> WriteIf(1, "\nNote Fibonacci numbers:\nPrimary numbers: 0.618, 0.786,
> 1.27 and
> 1.618","");
> WriteIf(1, "Secondary numbers: 0.382, 0.50, 1.00, 2.00, 2.24, 2.618 and
> 3.14","");
> 
> 
> _SECTION_END();
> 
> 
> 
> This displays all the retracements.
> 
> I just want it to find the retracements I want:
> 0.382,0.618,0.786,0.50,0.66,0.33,etc.
> 
> This is a screenshot of what I want:
> http://charts.dacharts.com/2008-10-12/Buff_33.png
> 
> Can anybody help me with this?
> 
> Thanks forward for help.
> Regards,
> Deviad
>



------------------------------------

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL 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/