簡単な移動平均のクロスオーバー戦略

作者: リン・ハーンチャオチャン, 日時: 2023-09-21 10:47:24
タグ:

概要

この戦略は3つの単純な移動平均値の黄金十字と死十字に基づいて取引する.高速SMAが中間SMAを横切り,中間SMAが遅いSMAを横切ったときに長くなります.逆のクロスオーバーが起こると短くなります.

戦略の論理

  1. 3つのSMAを設定し,異なる期間を設定します.速い,中,遅い
  2. 高速SMAが中間SMAと中間SMAを低速SMAに突破するとロング
  3. 高速SMAが中間SMAを下回り,中間SMAが遅いSMAを下回るとショート
  4. 誤ったブレイクを避けるためにエントリー遅延を設定できます
  5. リバースクロースオーバー信号が起動すると出口

特に,異なる期間の3つのSMA間のクロスオーバーを利用して取引する.高速SMAは短期トレンド,中期SMAは中期トレンド,遅いSMAは長期トレンドを表す.三つのSMAが順番に上昇するクロスオーバーすると,それは長くなることを示す上向きトレンドである.下向きクロスオーバーが発生すると,それは短くなることを示す下向きトレンドである.短期間の誤ったブレイクを避けるためにエントリー遅延も設定することができます.

利点分析

  1. 3つのSMAを使用すると方向の正確性が向上します
  2. 遅刻して入ると 偽の脱出や 罠にはまらない
  3. シンプルで直感的な論理,理解しやすい
  4. 異なるサイクルのための柔軟なSMAパラメータ調整
  5. トレンドをフォローすることで,反トレンドリスクが回避される

リスク分析

  1. 長期サイクルにおける長期保有リスク 損失拡大
  2. SMAクロスオーバーが遅れているため,入力のポイントを逃すかもしれない.
  3. SMA パラメータの最適化が必要で,そうでなければ信号が不正確である可能性があります.
  4. 長期保有は1日間のリスクをもたらす

リスクは,ポジションサイズ,SMA最適化,ストップロスの戦略などによって管理できます.

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

  1. 最適パラメータを見つけるために異なる SMA 期間をテストする
  2. 信号をフィルタリングするためにエントリー遅延を評価
  3. 実際の価格アクションに適応できるストップロスを導入する
  4. 研究パラメータの好み
  5. 保持を最適化するために再入力の追加とピラミッド式ルールをテストする

概要

この戦略は,トレンド方向を決定するために3つのSMAクロスオーバーに基づいてポジションを保持する.プロは単純な明確な信号と構成可能性であり,デメリットは遅れている信号とパラメータ依存性である. パラメータ最適化,ストップ損失などを通じてパフォーマンスを向上させ,リスクを制御することができる.これはトレーダーがSMAとクロスオーバー戦略を使用してマスターするのを助けます.


/*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)

もっと