Back

John Ehlers' MAMA and FRAMA indicators

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.
Update Backtest






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.



Wow pretty epic series of posts @JPB! Thank you for sharing! If you're interested please submit the Sine wave to github as an indicator and we'll build it into the LEAN Engine :)
0

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.


@Jared Broad Thank you :) I would enjoy seeing it being added to LEAN, but I'm not that familiar with github and the format for submitting new indicators. Is there some sort of guideline/ example I can follow?
1

No worries! Its great seeing high quality posts like this, showcasing a powerful indicator. We wrote a contributor guide here which steps you through working with github, and here's an example of the moving average indicator.

There was also this quick tutorial on how to create an indicator (https://lean.quantconnect.com/docs#topic14.html)
0

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.


Really cool software. Do you test on Forex symbols ?
Where is better results ?
Which symbols is most profitable for trading?
0

I had the same thought @Eugeny - FX symbols are more cyclical so potentially this indicator would work better.

I wonder if the flat period in 2001 could be avoided by using History to warm up the indicators first.
0

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.


I try use another MAMA & FAMA indicators for manual trading on metatrader platform.
And they working not very well.
Test on EUR/USD.
Can you place here rules for opening and closing position ?
May be I can translate this software for metatrader platform.
0

JP,
Very intrigued! Have you done any comparisons between MAMA & FRAMA vs fast EMA & Slow EMA yourself? Would love some screenshots if you have them. I am also very curious as to how well these work with forex given the nature of forex. Look forward to messing around with it!
- Having this built into QC would be sweet!

Eugeny,
The signals woud still be the same- buy when Mama crosses up through FRAMA and sell/short when MAMA crosses down through FRAMA. Have you tried adjusting the M & F and or the time frame?
1

@Timothy Comisky

I'm afraid such comparisons are not completely objective due to the differences between the MAMA & FRAMA framework and the normal EMA strategy. This because any design decisions will largely impact the strategies' outcomes. What you could do, however, is try to find the most profitable (general) setup for both frameworks and then test them over the same period for the same symbol. This could yield a decent comparison.
0

As a side note:

Note that MAMA and FRAMA attack the neutrality problem in a different way. Much like the SMA and EMA attack the smoothing problem in a different way.

In the algorithm posted above, I combined MAMA and FRAMA. However, you can also duplicate the indicators themselves with different parameters and make a strategy out of that. Much like a SMA(20) and SMA(50) cross-over strategy. So you can create strategies purely based on MAMA or purely based on FRAMA or a combination of the two.

Happy coding ;)
0

Don't forget to check out my demonstration too!
1

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.

0

@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.

0

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.

0

@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.

0

Update Backtest





0

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.


Loading...

This discussion is closed