ZigZag
Author: iliakan
Creation Date: 7/6/2009 9:04 AM
profile picture

iliakan

#1
Where can I find ZigZag or ZigZagATR for WL 5 ?
profile picture

Eugene

#2
profile picture

iliakan

#3
I'd like to use ATR instead of % or fixed value.

How I'd code for example PeakATR ?
profile picture

Eugene

#4
Use ATRP.
profile picture

iliakan

#5
Not quite getting what you mean.. I want to chart ZigZag using 2*ATR(10)
How ATRP helps me here?

ZigZag is for finding Gartley-like patterns on its base.
profile picture

Cone

#6
I don't think I've seen an ATR zigzag coded even for Version 4, but it sounds like a good project for someone to knock out. In fact, we probably should whip up the zigzag studies for Version 5. I can probably do this after we kick WLD 5.4 out the door.
profile picture

Eugene

#7
Peak and Trough accept values of type double, and when PeakTroughMode.Percent is specified, will accept percentages.
profile picture

ovelten

#8
What is the ETA for the ZigZag indicator? What about ZigZag ATR ?
profile picture

ovelten

#9
Is the code for Peak/Trough available?
profile picture

Eugene

#10
Peak/Trough is a built-in indicator, so the code is closed source and not available.
profile picture

Swissi

#11
Peak/Trough works with fixed percentage.
I am looking for an indicator, where the %-up or down move is dynamic/flexible. I want to make it dependant f.ex. from the volatility of the stock. Is there already a script around, that is using such an indicator?
profile picture

Eugene

#12
Peak/Trough works with anything you supply it. You could call the .Value method in a loop, passing a dynamically calculated percent, and build a flexible indicator.
profile picture

Eugene

#13
EJoub asked:


Hi

Not strictly an indicator but can it be used to create entrties and exits?...WL can do anything.

I need to enter (on next bar at market?) if the retracement is at least a specified percentage.

(When a price is both higher than the price previous to it and after it.)

The selected code from your wiki is:

CODE:
Please log in to see this code.


The reverse of above logic will be required for the exit.

The code should be able to run in realtime....so my entries and exits will be close to actual price given other market conditions.

I'm aware that if the retracement is set for "x" that the actual retracement can be "x + any % more"
Thus I have to set the percentage to approximately mirror my statiistics. Thus I'm guided by statistics and not the ZIGZAG. I have gathered some data from my broker's price data but I can't program their ZigZag as code for trading because their program can't.

I have also seen and tested some of our other strategies using ZIGZAGS but they are too complicated.

Your assistance will be greatly appreciated Eugene.


profile picture

Eugene

#14
QUOTE:
I need to enter (on next bar at market?) if the retracement is at least a specified percentage.

(When a price is both higher than the price previous to it and after it.)

The entry/exit conditions seem not clearly formulated to me.
profile picture

EJoub

#15
QUOTE:
Not strictly an indicator but can it be used to create entrties and exits?...


No, not as a stand alone!

QUOTE:
The entry/exit conditions seem not clearly formulated to me.


I'm glad that have not told you exactly how...then you would retire tomorrow and .....

The ZigZag would not reverse until the stock decline to its set % or more from its high. From that high, a stock would have to decline to its set % to warrant another line. Only then can the retracement price (entry price) be seen and then it is historical.

Thanks
profile picture

Eugene

#16
Cone will correct me if I'm wrong:

CODE:
Please log in to see this code.
profile picture

Cone

#17
That works, but there's actually a more direct method documented in the source code ;)

Put this in the loop. The output should be pretty clear based on the property names.

CODE:
Please log in to see this code.
profile picture

EJoub

#18
Thank you Eugene and Cone for the code. Please, I need help with Cone's "Put this in the loop."
profile picture

Eugene

#19
CODE:
Please log in to see this code.
profile picture

Cone

#20
If this is confusing, just don't use it.

The point was just to show you another way to access those values on every bar. (Just copy the code and put it as the first statement in the for loop and look at the debug window.) Eugene's code works just fine to buy as soon as a trough is detected and sell as soon as a peak is detected.

p.s. You're going to have to find a very novel way to use a ZigZag study in order to generate enough profits to retire on it.

-------
Well, while I was typing Eugene implemented the other way for you.. the result will be the same.
profile picture

EJoub

#21
@ Cone

Thanks for all the above information.
Yes, no one will retire using the ZigZag...from my posts above it is clear that that was not my plan.

p.s. I was watching Anglo American (AGL) the last hour of today and saw how a Zig disappeared and replaced by a Zag.

@ Eugene, thanks for the second code...I see it does not give the same results as the first one...

You both are great as usual.
profile picture

Cone

#22
I didn't look closely enough. Eugene's first code should have been using TroughBarSeries and PeakBarSeries to trigger the transitions instead of TroughSeries and PeakSeries, which compares the previous peak/trough value to the new one.

The version with Peak/TroughBarSeries below will be almost the same except maybe a trade or two during at the beginning of the series. (peak/troughDetected can trigger immediately, whereas this version requires two peaks and troughs to determine if a new peak or trough has occurred)

CODE:
Please log in to see this code.
profile picture

EJoub

#23
Thanks. Trying to fix it I missed the "Bar" the first time as well.:)

I have an idea that another indicator can predict the continuation of a Zig line or a Zag line or whether they will pivot at the price trend reversal.

Given time, I will come back to this with more information.