Exploring the McGinley Dynamic Trading System
Discover the McGinley Dynamic Trading System, developed by John R. McGinley. It’s recognized as Investopedia’s most reliable indicator, offering unique advantages over traditional moving averages.
The McGinley Dynamic Indicator
Compared to simple and exponential moving averages, the McGinley Dynamic is highly responsive to raw data. It’s designed to minimize whipsaws and closely track prices, outperforming conventional moving averages.
Formula for the McGinley Dynamic Indicator
MD = MD-1 + (Price – MD-1) / (N * (Price / MD-1) 4
MD-1: Indicator value for the previous candle or bar
Price: Price of the security
N: Smoothing factor
For more on AFL coding and creating your own trading systems, visit this link.
McGinley Dynamic Trading System – AFL Overview
Parameter | Value |
Preferred Timeframe | McGinley Dynamic |
Indicators Used | 25-period McGinley Dynamic indicator |
Buy Condition |
|
Short Condition |
|
Sell Condition |
|
Cover Condition |
|
Stop Loss | 10% |
Targets | 40% |
Position Size | 150 (fixed) |
Initial Equity | 200,000 |
Brokerage | 100 per order |
Margin | 10% |
AFL Code
//------------------------------------------------------
//
// Formula Name: Anti-Martingale Trading system
// Website: https://zerobrokerageclub.com/
//------------------------------------------------------
_SECTION_BEGIN("McGinley Dynamic Indicator");
SetBarsRequired( sbrAll );
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
//Initial Parameters
SetTradeDelays( 1,1,1, 1 );
SetOption( "InitialEquity", 200000);
SetOption("FuturesMode" ,True);
SetOption("MinShares",1);
SetOption("CommissionMode",2);
SetOption("CommissionAmount",100);
SetOption("AccountMargin",10);
SetOption("RefreshWhenCompleted",True);
//SetPositionSize(150,spsShares);
SetPositionSize(20,spsPercentOfEquity);
SetOption( "AllowPositionShrinking", True );
N = Param("McGinley Dynamic N ",25,5,40,5);
MD[0] = C[0];
for( i = 1; i < BarCount; i++ )
{
MD[ i ] = MD[ i - 1 ] + (C[i]-MD[i-1])/( N*(C[i] / MD[i-1])^4) ;
}
Plot( Close, "Price",colorWhite, styleCandle );
Plot(MD,"McGinley Dynamic",colorYellow,1|styleThick);
Buy=C>MD AND C>Ref(C,-1) AND Ref(C,-1)>Ref(C,-2);
Short=C
AFL Screenshot
View the screenshot of the McGinley Dynamic Trading System for NSE Nifty below:
McGinley Dynamic Trading System – Backtest Report
This strategy has shown a respectable Compound Annual Growth Rate (CAGR) over the last 12 years, albeit with a slightly higher drawdown typical of trend-following strategies.
Parameter | Value |
NSE Nifty | |
Initial Capital | 200000 |
Final Capital | 1973764.04 |
Scrip Name | NSE Nifty |
Backtest Period | 01-Jan-2004 to 19-Oct-2016 |
Timeframe | Daily |
Net Profit % | 771.55% |
Annual Return % | 18.42% |
Number of Trades | 128 |
Winning Trade % | 36.72% |
Average holding Period | 23.43 periods |
Max consecutive losses | 9 |
Max system % drawdown | -17.90% |
Max Trade % drawdown | -70.97% |
For a detailed backtest report, download it here.
Equity Curve and Profit Table
Explore the equity curve and profit table for the McGinley Dynamic Trading System:
Additional Amibroker Settings for Backtesting
To optimize your backtesting in Amibroker, visit Symbol–>Information, and specify the lot size and margin requirement. The screenshot below illustrates a lot size of 75 and a margin requirement of 10% for NSE Nifty:
One Comment