ハイキン・アシ パーセンチル インターポレーション 取引戦略

作者: リン・ハーンチャオチャン開催日:2023年12月25日 11:02:25
タグ:

img

概要

この戦略は,ハイキンアシのキャンドルスタイクに基づいて取引信号を生成する.特に,ハイキンアシの閉値と75パーセント値レベルのクロスオーバーに基づいて購入・販売信号が考慮される.また,ハイキンアシの閉値が特定の移動平均値以上である.

戦略の論理

この戦略は,分析のために通常のろうそくの代わりにハイキンアシのろうそくを使用する.ハイキンアシのろうそくの滑らかな性質は,トレンドと逆転をより明確に識別するのに役立ちます.特に,戦略は,トレード信号を生成するために百分位チャンネルと移動平均を組み合わせます:

  1. ハイキン・アシの閉局が75パーセントを超えると 長い信号が発信されます
  2. 5期間の移動平均値を下回る時,セールシグナルが発信されます.

ストップ・ロストとトレリング・ストップも,取引ごとに下向きリスクを制御するために使用されます.

利点

  1. ハイキン・アシ (Heikin Ashi) のろうそくは 傾向をはっきりと識別し 変化を素早く発見します
  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)


もっと