The Compound Breakout Strategy
This strategy calculates the highest and lowest prices of recent N bars to set double breakout conditions combined with moving average line to implement low-buying and high-selling trading strategy.

Overview
This strategy calculates the highest and lowest prices of recent N bars to set double breakout conditions combined with moving average line to implement low-buying and high-selling trading strategy.
Strategy Principles
The strategy is mainly based on the following principles:
- Calculate the minimum low price minLow of recent 7 bars to determine the breakout buy condition
- Calculate the maximum high price maxHigh of recent 7 bars to determine the breakout sell condition
- Calculate the 200-period simple moving average line mma to determine the trend direction combined with mma
- Buy condition: close price breaks through minLow and is higher than mma
- Sell condition: close price breaks through maxHigh or is higher than maxHigh
By calculating the extremes of recent N bars, it judges whether the market is extremely oversold or overbought. Combined with the moving average line to determine the trend direction, it sets double conditions to achieve the breakout trading strategy of low-buying and high-selling.
Advantage Analysis
The strategy has the following advantages:
- The double condition setting makes the trading signals of the strategy more reliable
- Using the extremes of K lines to judge the oversold and overbought status can seize the chance of reversal
- Combining the moving average line to determine the trend direction avoids reverse operations
- It implements the idea of low-buying and high-selling, which is consistent with the trading psychology of most traders
- The logic of the strategy is simple and clear, easy to understand and implement
Through double confirmation, the signal quality of the strategy is relatively high, and the space for parameter optimization is large, which is suitable for different market environments.
Risk Analysis
The strategy also has some risks:
- The double condition limit the frequency of signals, possibly missing some trading opportunities
- Improper settings of computing cycle for K line extremes may fail to accurately determine the oversold and overbought status
- Improper parameter settings of the moving average line may incorrectly determine the trend direction
- It needs to optimize multiple parameters simultaneously, making parameter optimization more difficult
These risks can be reduced by adjusting computing cycles, optimizing parameter combinations and other methods. In addition, considering combining with other indicators for optimization.
Optimization Directions
The strategy can be mainly optimized in the following directions:
- Optimize the computing cycle of K line extremes to find the most appropriate cycle parameters to determine overbought and oversold
- Test the effects of moving average lines of different lengths
- Increase other combined indicators such as BOLL channels, KD indicators, etc.
- Increase stop loss strategies to control single stop loss
- Optimize entry and exit conditions to improve signal quality
Through parameter optimization, indicator optimization, risk control optimization and other means, the profit factor of the strategy can be greatly improved.
Summary
In general, this is a very practical breakout strategy. Calculating extremes of K lines to determine oversold and overbought status, using moving average line to determine trend direction, setting double filtering conditions to filter false signals, it implements high-quality low-buying and high-selling strategies. By optimizing computing cycles, adding other indicators and other means, the strategy effect can be further enhanced. The strategy is suitable for both beginners to learn and professional traders to optimize and use.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 7 | Quantity of day low |
| v_input_2 | 7 | Quantity of day high |
| v_input_3 | 200 | Length of SMA |
| v_input_4 | 2009 | Backtest Start Year |
| v_input_5 | true | Backtest Start Month |
| v_input_6 | 2 | Backtest Start Day |
| v_input_7 | 2020 | Backtest Stop Year |
| v_input_8 | 12 | Backtest Stop Month |
| v_input_9 | 30 | Backtest Stop Day |
Source Pine Script
/*backtest
start: 2023-02-22 00:00:00
end: 2024-02-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Larry Connors por RON", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=100)
value1 = input(7, title="Quantity of day low")
value2 = input(7, title="Quantity of day high")
entry = lowest(close[1], value1)
exit = highest(close[1], value2)
lengthMMA = input(200, title="Length of SMA", minval=1)
mma = sma(close, lengthMMA)
// Calcular el mínimo de los precios bajos de las últimas 'value1' velas
minLow = lowest(low, value1)
// Calcular el máximo de los precios altos de las últimas 'value2' velas
maxHigh = highest(high, value2)
// Test 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
if testPeriod()
// Condiciones de entrada
conditionMet = (close > mma) and (close < entry) and (low == minLow)
strategy.entry("Buy", strategy.long, when=conditionMet)
if conditionMet
label.new(bar_index, entry, text="↑", style=label.style_arrowup, color=color.green, size=size.small, yloc=yloc.belowbar)
// Condiciones de salida
conditionExit = close > exit or close > maxHigh
strategy.close("Buy", when=conditionExit)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-29. 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.
/agenkit build a production-grade trading bot with a backtest engine, risk controls and paper trading by default from strategies/The-Compound-Breakout-Strategy.md- npx agenkit install engineering-kit in your project
- Paste the command into your agent and approve each phase
- 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
- 5 Day Moving Average Channel Breakout Strategy Combined With Mileage ConceptPine Script · Breakout · 1d
- Adaptive Bollinger Breakout with Moving Average Quantitative Strategy SystemPine Script · Breakout · 1h
- Adaptive Multi Period Trading Strategy Based on Wave Trend Momentum BreakoutPine Script · Breakout · 2h
- Adaptive Trading Strategy Based on ADX IndicatorPine Script · Breakout · 1d
- Average Line Breakthrough StrategyPine Script · Breakout · 1d
- BB Breakout StrategyPine Script · Breakout · 1d