Channel Breakout SMA Strategy
This strategy is based on channel breakout and uses moving average crossover as exit signal. It works well on futures and indices.

Overview
This strategy is based on channel breakout and uses moving average crossover as exit signal. It works well on futures and indices.
Strategy Logic
Calculate highest high and lowest low over certain periods to construct upper and lower channel.
Go long when price breaks above upper channel; go short when price breaks below lower channel.
Calculate fast and slow SMA lines.
If long, close long when fast SMA crosses below slow SMA; If short, close short when fast SMA crosses above slow SMA.
Advantage Analysis
Combining channel and moving average system can improve profitability.
Channel judges rotation and SMA judges trend exhaustion.
SMA filter avoids whipsaws and reduces unnecessary trades.
Adjustable channel range fits different periods and volatility.
Risk Analysis
Improper channel range may miss breakout or generate false breakout.
Improper SMA parameters may exit early or late.
Need reasonable position sizing to limit single loss.
Watch for valid breakout, avoid chasing high/selling low.
Optimization
Test parameters to optimize channel range and SMA periods.
Add trend filter to improve breakout success rate.
Add position sizing such as fixed fraction and Martingale.
Add stop loss to control single loss.
Summary
This strategy capitalizes on channel and SMA to achieve steady gains in strong trends. But whipsaw losses must be avoided and position sizing is critical. Further enhancements on parameter tuning, signal filtering and risk management will improve robustness.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 7 | Length |
Source Pine Script
/*backtest
start: 2023-10-01 00:00:00
end: 2023-10-13 00:00:00
period: 1m
basePeriod: 1m
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/
// © anshuanshu333
//@version=4
// strategy("ChBrkOutStrategySMA", overlay=true, initial_capital = 200000)
length = input(title="Length", type=input.integer, minval=1, maxval=1000, defval=7)
fastSMA = sma(close,9)
slowSMA = sma(close,21)
upBound = highest(high, length)
downBound = lowest(low, length)
boundLongEntry = ((close >= upBound) or (high >= upBound)) and fastSMA>slowSMA and (close > open)
boundShortEntry =((close <= downBound) or (low <= downBound)) and fastSMA<slowSMA and (close <open)
u=plot(upBound, title = "Upper Bound",color=color.blue, linewidth=1)
l=plot(downBound, title = "Lower Bound",color=color.red, linewidth=1)
plot(fastSMA,title = "Fast SMA", color = color.red, linewidth =2)
plot(slowSMA,title = "Slow SMA" ,color = color.green, linewidth =1)
fill(u,l, transp=95)
plot(avg(upBound,downBound), title = "Avg", color=color.gray,linewidth =1)
if (boundLongEntry )
strategy.entry("LE", long = true)
if (boundShortEntry)
strategy.entry("SE", long = false)
SmaLongExit = crossunder(fastSMA,slowSMA)
SmaShortExit = crossover(fastSMA,slowSMA)
//Close TRades
if (strategy.position_size > 0)
strategy.close(id="LE",when= SmaLongExit)
if (strategy.position_size < 0)
strategy.close(id="SE",when= SmaShortExit)Published by ChaoZhang on the FMZ strategy square · last modified 2023-10-23. 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/Channel-Breakout-SMA-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