0bps

Strategy vault / Momentum

MACD and RSI Based 5 Minute Momentum Trading Strategy

This strategy combines the MACD and RSI indicators for short-term momentum trading on the XRP/USDT 5-minute chart. It identifies buying and selling signals by detecting MACD crossovers to capture price swings on…

Author
ChaoZhang
Complexity
Intermediate · 45 lines
Parameters
8
Backtest bar
2h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

This strategy combines the MACD and RSI indicators for short-term momentum trading on the XRP/USDT 5-minute chart. It identifies buying and selling signals by detecting MACD crossovers to capture price swings on XRP/USDT. Meanwhile, RSI overbought and oversold signals are used to confirm the trading signals. The strategy suits aggressive traders who aim to capitalize on short-term market momentum.

Strategy Logic

  1. Use RSI indicator to identify overbought and oversold levels. Below 30 is oversold while above 70 is overbought.

  2. Use MACD indicator to generate buy and sell signals. MACD line crossing above signal line gives buy signal while crossing below gives sell signal.

  3. Go long XRP/USDT when RSI shows oversold plus MACD bullish crossover.

  4. Go short XRP/USDT on RSI overbought or MACD bearish crossover signals.

  5. Set stop loss and take profit price levels.

Advantages

  1. Combining RSI and MACD filters false signals.

  2. Captures high momentum price swings.

  3. Suits aggressive short-term traders.

  4. Customizable parameters for adaptability.

Risks

  1. High volatility risks stop loss being hit.

  2. MACD prone to false signals without confirmation.

  3. Challenging emotional control on ultra short-term trades.

  4. Trading costs and fees erode profits.

Enhancements

  1. Optimize RSI parameters for best settings.

  2. Test profitability across different holding periods.

  3. Add other indicators to confirm MACD signals.

  4. Implement trailing stop loss to lock in profits and reduce risk.

Conclusion

This is a 5-minute MACD and RSI strategy for trading short-term XRP/USDT momentum. It capitalizes on catching trend reversals but risks and costs are higher for such short-term trading. Controlling position sizing and stops while optimizing parameters can enhance performance. Overall it suits aggressive traders aiming to profit from market swings.

Parameters

NameDefaultWhat it controls
v_input_114RSI Length
v_input_270RSI Overbought Threshold
v_input_330RSI Oversold Threshold
v_input_412MACD Short Length
v_input_526MACD Long Length
v_input_69MACD Signal Length
v_input_7trueStop Loss Percentage
v_input_82Take Profit Percentage

Source Pine Script

/*backtest
start: 2023-12-01 00:00:00
end: 2023-12-31 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("XRP/USDT 5-Minute Momentum Strategy", shorttitle="XRP Momentum", overlay=true)

// Input parameters
rsi_length = input(14, title="RSI Length")
rsi_overbought = input(70, title="RSI Overbought Threshold")
rsi_oversold = input(30, title="RSI Oversold Threshold")
macd_short_length = input(12, title="MACD Short Length")
macd_long_length = input(26, title="MACD Long Length")
macd_signal_length = input(9, title="MACD Signal Length")
stop_loss_pct = input(1, title="Stop Loss Percentage")
take_profit_pct = input(2, title="Take Profit Percentage")

// Calculate RSI
rsi = ta.rsi(close, rsi_length)
// Calculate MACD
[macd_line, signal_line, _] = ta.macd(close, macd_short_length, macd_long_length, macd_signal_length)

// Define buy and sell conditions
buy_condition = ta.crossover(rsi, rsi_oversold) and ta.crossover(macd_line, signal_line)
sell_condition = ta.crossunder(rsi, rsi_overbought) or ta.crossunder(macd_line, signal_line)

// Calculate stop loss and take profit levels
stop_loss = close * (1 - stop_loss_pct / 100)
take_profit = close * (1 + take_profit_pct / 100)

// Plot shapes on the chart to visualize buy/sell signals
plotshape(buy_condition, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(sell_condition, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)

// Use the `strategy.close` function to manage positions
strategy.entry("Buy", strategy.long, when=buy_condition)
strategy.entry("Sell", strategy.short, when=sell_condition)

strategy.close("Buy", when=close > take_profit or close < stop_loss)
strategy.close("Sell", when=close < take_profit or close > stop_loss)

Published by ChaoZhang on the FMZ strategy square · last modified 2024-01-30. 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-and-RSI-Based-5-Minute-Momentum-Trading-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