移動平均値とストカスティック取引戦略

作者: リン・ハーンチャオチャン,日付: 2024-02-02 10:48:37
タグ:

img

概要

この戦略は,動向平均値とストカストティックオシレーターを組み合わせて自動化された株式取引システムを実装する. 2つの異なる長さの動向平均値とストカストティック指標を使用して,トレンドと過剰購入/過剰販売のシグナルを把握し,過剰購入/過剰販売の地域におけるトレンド方向と指標信号に基づいて購入および販売の決定を行う.

戦略の論理

1. 移動 平均

移動平均線は5日間の移動線と20日間の移動平均線を使用する. 移動平均線がスローラインを越えるのは購入信号であり,下を通るのは販売信号である. 移動平均線は価格の傾向と方向性を決定する.

2.ストカスティックオシレーター

ストキャストパラメータは:K線14期,K線スムーズ期3,D線スムーズ期3期に設定されている.K線上の20未満は過売り地域であり,80を超えるのは過買い地域である.ストキャストオシレーターは,過買い/過売り地域にあるかどうかを決定する.

3. 入場規則

購入条件: 遅いMAとK線 <20 (過売り地域) の上での高速MAクロスオーバー 販売条件: 緩やかなMAとK線 > 80 (過買い地域) 以下の高速MAクロスオーバー

買い条件が満たされたらロング,売条件が満たされたらショート.

4. ストップ 損失 設定

購入後に1%の利益目標を設定し 売却後に1%のストップロスを設定します

利点分析

この戦略は,トレンドと指標を組み合わせ,中長期の価格トレンドを効果的に把握し,ストカスタスティックオシレーターを使用して取引のタイミングを制御し,明確な方向性バイアスなしにランダムなエントリーを避ける. 戦略パラメータは異なる市場環境に調整可能である. 全体的にこの戦略は上昇傾向の大きな/ミッドキャップ株式で非常にうまく機能する.

リスク と 解決策

  • 重要なニュースイベントによる価格急上昇は大きな損失を伴う可能性があります.ストップ損失はリスクを制御できます.

  • 持続的な範囲限定市場では,連続して小規模な損失を引き起こす可能性があります.損失を減らすためにMA期間を調整します.

  • 価格が逆転する傾向のある重要な市場期間を避ける.

最適化

  • 異なるMA長さなどの最適なパラメータを見つけるために,異なるパラメータ組み合わせをテストする.

  • 利益率を向上させるため フィルター条件のボリュームや波動性などの他の分析ツールを組み込む

  • 単一株のリスクを減らすため 強い株や上限指数を選ぶような 株の選択メカニズムを研究します

結論

ストップ損失と利益目標により,全体的な利益/損失プロファイルは堅調である.パラメータ調整とストックプールフィルタリングからさらなる改善が期待できる.一般的にこれは実行が容易で堅牢な定量的な取引戦略である.


/*backtest
start: 2024-01-25 00:00:00
end: 2024-02-01 00:00:00
period: 5m
basePeriod: 1m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=4
strategy("Moving Average and Stochastic Strategy 80% ", overlay=true)

// Moving Average Settings
maShortLength = input(5, title="Short MA Length")
maLongLength = input(20, title="Long MA Length")

// Stochastic Settings
stochLength = input(14, title="Stochastic Length")
smoothK = input(3, title="Stochastic %K")
smoothD = input(3, title="Stochastic %D")
stochOverbought = 80
stochOversold = 20

// Profit Target Settings
profitTarget = input(1, title="Profit Target (%)") // 1% profit target

// Calculate Moving Averages
maShort = sma(close, maShortLength)
maLong = sma(close, maLongLength)

// Calculate Stochastic
k = sma(stoch(close, high, low, stochLength), smoothK)
d = sma(k, smoothD)

// Entry Conditions
longConditionMA = crossover(maShort, maLong) and k < stochOversold
shortConditionMA = crossunder(maShort, maLong) and k > stochOverbought

// Opposite Conditions
oppositeLongConditionMA = crossunder(maShort, maLong) and k < stochOversold
oppositeShortConditionMA = crossover(maShort, maLong) and k > stochOverbought

// Strategy Logic
if (longConditionMA)
    strategy.entry("Buy", strategy.long)
    strategy.exit("Exit Buy", "Buy", profit=close * (50 + profitTarget / 100))

if (shortConditionMA)
    strategy.entry("Sell", strategy.short)
    strategy.exit("Exit Sell", "Sell", profit=close * (20 - profitTarget / 100))

// Opposite Strategy Logic
if (oppositeLongConditionMA)
    strategy.entry("Sell", strategy.short)
    strategy.exit("Exit Sell", "Sell", profit=close * (50 - profitTarget / 100))

if (oppositeShortConditionMA)
    strategy.entry("Buy", strategy.long)
    strategy.exit("Exit Buy", "Buy", profit=close * (20 + profitTarget / 100))

// Plot Moving Averages
plot(maShort, color=color.blue, title="Short MA")
plot(maLong, color=color.red, title="Long MA")

// Plot Stochastic
hline(stochOverbought, "Overbought", color=color.red)
hline(stochOversold, "Oversold", color=color.green)
plot(k, color=color.black, title="Stochastic %K")

もっと