
이 전략은 이동 평균의 교차와 동적 ATR 중지 손실을 기반으로 한 양적 거래 전략이다. 이 전략은 두 개의 다른 주기에서 간단한 이동 평균 ((SMA) 를 사용하여 거래 신호를 생성하고, 평균 실제 파동의 폭 ((ATR) 을 사용하여 위험 통제를 위해 중지 및 중지 위치를 동적으로 설정합니다. 또한, 이 전략은 전략의 안정성을 높이기 위해 다른 거래 시간에 따라 거래 신호를 필터링합니다.
이 전략의 핵심 원칙은 이동 평균의 교차를 이용해서 가격 트렌드의 변화를 포착하는 것이다. 빠른 이동 평균이 아래에서 위로 느린 이동 평균을 통과할 때, 구매 신호를 생성한다. 빠른 이동 평균이 위에서 아래로 느린 이동 평균을 통과할 때, 판매 신호를 생성한다. 동시에, 이 전략은 ATR를 동적으로 사용해서 스톱과 스톱로스를 설정하고, 스톱로스는 입시 가격에 3배의 ATR을 추가하고, 스톱로스는 입시 가격에 1.5배의 ATR을 제거한다. 또한, 이 전략은 유럽 거래 시간대에만 거래 신호를 생성하여 유동성이 낮은 시간에 거래하는 것을 피한다.
이 전략은 간단하고 이해하기 쉬운 트렌드 추적 전략으로, 이동 평균을 교차하여 가격 트렌드를 포착하고 ATR을 사용하여 위험을 제어합니다. 이 전략에는 약간의 위험이 있지만, 매개 변수 최적화, 신호 필터링, 위험 관리 등의 측면에서 최적화를 통해 전략의 안정성과 수익성을 더욱 향상시킬 수 있습니다.
/*backtest
start: 2024-04-01 00:00:00
end: 2024-04-30 23:59:59
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Enhanced Moving Average Crossover Strategy", overlay=true)
// Input parameters
fastLength = input(10, title="Fast MA Length")
slowLength = input(50, title="Slow MA Length")
atrLength = input(14, title="ATR Length")
riskPerTrade = input(1, title="Risk Per Trade (%)") / 100
// Time-based conditions
isLondonSession = hour >= 8 and hour <= 15
isAsianSession = hour >= 0 and hour <= 7
isEuropeanSession = hour >= 7 and hour <= 14
// Moving Averages
fastMA = ta.sma(close, fastLength)
slowMA = ta.sma(close, slowLength)
// Average True Range (ATR) for dynamic stop loss and take profit
atr = ta.atr(atrLength)
// Buy and Sell Conditions
buySignal = ta.crossover(fastMA, slowMA)
sellSignal = ta.crossunder(fastMA, slowMA)
// Dynamic stop loss and take profit
stopLoss = close - atr * 1.5
takeProfit = close + atr * 3
// Strategy Logic
if (buySignal and isEuropeanSession)
strategy.entry("Buy", strategy.long)
strategy.exit("Take Profit/Stop Loss", "Buy", limit=takeProfit, stop=stopLoss)
if (sellSignal and isEuropeanSession)
strategy.entry("Sell", strategy.short)
strategy.exit("Take Profit/Stop Loss", "Sell", limit=takeProfit, stop=stopLoss)
// Plotting
plot(fastMA, color=color.blue, title="Fast MA")
plot(slowMA, color=color.red, title="Slow MA")
plotshape(series=buySignal, location=location.belowbar, color=color.green, style=shape.labelup, text="BUY")
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.labeldown, text="SELL")