移動平均ゴールデンクロスとデッドクロス戦略


作成日: 2023-09-21 10:47:24 最終変更日: 2023-09-21 10:47:24
コピー: 0 クリック数: 639
1
フォロー
1617
フォロワー

概要

この戦略は,3つの移動平均の金叉死叉形式に基づいて取引されます. 急速移動平均線上を中速線と中速線上を遅速線を横切るときは多行し,急速移動平均線下を中速線と中速線下を遅速線を横切るときは空行します.

戦略原則

  1. 3つの周期の移動平均を設定します. 速線,中速線,遅速線.
  2. スピードラインが中速ラインを横断し,中速ラインがスローラインを横断すると,さらに
  3. 速線下が中速線と中速線下が遅速線を横切るとき,空白する
  4. 設定可能な入口遅延,偽突破フィルター
  5. 逆転信号が発射されたとき,平仓

具体的には,この戦略は,3つの異なる周期の移動平均線間の交差を利用して取引する. 急速線は現在の短期トレンドを表し,中速線は中期トレンドを表し,遅い線は長期トレンドを表す. 短中長期の3つの均等線が順番に上昇して交差すると,トレンドが開始され,多額の取引が行われ,下方交差すると,トレンドが逆転し,空白となる.

優位分析

  1. 3つの均等線を用いてトレンドの方向の変化を判断し,精度を高めます.
  2. 遅延入場は,偽突破をフィルタリングして,隠蔽を回避できます.
  3. 取引ロジックはシンプルで直感的で,理解しやすい.
  4. フレキシブルな平均線パラメータを調整し,異なる周期に適用
  5. 逆転のリスクを避けるために,順位をつけましょう.

リスク分析

  1. 大周期では長期の保有期間が必要で,損失拡大の危険性がある
  2. 三線交差は遅滞しており,入口のベストポイントを逃している可能性がある.
  3. 平均線パラメータを最適化する必要がある,そうでなければ信号は不正確である
  4. 長期投資は夜間リスクも考慮する

ポジション保持時間を調整し,平均線パラメータを最適化し,ストップ・ロスの戦略を導入することによってリスクを管理することができます.

最適化の方向

  1. 異なる平均周期パラメータをテストし,最適なパラメータを見つけます.
  2. 異なる入場遅延の優劣をフィルター信号で評価する
  3. ストップ・ストラトジーを導入し,実際の状況に応じてストップ・ポジションを調整する.
  4. 異なる品種のパラメータの好みを研究し,パラメータ最適化システムを構築する
  5. ポジション保持を最適化するために再入場と加仓ルールをテスト

要約する

この戦略は,三均線交差判定の傾向方向に基づいてポジションを保持する. 取引信号が単純で明確で,構成性が強であることの利点; 欠点は,遅滞が容易で,パラメータの最適化が必要である. パラメータの最適化,停止損失戦略などの効果を向上させ,撤回リスクを制御することができる. この戦略は,トレーダーが移動平均の適用と多均線交差の取引理念を習得するのを助ける.

ストラテジーソースコード
/*backtest
start: 2023-08-21 00:00:00
end: 2023-09-20 00:00:00
period: 3h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// © DaynTrading

//@version=4
// strategy(
//      title="Simple Moving Average Cross",
//      overlay=true,
//      initial_capital=5000,
//      default_qty_type=strategy.percent_of_equity,
//      default_qty_value=2,
//      commission_type=strategy.commission.percent,
//      commission_value=0.075,
//      pyramiding=0
//      )

sma_top_input = input(title="SMA Top", type=input.integer, defval=20)
sma_mid_input = input(title="SMA Mid", type=input.integer, defval=50)
sma_low_input = input(title="SMA Low", type=input.integer, defval=200)

bars_long = input(title="Long: After trigger, how many bars to wait?", type=input.integer, defval=5)
bars_short = input(title="Short: After trigger, how many bars to wait?", type=input.integer, defval=5)

sma_top = sma(close, sma_top_input)
sma_mid = sma(close, sma_mid_input)
sma_low = sma(close, sma_low_input)

long = sma_top > sma_mid and sma_mid > sma_low
short = sma_top < sma_mid and sma_mid < sma_low

long_condition = long and long[bars_long] and not long[bars_long + 1]
short_condition = short and short[bars_short] and not short[bars_short + 1]

close_long = sma_top < sma_mid and sma_mid < sma_low and not long[bars_long + 1]
close_short = sma_top > sma_mid and sma_mid > sma_low and not short[bars_short + 1]

plot(sma_top, title="SMA Top", color=#95f252, linewidth=2)
plot(sma_mid, title="SMA Mid", color=#FF1493, linewidth=2)
plot(sma_low, title="SMA Low", color=#6a0dad, linewidth=2)

strategy.entry("LongPosition", strategy.long, when = long_condition)
strategy.entry("ShortPosition", strategy.short, when = short_condition)
    
strategy.close("LongPosition", when = close_short)
strategy.close("ShortPosition", when = close_long)