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

Re: [amibroker] The Theory of Zig and How to make it Work



PureBytes Links

Trading Reference Links

the peaks and troughs are determined after the price has retraced
beyond the percentage from the higher high or lower low. So the
current price will change the history, you do not know where the peak
or trough bar will occur until sometime in the future.
If you want to use zig in backtesting/trading then you must include
the condition that the price has gone beyond the required percentage
eg for general condition
Buy = OtherBuyConditions and highestsince(troughbar(c,10)==0, C) >
trough(C,10)*1.1;
or for single event
Buy = Cross( C,  trough(C,10)*1.1 );

there are other methods for this,
Rise = flip( Cross( C,  trough(C,10)*1.1 ), Cross( C,  peak(C,10)*0.9
) or barindex()==lastvalue(barindex()) );


-- 
Cheers
Graham Kav
AFL Writing Service
http://www.aflwriting.com




2008/10/31 Ken Close <ken45140@xxxxxxxxx>:
> A friend asked me why he can not trade with the Zig indicator.
> I answered: "Because it looks into the future."
> He said, "What does that really mean?"
> I said: "It looks into the future."
> He said, "Huh".
>
> Can someone explain, without using the words "It looks into the future", why
> the Zig indicator can not work.
> How is it coded internally?  What makes it work--plot that is?"
>
> I found some code on my hard drive from 2004 called "Zig Zag Safe to Use".
> I will copy the code below.
> Why does this code say that it is "Safe to Use"?
> What do you look at, what does the several adjustment values do, that makes
> it safe?
>
> Any explanations in english, that are easy to understand?
> Will this code be safe to trade?
>
> Thanks,
> Ken
> ============================================================
>
> array = Close;
> amount = Param("Amount", 5, 1, 50, 0.5 );
> adjust =
> Param("adjust",0.001,0.001,0.10,0.001);
> zz0 = Zig( array, amount );
> zz1 = Ref( zz0, -1 );
> zz2 = Ref( zz0, -2 );
> tr = ValueWhen(zz0 > zz1 AND zz1 < zz2, zz1);
> pk = ValueWhen(zz0 < zz1 AND zz1 > zz2, zz1);
> PU = tr + 0.01 * abs(tr)*amount;
> PD = pk - 0.01 * abs(pk)*amount;
> ZZT = IIf( array >= PU AND zz0 > zz1, 1,
> IIf( array <= PD AND zz0 < zz1, -1, 0 ) );
> ZZT = ValueWhen( ZZT != 0, ZZT );
> // plot price bar chart
> Plot
> ( Close, "Price", 1, styleLine );
> // plot Zigzag and zigzag trend
> Plot
> ( ZZT, "ZigZagTrend", colorRed, styleOwnScale );
> Plot
> ( zz0, "ZigZag line", colorBlue, styleThick );
> // Plot the ribbon
> ribboncol= IIf( ZZT > 0, colorGreen, colorRed );
> Plot
> ( 2, "ZZT Ribbon", ribboncol, styleArea | styleOwnScale | styleNoLabel, 0,
> 100 );
> GraphXSpace
> = 10;
> Buy
> = Cover = Cross( ZZT, 0 );
> Sell
> = Short = Cross( 0, ZZT );
> // plot arrows
> PlotShapes
> ( Buy + 2 * Sell, ribboncol, 0, IIf( Buy, L, H ), -30 );
>   

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

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