
この戦略は,移動平均に基づく取引戦略である. 45日移動平均を主要技術指標として使用し,価格が移動平均を突破したシグナルに基づいて買入と売却を行う.
価格が上昇して45日移動平均を突破すると,買入シグナルが生成される. ポジションを保持して8日後に,売出シグナルが生成される. その後,価格が再び上昇して45日移動平均を突破すると,また買入シグナルが生成される.
この戦略の具体的原理は以下の通りです.
この戦略の核心となる取引の論理は,
この戦略の利点は以下の通りです.
この戦略にはいくつかのリスクがあります.
対策として
この戦略は,以下のような点で最適化できます.
移動平均のパラメータを最適化して,最適なパラメータの組み合わせを探します. 15日,30日,60日など,異なる日数パラメータをテストできます.
ポジション保持時間を最適化して,最適なポジション保持日数を探す. 5日,10日,15日など,異なるポジション保持期間をテストすることができます.
トレンドを追跡し,リスクを制御するために移動ストップを追加する.例えば,トライリングストップまたはATRストップ.
MACD,KDJなどの他の指標にフィルタリングを加え,偽信号を減らす.
再入国条件を最適化して,過剰な取引を防止する.例えば,冷却期間を延長するなど.
異なる市場と異なる品種の効果をテストする.パラメータは異なる市場のために最適化する必要があります.
この移動平均線交差戦略は,全体としてシンプルで実用的なトレンド追跡戦略である.移動平均線のトレンド追跡機能を利用し,価格突破と組み合わせて取引信号を生成する.利点は,実行が容易であり,トレード-オフは,いくつかの誤りや誤りがある可能性がある.パラメータを最適化し,補助的な技術指標を追加することで,よりよい効果を得ることができる.
/*backtest
start: 2023-01-16 00:00:00
end: 2024-01-22 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Moving Average Crossover Strategy", overlay=true)
// Calculate the 45-day moving average
ma_length = 45
ma = ta.sma(close, ma_length)
// Track position entry and entry bar
var bool in_long_position = na
var int entry_bar = na
var int exit_bar = na
// Entry condition: Close price crosses above the 45-day moving average to enter the position
if (not in_long_position and ta.crossover(close, ma) and not na(ma[1]) and close > ma and close[1] < ma[1])
in_long_position := true
entry_bar := bar_index
// Exit condition: Close the position after holding for 8 trading days
if (in_long_position and bar_index - entry_bar >= 8)
in_long_position := false
exit_bar := bar_index
// Re-entry condition: Wait for price to cross over the 45-day moving average again
if (not in_long_position and ta.crossover(close, ma) and not na(ma[1]) and close > ma and close[1] > ma[1] and (na(exit_bar) or bar_index - exit_bar >= 8))
in_long_position := true
entry_bar := bar_index
// Execute long entry and exit
if (in_long_position)
strategy.entry("Long", strategy.long)
if (not in_long_position)
strategy.close("Long")