Teknik Analiz Dünyasına Hoşgeldiniz. Paylaşmak Güzeldir.

Yayından kaldırmak istediğiniz formüller için algoritmabul@gmail.com ile iletişime geçebilirsiniz... 

  • DİKKAT: Formüller, Sistemler sadece eğitim amaçlıdır. Alım satım, olası anapara kaybı ve diğer kayıplar dahil olmak üzere "YÜKSEK RİSK" içerir.
  • Mucize teknik gösterge yoktur, sadece doğru veya yanlış kullanılan göstergeler vardır.

İndikatör ZigZag - Trend by Spyros Raftopoulos

Teknik analizde fiyatın yönü veya trendin devamıyla ilgili fikir veren matematiksel modellerdir. İndikatörlerin Türkçe karşılığı göstergedir.

algoritma

eiπ + 1 = 0
Algorithmist
Algoritma
Katılım
23 Eki 2020
Mesajlar
1,797

SR ZigZag Trend (NEW INDICATOR)

* To: <metastock@xxxxxxxxxxxxxxxxxx>
* Subject: SR ZigZag Trend (NEW INDICATOR)
* From: "raftsp" <raftsp@xxxxxxxxx>
* Date: Sun, 12 May 2002 18:44:43 +0300
* Importance: Normal
* In-Reply-To: <200205110438.WAA19101@xxxxxxxxxxxxxxxxxx>
* Reply-To: metastock@xxxxxxxxxxxxx
* Sender: owner-metastock@xxxxxxxxxxxxx

Ok, this is going to be a lengthy message, but I guess it is going to be an interesting one, so, please read carefully. It is better not to include the whole message in your replies. Before you hit the send button, please delete this message from your answer, or we will all end up with very long messages!

I had promised a version of ZigZag validity suitable for back tests.

The bad news:
Yesterday I saw that, though such an indicator is possible, its development is a very tricky job. This is because the cases of missed signals (invisible false zigzags of the past) do not fall into one single category but rather into many different ones (for example cases of missed zigzags during confirmed trends, cases of fluctuations of prices during doubtful trends etc.). Now, I think that dealing with all these cases is almost as hard or even harder than developing a new zigzag indicator from scratch.

The good news:
I think there is a much simpler solution to the problem. Instead of trying to discover and validate each invisible zigzag, one can deal only with the confirmed trends. After all, this is what we all want and it is much easier,
too!

Following this idea, I wrote a new binary indicator, which returns 1 for confirmed up trends and -1 for confirmed downtrends and which is also based on the Zigzag indicator. The idea is that the user of Zigzag does not wish to deal with doubtful periods at all. He does not want to be mislead by false Zig signals, but neither should he get into the trap of detecting past invisible formations, just to reject them!

My new indicator takes advantage of Zig's ability to mark major troughs and peaks but at the same time it avoids any premature - and thus dangerous - evaluations about the evolving trend. In fact, it is like having an always-valid binary Zigzag!

If what I suggest here is correct - and I do say IF - then we have a kind of zig which is not only useful for visual inspections but can also be used in system tests and can be even optimized like any other indicator used in systems. I have to be precautionary because until now, almost every attempt for a completely satisfactory confrontation of problems related to the Zigzag indicator, at least those I am aware of, have failed. Of course this includes my own! (Well, ZigZag validity works fine but only as far as the LAST dynamic leg is concerned). This one seems to work equally well not only with current prices but also with historical ones. So, all we can do for now is wish it a better luck.

The new indicator will be called "SR ZigZag Trend". I have tested its behavior in more than 50 cases, which include disappearing and re-appearing of zigzags in down and up trends, in weak and strong, gradual and abrupt moves. In all these cases it worked correctly, but it is very early for enthusiasm because dealing with Zigzag seems like alchemy. You never know if what you see is true. I will only be sure when my indicator passes all the necessary tests. And there have to be hundreds of them to convince me! Therefore, I suggest you should consider yourselves kind of "beta testers". Before starting to use my indicator in systems, please take the time to test it yourselves. For testing both the ZigZag and my indicator I would suggest the following method:

  1. Use the Zigzag indicator and the SR ZigZag Trend with the same percent of close (say 10%).​
  2. Add a second more sensitive Zigzag indicator (say 3 %)​
  3. During a long trend indicated by the 10% Zig (a long line) find a few minor zigzags of the 3% Zig and mark them with vertical lines.​
  4. Keep a note of the dates when these marks appear and of the readings of both the 10% ZigZag and the SR ZigZag Trend on those dates. You are making a table with 3 columns: Date, 10%Zig (up or down), SR ZigZag Trend (1 or -1).​
  5. Close the chart and re-open it using the first date you have noted as the LAST date of the chart.​
  6. Observe the behavior of the 10% Zigzag: In some cases it should be heading towards the opposite direction of what you had previously noted. On the contrary, the SR ZigZag Trend should NOT reconsider its value. If it is like I say, then repeat steps #5 and #6 until all the dates you have marked are examined. If you notice any revisions in the values of SR ZigZag Trend then you have caught a mistake (bad luck for all of us but especially for me). Take a detailed note of it, stop testing and contact me.​
If everything seems ok with the cases you have examined, this still doesn't mean that everyone else had the same experience. So, please post your results and read what the others have to say.

You will notice that the indicator follows Zig's changes of direction with a delay, which is necessary for the confirmation of the trend. Hopefully, once a new trend is detected and confirmed, SR ZigZag Trend will not be revised, until the next (opposite) trend's confirmation. Due to this delay, the values returned by SR ZigZag Trend do not always coincide with profitable buy and sell signals, though in many cases they really do! But this is the
old well-known sad story of any trend-following system. What is new here, is that the fans of ZigZag, MAY have now a kind of Zig, which they can play with harmlessly. And maybe the results are not so exciting as when playing ball with Zig, but here one kicks a real ball not a balloon!

A few notes before going to the code. I have no reason to doubt anyone's good will, intentions and honesty. But I have to repeat what is usually said about intellectual property. I hope you all understand. So here we go: Please don't change the indicator's name, its comments or its code, if in the future you need to post it to someone. My name and e-mail address should be present in case someone wants to contact me directly. Any changes made to
my formula should be discussed with me before being published (outside this group). It may not be used for commercial reasons without my written permission, neither as it is nor as part of other products. Any formulas, systems, experts, explorations, plug-ins or stand-alone applications, which use the whole code or important parts of it, or reference it, should mention my name. I am not responsible for any losses.. ..blah blah, though I will take your profits if you succeed :)
Needless to say, that I would be glad to hear any of your suggestions, corrections, or possible improvements.
In any case I would appreciate your feedback.
Good luck
Spyros


This 4th version of the SR ZigZag Trend indicator (short name: "SR ZZT") works with both methods (Percents AND Points) and can calculate various price fields (Open, High, Low, Close AND Indicators). This means that you can use it to check for valid trends and swing points of various prices and indicators, for valid divergences, for comparisons and much more. The code is quite fast, clear and very easy to follow. So please do not change it in case you need to refer to it.​


ZigZag Trend (SR ZZT) v.4

{by Spyros Raftopoulos}
{It is based on the Zig Zag indicator and it returns 1 for a confirmed
uptrend, and -1 for a confirmed downtrend.}
{****************************************}
vr:=Input("Field (0=Ind/tor, 1=Open, 2=High, 3=Low, 4=Close)",0,4,0);
amnt:=Input("Reversal amount",0.001,1000,10);
md:=Input("Method (1=Percent, 2=Points)",1,2,1);

{****************************************}
vr:=If(vr=1,OPEN,If(vr=2,HIGH,If(vr=3,LOW,If(vr=4,CLOSE,P))));
zz0:=If(md=1, Zig(vr,amnt,%), Zig(vr,amnt,$));
zz1:=Ref(zz0,-1);
zz2:=Ref(zz0,-2);

{****************************************}
tr:=ValueWhen(1,zz0>zz1 AND zz1<zz2, zz1);
pk:=ValueWhen(1,zz0<zz1 AND zz1>zz2, zz1);
PU:=If(md=1,tr+Abs(tr)*amnt/100,tr+amnt);
PD:=If(md=1,pk-Abs(pk)*amnt/100,pk-amnt);
res:=If(vr>=PU AND zz0>zz1,1,
If(vr<=PD AND zz0<zz1,-1,0));
res:=If(res<>0,res,ValueWhen(1,res<>0,res));
res​



Before you start using it, please read the following.
- The default field value is 0 (the "P" special data array identifier), since this makes the indicator ready for use in various situations. Furthermore this choice ensures that when no other plot is used, the SR ZZT indicator will use Close prices (read about the "P" variable in the MS manual for more information).
- However, if you drop the indicator on a plot but you have chosen another option (say 4, for Close), then SR ZZT will examine the Close prices instead of the plot it was dropped on.
- Some indicators return negative and/or zero values. Though SR ZZT can handle such values too, the Percent method might practically result in misleading indications. For example consider the following cases: from -50 to +50 there is a 200% change, whereas from -100 to +50 there is only 150% change and even more interestingly from -50 to 0 we have 100% change and from -1 to 0 we have also 100% change! This means that when you drop a zig() on CMO() for example, you might see the zig (even one with percent=100) forming zigzags also for tiny CMO() changes! This is practically useless in analysis, but it is neither a problem of the SR ZZT nor of the Zigzag indicator. It is rather a strange situation related to percentage calculations (a mathematical one). In order to use zig or SR ZZT with indicators returning zero and/or negative values, you might prefer to use POINTS instead of percentages in many cases.
- On the other hand, the Points method has the following disadvantage: a fixed difference in points is much more easily covered by large absolute values than by small ones. For example suppose you search for a reversal amount of 2 points. It is very easy for the close price to go from 100 to 102 (=2%), but very hard to go from 2 to 4 (=100%). If you drop a zig using 2 points reversal amount on a security, you will notice that it is much more volatile in high prices than in low ones!
Therefore the method to be used in each situation should be carefully considered.
In difficult cases, a solution could be to check by using both methods (percent AND points) providing the proper reversal amount for each method.
A few calculations showed that the indicator works fine, but please check it yourselves and let me know if you find anything strange in its behaviour.

To check it:
1. Drop a zig() on an indicator (say CMO).
2. Drop SR ZZT with the same method, the same reversal amount and Field=0 on the same indicator (CMO).
3. Manually calculate the difference between a swing point and the CMO's value when SR ZZT changes direction. If this value>=abs(reversal amount) Then,
4. Manually calculate the difference between the same swing point and the CMO's value 1 bar before SR ZZT changes direction. If this value<abs(reversal amount) then everything is fine. Else, take a detailed note and contact me. End if.
I hope you find this indicator as useful as I do. Have fun and take care.
Spyros



Hi, Spyros:
Thanks for your work and regular postings. Thot I would pass on to you a version that will run a bit more efficiently, and be a bit more easy to follow for others, as well. There are no changes to the logic or the math.
One additional thot: have you considered creating a "neutral" condition =0 during the times when the old upswing appears to be at an end, but the new downswing has not yet been confirmed?
Something to think about ...
Good Luck!
Jim​

Source / From:
metastock[at]metastock[dot]com

matriks
Kod:
amnt:=3;
md:=1;
vr:=CLOSE;
zz0:=If(md=1, Zig(vr,amnt,%), Zig(vr,amnt,$));
zz1:=Ref(zz0,-1);
zz2:=Ref(zz0,-2);
tr:=ValueWhen(1,zz0>zz1 AND zz1<zz2, zz1);
pk:=ValueWhen(1,zz0<zz1 AND zz1>zz2, zz1);
PU:=If(md=1,tr+Abs(tr)*amnt/100,tr+amnt);
PD:=If(md=1,pk-Abs(pk)*amnt/100,pk-amnt);
res:=If(vr>=PU AND zz0>zz1,1,If(vr<=PD AND zz0<zz1,-1,0));
res1:=If(res<>0,res,ValueWhen(1,res<>0,res));
res1
 

Forumdan daha fazla yararlanmak için giriş yapın yada üye olun!

Forumdan daha fazla yararlanmak için giriş yapın veya kayıt olun!

Kayıt ol

Forumda bir hesap oluşturmak tamamen ücretsizdir.

Şimdi kayıt ol
Giriş yap

Eğer bir hesabınız var ise lütfen giriş yapın

Giriş yap