高速移動平均と低速移動平均のクロスオーバー戦略に基づく


作成日: 2024-02-27 16:06:30 最終変更日: 2024-02-27 16:06:30
コピー: 1 クリック数: 780
1
フォロー
1617
フォロワー

高速移動平均と低速移動平均のクロスオーバー戦略に基づく

概要

快速移動平均線交差策略は,簡単な移動平均策略である.それは,2つの移動平均線を使用し,速くゆっくり,高速移動平均線が,下からゆっくり移動平均線を横切るとき,価格が上昇する可能性を示し,高速移動平均線が上から下にゆっくり移動平均線を横切るとき,価格が低下する可能性を示し,平衡する.これは将来の価格行動を予測する指標として使用できます.

戦略原則

この戦略は,2つの移動平均を使用し,速いと遅いである.具体的には,高速移動平均の長さは25サイクルをデフォルトし,遅い移動平均の長さは62サイクルをデフォルトする.戦略は,SMA,EMA,WMA,RMA,VWMAを含む異なるタイプの移動平均を選択することを許可する.

急速移動平均線が,下からゆっくり移動平均線を横断すると,短期価格が長期価格を突破し始めることを示す,典型的な金交差信号であり,価格が上昇チャネルに入ると予測される,このとき戦略は多; 急速移動平均線が,上から下からゆっくり移動平均線を横断すると,短期価格が長期価格を突破し始めることを示す,死亡交差信号であり,価格が下降チャネルに入ると予測される,このとき戦略は平仓である.

このように,平均線の交差によって,価格の傾向と方向を判断し,それに応じて多かれ少なかれ平仓を取って,利益を得ることができる.

優位分析

この戦略の利点は以下の通りです.

  1. シンプルで理解し,実行できる
  2. パラメータの設定は柔軟で,カスタマイズ可能な周期と平均速度のタイプ
  3. 信頼性の高い指標で,価格の傾向を正確に判断する
  4. 自動化,人間の判断を避け,心理的な要因の影響を軽減する
  5. 複数の品種に対応し,株式指数,外貨,暗号通貨などの品種に広く適用される
  6. 簡単に最適化し,パラメータの組み合わせを調整し,より良い配置を探します.
  7. 拡張性があり,他の指標や戦略と組み合わせることができます.

全体として,この戦略は,急激な平均線交差を核心取引信号として使用し,価格の将来の傾向を判断する能力が強く,トレンド追跡の優位性に基づいて,良い利益を得ることができ,実戦での適用に値する.

リスク分析

この戦略にはいくつかの潜在的リスクがあります.

  1. 遅い平均線交差信号は,価格が長期のトレンドの反転ではなく,短期的な調整を表示する誤報を発生させる可能性があります.
  2. 長短平均線を誤って選択すると,頻繁に取引したり,良い機会を逃したりする可能性があります.
  3. 価格が急激に波動する時には,急激な平均線交差信号は目立たないかもしれません.
  4. 取引費用が高い品種で,交差信号の取引が頻繁すぎると収益が損なわれます.
  5. 拡張性の強さは過度に最適化される危険性も伴います

これらのリスクは,以下の方法で制御および改善できます.

  1. 他の指標と組み合わせたフィルタリングで,量値が指標から離れているような誤報を避ける
  2. 平均線パラメータを調整し,最適な組み合わせを見つけ,誤った取引の確率を減らす
  3. 市場が激しくなる中,戦略を休止し,大きな波動を避ける
  4. 停損幅を適切に緩和し,不必要な損失を減らす
  5. 多品種再調査,リスク評価,過度最適化防止

最適化の方向

この戦略の改善策は以下の通りです.

  1. 急速平均線と遅速平均線の周期選択:現在のデフォルトパラメータは最適ではないかもしれない.異なる周期パラメータを試して最適の配置を見つけることができます.

  2. 移動平均のタイプを選択:特定の品種にどのタイプが最適かをテストするために,複数の移動平均が現在提供されています.

  3. 他の指標または戦略との組み合わせ:波動率指標,量値指標,またはトレンド追跡戦略との組み合わせを試して効果を上げることができます.

  4. パラメータの自己適応最適化:平均周期のパラメータを市場の変動率と流動性に応じて自動的に調整して安定性を高める

  5. AIモデル支援:機械学習アルゴリズムを使用して大量のデータを分析し,最適の取引ルールを自動的に探す

これらの最適化手段によって,戦略の収益性や安定性をさらに向上させることが期待されます.

要約する

快速平均線交差策は全体的に非常に実用的なトレンド追跡策である. それは,価格の異なる時間尺度での変化の法則を把握し,快速平均線を突破し,遅い平均線を突破して,価格の将来の可能性のある傾向と方向を判断する. 策略の構想は,単純で明快で,容易に理解し,実行し,パラメータをカスタマイズできる柔軟性があり,同時に信頼性が高く,自動化が高度で,適用範囲は広大で,拡張性が強い. もちろん,一定の誤報リスクがあり,最大限の効果を出すために他の指標と組み合わせて使用する必要がある.

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

//@version=5
//Author @divonn1994

initial_balance = 100
strategy(title='Fast v Slow Moving Averages Strategy', shorttitle = 'Fast v Slow', overlay=true, pyramiding=0, default_qty_value=100, default_qty_type=strategy.percent_of_equity, precision=7, currency=currency.USD, commission_value=0.1, commission_type=strategy.commission.percent, initial_capital=initial_balance)

//Input for number of bars for moving average, Switch to choose moving average type, Display Options and Time Frame of trading----------------------------------------------------------------

fastBars = input.int(25, "Fast moving average length", minval=1)
slowBars = input.int(62, "Slow moving average length", minval=1)
strategy = input.string("EMA", "MA type", options = ["EMA", "VWMA", "SMA", "RMA", "WMA"])

redOn = input.string("On", "Red Background Color On/Off", options = ["On", "Off"], group='Display')
greenOn = input.string("On", "Green Background Color On/Off", options = ["On", "Off"], group='Display')
maOn = input.string("On", "Moving Average Plot On/Off", options = ["On", "Off"], group='Display')

startMonth = input.int(title='Start Month 1-12 (set any start time to 0 for furthest date)', defval=1, minval=0, maxval=12, group='Beginning of Strategy')
startDate = input.int(title='Start Date 1-31 (set any start time to 0 for furthest date)', defval=1, minval=0, maxval=31, group='Beginning of Strategy')
startYear = input.int(title='Start Year 2000-2100 (set any start time to 0 for furthest date)', defval=2011, minval=2000, maxval=2100, group='Beginning of Strategy')

endMonth = input.int(title='End Month 1-12 (set any end time to 0 for today\'s date)', defval=0, minval=0, maxval=12, group='End of Strategy')
endDate = input.int(title='End Date 1-31 (set any end time to 0 for today\'s date)', defval=0, minval=0, maxval=31, group='End of Strategy')
endYear = input.int(title='End Year 2000-2100 (set any end time to 0 for today\'s date)', defval=0, minval=0, maxval=2100, group='End of Strategy')

//Strategy Calculations-----------------------------------------------------------------------------------------------------------------------------------------------------------------------

inDateRange = true

maMomentum = switch strategy
    "EMA" => (ta.ema(close, fastBars) >= ta.ema(close, slowBars)) ? 1 : -1
    "SMA" => (ta.sma(close, fastBars) >= ta.sma(close, slowBars)) ? 1 : -1
    "RMA" => (ta.rma(close, fastBars) >= ta.rma(close, slowBars)) ? 1 : -1
    "WMA" => (ta.wma(close, fastBars) >= ta.wma(close, slowBars)) ? 1 : -1
    "VWMA" => (ta.vwma(close, fastBars) >= ta.vwma(close, slowBars)) ? 1 : -1
    =>
        runtime.error("No matching MA type found.")
        float(na)

fastMA = switch strategy
    "EMA" => ta.ema(close, fastBars)
    "SMA" => ta.sma(close, fastBars)
    "RMA" => ta.rma(close, fastBars)
    "WMA" => ta.wma(close, fastBars)
    "VWMA" => ta.vwma(close, fastBars)
    =>
        runtime.error("No matching MA type found.")
        float(na)
        
slowMA = switch strategy
    "EMA" => ta.ema(close, slowBars)
    "SMA" => ta.sma(close, slowBars)
    "RMA" => ta.rma(close, slowBars)
    "WMA" => ta.wma(close, slowBars)
    "VWMA" => ta.vwma(close, slowBars)
    =>
        runtime.error("No matching MA type found.")
        float(na)

//Enter or Exit Positions--------------------------------------------------------------------------------------------------------------------------------------------------------------------

if ta.crossover(maMomentum, 0)
    if inDateRange
        strategy.entry('long', strategy.long, comment='long')
if ta.crossunder(maMomentum, 0)
    if inDateRange
        strategy.close('long')

//Plot Strategy Behavior---------------------------------------------------------------------------------------------------------------------------------------------------------------------

plot(series = maOn == "On" ? fastMA : na, title = "Fast Moving Average", color = color.new(color.white,0), linewidth=2, offset=1)
plot(series = maOn == "On" ? slowMA : na, title = "Slow Moving Average", color = color.new(color.purple,0), linewidth=3, offset=1)
bgcolor(color = inDateRange and (greenOn == "On") and maMomentum > 0 ? color.new(color.green,75) : inDateRange and (redOn == "On") and maMomentum <= 0 ? color.new(color.red,75) : na, offset=1)