Mastering the Blau_MACD Indicator for MetaTrader 5: A Trader's Guide

Mike 2011.07.08 01:56 76 0 0
Attachments

Author: Andrey N. Bolkonsky

If you're diving into technical analysis, you might want to check out the Moving Averages Convergence/Divergence (MACD) Indicator by William Blau. This tool is detailed in his book, Momentum, Direction, and Divergence: Applying the Latest Momentum Indicators for Technical Analysis.

The MACD Indicator is calculated by subtracting two exponentially smoothed moving averages (EMA). The fast EMA has a period of s, while the slow EMA uses a period of r.

The value of the MACD shows the relationship between the fast s-period EMA and the slow r-period EMA. When EMA(s) is greater than EMA(r), the MACD is positive. If EMA(s) is less than EMA(r), it’s negative. A rising MACD indicates divergence between the moving averages, while a falling MACD suggests they are converging.

  • Place WilliamBlau.mqh in terminal_data_folder\MQL5\Include\
  • Place Blau_SM_Stochastic.mq5 in terminal_data_folder\MQL5\Indicators\

Moving Averages Convergence/Divergence by William Blau.

Moving Averages Convergence/Divergence by William Blau.

Calculation:

The MACD is calculated using the following formula:

macd(price,r,s) = EMA(price,s) - EMA(price,r)
s < r

Where:

  • price - the closing price of the current period;
  • EMA(price,r) - the slow EMA based on period r;
  • EMA(price,s) - the fast EMA based on period s.

William Blau’s formula for MACD looks like this:

MACD(price,r,s,u) = EMA( macd(price,r,s) ,u) = EMA( EMA(price,s)-EMA(price,r) ,u)
s < r

Where:

  • price - the closing price;
  • EMA(price,r) - first smoothing using the slow EMA;
  • EMA(price,s) - second smoothing using the fast EMA;
  • macd(r,s)=EMA(price,s)-EMA(price,r) - the convergence/divergence of the moving averages;
  • EMA(macd(r,s),u) - third smoothing applied to the MACD.
Input parameters:
  • r - period of the first EMA (slow), default is r=20;
  • s - period of the second EMA (fast), default is s=5;
  • u - period of the third EMA applied to the MACD, default is u=3;
  • AppliedPrice - type of price, default is AppliedPrice=PRICE_CLOSE.
Note:
  • r>1, s>1;
  • s<r (according to William Blau, no checks are implemented in the code);
  • u>0. If u=1, no smoothing is applied;
  • Minimum rates =([max(r,s)]+u-2+1).

List
Comments 0