0bps

Strategy vault / Breakout

Oscillation Breakthrough Strategy

This strategy is based on the classic idea of Larry Connors, using double moving average system to capture the medium-term oscillation of the market and take profit when it is overbought or oversold.

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

IMG

Overview

This strategy is based on the classic idea of Larry Connors, using double moving average system to capture the medium-term oscillation of the market and take profit when it is overbought or oversold.

Strategy Logic

  1. Use 2-period RSI to determine if the price is in oversold region.

  2. Use long period moving average (200 periods) to determine the major trend direction. Only consider opening position when price is above the long MA.

  3. When price is above long MA and RSI is below oversold line, open long position at market price.

  4. When price breaks through short period MA (5 periods) upwards, close long position at market price to take profit.

In addition, the strategy provides the following configurable options:

  • RSI parameters: period length, overbought/oversold levels.

  • MA parameters: long and short period.

  • RSI MA filter: add RSI MA to avoid RSI fluctuation.

  • Stop loss: configurable to add stop loss or not.

Advantage Analysis

  1. The double MA system can effectively track medium-long term trends.

  2. RSI avoids missing the best entry timing during violent fluctuation.

  3. Flexible configuration suitable for parameter optimization.

  4. Breakthrough strategy, not likely to miss signals.

Risk Analysis

  1. Double MA strategy is sensitive to parameters, requiring optimization to achieve best performance.

  2. No stop loss brings risk of expanding losses. Cautious position sizing is needed.

  3. False breakout risks losses in oscillating market. Consider optimizing MA periods or adding other filters.

  4. Backtest overfitting risk. Requires validation across markets and time periods.

Optimization Directions

  1. Test and optimize combinations of RSI and MA parameters to find optimum.

  2. Test additional entry filters like volume spike to reduce false signals.

  3. Add trailing stop loss to control single trade loss. Assess impact on overall profitability.

  4. Evaluate impact of different holding periods to find optimal.

  5. Test robustness in longer timeframes like daily.

Summary

This strategy combines double MA trend tracking and RSI overbought/oversold to form a typical breakout system. With parameter optimization, strict risk management and robustness validation, it can become a powerful quantitative trading tool. But traders should beware of backtest overfitting and keep improving the strategy to adapt to changing market conditions.

Parameters

NameDefaultWhat it controls
v_input_12RSI Lenght
v_input_210OverBought Level for RSI
v_input_35Short MA Length
v_input_4200Long MA Length
v_input_5trueRSI Moving Average Filter
v_input_64RSI Moving Average Length
v_input_730OverBought Level for the Moving Average of the RSI
v_input_8falseApply Stop Loss
v_input_910% Stop Loss
v_input_102009Backtest Start Year
v_input_11trueBacktest Start Month
v_input_122Backtest Start Day
v_input_132020Backtest Stop Year
v_input_1412Backtest Stop Month
v_input_1530Backtest Stop Day

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"}]
*/

//@version=3
strategy("RSI Strategy", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100)

//Starter Parameters

length = input(title="RSI Lenght", defval=2)
overBoughtRSI = input(title="OverBought Level for RSI",  defval=10)
shortLength = input(title="Short MA Length",  defval=5)
longLength = input(title="Long MA Length",  defval=200)

RuleMRSI=input(title="RSI Moving Average Filter", defval= true)
lengthmrsi=input(title="RSI Moving Average Length",  defval=4)
overBoughtMRSI=input(title="OverBought Level for the Moving Average of the RSI",  defval=30)

Rulestop=input(title="Apply Stop Loss", defval=false)
stop_percentual=input(title="% Stop Loss",  defval=10)

//RSI

vrsi = rsi(close, length)

//Moving Averages

longma = sma(close,longLength)
shortma = sma(close,shortLength)
mrsi=sma(vrsi,lengthmrsi)

//Stop Loss

stop_level = strategy.position_avg_price*((100-stop_percentual)/100)

//Backtest Period
testStartYear = input(2009, "Backtest Start Year")
testStartMonth = input(1, "Backtest Start Month")
testStartDay = input(2, "Backtest Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2020, "Backtest Stop Year")
testStopMonth = input(12, "Backtest Stop Month")
testStopDay = input(30, "Backtest Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

testPeriod() => true
    
//Strategy

if testPeriod() and (not na(vrsi))
    if  (RuleMRSI==false) and (Rulestop==false)
        if (vrsi<overBoughtRSI) and (close>longma)
            strategy.entry("RsiLE", strategy.long , comment="Open")
        if (close>shortma)
            strategy.close_all()

    if (RuleMRSI==true) and (Rulestop==false)
        if (vrsi<overBoughtRSI) and (close>longma) and (mrsi<overBoughtMRSI)
            strategy.entry("RsiLE", strategy.long , comment="Open")
        if (close>shortma)
            strategy.close_all()

    if (RuleMRSI==false) and (Rulestop==true)
        if (vrsi<overBoughtRSI) and (close>longma)
            strategy.entry("RsiLE", strategy.long , comment="Open")
            strategy.exit("RsiLE", stop = stop_level)
        if (close>shortma)
            strategy.close_all()

    if (RuleMRSI==true) and (Rulestop==true)
        if (vrsi<overBoughtRSI) and (close>longma) and (mrsi<overBoughtMRSI)
            strategy.entry("RsiLE", strategy.long , comment="Open")
            strategy.exit("RsiLE", stop = stop_level)
        if (close>shortma)
            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/Oscillation-Breakthrough-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