Hi all,
I recently developed the ZigZagHighLow indicator as found here:
https://www.investopedia.com/terms/z/zig_zag_indicator.asp
And wanted to share it with the community. All you need to do is just paste the class into your algorithm and call the constructor to initialize it. Also within the OnData(Slice) method, you need to update it with the new high and low values of the stock associated with the indicator. Below is an attached sample with all of the code you should need.
Here is a sample constructor call:
ZigZagHighLow zzhl = new ZigZagHighLow("SPY", 100, 0.1m, ATR("SPY", 10), 0.5m, history_bars);
Note that history bars is defined as a list of trading bars for loading warm up data. See sample program for how to init this.
Here is a sample update call to be included in the OnData(Slice) method:
zzhl.update(Securities["SPY"].High, Securities["SPY"].Low);
If you have any questions feel free to let me know. Enjoy!
Pi..R
Cool, thanks for sharing, that's a nice one :)
Derek Melchin
Hi Conor,
Thanks for sharing with the community!
Continuing with the development of this algorithm, consider the following:
Best,
Derek Melchin
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Axist
Can this be translated to Python?
Varad Kabade
Hi Axist,
In the attached backtest, we can find the ZigZagHighLow custom indicator implemented in python and the updates mentioned by Derek.
Things to understand here are we cannot use Maximum/Minimum indicators here because the value given by this indicator is the maximum global value (max value since the initialization of indicator), but here we need the max/min value according to the period of indicator hence we stick with Rolling Windows.
Best,
Varad Kabade
Jon Brygge
Hi Conor and Varad,
Are your code supposed to create a Zig-Zag indicator as shown on the picture below (from the link)?
Best,
Jon
Conor Flynn
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!