
이 전략은 특정 날짜로 촉발되는 다중 포지션 구축과 trailing stop loss의 위험 관리 메커니즘을 위한 전략이다. 이 전략은 특히 특정 달력 날짜에 따라 포지션을 자동으로 입력하고, 동적 위험 제어 방법을 통해 포지션을 관리하는 트레이더에게 적합하다.
이 전략은 먼저 특정 상장 날짜를 입력하여 월일을 포함하고, 그 날짜에 따라 정확한 상장 시간을 계산합니다. 전략은 또한 스톱 손실을 추적하는 비율 변수를 입력합니다.
상장일 당일, 전략은 여러 상장 포지션을 열립니다. 동시에, 최고 가격 (highestPrice) 과 스톱로스 (stopLoss) 를 기록합니다. 이 중 최고 가격은 후속 시간 동안 지속적으로 업데이트되며, 스톱로스 가격은 최고 가격의 일정한 비율로 아래로 트래일링됩니다.
만약 가격이 스톱로스 가격보다 낮다면, 평형 상태에서 퇴출한다. 그렇지 않으면 포지션이 계속 유지되고, 스톱로스 가격은 최고 가격에 따라 계속 하향으로 추적하여 이익을 잠금하고, 위험을 통제한다.
이 전략은 다음과 같은 몇 가지 주요 장점을 가지고 있습니다.
이 전략에는 몇 가지 위험도 있습니다.
대응 최적화 조치:
이 전략은 다음과 같은 방향으로 최적화될 수 있습니다.
이 전략은 특정 날짜에 상장하고 손실을 추적하는 방식을 채택하여 입장을 자동화하고 위험을 동적으로 제어 할 수 있습니다. 전략은 간단하고 직관적이며, 작동하기 쉽고, 긴 라인 포지션에 적합합니다. 추가 최적화를 통해 매우 실용적인 양적 거래 전략이 될 수 있습니다.
/*backtest
start: 2024-01-24 00:00:00
end: 2024-01-31 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Trailing Stop Loss Percent",
overlay=true, pyramiding=1)
// Input for the specific entry date
entryDay = input.int(defval = 1, title = "Entry Day", minval = 1, maxval = 31)
entryMonth = input.int(defval = 1, title = "Entry Month", minval = 1, maxval = 12)
entryYear = input.int(defval = 2023, title = "Entry Year", minval = 1970)
// Calculate the entry date timestamp
entryDate = timestamp(entryYear, entryMonth, entryDay, 00, 00)
// Trailing Stop Loss Percentage
trailStopPercent = input.float(defval = 5.0, title = "Trailing Stop Loss (%)", minval = 0.1)
// Entry Condition
enterTrade = true
// Variables to track the highest price and stop loss level since entry
var float highestPrice = na
var float stopLoss = na
// Update the highest price and stop loss level
if strategy.position_size > 0
highestPrice := math.max(highestPrice, high)
stopLoss := highestPrice * (1 - trailStopPercent / 100)
// Enter the strategy
if enterTrade
strategy.entry("Long Entry", strategy.long)
highestPrice := high
stopLoss := highestPrice * (1 - trailStopPercent / 100)
// Exit the strategy if the stop loss is hit
if strategy.position_size > 0 and low <= stopLoss
strategy.close("Long Entry")
// Plotting the stop loss level for reference
plot(strategy.position_size > 0 ? stopLoss : na, "Trailing Stop Loss", color=color.red)