하이킨 아시 퍼센틸 인터폴레이션 거래 전략

저자:차오장, 날짜: 2023-12-25 11:02:25
태그:

img

전반적인 설명

이 전략은 하이킨 아시 촛불을 기반으로 거래 신호를 생성합니다. 구체적으로, 하이킨 아시 폐쇄 가격과 75 퍼센틸 가격 수준의 교차에 따라 구매 및 판매 신호가 고려되며, 하이킨 아시 폐쇄 가격이 특정 이동 평균보다 높습니다.

전략 논리

이 전략은 분석을 위해 일반 촛불 대신 하이킨 아시 촛불을 사용합니다. 하이킨 아시 촛불의 부드러운 성격은 트렌드와 반전을 더 명확하게 식별하는 데 도움이됩니다. 구체적으로 전략은 거래 신호를 생성하기 위해 퍼센틸 채널과 이동 평균을 결합합니다.

  1. 하이킨 아시 클로즈가 75 퍼센틸 수준을 넘으면 긴 신호가 발생합니다.
  2. 파는 신호는 하이킨 아시 (Heikin Ashi) 폐쇄가 5주기 이동평균 아래를 넘을 때 발사됩니다.

스톱 로즈와 트레일링 스톱은 거래당 하향 리스크를 제어하기 위해 사용되기도 합니다.

장점

  1. 하이킨 아시 촛불은 트렌드를 명확히 파악하고, 역전을 즉시 감지합니다.
  2. 퍼센틸 채널은 시간 입구와 출구에 과잉 구매 / 과잉 판매 조건을 결정하는 데 도움이됩니다.
  3. 스톱 로즈와 트레일링 스톱의 사용은 위험을 능동적으로 제어합니다.

위험성

  1. 하이킨 아시 촛불은 설계에 따라 지연을 가지고 있으며, 이는 최고의 입시/출시 가격을 놓치는 결과를 초래할 수 있습니다.
  2. 퍼센틸 채널은 트렌드 반전을 완전히 파악하지 못해 잠재적인 위프사우로 이어집니다.
  3. 부적절한 스톱 로스 투입은 수익을 조기에 단축시키거나 용납할 수 없는 손실을 초래할 수 있습니다.

위험을 완화하기 위해 이동 평균 기간과 중지 손실 비율과 같은 매개 변수는 조정되어야 할 수 있습니다.

개선

  1. 최적의 매개 변수를 찾기 위해 다른 이동 평균 조합을 테스트합니다.
  2. 가격 핫존을 더 잘 식별하기 위해 퍼센틸 채널 길이를 정렬하십시오.
  3. 신호를 확인하고 잘못된 신호를 피하기 위해 추가 표시기를 포함합니다.
  4. 동적 스톱 손실 거리를 구현합니다.

결론

이 전략은 하이킨 아시 촛불, 퍼센틸 채널 및 이동 평균을 결합하여 트렌드를 식별하고 스톱 로스를 통해 위험을 제어 할 수있는 체계적인 접근 방식을 형성합니다. 매개 변수를 최적화하고 보완적 인 지표를 통합함으로써 추가 성과 개선이 예상 될 수 있습니다.


/*backtest
start: 2023-12-17 00:00:00
end: 2023-12-24 00:00:00
period: 45m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("HK Percentile Interpolation One",shorttitle = "HKPIO", overlay=false, default_qty_type = strategy.cash, default_qty_value = 5000, calc_on_order_fills = true, calc_on_every_tick = true)

// Input parameters
stopLossPercentage = input(3, title="Stop Loss (%)") // User can set Stop Loss as a percentage
trailStopPercentage = input(1.5, title="Trailing Stop (%)") // User can set Trailing Stop as a percentage
lookback = input.int(14, title="Lookback Period", minval=1) // User can set the lookback period for percentile calculation
yellowLine_length = input.int(5, "Yellow", minval=1) // User can set the length for Yellow EMA
purplLine_length = input.int(10, "Purple", minval=1) // User can set the length for Purple EMA
holdPeriod = input.int(200, title="Minimum Holding Period", minval=10) // User can set the minimum holding period
startDate = timestamp("2021 01 01")  // User can set the start date for the strategy

// Calculate Heikin Ashi values
haClose = ohlc4
var float haOpen = na
haOpen := na(haOpen[1]) ? (open + close) / 2 : (haOpen[1] + haClose[1]) / 2
haHigh = math.max(nz(haOpen, high), nz(haClose, high), high)
haLow = math.min(nz(haOpen, low), nz(haClose, low), low)

// Calculate Moving Averages
yellowLine = ta.ema(haClose, yellowLine_length)
purplLine = ta.ema(haClose, purplLine_length)

// Calculate 25th and 75th percentiles
p25 = ta.percentile_linear_interpolation(haClose, lookback, 28)
p75 = ta.percentile_linear_interpolation(haClose, lookback, 78)

// Generate buy/sell signals
longSignal = ta.crossover(haClose, p75) and haClose > yellowLine
sellSignal = ta.crossunder(haClose, yellowLine)
longSignal1 = ta.crossover(haClose, p75) and haClose > purplLine
sellSignal1 = ta.crossunder(haClose, purplLine)

// Set start time and trade conditions
if(time >= startDate)
    // When longSignal is true, enter a long trade and set stop loss and trailing stop conditions
    if (longSignal)
        strategy.entry("Long", strategy.long, 1)
        strategy.exit("Sell", "Long", stop=close*(1-stopLossPercentage/100), trail_points=close*trailStopPercentage/100, trail_offset=close*trailStopPercentage/100)
    // When sellSignal is true, close the long trade
    if (sellSignal)
        strategy.close("Long")
    // When sellSignal1 is true, enter a short trade
    if (sellSignal1)
        strategy.entry("Short", strategy.short, 1)
    // When longSignal1 is true, close the short trade
    if (longSignal1)
        strategy.close("Short")

// Plot Heikin Ashi candles
plotcandle(haOpen, haHigh, haLow, haClose, title="Heikin Ashi", color=(haClose >= haOpen ? color.rgb(1, 168, 6) : color.rgb(176, 0, 0)))

// Plot 25th and 75th percentile levels
plot(p25, title="25th Percentile", color=color.green, linewidth=1, style=plot.style_circles)
plot(p75, title="75th Percentile", color=color.red, linewidth=1, style=plot.style_circles)

// Plot Moving Averages
plot(yellowLine, color = color.rgb(254, 242, 73, 2), linewidth = 2, style = plot.style_stepline)
plot(purplLine, color = color.rgb(255, 77, 234, 2), linewidth = 2, style = plot.style_stepline)


더 많은