0bps

Strategy vault / Trend following

MACD RSI Combo Trend Strategy

This strategy combines the MACD and RSI indicators to determine trend direction and overbought/oversold levels for trend trading. It goes long/short when MACD crosses zero line and RSI is beyond overbought/oversold…

Author
ChaoZhang
Complexity
Starter · 41 lines
Parameters
6
Backtest bar
6h · swing
Tested on
BTC/USDT · futures

Overview

This strategy combines the MACD and RSI indicators to determine trend direction and overbought/oversold levels for trend trading. It goes long/short when MACD crosses zero line and RSI is beyond overbought/oversold thresholds.

Strategy Logic

Main logic:

  • Calculate MACD line and Signal line (EMA of MACD)

  • Delta is their difference, expressing price momentum change

  • RSI to gauge overbought/oversold conditions

  • Go long when Delta crosses above zero line and RSI overbought (default 70)

  • Go short when Delta crosses below zero line and RSI oversold (default 30)

MACD for momentum direction, RSI for overbought/sold - combo filters many false signals.

Advantages

  • Combines two indicators for filtered signals

  • MACD measures momentum, RSI measures overbought/sold

  • Configurable parameters for different markets

  • Clear trend trading strategy rationale

Risks

  • Limited effectiveness from single indicator combo

  • No stop loss, unable to control loss per trade

  • Does not consider position sizing

Mitigations:

  • Test other indicators, find optimal combinations

  • Add trailing or hard stop loss

  • Position size based on account size or volatility

Enhancement Opportunities

  • Test MACD with other indicator combos

  • Optimize parameters for stability

  • Filter signals by trend to avoid false breakouts

  • Use trailing stop loss to protect profits

  • ML to judge signal quality

Conclusion

This strategy combines MACD and RSI for solid trend determination. Stability can be improved through parameter optimization, stop loss, intelligent filters etc. It provides an effective trend trading framework for further enhancements.

Parameters

NameDefaultWhat it controls
v_input_112fastLength
v_input_226slowlength
v_input_39MACDLength
v_input_414length_rsi
v_input_530overSold
v_input_670overBought

Source Pine Script

/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 6h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
strategy("MACD RSI Strategy", overlay=true)

fastLength = input(12)
slowlength = input(26)
MACDLength = input(9)

MACD = ema(close, fastLength) - ema(close, slowlength)
aMACD = ema(MACD, MACDLength)
delta = MACD - aMACD

// RSI



length_rsi = input( 14 )
overSold = input( 30 )
overBought = input( 70 )
price = close

vrsi = rsi(price, length_rsi)

//

if (not na(vrsi))
    if (crossover(delta, 0) and crossover(vrsi, overBought ))
        strategy.entry("MacdLE", strategy.long, comment="LE")
    if (crossunder(delta, 0) and crossunder(vrsi, overSold))
        strategy.entry("MacdSE", strategy.short, comment="SE")

//plot(strategy.equity, title="equity", color=red, linewidth=2, style=areabr)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-21. Collected in the Quant Trading Vault. Unvalidated research: re-test with your own data and costs before trusting it.

Build this with AgenKit

A spec is not a trading system. Paste this into your coding agent and AgenKit runs a specialist team — architecture, test-first build, risk gates, review — with paper trading on by default.

in Claude Code, Cursor, Codex & 4 more
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/MACD-RSI-Combo-Trend-Strategy.md
  1. npx agenkit install engineering-kit in your project
  2. Paste the command into your agent and approve each phase
  3. Get tests, backtest, risk controls and a paper-trading switch

Understand it first

Before you run this, read the lesson behind the idea and how to backtest it honestly. Specs like this one are the survivors of an unknown number of trials; deflate their results accordingly.

Related specs

esc

Try , , or .

↑↓ move↵ open