
간격 거래 전략은 이동 평균을 기반으로 한 트렌드 추적 전략이다. 이 전략은 30일 지수 이동 평균을 사용하여 가격 트렌드를 식별하고, 가격이 평균을 돌파했을 때 진입하고, 가격이 평균 아래로 돌아갔을 때 진출한다. 이 전략은 30분에서 일선 시간 프레임의 거래에 적용된다.
이 전략은 주로 가격과 30일 지수 이동 평균의 관계를 기반으로 입수 및 퇴출 신호를 판단한다. 구체적으로:
따라서, CAPTURE 가격 트렌드에 대한 돌파구를 통해 트렌드 거래 기회를 잠금합니다.
이 전략은 다음과 같은 장점이 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
이 전략은 다음과 같은 부분에서 최적화될 수 있습니다.
간격 거래 전략은 가격의 EMA 돌파를 포착하는 방식으로 트렌드 추적을 수행하는 간단한 실용적인 계량화 전략입니다. 이 전략은 중장선 지점을 보유하거나 단선 거래를 할 수 있도록 유연하게 조정 및 최적화 할 수 있습니다.
/*backtest
start: 2024-01-23 00:00:00
end: 2024-02-22 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Spaced Out Trading Strategy", overlay=true)
// Define strategy parameters
emaPeriod = input(30, title="EMA Period") // Longer EMA period for more spaced-out trades
stopLossPct = input(2.0, title="Stop Loss Percentage") // Stop loss percentage
takeProfitPct = input(3.0, title="Take Profit Percentage") // Take profit percentage
// Calculate EMA
emaValue = ta.ema(close, emaPeriod)
// Define entry and exit conditions
enterLong = ta.crossover(close, emaValue)
exitLong = ta.crossunder(close, emaValue)
// Place orders
contractsQty = 5 // Number of contracts to buy
var float lastTradePrice = na // Track the last trade price
if enterLong and strategy.position_size == 0
strategy.entry("Buy Call", strategy.long, qty = contractsQty)
lastTradePrice := close
else if exitLong and strategy.position_size > 0
strategy.close("Buy Call")
lastTradePrice := na
// Calculate stop loss and take profit
stopLossPrice = lastTradePrice * (1 - stopLossPct / 100)
takeProfitPrice = lastTradePrice * (1 + takeProfitPct / 100)
strategy.exit("Sell Call", "Buy Call", stop = stopLossPrice, limit = takeProfitPrice)