Here is the Sine Wave indicator 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 Sine Wave indicator. The Sine Wave (also called MESA) indicator is based on the assumption that markets move in cyclical patterns. He tries to quantify such cycles and then predict them (by making his indicator leading instead of lagging like most indicators). This works extremely well when the market is indeed moving in a cycle. When the market is trending, however, this system fails (and one should adjust for that). Here is an example where the indicator is working well and when it is not. Note that when the market is trending, you could recognise this and use it to your advantage (see his Empirical Mode Decomposition recognition algorithm).



So when the market is cyclical, you could use the Sine Wave Indicator. When the market is trending, you could use a moving average-based indicator. Right now, I haven't incorporated this yet. The algorithm (as is) should therefore be used on markets that are known to move in cyclical patterns. The S&P 500 (e.g. SPY) is one of such markets, but many believe that the FOREX markets are also quite cyclical. It's interesting to see that it performs quite well on SPY but fails miserably on, for example, AAPL.

I hope you like it. Happy coding.