Strategy vault / Trend following
Adaptive Trend Following Strategy Combining Dual Moving Average Crossover and RSI
This strategy is a trend following system that combines a dual moving average crossover with the Relative Strength Index (RSI). It captures market trends through the crossover of 9-period and 21-period Exponential…

Overview
This strategy is a trend following system that combines a dual moving average crossover with the Relative Strength Index (RSI). It captures market trends through the crossover of 9-period and 21-period Exponential Moving Averages (EMA), while using RSI for overbought/oversold filtering and volume confirmation to enhance signal reliability. The strategy also incorporates a dynamic stop-loss mechanism based on Average True Range (ATR) for comprehensive risk control.
Strategy Principles
The core logic is based on several key elements:
- Using fast EMA (9-period) and slow EMA (21-period) crossovers to identify potential trend changes
- Filtering through RSI indicator, allowing trades only when RSI is between 40-60
- Setting minimum volume threshold (100,000) as trade confirmation
- Implementing 1.5x ATR as dynamic stop-loss distance for flexible risk control
Long signals are generated when the fast EMA crosses above the slow EMA, RSI is above 40, and volume exceeds the threshold. Conversely, short signals occur when the fast EMA crosses below the slow EMA, RSI is below 60, and volume confirms.
Strategy Advantages
- Scientific indicator combination: integrating trend following, momentum, and volume analysis
- Comprehensive risk control: multi-level risk management through RSI filtering and dynamic stops
- Flexible parameters: key parameters can be optimized for different market characteristics
- Strict signal confirmation: multiple conditions required, effectively reducing false signals
- Clear execution logic: explicit rules facilitating live trading and backtesting
Strategy Risks
- Frequent trades in ranging markets: multiple crossovers during consolidation
- RSI filter may miss trend beginnings: RSI might be high at strong trend initiation
- Volume filter might be too strict: challenging for low liquidity instruments
- Fixed multiplier ATR stops may lack flexibility during extreme volatility
- Absence of fixed take-profit levels may affect capital efficiency
Optimization Directions
- Introduce adaptive parameters: dynamically adjust EMA periods and RSI thresholds based on volatility
- Optimize stop-loss mechanism: implement multi-level stops using support/resistance
- Add market environment filtering: incorporate trend strength indicators
- Improve money management: adjust position sizes based on signal strength and volatility
- Add take-profit mechanism: implement ATR-based dynamic take-profit levels
Summary
The strategy constructs a logically rigorous trend following system through scientific combination of classic technical indicators. Its multiple filtering mechanisms and risk control measures provide strong practical value. There's room for further improvement through the suggested optimizations. It's particularly suitable for volatile and liquid markets, but requires thorough testing and parameter optimization before implementation.
Source Pine Script
/*backtest
start: 2024-11-07 00:00:00
end: 2025-02-18 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=5
strategy("Call & Put Options Strategy (Optimized)", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// ? Configuration Parameters
emaShort = input(9, title="Short EMA")
emaLong = input(21, title="Long EMA")
rsiLength = input(14, title="RSI Period")
rsiOverbought = input(60, title="RSI Overbought") // Adjusted for more signals
rsiOversold = input(40, title="RSI Oversold") // More flexible to confirm buys
atrLength = input(14, title="ATR Period")
atrMult = input(1.5, title="ATR Multiplier for Stop Loss")
minVol = input(100000, title="Minimum Volume to Confirm Entry") // Volume filter
// ? Indicator Calculations
emaFast = ta.ema(close, emaShort)
emaSlow = ta.ema(close, emaLong)
rsi = ta.rsi(close, rsiLength)
atr = ta.atr(atrLength)
vol = volume
// ? Entry Signal Conditions
condCALL = ta.crossover(emaFast, emaSlow) and rsi > rsiOversold and vol > minVol
condPUT = ta.crossunder(emaFast, emaSlow) and rsi < rsiOverbought and vol > minVol
// ? Plot signals on the chart
plotshape(condCALL, location=location.belowbar, color=color.green, style=shape.labelup, title="CALL", size=size.small)
plotshape(condPUT, location=location.abovebar, color=color.red, style=shape.labeldown, title="PUT", size=size.small)
// ? Alert conditions
alertcondition(condCALL, title="CALL Signal", message="? CALL signal confirmed")
alertcondition(condPUT, title="PUT Signal", message="? PUT signal confirmed")
// ? Risk Management - Stop Loss and Take Profit
longStop = close - (atr * atrMult)
shortStop = close + (atr * atrMult)
strategy.entry("CALL", strategy.long, when=condCALL)
strategy.exit("CALL Exit", from_entry="CALL", stop=longStop)
strategy.entry("PUT", strategy.short, when=condPUT)
strategy.exit("PUT Exit", from_entry="PUT", stop=shortStop)
Published by ianzeng123 on the FMZ strategy square · last modified 2025-02-27. 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-Strategy-Combining-Dual-Moving-Average-Crossover-and-RSI.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
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h
- Multi Indicator Trend Following Strategy with ATR Dynamic Stop Loss Take ProfitPine Script · Trend following · 1d
- Multi Moving Average and Indicator Cross Trend Following Quantitative Trading SystemPine Script · Trend following · 1d
- Multi Factor Trend Price Action Strategy with Dynamic Risk Management SystemPine Script · Trend following · 2h
- Trend Tracking and Short term Trading Strategy Based on ADX IndicatorPine Script · Trend following · 1d
- Dynamic ATR Trailing Stop with EMA Cross Combination StrategyPine Script · Trend following · 2h