
이 전략은 8주기 및 21주기 지수 이동 평균 (EMA) 과 패러블 라인 SAR 지표를 결합하여 트렌드를 포착하고 위험을 관리합니다. 이 전략은 특정 교차와 가격 행동 조건에 따라 포지션을 개시하고 포지션을 종료하며, 고정된 스톱 손실과 특정 시간 동안 필드 포지션을 포함 한 출구 규칙을 정의합니다.
이 전략은 두 개의 다른 주기의 EMA ((8주기 및 21주기) 와 패러폴리 라인 SAR 지표를 사용하여 포지션 개시 및 포지션 조건을 결정한다. 단기 EMA가 장기 EMA 위를 가로질러 SAR보다 높은 마감 가격으로 마감되면 전략은 상위 포지션을 열고, 단기 EMA가 장기 EMA 아래를 가로질러 SAR보다 낮은 마감 가격으로 마감되면 전략은 상위 포지션을 열고.
EMA 평행선과 평행선 SAR 조합 전략은 두 가지 일반적으로 사용되는 기술 지표를 결합하여 트렌드를 포착하고 위험을 제어하려고합니다. 이 전략은 간단하고 이해하기 쉽고 초보자 학습 및 사용에 적합합니다. 그러나 이 전략에는 시장의 변동에 대한 적응력이 부족하고 시장 정서 및 기본 요소에 대한 고려가 부족하는 것과 같은 몇 가지 제한이 있습니다. 따라서 실제 응용에서는 시장과 특정 거래 유형에 따라 전략이 최적화되고 개선되어야 안정성과 수익성을 높일 수 있습니다.
/*backtest
start: 2024-05-01 00:00:00
end: 2024-05-31 23:59:59
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("EMA and Parabolic SAR Strategy", overlay=true)
// Input parameters for EMAs and Parabolic SAR
emaShortPeriod = input.int(8, title="Short EMA Period")
emaLongPeriod = input.int(21, title="Long EMA Period")
sarStart = input.float(0.02, title="Parabolic SAR Start")
sarIncrement = input.float(0.02, title="Parabolic SAR Increment")
sarMaximum = input.float(0.2, title="Parabolic SAR Maximum")
fixedSL = input.int(83, title="Fixed Stop Loss (pts)")
// Calculate EMAs and Parabolic SAR
emaShort = ta.ema(close, emaShortPeriod)
emaLong = ta.ema(close, emaLongPeriod)
sar = ta.sar(sarStart, sarIncrement, sarMaximum)
// Entry conditions
longCondition = ta.crossover(emaShort, emaLong) and close > sar
shortCondition = ta.crossunder(emaShort, emaLong) and close < sar
// Exit conditions
longExitCondition = close < sar
shortExitCondition = close > sar
// Strategy entry and exit
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
if (longExitCondition)
strategy.close("Long")
if (shortExitCondition)
strategy.close("Short")
// Fixed Stop Loss
strategy.exit("Long Exit", "Long", stop=close - fixedSL * syminfo.mintick)
strategy.exit("Short Exit", "Short", stop=close + fixedSL * syminfo.mintick)
// Exit all positions at 15:15
exitHour = 15
exitMinute = 15
exitTime = timestamp(year(timenow), month(timenow), dayofmonth(timenow), exitHour, exitMinute)
if (timenow >= exitTime)
strategy.close_all()
// Plot EMAs and Parabolic SAR
plot(emaShort, color=color.blue, title="8 EMA")
plot(emaLong, color=color.red, title="21 EMA")
plot(sar, style=plot.style_cross, color=color.green, title="Parabolic SAR")