This is a trend-following strategy based on Exponential Moving Average (EMA) crossovers and Relative Strength Index (RSI) confirmation. The strategy combines signals from short-term and long-term EMA crossovers with RSI momentum confirmation, while incorporating a percentage-based stop-loss mechanism. It aims to capture significant market trend reversals while maintaining risk control through the synergistic effect of technical indicators.
The strategy employs a dual technical indicator filtering mechanism: First, it identifies potential trend reversal points through the crossover of short-term EMA (9 periods) and long-term EMA (21 periods). Buy signals are generated when the short-term EMA crosses above the long-term EMA and the RSI value is above the specified level. Sell signals occur when the short-term EMA crosses below the long-term EMA and the RSI value is below the specified level. Additionally, the strategy incorporates a percentage-based stop-loss mechanism, setting dynamic stop-loss levels for each trade to effectively control downside risk.
This strategy constructs a complete trend-following trading system through the combination of moving averages and momentum indicators. Its main advantages lie in its reliable signal confirmation mechanism and comprehensive risk control system. While there are some inherent limitations, the strategy’s overall performance can be further enhanced through the proposed optimization directions. This is a robust strategy framework suitable for medium to long-term trend traders.
/*backtest start: 2019-12-23 08:00:00 end: 2024-12-25 08:00:00 period: 1d basePeriod: 1d exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Simple Trend Following Strategy", overlay=true) // Inputs shortEMA = input.int(9, title="Short EMA Length", minval=1) longEMA = input.int(21, title="Long EMA Length", minval=1) confirmationRSI = input.int(50, title="RSI Confirmation Level", minval=1, maxval=100) stopLossPercent = input.float(2, title="Stop Loss Percentage", minval=0.1) // Stop Loss percentage // Calculations emaShort = ta.ema(close, shortEMA) emaLong = ta.ema(close, longEMA) rsiValue = ta.rsi(close, 14) // Buy and Sell Conditions buySignal = ta.crossover(emaShort, emaLong) and rsiValue > confirmationRSI sellSignal = ta.crossunder(emaShort, emaLong) and rsiValue < confirmationRSI // Plotting Signals plotshape(buySignal, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, text="BUY") plotshape(sellSignal, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL") // Plotting EMAs plot(emaShort, title="Short EMA", color=color.yellow) plot(emaLong, title="Long EMA", color=color.purple) // Strategy logic strategy.entry("Buy", strategy.long, when=buySignal) strategy.entry("Sell", strategy.short, when=sellSignal) // Calculate stop loss price based on stopLossPercent longStopLossPrice = strategy.position_avg_price * (1 - stopLossPercent / 100) shortStopLossPrice = strategy.position_avg_price * (1 + stopLossPercent / 100) // Draw stop loss line for long positions if (strategy.position_size > 0) // For long positions line.new(x1=bar_index, y1=longStopLossPrice, x2=bar_index + 1, y2=longStopLossPrice, color=color.red, width=2, style=line.style_dashed) // Draw stop loss line for short positions if (strategy.position_size < 0) // For short positions line.new(x1=bar_index, y1=shortStopLossPrice, x2=bar_index + 1, y2=shortStopLossPrice, color=color.green, width=2, style=line.style_dashed)