
이 전략은 지수 이동 평균 (EMA) 의 교차를 기반으로 한 다단계 전략이다. 가격이 아래에서 EMA를 돌파할 때 다단계 입장을 취하고, 가격이 위로부터 EMA를 돌파할 때 평점을 취한다. 이 전략은 또한 잠재적인 하향 위험을 제어하고 수익을 고정하기 위해 보조적인 위험 관리 조치로 SL, 목표 수익 (TP) 및 추적 중지 (TSL) 을 포함합니다.
이 전략은 EMA 교차를 기반으로 한 간단하고 효과적인 거래 방법을 제공하며, EMA를 돌파하는 잠재적인 트렌드를 따라가는 동시에 중지, 목표 수익, 그리고 중지 손실을 추적하는 것과 같은 위험 관리 조치를 취한다. 그러나, 전략에는 가짜 돌파, 신호 지연, 충격 시장의 부적절한 성능 및 파라미터 민감성 등의 위험이 있습니다. 최적화 전략은 다른 지표, 동적 중지 수익 설정, 트렌드 확인 및 다중 시간 프레임 분석과 함께 고려 할 수 있습니다. 실제 응용에서는 특정 시장과 거래 스타일에 따라 적절한 조정이 필요합니다. 실제 계정에 배치하기 전에, 회수 테스트 및 시뮬레이션 환경에서 전략을 완전히 테스트하고 최적화해야합니다.
/*backtest
start: 2023-04-23 00:00:00
end: 2024-04-28 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=4
strategy("Long Entry on EMA Cross with Risk Management", overlay=true)
// Parameters
emaLength = input(20, title="EMA Length")
stopLossPercent = input(1, title="Stop Loss %")
targetPercent = input(2, title="Target %")
trailingStopLossPercent = input(0.5, title="Trailing Stop Loss %")
// Calculate EMA
ema = ema(close, emaLength)
// Long Entry Condition
longCondition = crossover(close, ema)
// Exit Condition
exitCondition = crossunder(close, ema)
// Stop Loss, Target Profit, Trailing Stop Loss
stopLossLevel = strategy.position_avg_price * (1 - stopLossPercent / 100)
targetProfitLevel = strategy.position_avg_price * (1 + targetPercent / 100)
trailingStopLossLevel = close * (1 - trailingStopLossPercent / 100)
trailingStopLossLevel := max(trailingStopLossLevel, nz(trailingStopLossLevel[1]))
// Submit Long Order
strategy.entry("Long", strategy.long, when=longCondition)
// Submit Exit Orders
strategy.exit("Exit", "Long", stop=stopLossLevel, limit=targetProfitLevel, trail_offset=trailingStopLossLevel, when=exitCondition)
// Plot EMA
plot(ema, color=color.blue, linewidth=2)
// Plot Stop Loss, Target Profit, and Trailing Stop Loss Levels
plot(stopLossLevel, title="Stop Loss", color=color.red, linewidth=2)
plot(targetProfitLevel, title="Target Profit", color=color.green, linewidth=2)
plot(trailingStopLossLevel, title="Trailing Stop Loss", color=color.orange, linewidth=2)