Strategy vault / Trend following
Multi Target EMA Crossover Trend Following Strategy
This strategy is a trend following system based on EMA crossover signals. It uses a 34-period EMA as the main trend indicator, combined with multiple take-profit levels and risk management mechanisms for fully…

Overview
This strategy is a trend following system based on EMA crossover signals. It uses a 34-period EMA as the main trend indicator, combined with multiple take-profit levels and risk management mechanisms for fully automated trading. The core concept is to capture trend initiation points through price-EMA crossovers and maximize profit opportunities through multiple profit targets.
Strategy Principles
The strategy operates based on these core principles:
- Uses 34-period EMA as trend indicator
- Opens long positions at EMA price when price crosses above EMA
- Implements triple take-profit targets (5%, 10%, 15%) for staged profit-taking
- Sets 7% stop-loss for risk control
- Maintains 10% position for long-term trend capture
- Implements 8-hour minimum trade interval to prevent overtrading
- Supports both fixed volume and dynamic position sizing
Strategy Advantages
- Multiple profit targets design performs well in various market conditions
- Partial position retention for long-term trends captures extended movements
- Supports leveraged trading with adjustable risk exposure
- Includes mechanisms to prevent overtrading
- Flexible position management with fixed or dynamic sizing options
- Fully automated execution requiring no manual intervention
- Highly parametric design accommodating different trading styles
Strategy Risks
- EMA as a lagging indicator may delay entry timing
- Multiple stop-losses possible in ranging markets
- Leverage may amplify losses
- Fixed percentage stop-loss may lack flexibility in volatile markets
- Multiple profit targets might exit strong trends too early Mitigation measures:
- Recommended for use in clear trending markets
- Adjust stop-loss based on market volatility
- Exercise caution with leverage
- Regular parameter optimization through backtesting
Optimization Directions
- Add trend strength filter to improve entry quality
- Implement dynamic stop-loss mechanism using ATR
- Incorporate volume confirmation indicators
- Develop adaptive profit target mechanism
- Add market condition assessment module
- Optimize dynamic trade interval adjustment These optimizations can enhance strategy stability and profitability while reducing false signals.
Summary
This is a well-designed trend following strategy with clear logic. It captures trends through EMA crossovers, manages risk with multiple profit targets, and retains partial positions for extended trends. The strategy's high adaptability suits traders with different risk preferences. While inherent risks exist, proper parameter settings and risk management can achieve stable returns.
Source Pine Script
/*backtest
start: 2024-02-08 00:00:00
end: 2025-02-06 08:00:00
period: 2d
basePeriod: 2d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA25 Long Strategy", overlay=true)
// Inputs
initial_capital = input.float(50000, title="Initial Capital ($)")
leverage = input.int(1, title="Leverage")
mode = input.string("Fixed Volume", title="Position Sizing Mode", options=["Fixed Volume", "Current Balance"])
ema_length = input.int(34, title="EMA Length")
stop_loss_percent = input.float(7, title="Stop Loss (%)", step=0.1) / 100
take_profit_1_percent = input.float(5, title="Take Profit 1 (%)", step=0.1) / 100
take_profit_2_percent = input.float(10, title="Take Profit 2 (%)", step=0.1) / 100
take_profit_3_percent = input.float(15, title="Take Profit 3 (%)", step=0.1) / 100
position_size_percent = input.float(100, title="Position Size (%)", step=1) / 100
long_term_hold_percent = input.float(10, title="Long Term Hold (%)", step=1) / 100
trade_delay = input.int(8, title="Trade Delay (hours)", minval=1) * 60 // Convert hours to minutes
// Calculate EMA
ema = ta.ema(close, ema_length)
// Plot EMA
plot(ema, title="EMA25", color=color.blue)
// Determine if a new trade can be placed
var float last_trade_time = na
can_trade = na(last_trade_time) or (time - last_trade_time) > trade_delay * 60 * 1000
// Determine position size based on selected mode
var float position_size = na
if (mode == "Fixed Volume")
position_size := initial_capital * leverage * position_size_percent / close
else
position_size := strategy.equity * leverage * position_size_percent / close
// Entry Condition
var float entry_price = na
price_crossed_ema_up = ta.crossover(close, ema)
price_crossed_ema_down = ta.crossunder(close, ema)
if ((price_crossed_ema_up or price_crossed_ema_down) and can_trade)
entry_price := ema
strategy.entry("Long", strategy.long, qty=position_size, limit=entry_price)
last_trade_time := time
label.new(bar_index, entry_price, text="Entry", color=color.green, style=label.style_label_up, textcolor=color.white, size=size.small)
// Stop Loss
strategy.exit("Stop Loss", from_entry="Long", stop=entry_price * (1 - stop_loss_percent))
// Take Profits
take_profit_1_price = entry_price * (1 + take_profit_1_percent)
take_profit_2_price = entry_price * (1 + take_profit_2_percent)
take_profit_3_price = entry_price * (1 + take_profit_3_percent)
strategy.exit("Take Profit 1", from_entry="Long", limit=take_profit_1_price, qty=position_size / 3)
strategy.exit("Take Profit 2", from_entry="Long", limit=take_profit_2_price, qty=position_size / 3)
strategy.exit("Take Profit 3", from_entry="Long", limit=take_profit_3_price, qty=position_size / 3)
// Long Term Hold (10% of position)
hold_qty = position_size * long_term_hold_percent
if (strategy.position_size > hold_qty)
strategy.close("Long Term Hold")Published by ChaoZhang on the FMZ strategy square · last modified 2025-02-08. 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-Target-EMA-Crossover-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 Dual EMA Trend Following StrategyPine Script · Trend following · 1d
- Fixed Range Volume Profile And Anchored VWAP Trend Identification Strategy With Dynamic Stop LossPine Script · Trend following · 1h
- Multi Exponential Moving Average Crossover Strategy with Volume Based ATR Dynamic Stop Loss OptimizationPine Script · Trend following · 2d
- Multi Factor Trend Price Action Strategy with Dynamic Risk Management SystemPine Script · Trend following · 2h
- Multi Period Moving Average Ribbon and MACD Crossover Strategy SystemPine Script · Trend following · 1h
- Multi Period Trend Following with Volume Confirmation StrategyPine Script · Trend following · 5d