Moving Average Channel Breakout Strategy 435159
This is a moving average channel breakout strategy based on moving averages and range channels. It uses moving average lines and upper/lower channel lines to determine breakouts for trading signals.

Overview
This is a moving average channel breakout strategy based on moving averages and range channels. It uses moving average lines and upper/lower channel lines to determine breakouts for trading signals.
Strategy Logic
The core logic of this strategy is:
Set a moving average line of certain period as the middle line.
Set upper and lower channel lines by multiplying the middle line by certain percentages. The upper line is middle line * (100% + preset percentage). The lower line is middle line * (100% - preset percentage).
When price breaks out above the upper line, go short. When price breaks out below the lower line, go long.
Set order prices at the corresponding upper/lower lines.
Close positions when price comes back to the middle line.
So it trades based on the breakouts of the moving average channel.
Advantage Analysis
The advantages of this strategy are:
Simple and clear concept, easy to understand and implement.
Adjustable parameters fitting different market conditions.
Middle line and channel range can filter market noise and catch trends.
Limit orders control risks.
Cut losses when price comes back to middle line.
Risk Analysis
There are also some risks:
Improper parameter settings may cause over/insufficient trading.
High probability of false breakouts and stop loss.
Failure of the middle and channel lines under huge market swings.
Premature exit when forced to close on middle line.
Solutions:
Optimize parameters like MA period and channel percentage.
Add other indicators like volume to avoid false breakouts.
Increase manual intervention.
Use longer MA period and wider channel range.
Optimization
The strategy can be improved from the following aspects:
Add stop loss methods like trailing stop to limit losses.
Add filtering indicators like MACD to reduce false signals.
Enable automatic parameter optimization.
Add more open position criteria beyond breakout.
Optimize MA and channel parameters.
Conclusion
In conclusion, this is a practical MA channel breakout strategy. It has a simple logic for easy use, while the channel range can filter noise. It performs well in trending markets. But risks exist and parameters together with additional filters need optimization for actual trading. The strategy has certain practical and development value.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | Long |
| v_input_2 | true | Short |
| v_input_3 | 100 | Lot, % |
| v_input_4 | 3 | Length |
| v_input_5_ohlc4 | 0 | Source: ohlc4 | high | low | open | hl2 | hlc3 | hlcc4 | close |
| v_input_6 | 10 | Short line (red) |
| v_input_7 | -5 | Long line (lime) |
| v_input_8 | 1900 | From Year |
| v_input_9 | 2100 | To Year |
| v_input_10 | true | From Month |
| v_input_11 | 12 | To Month |
| v_input_12 | true | From day |
| v_input_13 | 31 | To day |
Source Pine Script
/*backtest
start: 2023-01-01 00:00:00
end: 2023-08-15 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//Noro
//2018
//@version=3
strategy(title = "Robot WhiteBox ShiftMA", shorttitle = "Robot WhiteBox ShiftMA", overlay = true, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Lot, %")
per = input(3, title = "Length")
src = input(ohlc4, title = "Source")
shortlevel = input(10.0, title = "Short line (red)")
longlevel = input(-5.0, title = "Long line (lime)")
fromyear = input(1900, defval = 1900, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")
//SMAs
sma = sma(src, per)
shortline = sma * ((100 + shortlevel) / 100)
longline = sma * ((100 + longlevel) / 100)
plot(shortline, linewidth = 2, color = red, title = "Short line")
plot(sma, linewidth = 2, color = blue, title = "SMA line")
plot(longline, linewidth = 2, color = lime, title = "Long line")
//Trading
size = strategy.position_size
lot = 0.0
lot := size == 0 ? strategy.equity / close * capital / 100 : lot[1]
if (not na(close[per])) and size == 0 and needlong
strategy.entry("L", strategy.long, lot, limit = longline)
if (not na(close[per])) and size == 0 and needshort
strategy.entry("S", strategy.short, lot, limit = shortline)
if (not na(close[per])) and size > 0
strategy.entry("Close", strategy.short, 0, limit = sma)
if (not na(close[per])) and size < 0
strategy.entry("Close", strategy.long, 0, limit = sma)
if time > timestamp(toyear, tomonth, today, 23, 59)
strategy.close_all()Published by ChaoZhang on the FMZ strategy square · last modified 2023-12-12. 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/Moving-Average-Channel-Breakout-Strategy-435159.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
- Adaptive Trading Strategy Based on ADX IndicatorPine Script · Breakout · 1d
- Average Line Breakthrough StrategyPine Script · Breakout · 1d
- Bollinger Bands Dynamic Breakout StrategyPine Script · Breakout · 1h
- Bull Flag Breakout StrategyPine Script · Breakout · 1h
- Bull Market Tracking SystemPine Script · Breakout · 1h
- Cross boundary Dynamic Range Quantitative Trading Strategy Based on Bollinger BandsPine Script · Breakout · 3h