This strategy is a crossover strategy based on two moving averages, EMA and SMA. When the slower EMA crosses above the faster SMA, it generates a buy signal; when the slower EMA crosses below the faster SMA, it generates a sell signal. The strategy aims to capture upward trends in bull markets while providing some support.
The strategy uses two moving averages: a 20-period SMA and a 21-period EMA. When the EMA crosses above the SMA, it indicates that the market may be turning into an upward trend, thus generating a buy signal. Conversely, when the EMA crosses below the SMA, it indicates that the market may be turning into a downward trend, thus generating a sell signal. To confirm the signals, the strategy also requires the current closing price to be higher than the previous closing price (for buy signals) or lower than the previous closing price (for sell signals).
The EMA-SMA Crossover Bull Market Support Band Strategy is a simple and easy-to-understand trend-following strategy that is particularly suitable for bull markets. However, the strategy also has certain limitations, such as false signals, lag, and limited trend recognition ability. By combining with other indicators, optimizing parameters, and adding stop-loss and take-profit, the performance and robustness of the strategy can be further improved.
/*backtest start: 2023-05-17 00:00:00 end: 2024-05-22 00:00:00 period: 1d basePeriod: 1h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ // This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/ // © rodrinverte //@version=5 strategy("EMA-SMA Crossover Strategy", overlay=true, initial_capital = 1000) // Definir la longitud de las medias móviles fast = ta.sma(close, 20) slow = ta.ema(close, 21) // Definir condiciones de compra y venta buySignal = ta.crossover(slow, fast) sellSignal = ta.crossunder(slow, fast) // Configurar colores de las líneas y relleno emaColor = buySignal ? color.green : sellSignal ? color.red : color.blue smaColor = color.gray fillColor = slow < fast ? color.new(color.green, 90) : color.new(color.red, 90) // Esperar un periodo para confirmar la señal de compra o venta buyConfirmation = close > close[1] and buySignal sellConfirmation = close < close[1] and sellSignal // Dibujar las medias móviles plot(slow, title="EMA", color=emaColor) plot(fast, title="SMA", color=smaColor) // Configurar las señales de compra y venta plotshape(buyConfirmation, style=shape.triangleup, location=location.belowbar, color=color.green, size=size.small) plotshape(sellConfirmation, style=shape.triangledown, location=location.abovebar, color=color.red, size=size.small) // Estrategia de compra y venta if (buyConfirmation) strategy.entry("Buy", strategy.long) if (sellConfirmation) strategy.entry("Sell", strategy.short) // Cerrar posición opuesta al cruce original if (sellSignal) strategy.close("Buy") if (buySignal) strategy.close("Sell")