0bps

Strategy vault / Breakout

Cumulative RSI Breakout Strategy

This strategy utilizes the Cumulative RSI indicator to identify trends and makes buy and sell decisions when the cumulative RSI value breaks through key threshold levels. It can effectively filter market noise and…

Author
ChaoZhang
Complexity
Intermediate · 51 lines
Parameters
12
Backtest bar
1h · intraday
Tested on
BTC/USDT · futures

IMG

Overview

This strategy utilizes the Cumulative RSI indicator to identify trends and makes buy and sell decisions when the cumulative RSI value breaks through key threshold levels. It can effectively filter market noise and capture longer-term trend trading opportunities.

Strategy Logic

The strategy is primarily based on the Cumulative RSI indicator for trading decisions. The Cumulative RSI indicator is the accumulation of RSI values. By setting the cumlen parameter, the RSI values over the past cumlen days are added up to derive the Cumulative RSI indicator. This indicator can filter out short-term market noise.

When the Cumulative RSI indicator crosses above the Bollinger Band upper rail, a long position will be opened. When the Cumulative RSI crosses below the Bollinger Band lower rail, the open position will be closed. The Bollinger Band rails are dynamically calculated based on historical data over many years.

Additionally, a trend filter option is added. Long trades will only be opened when the price is above the 100-day Moving Average, meaning it is in an upward trend channel. This filter avoids erroneous trades during market fluctuations.

Advantages

  • Effectively filter noise and capture mid-to-long-term trends using Cumulative RSI
  • Avoid unreasonable trades with the trend filter
  • Use dynamic reference levels instead of fixed values for decision making
  • Highly configurable parameters for adjustments based on different markets
  • Outstanding backtest results over 10 years, significantly outperforming buy and hold

Risks and Improvements

  • Decisions based solely on one indicator, can add other indicators or filters
  • Fixed high leverage ratio, can adjust based on drawdowns
  • Only long trades, can look into shorting opportunities
  • Optimize parameters combinations which vary significantly across markets
  • Enrich exit conditions with stop loss, moving stop loss etc.
  • Consider combining with other strategies for synergistic effects

Summary

The Cumulative RSI breakout strategy has smooth logic flow and accurately identifies mid-to-long term trends by filtering with Cumulative RSI and adding trend judgment. The backtest results are exceptional over the past decade. There is still room for improvements in areas like parameter tuning, adding indicators, enriching exit conditions to make the strategy more robust. The novel concept is worth further exploration and application.

Parameters

NameDefaultWhat it controls
v_input_int_13RSI Length
v_input_13RSI Cumulation Length
v_input_294Oversold Level
v_input_320Overbought Level
v_input_4falseOnly Trade When Price is Above EMA?
v_input_5100EMA Length
v_input_int_2trueStart Date
v_input_int_3trueStart Month
v_input_int_42010Start Year
v_input_int_5trueEnd Date
v_input_int_6trueEnd Month
v_input_int_72099End Year

Source Pine Script

/*backtest
start: 2023-09-26 00:00:00
end: 2023-10-26 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// @version=5
// Author = TradeAutomation


strategy(title="Cumulative RSI Strategy", shorttitle="CRSI Strategy", process_orders_on_close=true, overlay=true, commission_type=strategy.commission.cash_per_contract, commission_value=.0035, slippage = 1, margin_long = 75, initial_capital = 25000, default_qty_type=strategy.percent_of_equity, default_qty_value=110)


// Cumulative RSI Indicator Calculations //
rlen  = input.int(title="RSI Length", defval=3, minval=1)
cumlen = input(3, "RSI Cumulation Length")
rsi = ta.rsi(close, rlen)
cumRSI = math.sum(rsi, cumlen)
ob = (100*cumlen*input(94, "Oversold Level")*.01)
os = (100*cumlen*input(20, "Overbought Level")*.01)


// Operational Function //
TrendFilterInput = input(false, "Only Trade When Price is Above EMA?")
ema = ta.ema(close, input(100, "EMA Length"))
TrendisLong = (close>ema)
plot(ema)


// Backtest Timeframe Inputs // 
startDate = input.int(title="Start Date", defval=1, minval=1, maxval=31)
startMonth = input.int(title="Start Month", defval=1, minval=1, maxval=12)
startYear = input.int(title="Start Year", defval=2010, minval=1950, maxval=2100)
endDate = input.int(title="End Date", defval=1, minval=1, maxval=31)
endMonth = input.int(title="End Month", defval=1, minval=1, maxval=12)
endYear = input.int(title="End Year", defval=2099, minval=1950, maxval=2100)
InDateRange = (time >= timestamp(syminfo.timezone, startYear, startMonth, startDate, 0, 0)) and (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))


// Buy and Sell Functions //
if (InDateRange and TrendFilterInput==true)
    strategy.entry("Long", strategy.long, when = ta.crossover(cumRSI, os) and TrendisLong, comment="Buy", alert_message="buy")
    strategy.close("Long", when = ta.crossover(cumRSI, ob) , comment="Sell", alert_message="Sell")
if (InDateRange and TrendFilterInput==false)
    strategy.entry("Long", strategy.long, when = ta.crossover(cumRSI, os), comment="Buy", alert_message="buy")
    strategy.close("Long", when = ta.crossover(cumRSI, ob), comment="Sell", alert_message="sell")
if (not InDateRange)
    strategy.close_all()

Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-27. 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/Cumulative-RSI-Breakout-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