Strategy vault / Trend following
Multi Indicator Crossover Dynamic Stop Loss Trend Following Strategy
This strategy is a long-only approach for spot markets that utilizes multiple technical indicators. It primarily relies on the crossover signals between fast and slow Exponential Moving Averages (EMA), combined with…

Overview
This strategy is a long-only approach for spot markets that utilizes multiple technical indicators. It primarily relies on the crossover signals between fast and slow Exponential Moving Averages (EMA), combined with the Relative Strength Index (RSI), Average Directional Index (ADX), and Moving Average Convergence Divergence (MACD) for trade confirmation. The strategy employs the Average True Range (ATR) for dynamic stop-loss and take-profit levels to manage risk.
Strategy Principles
The core logic is based on the following key components:
- Uses 8-period and 21-period EMA crossover as primary entry signals
- Confirms trend strength with ADX>25
- Validates trend direction using MACD golden cross
- Employs RSI<70 to avoid entries in overbought regions
- Sets stop-loss at 1.5x ATR and take-profit at 2x ATR
- Implements trailing stop-loss to secure profits
Strategy Advantages
- Multiple confirmation mechanisms significantly improve trade reliability
- Dynamic stop-loss and take-profit levels adapt to market volatility
- Trailing stop-loss effectively protects accumulated profits
- Executes trades only on confirmed candles, reducing false signals
- Uses percentage-based position sizing for better risk control
- Accounts for trading costs, reflecting real-world conditions
Strategy Risks
- Multiple indicators may cause missed trading opportunities
- Rapid oscillating markets might generate frequent false signals
- Large price gaps could render stop-losses ineffective
- Trading costs may impact overall strategy returns
- Long-only approach might underperform in bear markets
Strategy Optimization Directions
- Consider adding market environment filters to adjust parameters under different conditions
- Incorporate volume indicators as additional confirmation signals
- Optimize EMA and MACD parameters for different timeframes
- Refine profit-taking and stop-loss mechanisms, consider partial profit-taking
- Enhance position management logic for more flexible position control
Summary
This is a well-designed trend-following strategy that seeks stable returns while controlling risk through the use of multiple technical indicators. The strategy's strengths lie in its comprehensive confirmation mechanisms and risk management system, though it still requires parameter optimization and logic improvements based on actual market conditions. To address existing risks, the strategy can be enhanced by adding market environment filters and optimizing parameters to further improve stability and profitability.
Source Pine Script
/*backtest
start: 2024-02-21 00:00:00
end: 2025-02-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Binance","currency":"ETH_USDT"}]
*/
//@version=6
strategy("Optimized Long-Only Strategy (Spot Market) - Candle Signals Only", overlay=true, initial_capital=10000, default_qty_type=strategy.percent_of_equity, default_qty_value=10, commission_type=strategy.commission.percent, commission_value=0.1)
// INPUTS
fastEMA_len = input.int(8, "Fast EMA Length", minval=1)
slowEMA_len = input.int(21, "Slow EMA Length", minval=1)
rsiPeriod = input.int(14, "RSI Period")
rsiOverbought = input.int(70, "RSI Overbought Level", minval=50)
adxPeriod = input.int(14, "ADX Period", minval=1)
adxThreshold = input.int(25, "ADX Trend Strength Threshold", minval=1)
fastMACD = input.int(12, "MACD Fast Length", minval=1)
slowMACD = input.int(26, "MACD Slow Length", minval=1)
signalMACD = input.int(9, "MACD Signal Length", minval=1)
atrPeriod = input.int(14, "ATR Period", minval=1)
atrStopMultiplier = input.float(1.5, "ATR Stop Loss Multiplier", step=0.1)
atrProfitMultiplier = input.float(2.0, "ATR Profit Target Multiplier", step=0.1)
// CALCULATIONS
emaFast = ta.ema(close, fastEMA_len)
emaSlow = ta.ema(close, slowEMA_len)
rsiValue = ta.rsi(close, rsiPeriod)
// --- Custom ADX Calculation ---
up = ta.change(high)
down = -ta.change(low)
plusDM = (up > down and up > 0) ? up : 0
minusDM = (down > up and down > 0) ? down : 0
trueRange = ta.tr(true) // 'handle_na' parameter set to true
atrVal = ta.rma(trueRange, adxPeriod)
plusDI = 100 * ta.rma(plusDM, adxPeriod) / atrVal
minusDI = 100 * ta.rma(minusDM, adxPeriod) / atrVal
dx = 100 * math.abs(plusDI - minusDI) / (plusDI + minusDI)
adxValue = ta.rma(dx, adxPeriod)
// MACD Calculation (MACD line, signal line, histogram)
[macdLine, signalLine, _] = ta.macd(close, fastMACD, slowMACD, signalMACD)
// ATR for stops and targets
atrValue = ta.atr(atrPeriod)
// TRADING CONDITION (Long Only, on confirmed candle)
longCondition = ta.crossover(emaFast, emaSlow) and (adxValue > adxThreshold) and (macdLine > signalLine) and (rsiValue < rsiOverbought)
// POSITION MANAGEMENT: Execute only on confirmed candles
if barstate.isconfirmed and longCondition
strategy.entry("Long", strategy.long)
longStop = close - atrStopMultiplier * atrValue
longTarget = close + atrProfitMultiplier * atrValue
strategy.exit("Long Exit", from_entry="Long", stop=longStop, limit=longTarget, trail_points=atrValue * 0.5, trail_offset=atrValue * 0.3)
// PLOTTING
plot(emaFast, color=color.green, title="Fast EMA")
plot(emaSlow, color=color.red, title="Slow EMA")
plotshape(barstate.isconfirmed and longCondition, title="Buy Signal", style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", textcolor=color.white, size=size.tiny)
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/Multi-Indicator-Crossover-Dynamic-Stop-Loss-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
- Dynamic Trend Identification Strategy with Exponential Moving Average and Adaptive Volatility ThresholdPine Script · Trend following · 1h
- Dual Trend Strategy with EMA Crossover and RSI FilterPine Script · Trend following · 1d
- Multi Timeframe Volume and Trend Confluence Trading StrategyPine Script · Trend following · 1d
- Multi timeframe Trend Tracking Strategy Based on Impulse MACD and Dual Moving Average CrossoverPine Script · Trend following · 1d
- Gaussian Cross EMA Trend Retracement StrategyPine Script · Trend following · 1d
- Indicator Verification Automated Trading StrategyPine Script · Trend following · 10m