Trend detection using moving averages

Recently, I have been experimenting with a trend detection technique based on moving averages. I read about it in a book Forex Patterns & Probabilities: Trading Strategies for Trending & Range-Bound Markets by Ed Ponsi, which I highly recommend. The technique attempts to detect a trend (either an uptrend or downtrend) by checking if exponential moving averages are aligned in the “proper order”, as determined by the following conditions:

EMA(10) > EMA(20) > EMA(50) > EMA(200) (for an uptrend)

EMA(10) < EMA(20) < EMA(50) < EMA(200) (for a downtrend)

I wrote an indicator for Meta Trader that visualizes this method. The above conditions are calculated for every bar in a chart, and if a trend is detected little arrows are shown pointing either upward or downward depending on the trend direction (as shown in Fig. 1 and Fig. 2 below). In addition, a bigger arrow or “No Trend” text is shown in the upper left corner that corresponds to conditions calculated for the current (zero) bar.

The following is an example of a downtrend detected on a daily USD/GBP chart:

MATrendDetector indicator on a daily GBP/USD chart

Another example illustrates how the indicator looks like when there is no trend detected for the current (zero) bar (“No Trend” is displayed in the upper left corner). The indicator also shows periods of an uptrend and downtrend that occured in the past.

MATrendDetector on a 4-hour NZD/JPY chart

To better visualize this concept, below is the same chart as in Fig. 2. overlayed with moving averages used to calculate the indicator.

MATrendDetector on a 4-hour NZD/JPY chart overlayed with moving averages

I found this trend detection method to be very useful, and the visualization of it helped me better understand the nature of trends in Forex.

If you want to try it yourself, the source code of the indicator is available here. Your thoughts and comments are very welcome.