
이 전략은 이동평균선 교차 신호와 동적 위험 관리를 결합한 추세 추종 거래 시스템입니다. 빠르고 느린 지수 이동 평균(EMA)을 사용하여 시장 동향을 파악하고 이를 평균 참 범위(ATR) 지표와 결합하여 진입 시점을 최적화합니다. 동시에 이 전략은 백분율 손절매, 목표 이익 및 추적 손절매라는 3중 보호 메커니즘을 통합합니다.
전략의 핵심 논리는 다음과 같은 핵심 요소에 기초합니다.
이는 잘 설계되고 논리적으로 명확한 추세 추종 전략입니다. 이동평균선 교차를 통해 추세를 포착하고, ATR을 사용하여 위험을 통제하며, 다양한 손절매 메커니즘과 조정하면 완전한 거래 시스템이 형성됩니다. 이 전략의 주요 장점은 포괄적인 위험 관리와 높은 사용자 정의성이지만, 실제 거래에서는 거짓 신호와 거래 비용 문제에 주의해야 합니다. 제안된 최적화 방향을 통해 전략을 더욱 개선할 수 있는 여지가 여전히 남아 있습니다.
/*backtest
start: 2024-12-29 00:00:00
end: 2025-01-05 00:00:00
period: 2m
basePeriod: 2m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © jesusperezguitarra89
//@version=6
strategy("High Profit Buy/Sell Signals", overlay=true)
// Parámetros ajustables
fastLength = input.int(5, title="Fast EMA Length")
slowLength = input.int(20, title="Slow EMA Length")
atrLength = input.int(10, title="ATR Length")
atrMultiplier = input.float(2.5, title="ATR Multiplier")
stopLossPercent = input.float(1.0, title="Stop Loss %")
takeProfitPercent = input.float(5.0, title="Take Profit %")
trailingStop = input.float(2.0, title="Trailing Stop %")
// Cálculo de EMAs
fastEMA = ta.ema(close, fastLength)
slowEMA = ta.ema(close, slowLength)
// Cálculo del ATR
atr = ta.atr(atrLength)
// Señales de compra y venta
longCondition = ta.crossover(fastEMA, slowEMA) and close > slowEMA + atrMultiplier * atr
shortCondition = ta.crossunder(fastEMA, slowEMA) and close < slowEMA - atrMultiplier * atr
// Dibujar señales en el gráfico
plotshape(series=longCondition, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=shortCondition, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")
// Estrategia de backtesting para marcos de tiempo en minutos
if longCondition
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit", from_entry="Buy", limit=close * (1 + takeProfitPercent / 100), stop=close * (1 - stopLossPercent / 100), trail_points=atr * trailingStop)
if shortCondition
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit", from_entry="Sell", limit=close * (1 - takeProfitPercent / 100), stop=close * (1 + stopLossPercent / 100), trail_points=atr * trailingStop)
// Mostrar EMAs
plot(fastEMA, color=color.blue, title="Fast EMA")
plot(slowEMA, color=color.orange, title="Slow EMA")