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

[EquisMetaStock Group] Make 'trustful' Peak/Trough levels



PureBytes Links

Trading Reference Links

Spyros articles on zig zag validity and trend indicators are in the
August 2002 and November 2003 Stocks and Commodities magazine.

You can buy the articles for $4 each, if you don't have the magazines.

Here's a quote from Sypros

"The Zigzag approach to trend analysis can be based on some very
powerful tools.

First we have Zigzag itself, an indicator that filters out price noise
by connecting important peaks and troughs with straight lines that
make trends as obvious as it gets. But Zigzag is dynamic, meaning that
it revises its indications of the past according to new data and thus
its last leg is revisable itself! This is a major problem because you
can not use Zigzag either for back-testing of a trading idea (it will
probably give you an ideal but unfortunately false picture of your
system's hypothetical performance) or for live signals (it generates
invalid phantom signals). Zigzag is a fine tool but only for studying
the static picture of the major trends of the past.

Second we have Zigzag Validity which - as its name suggests - checks
the validity of the last leg of Zigzag. If the leg is valid it returns
1; if it is not it returns 0. With the Zigzag Validity indicator we
solve the problem of the last leg (of the current indication of
Zigzag). To put it otherwise, you can trust Zigzag Validity's current
indication but you cannot trust its past indications. This is
definitely a problem because although you can base trading decisions
on the current indication you cannot reliably back test your trading
ideas with this indicator either.

Third we have Zigzag Trend (ZZT), a binary indicator which adopts the
Zigzag mechanism but as opposed to the above two indicators, it gives
always valid signals about the direction of a trend and shows when
that trend was confirmed. It does not show peaks and troughs like
Zigzag, but returns +1 for valid up trends and -1 for valid downtrends
and it rejects all the invalid trends. The real power of ZZT is that
its signals are never revisable, so you can let the indicator provide
valid signals for both the past and the present. In other words ZZT
can be used for both back testing and live signal generation!

The Zigzag Threshold indicator is yet another step further. It
displays the price at which a Zigzag leg becomes valid. The beauty of
Zigzag Threshold is that it lets you know in advance how much prices
have to retrace their steps before a new trend is established. Zigzag
Trend and Zigzag Threshold are very close relatives. The moment at
which prices cross the returned by Zigzag Threshold level, ZZT changes
direction. Vice versa, the moment ZZT changes direction, prices cross
the threshold. So the values provided by the indicator serve not only
as signals of trend establishment, but also as excellent additional
support and resistance levels calculated with the Zigzag technique!"

Mark Katsanos wrong an article based on the zig zag called :Detecting
Breakouts From Flags and Pennants. Here's a little debate they had
about the theory. 

USING ZIGZAG TO DETECT BREAKOUTS, REVISITED

Editor,

I only just recently saw Markos Katsanos' reply to my previous letter
to the editor, both published in the November 2005 issue (I received
this issue with great delay because it got lost in the mail and your
subscription department was kind enough to send me a replacement
copy). This discussion stems from the article "Detecting Breakouts
>From Flags & Pennants" by Markos Katsanos, published in the May 2005 S&C.

I thought it would be a good idea to come back with a few comments,
albeit belatedly. Here is my reply:

1. Katsanos says that he does not use zig for detecting flags but only
for calculating the days since the formation of the flag pole. My
answer is that the use of zig without confirmation is wrong, no matter
what one is trying to calculate. In this case, for example, since zig
is not confirmed, the recent peak -- used as the flag pole -- is
revisable. And since the peak is revisable, the number of days since
the peak is also revisable!

2. Katsanos claims that it does not really matter whether the zig
reversal is confirmed or not and that it is actually better if it is
not confirmed, because the continuation of the trend is what we hope for.

However, I have two objections. First, a trader has to decide if he
really needs patterns. You can't say "I am trading flags" without
waiting to see if what you are looking at is a flag or not! You may be
trading well, but in this case, you are not trading flags. Second, if
you use the zigzag indicator to identify a pattern, you have to let
the indicator do its job. An unverified zigzag leg is not a leg at
all. If you don't need it, then why use it?

3. As Katsanos states, he uses a 17% zig just to make sure he will
have a steep-enough pole on the left side of the zig reversal. The
problem is that in order to have a 17% reversal (say, a top), one has
to wait until the price retraces by 17% and no less! If you don't want
to wait until the confirmation of the top, then only the previous
bottom of 17% is valid, not the recent peak. Therefore, the second
line of Markos' code for the signal to enter long that reads:
 

    X:=Barssince(ZZ<Ref(ZZ,-1)

    AND Ref(ZZ,-1)>Ref(ZZ,-2));


returns an invalid number of periods, because it refers to a peak and
not a trough. And unfortunately, the peak it refers to is a phantom one.

4. The above line cannot be substituted the way Katsanos suggests. He
suggests the use of X:= ref(HHV(C,20),-2) as an alternative, but the
two statements not only return different values, but they also refer
to entirely different classes.

Finally, my remarks refer mainly to the system code, not the
exploration code. And they refer to the validity of that code, which
will certainly lead to phantom signals, not to the trading idea and
the statistical evidence brought. My concerns are not just
theoretical. They have been confirmed by traders who already saw their
entry signals disappearing after initiating a position. A few
successful trades do not prove the scientific accuracy of a method.

Spyros Raftopoulos

Markos Katsanos replies:

You are absolutely right; MetaStock's zig function cannot be used to
detect peaks unless the second leg is confirmed. I am not, however,
using this function for the purpose that it was originally intended
(that is, to detect peaks) but rather to detect a temporary or
provisional peak (or reversal) before the original trend is resumed.

As you know, the way MetaStock calculates a zigzag is as follows:

Suppose we use the zig(C, 17, %) function to detect a 17% peak.
MetaStock calculates changes in prices until a 17% peak is reached and
price reverses to the downside. It then declares a provisional peak
and draws the left side of the peak, which can be revised if it is not
confirmed (that is, the reversal or the right side of the peak is also
17%).

By the way, this is only true for MetaStock. Other programs (like
TradeStation) wait for the second leg (right side) to decline by 17%
as well before declaring a peak, and that is probably the reason why
my code was not translated for other software.

In detecting flags, I used the zig to detect a 17% rise (on the left
side of the peak) but was not interested in a 17% reversal. In fact,
waiting for a 17% reversal will only detect failed flags, since the
successful ones do not usually decline by more than 13% before
breaking out in the prevailing direction (see also the statistics in
Figure 1 of my May 2005 article, "Detecting Breakouts From Flags &
Pennants").

In other words, I was only interested in failed zigs, or zigs that
were not later confirmed, and I used MetaStock's way of calculating
the zig for my benefit. This implies, however, as I have also already
mentioned in my previous letters, that because the zig will later most
likely be revised, this method can only be used with MetaStock
explorations.

And my last and most compelling argument is that the exploration code
works well and is successful in detecting flags. I have used this
exploration for more than a year now and it has produced many
profitable trades. I also know that of a number of magazine readers
are using it successfully. In fact, one of them (a British broker)
liked it so much that he decided to present it at a meeting with clients.

Concerning your comments on the alternative code X:=
ref(HHV(C,20),-2), I agree that this cannot be used to detect a peak
on its own. It is used, however, in conjunction with condition 2 (17th
line of the code):
 

    Ref (LinRegSlope(C, 13)/Ref(C,-13)*100,-X1)>2.2


which ensures that the slope of the left side of the peak (the pole)
is not less than 2.2% per day.

Editor's note:

Markos Katsanos has contributed several articles to STOCKS &
COMMODITIES on the topic of detecting breakouts, including "Detecting
Breakouts" (April 2003) and "Detecting Breakouts In Intraday Charts"
(September 2003). The articles sparked much interest and discussion,
so additional letters from readers with detailed responses from Markos
Katsanos can be found in the June 2003 and March 2004 issues in the
Letters to S&C column.

In addition, Spyros Raftopoulos was the author of two articles
published in STOCKS & COMMODITIES on using zigzag as an indicator:
"Zigzag Validity" (August 2002) and "The Zigzag Trend Indicator"
(November 2003). And since these articles also sparked much interest
and discussion, additional letters from readers with detailed
responses from Spyros Raftopoulos can be found in the following issues
in the Letters to S&C column: November 2002, January 2004, and April
2004. 

METASTOCK CODE FOR ZIGZAG VALIDITY
  {Zigzag validity by Spyros Raftopoulos}

  perc:=Input("Percent",0.2,100,10);

  Z:=Zig(Close,perc,%);
  last:=ValueWhen(1,( Z > Ref(Z,-1) AND Ref(Z,-1) < Ref(Z,-2))
  OR (Z < Ref(Z,-1) AND Ref(Z,-1) > Ref(Z,-2)),  Ref(Z,-1));

  pc:=(Close-last) * 100 / last;
  pc:= Abs(pc);

  SD:=(z > Ref(z,-1) AND Ref(z,-1) > Ref(z,-2))
  OR (z < Ref(z,-1) AND Ref(z,-1) < Ref(z,-2));

  res:=If(pc >= perc ,1,0);
  If(Alert(res,2) AND SD,1,res)


{ZigZag validity engine by Spyros Raftopoulos}
{additional code by Jose Silva}
{1=ZigZag valid, 0=ZigZag invalid}

perc:=Input("ZigZag percent",.1,100,5);
plot:=Input("plot:  signals=1,  % of valid signals=2,  ZigZag=3",1,3,
1);
x:=Input("use Open=1 High=2 Low=3 Close=4 Volume=5 P=6",1,6,4);

x:=If(x=1,O,If(x=2,H,If(x=3,L,If(x=5,V,If(x=6,P,C)))));
z:=Zig(x,perc,%);
z1:=Ref(z,-1);
z2:=Ref(z,-2);
last:=ValueWhen(1,z>z1 AND z1<z2
 OR z<z1 AND z1>z2,z1);
pc:=Abs((x-last)*100/last);
SD:=z>z1 AND z1>z2 OR z<z1 AND z1<z2;
res:=pc>=perc;
valid:=If(Alert(res,2) AND SD,1,res);
validper:=Cum(valid)/Cum(valid>-1)*100;

If(plot=3,z,If(plot=2,validper,valid))


I don't know how much of this is in the files section under the older
2002 docs or Preston 2005 doc, but have fun.

Super

--- In equismetastock@xxxxxxxxxxxxxxx, Kevin Barry <kevin_barry@xxx>
wrote:
>
> Just my tuppence worth on Spyros's validated ZigZag........
> 
> I use it in two ways in my (FX) trading strategy. Firstly, it is a very 
> good trend indicator. As long as the indicator value is +1, the
uptrend is 
> intact. An indicator value of -1 means that a downtrend is in place.
You 
> can adjust the percentage/point tolerances in the same way as you
can with 
> the MS ZigZag indicator.
> 
> More useful for me however, is using it as an objective indication
of when 
> and where to scale into the trade, which I do all the time. If
working a 
> long trade and the Validated ZigZag changes from +1 to -1, it indicates 
> that a pullback is occurring. When it changes back to +1, ideally
when the 
> price hits a Fib level or a pivot level, then I will add to the
trade and 
> move my stop up to just below the validated trough.
> 
> Hope it helps.
> 
> Regards,
> Kevin
> 
> 
> At 17:09 12/11/2007 +0000, you wrote:
> 
> >As I remember it, the last time I heard from Spyros he wasn't using
> >anything to do with the zig zag, including the ZZ, etc.
> >
> >Dirk, probabilities are the issue. When a peak or trough signal is
> >validated, all it means is that the price has changed direction enough
> >so that the direction change signal is stable. It says absolutely
> >nothing about the probability the stock will continue to rise or fall.
> >
> >Once you use a validated zig zag signal, it stops the zig zag from
> >picking the bottom or top in hindsight. That means that from the point
> >of the turn to the validation signal, the price required to meet the
> >validation percentage is not part of the trade profit. That changes
> >the performance of the zig zag function dramatically. Test it and
> >you'll see.
> >
> >You can use the validated zig zag signal like a filter as part of a
> >trading system, but it's not a great filter. At least that's been my
> >experience.
> >
> >Spyros has a series of articles on the zig zag in Stocks and
> >Commodities. He spent a lot of years working on the zig zag.
> >
> >--- In 
>
><mailto:equismetastock%40yahoogroups.com>equismetastock@xxxxxxxxxxxxxxx, 
> >"dirk_boodts" <etrader@> wrote:
> > >
> > > Thanks, this is very useful to find out if the latest turn is
> > > definite or not.
> > > The formula: cross(c,peak(1,c,5%) Should work because when the
> > > close is back up, it means that a trough is made and so the last
> > > peak is surely definite. (correct me if i'm wrong).
> > >
> > > The problem tough is that if the next close (bar) is not above the
> > > peak, then the expert advisor takes away the signal.... :-(
> > >
> > > Why is this? And is there something to do about it.
> > >
> > > rgds,
> > >
> > > Dirk
> > >
> > >
> > >
> > >
> > >
> > > --- In 
> >
<mailto:equismetastock%40yahoogroups.com>equismetastock@xxxxxxxxxxxxxxx, 
> > pumrysh <no_reply@> wrote:
> > > >
> > > > Spyros Raftopoulos did a good deal of work on this and has a
> > > > validating indicator. Check the files for ZZ indicators...3 files
> > > all
> > > > total.
> > > >
> > > > Preston
> > > >
> > > >
> > > >
> > > > --- In 
> >
<mailto:equismetastock%40yahoogroups.com>equismetastock@xxxxxxxxxxxxxxx, 
> > "dirk_boodts" <etrader@>
> > > > wrote:
> > > > >
> > > > > The Peak/trough indicator is very interesting but as you all
> > > know,
> > > > > one should avoid it when using in a system because it's
> > > hindsight.
> > > > >
> > > > > Although, I tought that Peak(1,C,5) must work (trustful) once
> > > the
> > > > > stock declined enough from that peak en rises again. With other
> > > > > words, once the trough(1,C,5) is made, then the Peak(1,C,5) can
> > > be
> > > > > used in a system, no..?
> > > > >
> > > > > I tried and yes indeed, once the close is back at the peak level
> > > it
> > > > > means that the stock made a low and the peak will not change
> > > > anymore.
> > > > > (am I correct?)
> > > > >
> > > > > THE PROBLEM tough is that in realtime after giving a signal -for
> > > > > example: C > Peak(1,C,5) - the next bar closes beyond the Peak
> > > > and
> > > > > the signal is gone. If the next bar is closer higher, the
> > > signal
> > > > > stays valid and we have a good signal.
> > > > >
> > > > > Any comments? How can we solve the problem that the signal
> > > doesn't
> > > > > dissapear the next bar?
> > > > >
> > > > >
> > > > > rgds
> > > > >
> > > >
> > >
> >
> >
> 
> 
> [Non-text portions of this message have been removed]
>




 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/equismetastock/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/equismetastock/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:equismetastock-digest@xxxxxxxxxxxxxxx 
    mailto:equismetastock-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    equismetastock-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/