
This is a trend-following strategy based on triple Exponential Moving Average (EMA) crossover signals. The strategy combines 9-period, 15-period, and 50-period EMAs, utilizing crossover signals between short-term and medium-term EMAs while using the long-term EMA as a trend filter, coupled with dynamic stop-loss and take-profit mechanisms for risk management. This strategy design fully considers both trend-following and risk management requirements, making it suitable for medium to long-term trading.
The core logic relies on monitoring crossover signals between the 9-period and 15-period EMAs while using the 50-period EMA as a trend confirmation indicator. Specifically: 1. Long entry signals are generated when price is above the 50-period EMA and the 9-period EMA crosses above the 15-period EMA 2. Exit signals occur when price is below the 50-period EMA and the 9-period EMA crosses below the 15-period EMA 3. Each trade incorporates fixed stop-loss and take-profit levels to protect capital and secure profits 4. The system includes alert functionality to notify traders of signal generation in real-time
This is a well-designed trend-following strategy with clear logic. The combination of multiple EMAs ensures signal reliability while achieving effective trend following. The built-in risk management mechanisms provide stability for strategy operation. Through the suggested optimization directions, there is room for further improvement. The strategy is suitable for traders seeking steady returns, but requires thorough testing and parameter optimization for specific market characteristics before implementation.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-11-27 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA Crossover Strategy with 50 EMA Filter", overlay=true)
// Customizable Inputs
ema9Length = input(9, title="EMA 9 Length")
ema15Length = input(15, title="EMA 15 Length")
ema50Length = input(50, title="EMA 50 Length")
stopLossPoints = input(100, title="Stop Loss Points")
takeProfitPoints = input(200, title="Take Profit Points")
// Calculate EMAs
ema9 = ta.ema(close, ema9Length)
ema15 = ta.ema(close, ema15Length)
ema50 = ta.ema(close, ema50Length)
// Detect crossovers
crossover_above = ta.crossover(ema9, ema15)
crossover_below = ta.crossunder(ema9, ema15)
// Plot EMAs
plot(ema9, color=color.blue, title="EMA 9")
plot(ema15, color=color.red, title="EMA 15")
// Make the 50 EMA invisible
plot(ema50, color=color.new(color.white, 100), title="EMA 50", display=display.none)
// Plot buy and sell signals as shapes
plotshape(crossover_above and close > ema50, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small)
plotshape(crossover_below and close < ema50, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small)
// Execute trades
if (crossover_above and close > ema50)
strategy.entry("Buy", strategy.long)
if (crossover_below and close < ema50)
strategy.close("Buy")
// Apply stop loss and take profit
if (crossover_above and close > ema50)
strategy.exit("Exit", from_entry="Buy", loss=stopLossPoints, profit=takeProfitPoints)
// Alerts for notifications
if (crossover_above and close > ema50)
alert("EMA 9 crossed above EMA 15 with price above EMA 50 - Buy Signal", alert.freq_once_per_bar_close)
if (crossover_below and close < ema50)
alert("EMA 9 crossed below EMA 15 with price below EMA 50 - Sell Signal", alert.freq_once_per_bar_close)