Indicators: McGinley Dynamic Indicator

Automated-Trading
163942
Automated-Trading  

McGinley Dynamic Indicator:

The McGinley Dynamic indicator is designed to follow prices, avoiding whipsaws that are given when conventional Moving Averages are used.

Conventional Moving Averages have a fixed period and therefore a fixed speed. As a result, price separation occurs when the price moves rapidly which can lead to unwanted results. The McGinley Dynamic however is designed to adjust speed inline with the market.

This tool can be used as a substitute for a conventional Moving Average as a trend confirmation indicator or crossover signal.

There are two inputs for this indicator:

  • MD_Period - In the same way you choose a period for a Moving Average, choose the period for this indicator. Make this 60% of the period you would otherwise use in a Moving Average. So if your MA period is 20, set this value to 12 for comparative indicator.
  • MD_smoothing - This adjusts the sensitivity of the line, the default value is 125.

The pictures below show comparisons between the McGinley Dynamic (Red line) and a simple Moving Average (Blue line). The McGinley Dynamic reacts to price increases sooner whilst also tracking closer to prices and reducing whipsaws.

Figure 1 - McGinley Dynamic vs SMA

Figure 2 - MD vs SMA

Author: Samuel Williams

drayzen
724
drayzen  
Automated-Trading:

McGinley Dynamic Indicator:

Author: Samuel Williams

Hi Samuel,
I've been testing with your indicator and it appears that the Period setting is working backwards.
I've been using an .mq4 McGinley indicator and the Period setting behaves the same as for an MA, the larger the number the flatter the curve becomes.
The way this is working the 60% rule can't be applied.
MT5 Build 1795

McGinley = 54 / MA = 90

lippmaje
1653
lippmaje  

There's a difference to the original formula.

You:

MDBuffer[i]=MDBuffer[i-1]+(close[i]-MDBuffer[i-1])/(MD_smooth*(close[i]/MDBuffer[i-1]));

McGinley:

MDBuffer[i]=MDBuffer[i-1]+(close[i]-MDBuffer[i-1])/(0.6*MD_smooth*MathPow(close[i]/MDBuffer[i-1],4));
ali saqi
7
ali saqi  
lippmaje:

There's a difference to the original formula.

You:

McGinley:


should we change the code to what you showed as "McGinley" ?

lippmaje
1653
lippmaje  
ali saqi:

should we change the code to what you showed as "McGinley" ?

Not sure. I just pointed it out so the author could comment. Whatever this formula means it differs from the original one, see Investopedia.
hrhsii
45
hrhsii  
lippmaje:

There's a difference to the original formula.

You:

McGinley:

I believe i see the error, or oversight, it looks like the formula was taken from: 
https://www.investopedia.com/terms/m/mcginley-dynamic.asp

This has a mistake missing the 0.6 constant, and the indicator author has missed the power 4.


The correct formula as lippmaje quoted is in:

https://www.investopedia.com/articles/forex/09/mcginley-dynamic-indicator.asp

So if you want the McGinley Dynamic indicator as McGinley intended I would correct it as advised

McGinley Dynamic Indicator Definition
McGinley Dynamic Indicator Definition
  • www.investopedia.com
The McGinley Dynamic indicator is a type of moving average that was designed to track the market better than existing moving average indicators. It is a technical indicator that improves upon moving average lines by adjusting for shifts in market speed. John R. McGinley, a market technician, is the inventor of the eponymous indicator. Key...
fxthegreat
7
fxthegreat  
if(useImprovedFormula)
          {
           mcg[i]   = ma[i+1]+(price-ma[i+1])/MathMin(McgPeriod,MathMax(1,(McgConstant*McgPeriod*MathPow(price/ma[i+1],4)))); //Improved
          }
          else
          {
            mcg[i]   = ma[i+1]+(price-ma[i+1])/(McgConstant*McgPeriod*MathPow(price/ma[i+1],4)); //Original
          }
Here is example mql4 code for original old McGiley formula and the improved version of same formula.