Adaptive EMA Dynamic Position Break out Trading Strategy
This strategy is an adaptive trading system based on a dual moving average system, which identifies buy signals through the crossover of fast moving average (EMA25) and slow moving average (EMA100), combined with…

Overview
This strategy is an adaptive trading system based on a dual moving average system, which identifies buy signals through the crossover of fast moving average (EMA25) and slow moving average (EMA100), combined with dynamic stop-loss and profit targets to optimize trading performance. The strategy adopts a breakout trading approach, focusing on risk control while ensuring returns, suitable for medium to long-term trend trading.
Strategy Principle
The core logic of the strategy includes three key components:
- Signal System: Using EMA25 crossing above EMA100 to generate long signals, which typically indicates the beginning of an uptrend.
- Risk Control: Using the lowest point of the most recent red candle below EMA100 as the stop-loss point, effectively preventing losses from false breakouts.
- Profit Management: Adopting a 1:3 risk-reward ratio for profit targets, and automatically adjusting the stop-loss to breakeven when reaching 2% profit, achieving risk-free position holding.
Strategy Advantages
- High Signal Reliability: Using slow EMA for trend confirmation effectively filters false signals.
- Comprehensive Risk Control: Dynamic stop-loss settings and breakout confirmation mechanism reduce trading risks.
- Stable Return Characteristics: Reasonable risk-reward ratio setting improves strategy's expected returns.
- High Automation Level: Includes complete signal generation, stop-loss/take-profit, and position management logic.
- Strong Adaptability: Parameters can be adjusted according to different market conditions.
Strategy Risks
- Oscillating Market Risk: May trigger frequent stop-losses in sideways markets.
- Slippage Risk: May face execution slippage during high volatility periods.
- False Breakout Risk: Moving average crossover signals may produce false breakouts.
- Parameter Sensitivity: Moving average period settings significantly impact strategy performance.
Strategy Optimization Directions
- Incorporate Volume Confirmation: Add volume indicators to the signal system to improve breakout reliability.
- Optimize Stop-Loss Mechanism: Consider introducing ATR dynamic stop-loss for better adaptability.
- Add Trend Strength Filtering: Include trend strength indicators like ADX to optimize entry timing.
- Perfect Position Management: Dynamically adjust position size based on volatility.
- Include Market Environment Assessment: Introduce market regime identification mechanism to adopt different parameter settings in different market environments.
Summary
The strategy captures trend initiation points through moving average crossovers, coupled with dynamic stop-loss and profit management mechanisms, achieving favorable risk-reward characteristics. The strategy design fully considers practical requirements and demonstrates strong practicality. Through the suggested optimization directions, the strategy's stability and adaptability can be further enhanced. It is suitable for traders with strong risk tolerance who pursue medium to long-term stable returns.
Source Pine Script
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-18 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover with TP and SL (Buy only) and Break-even", overlay=true)
// EMA sozlamalari
emaFastLength = input.int(25, title="Fast EMA Length")
emaSlowLength = input.int(100, title="Slow EMA Length")
// Hisoblash
emaFast = ta.ema(close, emaFastLength)
emaSlow = ta.ema(close, emaSlowLength)
// Kesishishni aniqlash
bullishCross = ta.crossover(emaFast, emaSlow) // EMA 25 EMA 100 ni yuqoriga kesib o'tganda
// EMA 100 tagidagi oxirgi qizil shamning tagini olish
lastRedCandleLow = ta.valuewhen(close < open and close < emaSlow, low, 0) // EMA 100 pastidagi qizil shamning tagi
// TP va SL darajalarini hisoblash
longSL = lastRedCandleLow
longTP = close + 3 * (close - longSL) // TP SL ga nisbatan 1:2 masofada
// Savdoni ochish va 2% foyda bo'lganda SLni break-even ga o'zgartirish
if (bullishCross)
strategy.entry("Buy", strategy.long) // Buy pozitsiyasini ochish
strategy.exit("Exit Buy", "Buy", stop=longSL, limit=longTP) // SL va TP qo'yish
// 2% foyda bo'lganda SLni break-even ga o'zgartirish
if (strategy.position_size > 0)
profitPercentage = (close - strategy.position_avg_price) / strategy.position_avg_price * 100
if (profitPercentage >= 2)
strategy.exit("Exit Buy BE", "Buy", stop=strategy.position_avg_price) // SLni break-even ga o'zgartirish
// Signalni ko'rsatish
plotshape(bullishCross, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
// // TP va SL chizish
// if (bullishCross)
// line.new(x1=bar_index, y1=longSL, x2=bar_index+1, y2=longSL, color=color.red, width=1, extend=extend.none)
// line.new(x1=bar_index, y1=longTP, x2=bar_index+1, y2=longTP, color=color.green, width=1, extend=extend.none)
// label.new(bar_index, longSL, text="SL: " + str.tostring(longSL), style=label.style_label_down, color=color.red, textcolor=color.white, size=size.small)
// label.new(bar_index, longTP, text="TP: " + str.tostring(longTP), style=label.style_label_up, color=color.green, textcolor=color.white, size=size.small)
// EMA chizish
plot(emaFast, color=color.blue, title="Fast EMA (25)")
plot(emaSlow, color=color.orange, title="Slow EMA (100)")
// Alert qo'shish
alertcondition(bullishCross, title="Buy Signal Alert", message="EMA 25 crossed above EMA 100! Buy Signal!")
Published by ChaoZhang on the FMZ strategy square · last modified 2024-12-20. 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-EMA-Dynamic-Position-Break-out-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
- Multi Filter Trend Breakthrough Smart Moving Average Trading StrategyPine Script · Breakout · 1h
- Multi Technical Indicator Dynamic Wave Trading StrategyPine Script · Breakout · 1h
- Multi Technical Indicator Trend Following Channel Breakout Trading Strategy with Candlestick Pattern Filtering SystemPine Script · Breakout · 1h
- Pivot Based Volume Weighted Breakout Reversal StrategyPine Script · Breakout · 1d
- Multi Strategy Adaptive Trend Following and Breakout Trading SystemPine Script · Breakout · 1d
- Multi Trend Breakout Momentum Trading StrategyPine Script · Breakout · 1d