Inspired by Warren Harding and Derek Melchin for their Trend0 algorithms, I decided to create my own FIR Filter (Power Weighted Moving Average) for prices and compare them to QC build-in indicators for testing and approval.
My assumptions were that Power Weighted Moving Average with power = 0 would correspond SMA and with power = 1 would correspond LWMA.
Visually, there is no difference between them, but if you look at the numbers, there is a slight discrepancy.
First, I would like Derek Melchin to take a look at my code, maybe I am missing something.
Here is comparison Power Weighted Moving Average (power = 0), SMA and History.mean().
Vladimir
Here is comparison Power Weighted Moving Average (power = 1) and LWMA.
Louis Szeto
Hi Vladimir
Sorry didnt catch the post of trend0 earlier, wanna ask if any hypothesis or intuition on what does the indicator do? And why it is better than the original moving average? As you know, pure synthesize without hypothesis is dangerous mindset on overfitting. Cheers on the development though🚀.
Cheers
Louis
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.
Vladimir
This backtest shows how digital filters behave differently with the same period, but with different power in different market modes.
.ekz.
Thanks for sharing, Vladimir I'm curious, though: what exactly is a Finite Impulse Response Digital Filter? If indeed it is just a power weighted moving average, why don't we just call it that? IE: Under what circumstances would one refer to it as otherwise? Are all ‘moving averages’ also ‘filters’ in some way?
I feel there is more to learn here, but it's not clear, why there would be a need for what seems to be additional complexity / cognitive overhead. I've seen some articles on digital signal processing for quants, but brushed them aside. Is there indeed some merit in that school of thought?
Vladimir
.ekz.,
-> Are all ‘moving averages’ also ‘filters’ in some way?
Yes
In my previous post FIR_0 is SMA, FIR_10 is LWMA.
-> what exactly is a Finite Impulse Response Digital Filter?
You may find the full classification of digital filters in Chapter 14 - Chapter 21 of
"The Scientist and Engineer's Guide to Digital Signal Processing".
.ekz.
Ahhh.. very interesting, Vladimir , and very helpful. I'll add this to my ever-expanding reading list.
As usual, thanks for all the knowledge :)
Vladimir
I made some corrections to the code,
Now Power Weighted Moving Average (power = 0), perfectly match History.mean().
GEightyFour
Interesting, but what use cases would this have over just using SMA/EMA?
Vladimir
GEightyFour,
If you choose the power factor in the range from -1 to 2,
then there are only two values that perfectly match the classic indicators.
Power Weighted Moving Average is equal to SMA if power = 0.
Power Weighted Moving Average is equal LWMA if power = 1.
Others can add a specific flavor to your algorithm because they behave differently.
Derek Melchin
Hi Vladimir,
We can simplify the calculation by replacing
with
See the attached backtest for reference.
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.
Vladimir
Derek Melchin,
Thank you for concise code.
Vladimir
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!