
이 전략은 EMA와 SMA의 두 가지 이동 평균을 기반으로 한 교차 전략입니다. 느린 EMA가 아래에서 위로 빠른 SMA를 통과하면 구매 신호를 생성합니다. 느린 EMA가 위에서 아래로 빠른 SMA를 통과하면 판매 신호를 생성합니다. 이 전략은 황소 시장의 상승 추세를 포착하면서 약간의 지지를 제공합니다.
이 전략은 두 개의 이동 평균을 사용한다: 20 주기의 SMA와 21 주기의 EMA. EMA가 아래에서 위쪽으로 SMA를 통과하면 시장이 상승 추세로 전환하고 있기 때문에 구매 신호가 발생한다. 반대로, EMA가 위쪽으로 SMA를 통과하면 시장이 하향 추세로 전환하고 있기 때문에 판매 신호가 발생한다. 신호를 확인하기 위해, 이 전략은 또한 현재 종결 가격을 이전 종결 가격보다 높게 요구한다 (구매 신호) 또는 이전 종결 가격보다 낮게 (판매 신호).
평선 교차 황소 시장 지지대 전략은 단순하고 이해하기 쉬운 트렌드 추적 전략으로, 특히 황소 시장 시에 적합하다. 그러나, 이 전략은 또한 잘못된 신호, 낙후성 및 트렌드 식별 능력 등과 같은 제한이 있다. 다른 지표와 최적화 파라미터를 결합하고 스톱 스톱을 추가하는 방법과 같은 전략을 추가하여 전략의 성과와 안정성을 더욱 향상시킬 수 있다.
/*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")