アダプティブ指数関数移動平均範囲戦略

作者: リン・ハーンチャオチャン, 日付: 2024-02-26 14:58:32
タグ:

img

概要

この戦略は,より速い指数関数型ハル移動平均値 (EHMA) と適応チャネルを使用して,トレンドフォロー戦略を構築する.EHMAがより速く計算するため,価格トレンドの変化を効果的に特定し,偽のブレイクアウトによる不必要な取引を回避することができます.同時に,適応チャネルはいくつかの価格変動をフィルタリングすることができます.取引は価格がチャネルを突破したときのみ起動され,非効率な取引の確率を軽減し,収益性を高めます.

戦略原則

  1. 周期パラメータに基づいて指数的な重度の移動平均EHMAを計算します. EHMAはより速く計算し,価格傾向の変化を効果的に追跡することができます.

  2. RangeWidth パラメータに基づいて,EHMA の上下に適応チャネルを構築する.価格が上方のチャネルラインを上回ったり,下方のチャネルラインを下回ったりすると,トレンドが変化すると考えられ,取引信号が起動する.

  3. チャネルとの価格関係を見極める.価格が上線を突破するとロング,下線を突破するとショート.価格が上線を下に突破するとロングポジションを閉じる.価格が下線を下に突破するとショートポジションを閉じる.

利点分析

通常の移動平均戦略と比較して,この戦略には以下の利点があります.

  1. 移動平均を計算するためにEHMAアルゴリズムを使用します.EHMAは価格変化により敏感に反応し,誤ったブレイクによって引き起こされる不必要な取引を避けるために動向変化を効果的に特定することができます.

  2. アダプティブチャネルは,価格変動を効果的にフィルタリングすることができます. 価格傾向がしっかりと変化したときのみ取引信号が起動されます. これにより,いくつかの非効率な取引をフィルタリングし,収益性を向上させることができます.

  3. チャンネルの幅は,異なる市場状況に適応するために柔軟に調整できます.より広いチャンネルはより多くの変動をフィルターし,取引頻度を減らすことができます.より狭いチャンネルは傾向の変化を早期に特定し,取引頻度を増加することができます.

リスク分析

この戦略にはいくつかのリスクもあります:

  1. 偽のブレイクはまだ完全に回避できない. 価格がチャネルを超えてギャップする可能性があります. リスクを制御するためにパラメータを適切に調整する必要があります.

  2. チャンネルが幅が広い場合,いくつかの取引機会が逃れることもあります.敏感性を高めるために合理的にチャンネルを狭める.

  3. 狭すぎるチャネルは不効率な取引を増やすことができます 安定性を高めるためにチャネル幅を適切に拡大してください

オプティマイゼーションの方向性

この戦略は,次の側面で最適化できます.

  1. Period パラメータを最適化します. 移動平均計算サイクルを異なる製品とタイムフレームに適応するように調整します.

  2. RangeWidth パラメータを最適化します 市場の変動と個人のリスク優先順位に基づいてチャネル範囲を調整します

  3. ストップ・ロスの戦略を追加します.取引ごとに最大損失を効果的に制御するために,ポジションを保持する際に合理的なストップ・ロスのポイントを設定します.

  4. エントリーフィルタリングのための他の指標と組み合わせます.例えば,誤ったエントリを減らすためにボリュームを追加します.

  5. 戦略アプリケーションを多様化し,パラメータを最適化する.より多くの製品とタイムフレームで普遍的なパラメータをテストし,最適化する.

概要

この戦略は,EHMA指標と適応チャネル指標を組み合わせ,トレンドフォロー戦略を形成する. 不必要な取引を避けるために,市場のトレンドを効果的に特定し,価格変動をフィルタリングすることができます. 一連のパラメータ最適化とリスク制御の後,さまざまな製品とタイムフレームで安定した利益を達成することができます.


/*backtest
start: 2023-02-25 00:00:00
end: 2024-02-25 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
args: [["v_input_1",1]]
*/

// Credit is due where credit is due:
// Hull Moving Average: developed by Alan Hull
// EHMA: coded by Twitter @borserman
// I've built on their work in an attempt to create a strategy more robust to fake moves
// @0xLetoII

//@version=4
strategy(
  title="EHMA Range Strategy",
  process_orders_on_close=true,
  explicit_plot_zorder=true,
  overlay=true, 
  initial_capital=1500, 
  default_qty_type=strategy.percent_of_equity, 
  commission_type=strategy.commission.percent, 
  commission_value=0.085,
  default_qty_value=100
  )
  

// Position Type
pos_type = input(defval = "Long", title="Position Type", options=["Both", "Long", "Short"])

// Inputs
Period = input(defval=180, title="Length")
RangeWidth = input(defval=0.02, step=0.01, title="Range Width")
sqrtPeriod = sqrt(Period)

// Function for the Borserman EMA
borserman_ema(x, y) =>
    alpha = 2 / (y + 1)
    sum = 0.0
    sum := alpha * x + (1 - alpha) * nz(sum[1])

// Calculate the Exponential Hull Moving Average
EHMA = borserman_ema(2 * borserman_ema(close, Period / 2) - borserman_ema(close, Period), sqrtPeriod)

// Create upper & lower bounds around the EHMA for broader entries & exits
upper = EHMA + (EHMA * RangeWidth)
lower = EHMA - (EHMA * RangeWidth)

// Plots
EHMAcolor = (close > EHMA ? color.green : color.red)
plot(EHMA, color=EHMAcolor, linewidth=2)
plot(lower, color=color.orange, linewidth=2)
plot(upper, color=color.blue, linewidth=2)


// Strategy
long = close > upper
exit_long = close < lower
short = close < lower
exit_short = close > upper


// Calculate start/end date and time condition
startDate  = input(timestamp("2017-01-01T00:00:00"))
finishDate = input(timestamp("2029-01-01T00:00:00"))
 
time_cond  = true


// Entries & Exits
if pos_type == "Both"
    strategy.entry("Long", strategy.long, comment="Long", when=long and time_cond)
    strategy.close("Long", comment="Exit Long", when=exit_long and time_cond)
    strategy.entry("Short", strategy.short, comment="Short", when=short and time_cond)
    strategy.close("Short", comment="Exit Short", when=exit_short and time_cond)
if pos_type == "Long"
    strategy.entry("Long", strategy.long, comment="Long", when=long and time_cond)
    strategy.close("Long", comment="Exit Long", when=exit_long and time_cond)
if pos_type == "Short"
    strategy.entry("Short", strategy.short, comment="Short", when=short and time_cond)
    strategy.close("Short", comment="Exit Short", when=exit_short and time_cond)
    

もっと