5 Day Moving Average Channel Breakout Strategy Combined With Mileage Concept
This strategy combines the 5-day moving average channel and the mileage concept buy and sell signals to achieve both channel breakout and short-term trading functionalities. It first calculates the 5-day moving…

Overview
This strategy combines the 5-day moving average channel and the mileage concept buy and sell signals to achieve both channel breakout and short-term trading functionalities. It first calculates the 5-day moving averages of highest high and lowest low as the channel bands, and then determines the entry and exit based on the channel breakout signals and mileage concept candlestick patterns.
Strategy Logic
- Calculate 5-day moving averages of highest high and lowest low as the upper and lower channel bands
- Generate buy signal when closing price crosses above the upper band
- Generate sell signal when closing price crosses below the lower band
- Combine with mileage concept patterns to determine if price action matches buy/sell features
- Buy feature: Close > Open, High – Close < Close – Open, Open – Low < Close - Open
- Sell feature: Open – Close > Previous Open – Close for 3 consecutive candles
- Final buy condition = Channel breakout signal AND Mileage buy pattern
- Final sell condition = Channel breakout signal AND Mileage sell pattern
Advantage Analysis
- Combines channel breakout and mileage concept strategies for multi-layer confirmation, avoiding false signals
- Channel breakout captures intermediate-term trends
- Mileage concept identifies short-term reversal opportunities
- Simple parameters easy to adjust for different market environments
Risk Analysis
- Whipsaws may generate false signals when price fluctuates violently within channel
- Inaccurate mileage concept pattern recognition may lead to premature entry or insufficient exit
- Improper parameter tuning impacts signal quality
Optimization Directions
- Test different parameter sets to find optimal channel bands
- Try different channel periods to see if shorter or longer durations perform better
- Optimize mileage concept rules to filter out noise
- Consider adding stop loss to control single trade loss
Conclusion
This strategy synthesizes channel breakout and mileage concept short-term trading, achieving multi-layer confirmation and risk control. Further optimizations may improve strategy performance. Note that parameter tuning and risk management significantly impact results, requiring thorough testing and validation.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 5 | Number of Candles for Average |
Source Pine Script
/*backtest
start: 2023-01-29 00:00:00
end: 2024-02-04 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("5MABAND + Mileage Concept Buy & Sell Strategy", overlay=true)
// Command 1 - 5MABAND Calculation
length = input(5, title="Number of Candles for Average")
avgHigh = ta.sma(high, length)
avgLow = ta.sma(low, length)
// Plotting 5MABAND Bands
plot(avgHigh, color=color.green, title="5MABAND High Line", linewidth=2)
plot(avgLow, color=color.red, title="5MABAND Low Line", linewidth=2)
// Command 2 - Mileage Concept Buy Entry
mileageBuyCondition = close > open and high - close < close - open and open - low < close - open and close - open > close[1] - open[1] and close - open > close[2] - open[2] and close - open > close[3] - open[3] and close > open and open > close[1]
// Command 3 - Mileage Concept Sell Entry
mileageSellCondition = open - close > open[1] - close[1] and open - close > open[2] - close[2] and open - close > open[3] - close[3] and open > close and close > open[1] and close > avgHigh
// Command 4 - 5MABAND Buy Entry
buyAlertCandle_5MABAND = close > avgHigh
plotshape(buyAlertCandle_5MABAND, color=color.green, style=shape.triangleup, location=location.belowbar, size=size.small, title="Buy Signal (5MABAND)")
// Command 5 - 5MABAND Sell Entry
sellAlertCandle_5MABAND = close < avgLow
plotshape(sellAlertCandle_5MABAND, color=color.red, style=shape.triangledown, location=location.abovebar, size=size.small, title="Sell Signal (5MABAND)")
// Command 6 - 5MABAND Exit Trigger
exitTriggerCandle_5MABAND_Buy = low < avgLow
exitTriggerCandle_5MABAND_Sell = high > avgHigh
// Exit Signals for 5MABAND
exitBuySignal_5MABAND = close < avgLow
exitSellSignal_5MABAND = close > avgHigh
// Buy and Sell Conditions for 5MABAND
buyCondition_5MABAND = close > avgHigh and buyAlertCandle_5MABAND
sellCondition_5MABAND = close < avgLow and (exitTriggerCandle_5MABAND_Buy or exitSellSignal_5MABAND)
// Combine Buy Conditions for Mileage Concept and 5MABAND
combinedBuyCondition = mileageBuyCondition and buyCondition_5MABAND
combinedSellCondition = mileageSellCondition and sellCondition_5MABAND
// Execute Buy and Sell Orders
strategy.entry("Buy", strategy.long, when = combinedBuyCondition)
strategy.close("Buy", when = sellCondition_5MABAND)
strategy.entry("Sell", strategy.short, when = combinedSellCondition)
strategy.close("Sell", when = exitBuySignal_5MABAND)
// Exit Buy and Sell Orders for 5MABAND
strategy.close("Buy", when = exitBuySignal_5MABAND)
strategy.close("Sell", when = exitSellSignal_5MABAND)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-05. 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/5-Day-Moving-Average-Channel-Breakout-Strategy-Combined-With-Mileage-Concept.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 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
- BMSB Breakout Strategy BMSBPine Script · Breakout · 1h