Strategy vault / Trend following
Adaptive Trend Following and Multi Confirmation Trading Strategy
This strategy is a trend following trading system that combines the Coral Trend indicator with the Donchian Channel. By precisely capturing market momentum and providing multiple confirmations of trend breakouts, it…

Overview
This strategy is a trend following trading system that combines the Coral Trend indicator with the Donchian Channel. By precisely capturing market momentum and providing multiple confirmations of trend breakouts, it effectively filters out false signals in oscillating markets and improves trading accuracy. The strategy employs adaptive moving average techniques that can dynamically adjust parameters to maintain stable performance across different market conditions.
Strategy Principles
The core logic is built on the synergistic effect of two main indicators:
- Coral Trend Indicator: Calculates a smoothed value of (high + low + close)/3 and compares it with the current closing price to determine trend direction.
- Donchian Channel: Determines whether price breaks key levels by calculating the highest and lowest prices within a user-defined period.
The system generates long signals when both indicators confirm an uptrend (coralTrendVal == 1 and donchianTrendVal == 1), and short signals when both confirm a downtrend (coralTrendVal == -1 and donchianTrendVal == -1). The strategy uses a state machine (trendState) to track the current trend state and avoid duplicate signals.
Strategy Advantages
- Multiple Confirmation Mechanism: Combining two independent trend indicators significantly reduces the probability of false signals.
- Strong Adaptability: The smoothing calculation method of the Coral Trend indicator enables it to adapt to different market volatility states.
- Parameter Adjustability: The strategy offers flexible parameter settings that can be optimized for different trading instruments and timeframes.
- Trend Persistence Recognition: The system effectively identifies strong trend conditions and maintains positions during trends.
- Clear Visual Feedback: Traders can intuitively understand market conditions through chart markers and trend lines.
Strategy Risks
- Trend Reversal Risk: May experience lag at trend turning points, leading to drawdowns. Solution: Add volatility filters to reduce positions when market volatility increases.
- Sideways Market Performance: May generate excessive trading signals in range-bound markets. Solution: Add trend strength confirmation indicators to open positions only when trends are clear.
- Parameter Sensitivity: Different parameter settings may lead to significant variations in strategy performance. Solution: Recommend finding optimal parameter combinations through historical data backtesting.
Strategy Optimization Directions
- Dynamic Parameter Adjustment: Automatically adjust Donchian Channel period and Coral Trend smoothing period based on market volatility.
- Add Stop Loss Mechanism: Recommend adding dynamic ATR-based stop losses to improve risk control.
- Add Volume Confirmation: Include volume filtering conditions when generating signals to increase trend confirmation reliability.
- Optimize Position Management: Implement a dynamic position management system based on trend strength.
- Market Environment Classification: Add market environment recognition module to use different parameter combinations in different market states.
Summary
This strategy achieves a robust trend following system through multiple trend confirmation mechanisms and flexible parameter settings. Its adaptive features and clear signal logic make it suitable for various trading timeframes and market environments. Through the suggested optimization directions, there is room for further improvement in strategy performance. When applying to live trading, it is recommended to incorporate risk management measures and optimize parameters according to the characteristics of specific trading instruments.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-16 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT","balance":49999}]
*/
//@version=5
strategy("Coral Tides Strategy", shorttitle="CoralTidesStrat", overlay=true)
// === Inputs ===
dlen = input.int(defval=20, title="Donchian Channel Period", minval=10)
coralPeriod = input.int(defval=14, title="Coral Trend Period")
// === Functions ===
// Coral Trend Calculation
coralTrend(period) =>
smooth = (high + low + close) / 3
coral = ta.ema(smooth, period)
trend = 0
trend := close > coral ? 1 : close < coral ? -1 : trend[1]
[trend, coral]
// Donchian Trend Calculation
donchianTrend(len) =>
hh = ta.highest(high, len)
ll = ta.lowest(low, len)
trend = 0
trend := close > hh[1] ? 1 : close < ll[1] ? -1 : trend[1]
trend
// === Trend Calculation ===
[coralTrendVal, coralLine] = coralTrend(coralPeriod)
donchianTrendVal = donchianTrend(dlen)
// === Signal Logic ===
var int trendState = 0
buySignal = false
sellSignal = false
if (coralTrendVal == 1 and donchianTrendVal == 1 and trendState != 1)
buySignal := true
sellSignal := false
trendState := 1
else if (coralTrendVal == -1 and donchianTrendVal == -1 and trendState != -1)
sellSignal := true
buySignal := false
trendState := -1
else
buySignal := false
sellSignal := false
// === Strategy Execution ===
// Entry Signals
if (buySignal)
strategy.entry("Long", strategy.long)
if (sellSignal)
strategy.entry("Short", strategy.short)
// === Plots ===
// Coral Trend Line
plot(coralLine, color=color.green, linewidth=2, title="Coral Trend Line")
// Buy/Sell Signal Labels
if buySignal
label.new(bar_index, low, "BUY", color=color.green, textcolor=color.white, style=label.style_label_down, size=size.normal)
if sellSignal
label.new(bar_index, high, "SELL", color=color.red, textcolor=color.white, style=label.style_label_up, size=size.normal)
Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-17. 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/Adaptive-Trend-Following-and-Multi-Confirmation-Trading-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
- Triple Supertrend Ichimoku Cloud Quantitative Trading StrategyPine Script · Trend following · 1d
- Crossing Moving Average Trend Tracking StrategyPine Script · Trend following · 2h
- TrendHunter w MF Multi Timeframe Trend StrategyPine Script · Trend following · 1h
- Ichimoku Balance Line trend following StrategyPine Script · Trend following · 1d
- Five EMA RSI Trend Following Dynamic Channel Trading SystemPine Script · Trend following · 1d
- Ichimoku Cloud MACD and Stochastic Based Multi Timeframe Trend Tracking StrategyPine Script · Trend following · 4h