0bps

Strategy vault / Momentum

RSI Crossover Momentum Cyclical Strategy

The RSI Crossover Momentum Cyclical strategy is a quantitative trading strategy based on the Relative Strength Index (RSI) indicator. It generates buy and sell signals through RSI crossovers to achieve profitable…

Author
ChaoZhang
Complexity
Starter · 39 lines
Parameters
3
Backtest bar
1d · swing
Tested on
BTC/USDT · futures

IMG

Overview

The RSI Crossover Momentum Cyclical strategy is a quantitative trading strategy based on the Relative Strength Index (RSI) indicator. It generates buy and sell signals through RSI crossovers to achieve profitable trades. Buy signals are triggered when the RSI crosses above a user-defined threshold, while sell signals are triggered when the RSI falls below the threshold, closing positions gradually at a profit.

Strategy Logic

The strategy is built upon the RSI indicator, which gauges a stock's momentum and overbought/oversold levels. It first calculates RSI values, then trades based on the relationship between the RSI and preset buy/sell thresholds.

Specifically, when the RSI crosses above the buy threshold (default 60), a buy signal is generated. The strategy would then open a long position. Later when the RSI falls below the sell threshold (default 80), a sell signal occurs. The strategy would close the existing long position accordingly. By oscillating between the two thresholds, the momentum cycles back and forth to book profits.

The strategy is written in Pine Script using clear conditional logic for entries and exits. The RSI line is plotted with markers for buy/sell signals.

Advantages

  • Captures short-term trends effectively using price momentum
  • Customizable RSI parameters adaptive to market changes
  • Clean modern code style, easy to understand
  • Intuitive visualization of RSI curve and trade signals
  • Customizable thresholds catering to personal needs

Risks

  • Higher risks in short-term trading, needing close monitoring
  • Potential false signals and RSI divergence
  • Overeager entries risking chase trades
  • No stop loss mechanism to limit losses

We can set stop loss, optimize RSI parameters, or add filters to improve it.

Enhancement Opportunities

There are a few ways we can further optimize the strategy:

  1. Add filters like moving averages to reduce false signals
  2. Incorporate stop loss logic to control losses
  3. Optimize RSI parameters for different stocks and markets
  4. Develop adaptive systems that auto-adjust parameters
  5. Test different holding periods to find optimal combinations

Conclusion

This basic example demonstrates using RSI for quant trading. We can build on it with more indicators and risk management techniques. In practice, rigorous optimization and customization based on personal risk tolerance is needed before application. With sound methodology, this strategy can become an effective quantitative investment tool.

Parameters

NameDefaultWhat it controls
v_input_int_114RSI Period
v_input_160RSI Threshold for Buy
v_input_280RSI Threshold for Sell

Source Pine Script

/*backtest
start: 2022-12-06 00:00:00
end: 2023-12-12 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("RSI Cross 60/80 Strategy", overlay=true)

// Input for RSI period
rsiPeriod = input.int(14, title="RSI Period", minval=1)

// Calculate RSI
rsiValue = ta.rsi(close, rsiPeriod)

// Input for RSI thresholds
rsiBuyThreshold = input(60, title="RSI Threshold for Buy")
rsiSellThreshold = input(80, title="RSI Threshold for Sell")

// Conditions for Buy and Sell signals
buySignal = ta.crossover(rsiValue, rsiBuyThreshold)
sellSignal = ta.crossunder(rsiValue, rsiSellThreshold)

// Plot RSI on the chart
plot(rsiValue, title="RSI", color=color.blue)

// Strategy entry and exit
if (buySignal)
    strategy.entry("Buy", strategy.long)

if (sellSignal)
    strategy.close("Buy")

// Plot Buy and Sell signals on the chart
plotshape(series=buySignal, title="Buy Signal", color=color.green, style=shape.labelup, location=location.belowbar)
plotshape(series=sellSignal, title="Sell Signal", color=color.red, style=shape.labeldown, location=location.abovebar)

Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-13. 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/RSI-Crossover-Momentum-Cyclical-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