Overview
This strategy is a trend-following trading system based on the crossover of 110-day and 200-day Exponential Moving Averages (EMA). It identifies market trends through the intersection of short-term and long-term EMAs, incorporating stop-loss and take-profit mechanisms for risk control. The system automatically executes long and short positions upon trend confirmation while continuously monitoring position risk.
Strategy Principle
The core logic relies on the continuity of price trends, using EMA110 and EMA200 crossovers to capture trend reversal signals. When the shorter-term moving average (EMA110) crosses above the longer-term moving average (EMA200), it signals an uptrend formation, triggering a long position. Conversely, when the shorter-term moving average crosses below the longer-term moving average, it signals a downtrend formation, triggering a short position. For risk management, the strategy sets a 1% stop-loss and 0.5% take-profit level for each position to protect profits and limit potential losses.
Strategy Advantages
- Strong trend capture capability: Effectively filters short-term market noise through dual moving average crossovers
- Comprehensive risk control: Integrated stop-loss and take-profit mechanisms effectively control single-trade risk
- Rigorous execution logic: Automatically closes reverse positions before opening new ones, avoiding position overlap
- Clear signal indication: Trade signals are clearly displayed in the top-right corner table
- Reasonable parameter settings: 110-day and 200-day periods balance sensitivity and stability
Strategy Risks
- Sideways market risk: Frequent trading in range-bound markets may lead to losses
- Slippage risk: Significant slippage may occur during high market volatility
- Trend reversal risk: Stop-losses may not trigger quickly enough during sudden trend reversals
- Parameter optimization risk: Over-optimization may lead to strategy overfitting
- Systemic risk: Exposure to systemic risks during extreme market conditions
Strategy Optimization Directions
- Incorporate volume indicators: Confirm trend validity through volume analysis
- Optimize stop-loss mechanism: Consider implementing trailing stops or ATR-based dynamic stops
- Add trend filters: Integrate trend strength indicators to filter weak signals
- Improve position management: Dynamically adjust position sizes based on trend strength
- Implement drawdown control: Set maximum drawdown limits to pause trading when thresholds are reached
Summary
The strategy captures trends through moving average crossovers while managing risk through stop-loss and take-profit mechanisms, demonstrating sound design and logical rigor. Although it may underperform in ranging markets, the suggested optimizations can further enhance strategy stability and profitability. The strategy is suitable for medium to long-term investors seeking steady returns.
Strategy source code
/*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("EMA110/200 Cross with Stop-Loss and Take-Profit", overlay=true)
// Defining EMA110 and EMA200
ema110 = ta.ema(close, 110)
ema200 = ta.ema(close, 250)
// Plot EMA
plot(ema110, color=color.blue, title="EMA110")
plot(ema200, color=color.red, title="EMA200")
// Calculating Crossover Signals
longCondition = ta.crossover(ema110, ema200) // EMA110 crosses EMA200, go long
shortCondition = ta.crossunder(ema110, ema200) // EMA110 crosses below EMA200, go short
// Set stop loss and take profit
stopLoss = 0.01 // Stop loss 1%
takeProfit = 0.005 // Take profit 0.5%
// Determine whether there is a position
isLong = strategy.position_size > 0 // Is the current position a long position?
isShort = strategy.position_size < 0 // Is the current position a short position?
// Execute the strategy: close short when long, close long when short
if (longCondition and not isLong) // If the long conditions are met and there is no current long position
if (isShort) // If the current position is short, close the short position first
strategy.close("Short")
strategy.entry("Long", strategy.long) // Execute Long
strategy.exit("Take Profit/Stop Loss", "Long", stop=close * (1 - stopLoss), limit=close * (1 + takeProfit))
if (shortCondition and not isShort) // If the short selling conditions are met and there is no current short position
if (isLong) // If the current position is long, close the long position first
strategy.close("Long")
strategy.entry("Short", strategy.short) // Execute short
strategy.exit("Take Profit/Stop Loss", "Short", stop=close * (1 + stopLoss), limit=close * (1 - takeProfit))
// Display signals in a table
var table myTable = table.new(position.top_right, 1, 1)
if (longCondition and not isLong)
table.cell(myTable, 0, 0, "Buy Signal", text_color=color.green)
if (shortCondition and not isShort)
table.cell(myTable, 0, 0, "Sell Signal", text_color=color.red)
The original address: https://www.fmz.com/strategy/475597