Here is the MAMA and F(R)AMA moving averages by John Ehlers.
Most technical analysis is quite simple but John Ehlers takes it one step further and incorporates fractals and sine waves into his analysis. The mathematics in his technical analysis indicators is really some of the most advanced that you can find. He releases most of his findings publicly on his website here. Some of his papers are really a must-read for those who want to take their technical analysis to the next level.
I wanted to backtest some of his strategies so I've converted his EasyLanguage code into C#.
In this share, I present to you the MAMA and FRAMA moving averages. These moving averages follow the logic of most moving averages, except for the fact that they take the cyclical pattern of the market into account. Therefore, false trading signals (when there is no trend) are less likely to occur. If anything, these averages are quite interesting to study. You can find the original MAMA paper here, and the original FRAMA paper here.
With moving averages, there is always a common problem: they work very well when the market is trending. When the market is neutral, however, they fail. John Ehlers decided to tackle this problem and decompose the market into a cyclical regime and a trending regime using an Empirical Mode Decomposition. The intuition behind this decomposition is that when the market is cyclical, you could use his Sine Wave Indicator. When the market is trending, you could use a moving average-based indicator, like the MAMA and FRAMA moving averages. Note that you can play with the parameters to change the sensitivity of the indicators.
I hope you like it. Happy coding.
Jared Broad
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.
JP B
Jared Broad
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.
Eugeny Kaminsky
Jared Broad
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.
Eugeny Kaminsky
Timothy Comisky
JP B
JP B
JP B
James Smith
I've made some minor adaptations of this algorithm and have got some very interesting results. I can't admit to understanding a great deal about the theory behind this, but regardless, the behavior of it is fascinating and quite unlike anything else. Presumably this has something to do with the signal filters: the win/loss rate is noticeably superior to other moving averages. Thanks for sharing this.
JP B
@James Smith Glad to hear that. There are some small bugs in this version of the algorithm. You can find the updated version at the top of this discussion. The first algorithm in that thread has been corrected for the bugs. With regards to the behaviour: it remains quite complex indeed. Mostly because optimising with respect to cycle lengths is not so intuitive.
James Smith
Yes, I'm glad I'm not the only one to notice such a high quality contribution. I had to tweak some parameters on the original version before putting it into production, so will look forward to further improvements as a result of the fixes. I've also started backtesting an adaptation of your Sine Wave indicator. Will give you an idea of the results if you're interested.
JP B
@James Smith Thank you for the compliment. Sure, I'm always interested in backtesting results! My backtesting results with the Sine Wave indicator were quite positive only for periods in which stocks actually exhibit cycles. By construction, the Sine Wave indicator doesn't work well in trends. For trends, the MAMA/FRAMA indicators are very useful. Most difficult part is combining the two: trading the Sine Wave indicator in neutral times and the MAMA/FRAMA indicators in trends. Question remains when to switch between the two. The Empirical Mode Decomposition is supposed to help with this but I wasn't able to get it to work properly.
.ekz.
This is quite interesting --anyone out there want to take a stab at converting these to Python, as standalone indicators?Â
.ekz.
Looks like FRAMA already exists. Will start there… Â
JP B
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!