Type/to search

MACD Momentum Indicator Backtest Strategy

Cryptocurrency
Created: 2023-09-24 13:21:54
Last modified: 3 years ago
1
Follow
1781
Followers

Overview

This strategy combines the MACD momentum indicator with the RSI overbought/oversold indicator. When MACD crosses up or down, it checks if RSI also completes the corresponding bottoming/topping reversal over the lookback period to generate more reliable trading signals. Typical short-term mean reversion strategy logic.

Strategy Logic

  1. Calculate MACD DIFF, DEA and histogram. Crossover of DIFF above DEA gives bullish crossover signal, and crossover below gives death cross signal.

  2. Calculate RSI to identify oversold bounces and overbought selloffs. Lookback window checks if recent bottoming or topping has occurred.

  3. When MACD bullish crossover happens, if RSI has bounced off oversold within lookback window, long signal is generated. On MACD death cross, short signal is generated if RSI topped over lookback window.

  4. Stop loss set after entry to control risk.

Advantages

  1. MACD sensitively identifies trend changes. RSI effectively judges overbought/oversold levels.

  2. Requiring both MACD and RSI signals filters out false signals.

  3. Lookback window improves signal reliability.

  4. Stop loss aids risk management.

Risks

  1. Lagging of MACD and RSI may cause missed optimal entries.

  2. Lower probability of dual-indicator signal means fewer trades.

  3. No consideration of larger trend direction risks being trapped.

  4. Poor stop loss tuning may be too wide or too tight.

Possible Solutions:

  1. Adjust MACD and RSI parameters to reduce lag.

  2. Widen indicator threshold ranges to provide more signals.

  3. Add trend filter to avoid counter-trend entries.

  4. Test different stop loss parameters for optimal levels.

Optimization Directions

  1. Test SMA and other moving averages.

  2. Add trailing stop loss for flexible stops.

  3. Incorporate trend strength to judge entry quality.

  4. Use machine learning to predict indicator movements.

  5. Combine more factors to optimize entry timing.

Summary

This strategy filters for reliable reversal signals using coordinated MACD and RSI. The logic is clear and parameters flexible for enhancements like indicator selection, trend filters, stop loss techniques etc to acquire more trades while maintaining stability, but over-optimization risks need to be avoided.

Source
Pine
/*backtest
start: 2023-08-24 00:00:00
end: 2023-09-23 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
//based on Range Strat - MACD/RSI 
// strategy("MACD/RSI - edited", 
//      overlay=true,
Strategy parameters
Strategy parameters
Start Date
Start Date
RSI Settings
RSI Source
Length
Over Sold Threshold
Over Bought Threshold
RSI cross lookback period
MACD Settings
MACD Source
Fast Length
Slow Length
Signal Smoothing
Oscillator MA Type
Signal Line MA Type
Stop Loss Settings
Long Stop Loss (%)
Short Stop Loss (%)
Comment
All comments (0)
No data
No data
  • 1
iPhone Download
Forums
PINE Language
© 2015 - ∞ INVENTOR PTE LTD (SG)