ゴールデンクロス移動平均取引戦略

作者: リン・ハーンチャオチャン,日付: 2023年12月11日11時36分
タグ:

img

概要

ゴールデンクロス移動平均取引戦略は,古典的な定量的な取引戦略である.この戦略は,長期と短期のポジションの市場動向を決定するために,異なる期間の移動平均を使用する.短期移動平均が長期移動平均を超えると,それは購入信号とみなされる.短期移動平均が長期移動平均を下回ると,それは販売信号とみなされる.

戦略の論理

この戦略は,50日,100日,200日という異なる期間の3つの単純な移動平均値 (SMA) に基づいています. 具体的な取引論理は以下のとおりです.

  1. 入力信号: 50日間の移動平均が 100日間の移動平均を超えると,ロングにします.

  2. 出口シグナル:50日間の移動平均が100日間の移動平均を下回ると,ポジションを閉じる.または閉じる価格が100日間の移動平均を下回ると,出口する.または100日間の移動平均が200日間の移動平均を下回ると,出口する.

  3. 利益とストップロスを設定する.

この戦略は,市場平均価格の傾向を効果的に決定するために移動平均の能力を利用する.短期および長期平均のクロスオーバーは,市場が上向きまたは下向きの傾向に入ると見られ,その結果,ロングまたは出口信号が表示されます.これは戦略が市場傾向を効果的に把握することを可能にします.

利点

  1. 3つの移動平均値が必要になります.

  2. 移動平均は,取引に対する市場のランダム性の影響を軽減し,シグナルをより信頼性のあるものにします.

  3. 主要なトレンドを把握しやすい.移動平均は,短期線と長期線間のクロスオーバーを使用して,主要なトレンド変化を決定することで,平均市場価格のトレンドの変化を効果的に反映する.

  4. 高度にカスタマイズ可能.移動平均期間は,リスク管理の異なるレベルのために調整できます.

リスク

  1. 多くの誤った信号を生む可能性があります.短期および長期間の平均値があまりにも近い場合,頻繁にクロスオーバーが発生し,過度に無効な信号が発生します.

  2. 急激な出来事に対して反応が遅い.移動平均値は価格変化にゆっくり反応し,市場のニュースや主要なイベントに即座に反応することはできません.

  3. 小規模な変動から利益を得ることができない.ノイズフィルタリングは,小規模な市場の変動から利益を失うことを意味します.

  4. 主観的なパラメータ選択.適切な移動平均期間の多くは主観的で,特定の市場に依存します.

増進 の 機会

  1. 誤った信号を減らすためにフィルターを追加します.例えば,値範囲フィルターで,特定の大きさ以上の動きに信号を制限します.

  2. 配列戦略の他の指標を組み込むこと,例えば波動性またはボリューム指標など,信号の精度を向上させる.

  3. 機械学習アルゴリズムに基づく移動平均期を動的に最適化するための適応最適化モジュールを追加し,変化する市場状況に適応できるようにします.

  4. 高級な特徴抽出とモデリング能力のために 移動平均の代わりに 先進的なディープラーニングモデルを組み込む

結論

ゴールデンクロス移動平均取引戦略は,典型的なトレンドフォロー戦略である.これは,初心者向けに適した,単純で実践的な平均市場価格傾向を反映している.しかし,他の技術指標と組み合わせ,適応メカニズムを導入し,より複雑な市場に適応することで,信号品質を改善することで改善できるいくつかの欠点もある.全体的に,これは高い参照値と学習価値を持つ戦略である.


/*backtest
start: 2023-12-03 00:00:00
end: 2023-12-10 00:00:00
period: 1m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © CJDeegan

//@version=4
strategy(title = "[LIVE] Golden Cross", overlay=true)

// ------------Functions------------

//Percent to Decimal Conversion
perToDec(a) => a * 0.01
//Price Difference to Tick
diffToTick(a,b) => (a - b) / syminfo.mintick 

    
// ------------Strategy Inputs------------
takeProfitInput = input(300, "Take Profit Price (% Gain)")
stopLossInput = input(25, "Stop Loss (% Loss)")


startDate = input(title="Start Date", type=input.integer,
     defval=1, minval=1, maxval=31)
startMonth = input(title="Start Month", type=input.integer,
     defval=1, minval=1, maxval=12)
startYear = input(title="Start Year", type=input.integer,
     defval=2018, minval=1800, maxval=2100)

endDate = input(title="End Date", type=input.integer,
     defval=1, minval=1, maxval=31)
endMonth = input(title="End Month", type=input.integer,
     defval=1, minval=1, maxval=12)
endYear = input(title="End Year", type=input.integer,
     defval=2031, minval=1800, maxval=2100)

inDateRange = (time >= timestamp(syminfo.timezone, startYear,
         startMonth, startDate, 0, 0)) and
     (time < timestamp(syminfo.timezone, endYear, endMonth, endDate, 0, 0))
     

// ------------Populate Indicators------------

//EMA
sma50 = sma(close,50)
sma100 = sma(close,100)
sma200 = sma(close,200)


// ------------Entry Logic------------
//Guards
entryGuard = true
//Triggers
entryTrigger = crossover(sma50,sma100)
//Conditions
entryCondition = entryGuard and entryTrigger
//Calculations
//Execution
if (inDateRange and entryCondition)
    strategy.entry("Long", strategy.long, when = entryCondition, comment = "Entry")

//------------Exit Logic------------

//Guards
//Triggers
exitTrigger = crossunder(sma50,sma100) or close < sma100 or crossunder(sma100,sma200)
//Conditions
exitCondition = exitTrigger

//Calculations
//Take Profit
takeProfitPrice = strategy.position_avg_price + (strategy.position_avg_price * perToDec(takeProfitInput))
//Take Profit Ticks
takeProfitTicks = diffToTick(takeProfitPrice, strategy.position_avg_price)
//StopLoss
stopLossPrice = strategy.position_avg_price - (strategy.position_avg_price * perToDec(stopLossInput))

//Execution
if (inDateRange)
    strategy.close("Long", when = exitCondition, comment = "Sell Trigger")
    strategy.exit("Exit", "Long", comment="Stop", profit=takeProfitTicks, stop=stopLossPrice)

//Plots
plot(sma50, "SMA 50", color = color.blue)
plot(sma100, "SMA 100", color = color.green)
plot(sma200, "SMA 200", color = color.yellow)
entry = plot(strategy.position_size <= 0 ? na : strategy.position_avg_price, "Entry Price", color = color.yellow, style = plot.style_linebr)
profit = plot(strategy.position_size <= 0 ? na : takeProfitPrice, "Take Profit (Price)", color = color.green, style = plot.style_linebr)
stop = plot(strategy.position_size <= 0 ? na : stopLossPrice, "Stop Loss", color = color.red, style = plot.style_linebr)
fill(entry,profit, color=color.green)
fill(entry,stop, color=color.red)


もっと