Strategy vault / Trend following
Dynamic Channel Moving Average Trend Tracking Strategy
This strategy is designed based on the principle of dynamic channel and moving average trend tracking. It calculates the dynamic price channel, judges the trend direction through the upper and lower rails of the…

Overview
This strategy is designed based on the principle of dynamic channel and moving average trend tracking. It calculates the dynamic price channel, judges the trend direction through the upper and lower rails of the channel, and generates trading signals by combining the moving average to filter price volatility. This strategy is suitable for medium and short term trend trading.
Principle
The main principles of this strategy are:
Calculate dynamic price channel. The channel middle line is calculated from highest price and lowest price. The upper rail is middle line + price volatility MA, and the lower rail is middle line - price volatility MA.
Judge trend direction. When price breaks through the upper rail, it is defined as bullish. When price breaks through the lower rail, it is defined as bearish.
Filter noise. Use price volatility MA of a certain period to filter noise from random price fluctuations.
Generate trading signals. When bullish, a buy signal is generated when close price is lower than open price in that period. When bearish, a sell signal is generated when close price is higher than open price.
Advantages
The advantages of this strategy are:
- Dynamic channel can capture price trend in real time.
- MA filter can reduce false signals.
- Combining trend direction and K-line entity direction to generate trading signals avoids being trapped.
Risks
The risks of this strategy are:
- Improper Param selection may lead to overfitting.
- It is easy to generate wrong signals during sideways volatility.
- It cannot predict extreme price fluctuations.
Solutions:
- Strict Param selection and testing.
- Add filter conditions to identify sideways.
- Set stop loss/profit to control risks.
Optimization Directions
The strategy can be optimized in following aspects:
- Test stability of different period Params.
- Add VOLUME or volatility indicators to judge momentum.
- Combine bands, channels etc. to determine entry and exit.
Summary
This strategy integrates the ideas of dynamic channel and MA trend judgment, and performs well in capturing trend directions in medium and short term. But there are still some limitations, which need further testing and optimization to adapt more market situations.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | true | Long |
| v_input_2 | true | Short |
| v_input_3 | 20 | Period |
| v_input_4 | true | Color |
| v_input_5 | false | Show Bands |
| v_input_6 | false | Show Background |
Source Pine Script
/*backtest
start: 2024-01-01 00:00:00
end: 2024-01-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
strategy("Noro's Bands Strategy v1.0", shorttitle = "NoroBands str 1.0", overlay=true, default_qty_type = strategy.percent_of_equity, default_qty_value=100.0, pyramiding=0)
//Settings
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
len = input(20, defval = 20, minval = 2, maxval = 200, title = "Period")
color = input(true, "Color")
needbb = input(false, defval = false, title = "Show Bands")
needbg = input(false, defval = false, title = "Show Background")
src = close
//PriceChannel 1
lasthigh = highest(src, len)
lastlow = lowest(src, len)
center = (lasthigh + lastlow) / 2
//dist
dist = abs(src - center)
distsma = sma(dist, len)
hd = center + distsma
ld = center - distsma
//Trend
trend = close < ld and high < hd ? -1 : close > hd and low > ld ? 1 : trend[1]
//Lines
colo = needbb == false ? na : black
plot(hd, color = colo, linewidth = 1, transp = 0, title = "High band")
plot(center, color = colo, linewidth = 1, transp = 0, title = "center")
plot(ld, color = colo, linewidth = 1, transp = 0, title = "Low band")
//Background
col = needbg == false ? na : trend == 1 ? lime : red
bgcolor(col, transp = 90)
//up = and trend == 1 ? 1 : 0
//dn = and trend == -1 ? 1 : 0
up = close < hd and trend == 1 and (close < open or color == false) ? 1 : 0
dn = close > ld and trend == -1 and (close > open or color == false) ? 1 : 0
longCondition = up == 1
if (longCondition)
strategy.entry("Long", strategy.long, needlong == false ? 0 : na)
shortCondition = dn == 1
if (shortCondition)
strategy.entry("Short", strategy.short, needshort == false ? 0 : na)Published by ChaoZhang on the FMZ strategy square · last modified 2024-02-22. 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/Dynamic-Channel-Moving-Average-Trend-Tracking-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
- ADX MA and EMA Long Only Trend Tracking StrategyPine Script · Trend following · 1d
- ATR and Moving Average Crossover Hybrid StrategyPine Script · Trend following · 1h
- Adaptive FVG Detection and MA Trend Trading Strategy with Dynamic ResistancePine Script · Trend following · 1d
- Adaptive Risk Management Strategy Based on Dynamic ATR and Moving Average CrossoverPine Script · Trend following · 2h
- Adaptive Trading Strategy Based on Stochastic RSI Dual Line CrossoverPine Script · Trend following · 4h
- Adaptive Volatility Based Trend Following Short Strategy with Time Delay and Stop Loss ProtectionPine Script · Trend following · 2m