Strategy vault / Trend following
Multi Indicator Trend Tracking Strategy 427671
This strategy integrates multiple indicators for trend identification, and generates trading signals based on aligned directional changes. It combines moving average speed, STOCH and MACD to form a comprehensive and…
Overview
This strategy integrates multiple indicators for trend identification, and generates trading signals based on aligned directional changes. It combines moving average speed, STOCH and MACD to form a comprehensive and robust trend following system.
Strategy Logic
The core indicators are:
Moving average speed: Reflects price momentum.
STOCH: Oversold/overbought for trend changes.
MACD: Trend changes from dual moving averages.
The trading rules are:
Rising moving average speed gives bullish signal.
STOCH in overbought zone gives bearish signal.
MACD positive crossover gives bullish signal.
Enter when any 2 indicators align signals.
Exit when indicator signals change.
The combination evaluates trend from multiple dimensions, filtering noise for high-conviction signals.
Advantages
Compared to single indicators, the combo strategy has the following pros:
Combined view improves accuracy.
Ensemble filtering reduces false signals.
Incorporates trend and mean-reversion indicators.
Aligned signals have high conviction, avoiding false breakouts.
Simple and clear rules, easy to implement.
Flexible parameter tuning, robustness.
Applicable to different timeframes.
Can train indicator weights with machine learning.
Overall better stability and profitability than single indicators.
Risks
Despite the merits, risks to consider include:
Increased complexity with multiple indicators.
Challenging parameter optimization and weighting.
Conflicting indicator signals may occur.
Some lag always exists, cannot avoid all losses.
Uncertain unidirectional holding period with luck factor.
Ensemble signals cannot eliminate inherent trend trading risks.
High trade frequency increases transaction costs.
Need to monitor reward/risk ratios.
Enhancements
Based on the analysis, enhancements may involve:
Evaluate indicator efficacy across different markets.
Add parameter robustness checks to prevent overfitting.
Optimize indicator weighting to reduce conflicts.
Implement stops to limit severe losses.
Use time exits to control unlimited holding periods.
Assess trading frequency impact on transaction costs.
Incorporate risk metrics constraints.
Test robustness across multiple markets.
Continually validate strategy efficacy.
Conclusion
This strategy forms stable ensemble signals by integrating multiple indicators for trend assessment. But continual optimization is key for any strategy, monitoring risks and preventing overfitting. Quant trading is a continuous learning process.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1_close | 0 | Source: close | high | low | open | hl2 | hlc3 | hlcc4 | ohlc4 |
| v_input_int_1 | 50 | (?MA Speed)Avg Length |
| v_input_int_2 | true | Rate of Change Length |
| v_input_int_3 | 10 | Avg Rate of Change Length |
| v_input_int_4 | 14 | (?Stochastic)Stochastic Length |
| v_input_int_5 | 3 | Stochastic Smooth K |
| v_input_float_1 | 80 | Stochastic Overbought |
| v_input_float_2 | 20 | Stochastic Oversold |
| v_input_2 | 12 | (?MACD)Fast Length |
| v_input_3 | 26 | Slow Length |
| v_input_int_6 | 9 | MACD Avg Length |
Source Pine Script
/*backtest
start: 2022-09-16 00:00:00
end: 2023-09-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// By TradeStation
//@version=5
strategy("Mov Avg Speed Strategy", overlay=true)
src = input(close, title="Source")
// MA Speed
avg_len = input.int(50, minval=1, title="Avg Length", group="MA Speed")
roc_len = input.int(1, minval=1, title="Rate of Change Length", group="MA Speed")
avg_roc_len = input.int(10, minval=1, title="Avg Rate of Change Length", group="MA Speed")
// Stochastic
stoch_len = input.int(14, minval=1, title="Stochastic Length", group="Stochastic")
smooth_k = input.int(3, minval=1, title="Stochastic Smooth K", group="Stochastic")
overbought = input.float(80, title="Stochastic Overbought", group="Stochastic")
oversold = input.float(20, title="Stochastic Oversold", group="Stochastic")
// MACD
fast_length = input(12, title="Fast Length", group="MACD")
slow_length = input(26, title="Slow Length", group="MACD")
macd_avg_length = input.int(9, title="MACD Avg Length", minval=1, group="MACD")
// MA Speed
avg = ta.sma(src, avg_len)
roc = ta.roc(avg, roc_len)
avg_roc = ta.sma(roc, avg_roc_len)
avg_roc_signal = avg_roc > 0 ? 1 : avg_roc < 0 ? -1 : 0
// Stochastic k
k = ta.sma(ta.stoch(close, high, low, stoch_len), smooth_k)
stochastic_signal = k <= oversold ? 1 : k >= overbought ? -1 : 0
// MACD
fast_ma = ta.ema(src, fast_length)
slow_ma = ta.ema(src, slow_length)
macd = fast_ma - slow_ma
macd_avg = ta.ema(macd, macd_avg_length)
macd_signal = macd_avg > macd_avg[1] ? 1 : macd_avg < macd_avg[1] ? -1 : 0
// set the signal couint
long_count = 0
short_count = 0
if macd_signal == 1
long_count += 1
else if macd_signal == -1
short_count += 1
if stochastic_signal == 1
long_count += 1
else if stochastic_signal == -1
short_count += 1
if avg_roc_signal == 1
long_count += 1
else if avg_roc_signal == -1
short_count += 1
if (long_count >= 2)
strategy.entry("Long", strategy.long)
if (short_count >= 2)
strategy.entry("Short", strategy.short)Published by ChaoZhang on the FMZ strategy square · last modified 2023-09-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/Multi-Indicator-Trend-Tracking-Strategy-427671.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
- EMA SMA Multi Indicator Comprehensive Trend Following StrategyPine Script · Trend following · 1h
- Multifactor Driven Trend Trading StrategyPine Script · Trend following · 1m
- Trading Strategy Following Dual Timeframe TrendsPine Script · Trend following · 1h
- BlackBit Trader XO Macro Trend Scanner StrategyPine Script · Trend following · 1h
- MACD Trend Following Trading Strategy Based on MACD IndicatorPine Script · Trend following · 10m
- Mini Pullback Supertrend StrategyPine Script · Trend following · 1h