Strategy vault / Mean reversion
Advanced Quantitative Trend Following and Cloud Reversal Composite Trading Strategy
This strategy is a composite trading system combining Exponential Moving Average (EMA) crossover and Ichimoku Cloud. EMA crossover is primarily used to capture trend initiation signals and confirm buying…

Overview
This strategy is a composite trading system combining Exponential Moving Average (EMA) crossover and Ichimoku Cloud. EMA crossover is primarily used to capture trend initiation signals and confirm buying opportunities, while the Ichimoku Cloud is used to identify market reversals and determine selling points. Through the coordination of multi-dimensional technical indicators, the strategy can effectively capture trends while timely avoiding risks.
Strategy Principle
The strategy operates through two core components:
- EMA Crossover Buy Signal: Uses the crossover of short-period (9-day) and long-period (21-day) exponential moving averages to confirm trend direction. A buy signal is generated when the short-term EMA crosses above the long-term EMA, indicating strengthening short-term momentum.
- Ichimoku Cloud Sell Signal: Determines trend reversals through price position relative to the cloud and internal cloud structure. Sell signals are triggered when price breaks below the cloud or when Leading Span A crosses below Leading Span B. The strategy includes stop-loss at 1.5% and take-profit at 3%.
Strategy Advantages
- Multi-dimensional Signal Confirmation: The combination of EMA crossover and Ichimoku Cloud validates trading signals from different perspectives.
- Comprehensive Risk Control: Fixed percentage stop-loss and profit targets effectively control risk for each trade.
- Strong Trend Capture Capability: EMA crossover captures trend initiation while Ichimoku Cloud effectively identifies trend endings.
- Clear and Objective Signals: Trading signals are automatically generated by technical indicators, reducing subjective judgment interference.
Strategy Risks
- Ranging Market Risk: May generate frequent false signals in sideways markets, leading to consecutive stops.
- Lag Risk: Both moving averages and Ichimoku Cloud have inherent lag, potentially missing optimal entry points in rapid market moves.
- Parameter Sensitivity: Strategy performance is sensitive to parameter settings, requiring adjustment in different market conditions.
Strategy Optimization
- Add Market Environment Filters: Include volatility or trend strength indicators to adjust strategy parameters based on market conditions.
- Optimize Stop-Loss Mechanism: Consider implementing dynamic stops, such as trailing stops or ATR-based stops.
- Enhance Signal Confirmation: Add volume and momentum indicators to improve signal reliability.
- Implement Position Sizing: Dynamically adjust position size based on signal strength and market volatility.
Summary
This strategy builds a trading system capable of both trend following and reversal capture through the organic combination of EMA crossover and Ichimoku Cloud. The strategy design is rational with proper risk control, showing good practical application value. Through the suggested optimization directions, there is room for further improvement. For live trading, it is recommended to first determine suitable parameter combinations through backtesting and make dynamic adjustments based on actual market conditions.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2025-01-04 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover Buy + Ichimoku Cloud Sell Strategy", overlay=true)
// Input Parameters for the EMAs
shortEmaPeriod = input.int(9, title="Short EMA Period", minval=1)
longEmaPeriod = input.int(21, title="Long EMA Period", minval=1)
// Input Parameters for the Ichimoku Cloud
tenkanPeriod = input.int(9, title="Tenkan-Sen Period", minval=1)
kijunPeriod = input.int(26, title="Kijun-Sen Period", minval=1)
senkouSpanBPeriod = input.int(52, title="Senkou Span B Period", minval=1)
displacement = input.int(26, title="Displacement", minval=1)
// Calculate the EMAs
shortEma = ta.ema(close, shortEmaPeriod)
longEma = ta.ema(close, longEmaPeriod)
// Ichimoku Cloud Calculations
tenkanSen = ta.sma(close, tenkanPeriod)
kijunSen = ta.sma(close, kijunPeriod)
senkouSpanA = ta.sma(tenkanSen + kijunSen, 2)
senkouSpanB = ta.sma(close, senkouSpanBPeriod)
chikouSpan = close[displacement]
// Plot the EMAs on the chart
plot(shortEma, color=color.green, title="Short EMA")
plot(longEma, color=color.red, title="Long EMA")
// Plot the Ichimoku Cloud
plot(tenkanSen, color=color.blue, title="Tenkan-Sen")
plot(kijunSen, color=color.red, title="Kijun-Sen")
plot(senkouSpanA, color=color.green, title="Senkou Span A", offset=displacement)
plot(senkouSpanB, color=color.purple, title="Senkou Span B", offset=displacement)
plot(chikouSpan, color=color.orange, title="Chikou Span", offset=-displacement)
// Buy Condition: Short EMA crosses above Long EMA
buyCondition = ta.crossover(shortEma, longEma)
// Sell Condition: Tenkan-Sen crosses below Kijun-Sen, and price is below the cloud
sellCondition = ta.crossunder(tenkanSen, kijunSen) and close < senkouSpanA and close < senkouSpanB
// Plot Buy and Sell signals
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Execute Buy and Sell Orders
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Optional: Add Stop Loss and Take Profit (risk management)
stopLossPercentage = input.float(1.5, title="Stop Loss Percentage", minval=0.1) / 100
takeProfitPercentage = input.float(3.0, title="Take Profit Percentage", minval=0.1) / 100
longStopLoss = close * (1 - stopLossPercentage)
longTakeProfit = close * (1 + takeProfitPercentage)
shortStopLoss = close * (1 + stopLossPercentage)
shortTakeProfit = close * (1 - takeProfitPercentage)
strategy.exit("Take Profit/Stop Loss", "Buy", stop=longStopLoss, limit=longTakeProfit)
strategy.exit("Take Profit/Stop Loss", "Sell", stop=shortStopLoss, limit=shortTakeProfit)
Published by ChaoZhang on the FMZ strategy square · last modified 2025-01-06. 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/Advanced-Quantitative-Trend-Following-and-Cloud-Reversal-Composite-Trading-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 Adaptive Multi Timeframe Trend Following and Range Reversal Hybrid StrategyPine Script · Mean reversion · 2d
- Advanced Momentum EMA Trend Following with RSI Overbought Oversold Trading StrategyPine Script · Mean reversion · 1d
- Bidirectional Moving Average Reversion Trading StrategyPine Script · Mean reversion · 1h
- Comprehensive Strategy of Multiple Candlestick PatternsPine Script · Mean reversion · 1h
- Customizable Non Repainting HTF MACD MFI Scalable Bot StrategyPine Script · Mean reversion · 1d
- Enhanced Bollinger Mean Reversion Quantitative StrategyPine Script · Mean reversion · 1d