
이 전략은 9주기 및 21주기 지수 이동 평균 (EMA) 의 교차 상황을 모니터링하여 거래하는 쌍평선 교차를 기반으로 한 거래 시스템입니다. 전략은 10분 시간 프레임 내에서 작동하며, 포지션을 보유 할 때 포지션을 재개하지 않는 단편 거래 모드를 사용합니다. 시스템은 초기 자본 100,000을 사용하여, 각 거래는 계정 지분의 10%를 사용하여 작동합니다.
전략의 핵심 원칙은 단기 EMA가 시장 가격 변화에 대한 민감도가 긴 기간 EMA의 특성보다 높다는 것입니다. 단기 EMA ((9주기) 가 상향으로 긴 기간 EMA ((21주기) 를 통과하면 단기 상향이 증가하는 것을 나타냅니다. 시스템이 여러 신호를 냅니다. 단기 EMA가 하향으로 긴 기간 EMA를 통과하면 단기 하향이 증가하는 것을 나타냅니다. 시스템이 평지 신호를 냅니다.
이것은 합리적이고 논리적으로 명확하게 설계된 일직선 교차 전략이다. EMA 교차는 시장의 추세를 포착하고, 단편 거래 모드 및 비율 포지션 관리와 함께, 위험과 수익의 균형을 이룬다. 일부 고유 한 한계가 있음에도 불구하고, 제안된 최적화 방향을 통해 전략의 안정성과 적응력을 더욱 향상시킬 수 있다. 실제 적용에서, 거래자는 특정 시장 특성과 개인 위험 선호에 따라 그에 따른 조정을 할 것을 권장한다.
/*backtest
start: 2024-02-25 00:00:00
end: 2025-02-22 08:00:00
period: 1h
basePeriod: 1h
exchanges: [{"eid":"Binance","currency":"SOL_USDT"}]
*/
//@version=6
strategy("EMA Crossover Labels (One Trade at a Time)", overlay=true, initial_capital=100000, default_qty_type=strategy.percent_of_equity, default_qty_value=10)
// ==== User Inputs ====
// Set the testing timeframe (ensure the chart is on a 10-min timeframe)
testTimeFrame = input.timeframe("10", "Strategy Timeframe")
// EMA period inputs
emaPeriod9 = input.int(9, "EMA 9 Period", minval=1)
emaPeriod21 = input.int(21, "EMA 2q Period", minval=1)
// ==== Retrieve Price Data ====
// For simplicity, we use the chart's timeframe (should be 10-min)
price = close
// ==== Calculate EMAs ====
ema9 = ta.ema(price, emaPeriod9)
ema21 = ta.ema(price, emaPeriod21)
// ==== Define Crossover Conditions ====
// Buy signal: when EMA9 crosses above EMA21 AND no current position is open
buySignal = ta.crossover(ema9, ema21) and strategy.position_size == 0
// Sell signal: when EMA9 crosses below EMA21 AND a long position is active
sellSignal = ta.crossunder(ema9, ema21) and strategy.position_size > 0
// ==== Strategy Orders ====
// Enter a long position when a valid buy signal occurs
if buySignal
strategy.entry("Long", strategy.long)
alert("Long Signal: " + syminfo.tickerid + " - EMA9 crossed above EMA21", alert.freq_once_per_bar_close)
// Exit the long position when a valid sell signal occurs
if sellSignal
strategy.close("Long")
alert("Sell Long Signal: " + syminfo.tickerid + " - EMA9 crossed below EMA21", alert.freq_once_per_bar_close)
// ==== Plot Buy/Sell Labels ====
// Only plot a "Buy" label if there's no open position
plotshape(buySignal, title="Buy Label", location=location.belowbar, color=color.green, style=shape.labelup, text="Buy", textcolor=color.white)
// Only plot a "Sell" label if a position is active
plotshape(sellSignal, title="Sell Label", location=location.abovebar, color=color.red, style=shape.labeldown, text="Sell", textcolor=color.white)
// ==== Plot EMAs for Visualization ====
plot(ema9, color=color.blue, title="EMA 21")
plot(ema21, color=color.orange, title="EMA 21")