Strategy vault / Trend following
Triple EMA Crossover Strategy
The Triple EMA Crossover Strategy is a trading strategy based on the crossover signals generated by three exponential moving averages (EMAs) with different periods. The strategy employs a fast EMA (10 periods), a…

Overview
The Triple EMA Crossover Strategy is a trading strategy based on the crossover signals generated by three exponential moving averages (EMAs) with different periods. The strategy employs a fast EMA (10 periods), a medium EMA (25 periods), and a slow EMA (50 periods) to capture market trends while using the Average True Range (ATR) to set stop-loss and take-profit levels that adapt to different market volatility conditions. A bullish signal is generated when the fast EMA crosses above the slow EMA, and the medium EMA is also above the slow EMA; conversely, a bearish signal is triggered when the fast EMA crosses below the slow EMA, and the medium EMA is also below the slow EMA.
Strategy Principle
- Calculate three EMAs with different periods: fast (10), medium (25), and slow (50).
- Generate a bullish crossover signal when the fast EMA crosses above the slow EMA, and the medium EMA is above the slow EMA.
- Generate a bearish crossover signal when the fast EMA crosses below the slow EMA, and the medium EMA is below the slow EMA.
- Use ATR to calculate dynamic stop-loss and take-profit levels, setting the stop-loss at 3 times the ATR and the take-profit at 6 times the ATR.
- Enter a long position when a bullish crossover signal appears, setting the stop-loss and take-profit levels.
- Enter a short position when a bearish crossover signal appears, setting the stop-loss and take-profit levels.
Strategy Advantages
- The Triple EMA Crossover Strategy effectively filters out market noise and focuses on capturing major trends.
- By using EMAs with different periods, the strategy reacts more quickly to price changes while ensuring that signals are supported by medium to long-term trends.
- Utilizing ATR to dynamically adjust stop-loss and take-profit levels allows the strategy to adapt to different market volatility conditions, enhancing the effectiveness of risk management.
Strategy Risks
- In ranging or highly volatile markets, the strategy may generate false signals, leading to frequent trading and potential losses.
- The strategy's performance largely depends on the choice of EMA periods, and inappropriate parameter settings may result in decreased signal quality.
- Relying solely on moving average crossover signals may not provide a comprehensive market analysis, and the strategy should be used in conjunction with other technical indicators to confirm trends and signals.
Strategy Optimization Directions
- Consider incorporating other technical indicators, such as the Relative Strength Index (RSI) or Stochastic Oscillator, to validate the effectiveness of trends and crossover signals.
- Conduct parameter optimization tests for different market conditions and asset classes to identify the best combination of EMA periods and ATR multiplier settings.
- Introduce risk management measures, such as dynamically adjusting position sizes based on market volatility or halting trading under specific market conditions, to further control risks.
Summary
The Triple EMA Crossover Strategy offers traders an effective method for trend-following and risk management by leveraging crossover signals from exponential moving averages with different periods, combined with dynamic stop-loss and take-profit settings using ATR. Although the strategy performs well in trending markets, it may face challenges in ranging markets. Therefore, traders should consider combining it with other technical analysis tools and optimizing parameters for different market conditions and asset classes to enhance the strategy's reliability and profit potential.
Parameters
| Name | Default | What it controls |
|---|---|---|
| v_input_1 | 10 | Fast EMA Length |
| v_input_2 | 25 | Medium EMA Length |
| v_input_3 | 50 | Slow EMA Length |
| v_input_4 | 3 | Risk Multiplier for Stop Loss and Take Profit |
Source Pine Script
/*backtest
start: 2024-03-01 00:00:00
end: 2024-03-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Triple EMA Crossover Strategy", overlay=true, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// Input for EMA periods
fastLength = input(10, title="Fast EMA Length")
mediumLength = input(25, title="Medium EMA Length")
slowLength = input(50, title="Slow EMA Length")
riskMultiplier = input(3.0, title="Risk Multiplier for Stop Loss and Take Profit")
// Calculating EMAs
fastEMA = ta.ema(close, fastLength)
mediumEMA = ta.ema(close, mediumLength)
slowEMA = ta.ema(close, slowLength)
// Plot EMAs
plot(fastEMA, color=color.red, title="Fast EMA")
plot(mediumEMA, color=color.orange, title="Medium EMA")
plot(slowEMA, color=color.yellow, title="Slow EMA")
// Define the crossover conditions for a bullish and bearish signal
bullishCrossover = ta.crossover(fastEMA, slowEMA) and mediumEMA > slowEMA
bearishCrossover = ta.crossunder(fastEMA, slowEMA) and mediumEMA < slowEMA
// ATR for stop and limit calculations
atr = ta.atr(14)
longStopLoss = close - atr * riskMultiplier
shortStopLoss = close + atr * riskMultiplier
longTakeProfit = close + atr * riskMultiplier * 2
shortTakeProfit = close - atr * riskMultiplier * 2
// Entry signals with visual shapes
plotshape(series=bullishCrossover, location=location.belowbar, color=color.green, style=shape.triangleup, title="Buy Signal", text="BUY")
plotshape(series=bearishCrossover, location=location.abovebar, color=color.red, style=shape.triangledown, title="Sell Signal", text="SELL")
// Strategy execution
if (bullishCrossover)
strategy.entry("Long", strategy.long)
strategy.exit("Exit Long", "Long", stop=longStopLoss, limit=longTakeProfit)
if (bearishCrossover)
strategy.entry("Short", strategy.short)
strategy.exit("Exit Short", "Short", stop=shortStopLoss, limit=shortTakeProfit)
// Color bars based on EMA positions
barcolor(fastEMA > slowEMA ? color.green : slowEMA > fastEMA ? color.red : na, title="Bar Color")Published by ChaoZhang on the FMZ strategy square · last modified 2024-04-30. 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/Triple-EMA-Crossover-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
- EMA200 and Stochastic RSI StrategyPine Script · Trend following · 1h
- Trend Tracking Strategy Based on Multi factor Model with Adaptive Trailing StoplossPine Script · Trend following · 1d
- Mini Pullback Supertrend StrategyPine Script · Trend following · 1h
- Three Exponential Moving Averages and Stochastic Relative Strength Index Trading StrategyPine Script · Trend following · 1h
- Triple SuperTrend Quantitative Trading StrategyPine Script · Trend following · 1d
- Triple SuperTrend and Stoch RSI StrategyPine Script · Trend following · 1d