R&D Blog
MACD: Part 2 | Trading Strategy (Entry)
I. Trading Strategy
Developer: Gerald Appel. Source: Appel, G. (2005). Technical Analysis. NJ: Pearson Education, Inc. Concept: Trend following trading strategy based on the MACD (Moving Average Convergence Divergence) signal line. Research Goal: Performance verification of momentum signals. Specification: Table 1. Results: Figure 1-2. Trade Setup: Long Setup: MACD[i] > 0 and MACD[i] > Signal_Line[i]. Short Setup: MACD[i] < 0 and MACD[i] < Signal_Line[i]. 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. Signal Line: Alpha#3 = 2 / (EMA#3_Look_Back + 1); Signal_Line[i] = Alpha#3 × MACD[i] + (1 − Alpha#3) × Signal_Line[i − 1]; 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); EMA#3_Look_Back = 9; |
Setup: | Long Trades: MACD[i] > 0 and MACD[i] > Signal_Line[i]. Short Trades: MACD[i] < 0 and MACD[i] < Signal_Line[i]. 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: | MACD Exit: Long Trades: An exit at the open is placed after MACD[i − 1] < Signal_Line[i − 1]; Short Trades: An exit at the open is placed after MACD[i − 1] > Signal_Line[i − 1]; Index: i ~ Current Bar. 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 ($) | (805,957) | (39,551) | 11,748,863 | 41,701,355 |
Sharpe Ratio | (0.29) | 0.07 | 0.48 | 0.67 |
Ulcer Performance Index (UPI) | (0.07) | (0.00) | 0.28 | 0.65 |
Profit Factor | 0.96 | 1.00 | 1.04 | 1.12 |
CAGR (%) | (4.20) | (0.11) | 6.88 | 10.31 |
Max. Drawdown (%) | (90.38) | (85.48) | (68.05) | (49.08) |
Percent Profitable Trades (%) | 34.88 | 34.17 | 33.96 | 32.92 |
Avg. Win / Avg. Loss Ratio | 1.80 | 1.93 | 2.02 | 2.28 |
Table 2 | Inputs: Table 1; Fixed Fractional Sizing: 1%; Commission & Slippage: $100 Round Turn.
V. Rating: MACD (Part 2) | Trading Strategy
A/B/C/D
VI. Summary
A trading strategy based on the MACD line crossing its signal line performs worse than the previous MACD 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 1 (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
Codes: matlab/macd/2