Strategy vault / Mean reversion
Multi Indicator Fusion Mean Reversion Trend Following Strategy
This strategy combines mean reversion and trend following approaches, utilizing MA, MACD, and ATR technical indicators for generating trading signals and risk control. The core concept is to capture market reversals…

Overview
This strategy combines mean reversion and trend following approaches, utilizing MA, MACD, and ATR technical indicators for generating trading signals and risk control. The core concept is to capture market reversals when price deviates from moving averages, confirmed by MACD crossover signals, while implementing ATR-based dynamic stop-loss for risk management.
Strategy Principles
The strategy employs a triple verification mechanism:
- Using Moving Average (MA) to assess price deviation, with options for SMA or EMA
- Utilizing MACD crossovers to identify trend reversal timing
- Implementing ATR indicator for dynamic stop-loss placement Specifically, long positions are initiated when price is below MA with MACD golden cross, while short positions are triggered when price is above MA with MACD death cross. Stop-loss levels are automatically set based on ATR volatility.
Strategy Advantages
- High signal reliability: Multiple indicator verification reduces false signals
- Comprehensive risk control: ATR dynamic stop-loss prevents significant drawdowns
- Flexible parameters: Adjustable based on different market characteristics
- Clear strategy logic: Explicit entry and exit conditions
- Strong adaptability: Applicable to various timeframes and market conditions
Strategy Risks
- Frequent trading in choppy markets may increase costs
- Possible lag in trend reversal detection
- Parameter optimization risks overfitting
- Potential slippage during high volatility periods
- Multiple indicators may reduce strategy efficiency
Optimization Directions
- Incorporate volume indicators for enhanced signal reliability
- Add trend strength filters to avoid weak market conditions
- Optimize stop-loss mechanism, consider trailing stops
- Include volatility filters to adjust positions during high volatility periods
- Develop adaptive parameter mechanisms for improved stability
Summary
This strategy achieves a relatively robust trading system by combining mean reversion and trend following approaches. The multiple indicator verification mechanism enhances trading signal reliability, while ATR dynamic stop-loss effectively controls risk. Despite some room for optimization, it represents a logically sound and practical strategy framework.
Source Pine Script
/*backtest
start: 2024-10-01 00:00:00
end: 2024-10-31 23:59:59
period: 3h
basePeriod: 3h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Mean Reversion Strategy with ATR, MACD and MA", overlay=true)
// === Настройки для индикаторов ===
// Параметры скользящей средней (MA)
maLength = input.int(30, title="Период скользящей средней (MA)")
maType = input.string("EMA", title="Тип скользящей средней", options=["SMA", "EMA"])
// Параметры ATR
atrLength = input.int(10, title="Период ATR")
atrMultiplier = input.float(10, title="ATR множитель для стоп-лосса")
// Параметры MACD
macdFastLength = input.int(8, title="Период быстрой EMA для MACD")
macdSlowLength = input.int(26, title="Период медленной EMA для MACD")
macdSignalLength = input.int(5, title="Период сигнальной линии MACD")
// === Рассчёт индикаторов ===
// Скользящая средняя
ma = if maType == "SMA"
ta.sma(close, maLength)
else
ta.ema(close, maLength)
// ATR (Средний истинный диапазон)
atr = ta.atr(atrLength)
// MACD
[macdLine, signalLine, _] = ta.macd(close, macdFastLength, macdSlowLength, macdSignalLength)
// Условия для входа на покупку и продажу
longCondition = ta.crossover(macdLine, signalLine) and close < ma
shortCondition = ta.crossunder(macdLine, signalLine) and close > ma
// === Управление позициями ===
if (longCondition)
strategy.entry("Buy", strategy.long)
// Стоп-лосс на основе ATR
stopLossLevel = close - atr * atrMultiplier
strategy.exit("Take Profit/Stop Loss", "Buy", stop=stopLossLevel)
if (shortCondition)
strategy.entry("Sell", strategy.short)
// Стоп-лосс на основе ATR
stopLossLevel = close + atr * atrMultiplier
strategy.exit("Take Profit/Stop Loss", "Sell", stop=stopLossLevel)
// Визуализация
plot(ma, title="MA", color=color.blue, linewidth=2)
plot(macdLine, title="MACD Line", color=color.green)
plot(signalLine, title="Signal Line", color=color.red)
hline(0, "Zero Line", color=color.gray)
Published by ChaoZhang on the FMZ strategy square · last modified 2024-11-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/Multi-Indicator-Fusion-Mean-Reversion-Trend-Following-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
- Customizable Non Repainting HTF MACD MFI Scalable Bot StrategyPine Script · Mean reversion · 1d
- Dynamic Adaptive Multi Timeframe Trend Following and Range Reversal Hybrid StrategyPine Script · Mean reversion · 2d
- MACD Cross Period Trading StrategyPine Script · Mean reversion · 1d
- CCTBBO Reversal Tracking StrategyPine Script · Mean reversion · 45m
- Multi Indicator Weighted Smart Trading StrategyPine Script · Mean reversion · 2d
- EMA MACD Trend Reversal Quantitative Trading StrategyPine Script · Mean reversion · 1d