
이 전략은 두 개의 지수 이동 평균 ((EMA) 을 사용하여 가격 추세의 변화를 포착합니다. 단기 EMA가 아래쪽에서 장기 EMA를 통과하면 구매 신호를 생성합니다. 단기 EMA가 위쪽에서 장기 EMA를 통과하면 판매 신호를 생성합니다. 이 전략은 일일 손실과 수익을 제어하기 위해 일일 중지 및 중지 제한을 동시에 설정합니다.
EMA 쌍평평선 교차 전략은 간단하고 이해하기 쉬운 트렌드 시장에 적합한 거래 전략이다. 빠른 느린 평평선 교차를 통해 가격 트렌드의 변화를 더 잘 포착할 수 있다. 동시에, 매일의 중지 손실과 중지 설정은 위험을 효과적으로 제어할 수 있다. 그러나 이 전략은 불안한 시장이나 트렌드 전환 시 좋지 않은 성능을 발휘할 수 있으며, 다른 기술 지표 및 분석 방법과 함께 최적화 및 개선이 필요합니다.
/*backtest
start: 2023-06-01 00:00:00
end: 2024-06-06 00:00:00
period: 1d
basePeriod: 1h
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/
// © DD173838
//@version=5
strategy("Moving Average Strategy with Daily Limits", overlay=true)
// Moving Average settings
shortMaLength = input.int(9, title="Short MA Length")
longMaLength = input.int(21, title="Long MA Length")
// Calculate MAs
shortMa = ta.ema(close, shortMaLength)
longMa = ta.ema(close, longMaLength)
// Plot MAs
plot(shortMa, title="9 EMA", color=color.blue)
plot(longMa, title="21 EMA", color=color.red)
// Strategy conditions
crossUp = ta.crossover(shortMa, longMa)
crossDown = ta.crossunder(shortMa, longMa)
// Debug plots to check cross conditions
plotshape(series=crossUp, title="Cross Up", location=location.belowbar, color=color.green, style=shape.labelup, text="UP")
plotshape(series=crossDown, title="Cross Down", location=location.abovebar, color=color.red, style=shape.labeldown, text="DOWN")
// Entry at cross signals
if (crossUp)
strategy.entry("Long", strategy.long)
if (crossDown)
strategy.entry("Short", strategy.short)
// Daily drawdown and profit limits
var float startOfDayEquity = na
if (na(startOfDayEquity) or ta.change(time('D')) != 0)
startOfDayEquity := strategy.equity
maxDailyLoss = 50000 * 0.0025
maxDailyProfit = 50000 * 0.02
currentDailyPL = strategy.equity - startOfDayEquity
if (currentDailyPL <= -maxDailyLoss)
strategy.close_all(comment="Max Daily Loss Reached")
if (currentDailyPL >= maxDailyProfit)
strategy.close_all(comment="Max Daily Profit Reached")