適応型価格クロスオーバー移動平均取引戦略

HMA SL TP
作成日: 2024-09-26 16:12:36 最終変更日: 2024-09-26 16:12:36
コピー: 2 クリック数: 441
1
フォロー
1617
フォロワー

適応型価格クロスオーバー移動平均取引戦略

概要

自適性価格交差均線取引戦略は,ハル移動平均 ((HMA)) をベースにした量的な取引方法である.この戦略は,価格とHMAの交差を活用して,買入と売却の信号を生成し,リスクと利益を管理するために固定したストップ・ロスとストップ・ストップのレベルを設定する.この戦略は,HMAの104サイクルを主要指標として使用し,価格交差と組み合わせて取引を誘発する.

戦略原則

この戦略の核心は,Hull移動平均 ((HMA) を主要な指標として使用することである.HMAは,価格の変化に迅速に反応し,遅延を減らすことができる高度な移動平均である.戦略の論理は次のとおりである.

  1. 104サイクルHMAを計算する.
  2. 価格がHMAを超えて上昇するときに,より多く取引する.
  3. 価格がHMAを横切った時に空白を入れます.
  4. 取引ごとに固定ストップ・ロスト (<\(1.25) とストップ・ストップ (<\)37.5) のレベルを設定します.
  5. 取引ごとに2つの契約が使用されます.

策略は,開いたポジションをトラッキングすることによって,既にあるポジションを繰り返さないことを保証する.取引が平仓された後に,システムは,新しい取引シグナルが有効になるように,標識をリセットする.

戦略的優位性

  1. 適応性:HMAは市場の変化に迅速に適応し,偽信号を減らすことができます.
  2. リスク管理: 固定的ストップ・ロズとストップ・ストップのレベルを使用して,取引ごとにリスクを効果的に制御します.
  3. 取引規則は明確で,理解し,実行しやすい.
  4. 双方向の取引: 上昇と下落の機会を同時に捉え,利益の潜在力を高める.
  5. 自動化: 戦略は完全に自動化され,人間の介入や感情的な影響が少なくなります.

戦略リスク

  1. 取引頻度: 波動的な市場では,取引信号が過剰に発生し,取引コストが増加する可能性があります.
  2. 固定ストップ/ストップストップ:すべての市場条件に適さない場合があり,特定の状況では,早めに出場したり,大きなトレンドを逃したりする可能性があります.
  3. 単一の指標に依存する:HMAのみに依存することは,特定の市場環境で不十分である可能性があります.
  4. 遅滞性:HMAの遅滞が減ったにもかかわらず,急激な転換点ではまだ反応不足である可能性が高い.
  5. 市場環境フィルターの欠如: 市場全体の傾向や変動を考慮せずに,不適切な市場条件で取引することがあります.

戦略最適化の方向性

  1. 追加指標の導入:他の技術指標 (RSIやMACDなど) と組み合わせて信号を確認し,正確性を向上させる.
  2. ダイナミックなストップ/ストップ:市場の変動に応じて,異なる市場環境に対応するために,ストップとストップのレベルを調整する.
  3. 市場フィルターを追加する:トレンドの強さや波動率のフィルターを追加し,不利な市場条件で取引を避ける.
  4. HMAパラメータの最適化:異なるHMAサイクルをテストし,特定の市場に最も適したパラメータを見つけます.
  5. ポジション管理の導入:市場リスクと口座規模に応じて取引規模を動的に調整する.
  6. タイムフィルターを追加:重要な経済データの発表などの市場の変動が大きい時期に取引を避ける.

要約する

自動価格交差均等線取引戦略は,シンプルで効果的な量化取引方法である.この戦略は,ハル移動平均の優位性を利用することで,市場動向を捉えることができ,同時に,固定されたリスク管理措置によって資金を保護することができる.この戦略にはいくつかの潜在的リスクがあるが,継続的な最適化と改善によって,その性能と適応性をさらに向上させることができる.自動取引ソリューションを求めるトレーダーにとって,これは考慮すべき基本的な戦略の枠組みである.

ストラテジーソースコード
/*backtest
start: 2024-01-01 00:00:00
end: 2024-03-23 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("SHIESTD", overlay=true)

// Function to calculate Hull Moving Average (HMA)
hma(src, length) =>
    wma1 = ta.wma(src, length)
    wma2 = ta.wma(src, length / 2)
    hma = ta.wma(2 * wma2 - wma1, math.round(math.sqrt(length)))
    hma

// Parameters
hma_length = 104

// Calculate Hull Moving Average
hma_value = hma(close, hma_length)

// Plot HMA
plot(hma_value, title="104-period Hull Moving Average", color=color.blue, linewidth=2)

// Define SL and TP values in dollars
long_sl_amount = 1.25
long_tp_amount = 37.5
short_sl_amount = 1.25
short_tp_amount = 37.5

// Number of contracts
contracts = 2

// Function to calculate SL and TP prices based on entry price and dollar amounts
long_sl_price(entry_price) =>
    entry_price - long_sl_amount

long_tp_price(entry_price) =>
    entry_price + long_tp_amount

short_sl_price(entry_price) =>
    entry_price + short_sl_amount

short_tp_price(entry_price) =>
    entry_price - short_tp_amount

// Trading conditions
price_intersects_hma = ta.crossover(close, hma_value) or ta.crossunder(close, hma_value)

// Long and Short Conditions based on price intersecting HMA
long_condition = ta.crossover(close, hma_value)
short_condition = ta.crossunder(close, hma_value)

// Track open positions
var bool long_open = false
var bool short_open = false

// Handle Long Positions
if (long_condition and not long_open)
    entry_price = close
    strategy.entry("Long", strategy.long, qty=contracts)
    strategy.exit("Exit Long", from_entry="Long", stop=long_sl_price(entry_price), limit=long_tp_price(entry_price))
    long_open := true

// Handle Short Positions
if (short_condition and not short_open)
    entry_price = close
    strategy.entry("Short", strategy.short, qty=contracts)
    strategy.exit("Exit Short", from_entry="Short", stop=short_sl_price(entry_price), limit=short_tp_price(entry_price))
    short_open := true

// Reset flags when the position is closed
if (strategy.opentrades == 0)
    long_open := false
    short_open := false