R&D Blog
MACD: Part 1 | Trading Strategy (Entry)
I. Trading Strategy
Developer: Gerald Appel. Source: Appel, G. (2005). Technical Analysis. NJ: Pearson Education, Inc; Star, B., PhD (2016). Zero In On The MACD. Stocks & Commodities, May 2016. Concept: Trend following trading strategy based on the MACD (Moving Average Convergence Divergence) line. Research Goal: Performance verification of momentum signals. Specification: Table 1. Results: Figure 1-2. Trade Setup: Long Setup: MACD[i] > 0. Short Setup: MACD[i] < 0. Index: i ~ Current Bar. Trade Entry: Long Trade Entry: A buy at the open is placed after a long setup. Short Trade Entry: A sell at the open is placed after a short setup. Trade Exit: Table 1. Portfolio: 42 futures markets from four major market sectors (commodities, currencies, interest rates, and equity indexes). Data: 38 years since 1980. Testing Platform: MATLAB®.
II. Sensitivity Test
All 3-D charts are followed by 2-D contour charts for Profit Factor, Sharpe Ratio, Ulcer Performance Index, CAGR, Maximum Drawdown, Percent Profitable Trades, and Avg. Win / Avg. Loss Ratio. The final picture shows sensitivity of Equity Curve.
Tested Variables: EMA#1_Look_Back & EMA#2_Index (Definitions: Table 1):
Figure 1 | Portfolio Performance (Inputs: Table 1; Commission & Slippage: $0).
STRATEGY | SPECIFICATION | PARAMETERS |
Auxiliary Variables: | Exponential Moving Average #1 (EMA#1): Alpha#1 = 2 / (EMA#1_Look_Back + 1); EMA#1[i] = Alpha#1 × Close[i] + (1 − Alpha#1) × EMA#1[i − 1]; Index: i ~ Current Bar. Exponential Moving Average #2 (EMA#2): Alpha#2 = 2 / (EMA#2_Look_Back + 1); EMA#2[i] = Alpha#2 × Close[i] + (1 − Alpha#2) × EMA#2[i − 1]; Index: i ~ Current Bar. MACD: MACD[i] = EMA#1[i] − EMA#2[i] Index: i ~ Current Bar. | EMA#1_Look_Back = [5, 40], Step = 1; EMA#2_Index = [2.0, 4.0], Step = 0.05; EMA#2_Look_Back = round(EMA#1_Look_Back × EMA#2_Index); |
Setup: | Long Trades: MACD[i] > 0 Short Trades: MACD[i] < 0 Index: i ~ Current Bar. | |
Filter: | N/A | |
Entry: | Long Trades: A buy at the open is placed after a bullish Setup. Short Trades: A sell at the open is placed after a bearish Setup. | |
Exit: | Stop Loss Exit: ATR(ATR_Length) is the Average True Range over a period of ATR_Length. ATR_Stop is a multiple of ATR(ATR_Length). Long Trades: A sell stop is placed at [Entry − ATR(ATR_Length) * ATR_Stop]. Short Trades: A buy stop is placed at [Entry + ATR(ATR_Length) * ATR_Stop]. Stop Loss Exit is used to normalize risk via position sizing. | ATR_Length = 20; ATR_Stop = 6; |
Sensitivity Test: | EMA#1_Look_Back = [5, 40], Step = 1 EMA#2_Index = [2.0, 4.0], Step = 0.05 | |
Position Sizing: | Initial_Capital = $1,000,000 Fixed_Fractional = 1% Portfolio = 42 US Futures ATR_Stop = 6 (ATR ~ Average True Range) ATR_Length = 20 | |
Data: | 42 futures markets; 38 years (1980/01/01−2018/3/31) |
Table 1 | Specification of Trading Strategy.
III. Sensitivity Test with Commission & Slippage
Tested Variables: EMA#1_Look_Back & EMA#2_Index (Definitions: Table 1):
Figure 2 | Portfolio Performance (Inputs: Table 1; Commission & Slippage: $100 Round Turn).
IV. Benchmarking
We benchmark the base case strategy against alternatives:
Case #1: EMA#1_Look_Back = 12; EMA#2_Look_Back = 26 (Base Case).
Case #2: EMA#1_Look_Back = 20; EMA#2_Look_Back = 40.
Case #3: EMA#1_Look_Back = 40; EMA#2_Look_Back = 80.
Case #4: EMA#1_Look_Back = 80; EMA#2_Look_Back = 160.
Fixed Fractional Sizing | Case #1 | Case #2 | Case #3 | Case #4 |
Net Profit ($) | 5,713,438 | 33,290,114 | 299,995,611 | 416,863,142 |
Sharpe Ratio | 0.33 | 0.52 | 0.78 | 0.88 |
Ulcer Performance Index (UPI) | 0.17 | 0.34 | 0.75 | 1.08 |
Profit Factor | 1.02 | 1.04 | 1.14 | 1.33 |
CAGR (%) | 5.10 | 9.68 | 16.09 | 17.09 |
Max. Drawdown (%) | (84.08) | (76.69) | (58.96) | (49.37) |
Percent Profitable Trades (%) | 29.27 | 30.14 | 32.03 | 33.50 |
Avg. Win / Avg. Loss Ratio | 2.45 | 2.40 | 2.42 | 2.64 |
Table 2 | Inputs: Table 1; Fixed Fractional Sizing: 1%; Commission & Slippage: $100 Round Turn.
V. Basic Concepts
G. Appel, Technical Analysis (2005):
(1) MACD represents the difference of the short-term exponential moving average minus the long-term exponential average. (2) When market trends are improving, short-term averages will rise more quickly than long-term averages. MACD lines will turn up. (3) When market trends are losing strength, shorter-term averages will tend to flatten, ultimately falling below longer-term averages if declines continue. MACD lines will fall below 0.
What length moving averages should be employed for MACD? There are no hard and fast rules […]. As a general rule, the longer-term moving average will be two to three times the length of the shorter-term average.
VI. Rating: MACD (Part 1) | Trading Strategy
A/B/C/D
VII. Summary
(a) A trading strategy based on the MACD line crossing its zero line is an average momentum model; (b) The default parameters for the MACD should be avoided (i.e. EMA#1_Look_Back = 12 and EMA#2_Look_Back = 26).
Related Entries: MACD: Part 2 (Entry) | Fractal Adaptive Moving Average (Setup) | Zero Lag Moving Average (Entry & Exit) | Simple Moving Average Filter (Entry & Exit)
Related Topics: (Public) Trading Strategies
CFTC RULE 4.41: HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.
RISK DISCLOSURE: U.S. GOVERNMENT REQUIRED DISCLAIMER | CFTC RULE 4.41