モメントブレイク 移動平均戦略

作者: リン・ハーンチャオチャン,日付: 2023年11月27日 16:25:54
タグ:

img

概要

モメントブレイクムービング・アベレージ (Momentum Breakout Moving Average) 戦略は,モメント指数と移動平均クロスオーバー信号を組み合わせる株式取引戦略である.この戦略は,指数的な移動平均 (EMA),単純な移動平均 (SMA),移動平均収束分差 (MACD),および修正された相対強度指数 (StockRSI) を含む複数の技術指標を使用し,長期的上昇傾向を確認する際に購入信号を生成する.短期的なモメント指数が逆転信号を示したときに,戦略は利益を得ます.

戦略の論理

この戦略の主な要素は次のとおりです.

  1. EMA/SMAクロスオーバー: 9 期間の EMA 急速線が 21 期間の SMA 遅い線を横切って買い信号を誘発します.

  2. MACD インディケーター: EMA/SMAクロスオーバー信号と組み合わせると,MACDヒストグラムがプラスでなければならない.

  3. ストックRSI指標:StockRSIがOVERBOUGHTレベル (80) 以上またはOVERSOLDレベル (20) 以下になると信号が発信されます.

  4. ボリンジャー・バンド: 中央帯は20期SMAであり,帯の幅は2つの標準偏差である帯内に価格を要求する.

  5. 損失 を 止めて 利益 を 得る: 14 期間のATRに基づいて計算されます.

この戦略は,3つの指標のうち少なくとも2つが購入信号を与える必要がある.価格はボリンジャー帯内にあり,長期的トレンドは最終的な購入信号を生成するために上昇傾向のままである.MACDヒストグラムがマイナスになり,StockRSIが過剰購入領域に入ると販売信号を与える.

利点分析

この戦略の主な強みとは,

  1. バックテスト の 優秀 な 結果: 複数の実証された指標は,ベンチマークや個々の指標よりも優れた業績をもたらす.

  2. 最適化されたパラメータ: EMA 期間やボリンジャー帯などのキーパラメータは安定性を向上させるために最適化されています.

  3. 自動ストップ損失/利益取得: ボリンジャー帯とATRは,よりよいリスク管理のためにストップを動的に調整することができます.

  4. 簡単 に 実行 する: シンプルなコード構造と簡単なデータアクセシビリティにより,簡単な実用的な操作が可能になります.

リスク分析

良質な業績にも関わらず 主なリスクは以下です

  1. 偽信号: 市場における異常な変動や指標の不具合は,誤った信号を生む可能性があります.その後,長期傾向を追加フィルターとして組み込む必要があります.

  2. 適切なパラメータがない: 不適切なパラメータは,過剰な取引頻度や不十分な感度につながる可能性があります.パラメータは,異なる製品と市場環境に応じて調整する必要があります.

  3. 不適切なストップ・ロスト: ストップ・ロスは,あまりにも狭すぎると,早めにストップアウトする傾向があり,ストップ・ロスは,あまりにも広い範囲で設定されれば,過剰な損失を引き起こす可能性があります.ストップ・ロスのレベルと利益のレベルの間の適切なバランスが達成されるべきです.

上記のリスクに対処するために,次の措置が可決されます.

  1. 手動による介入: 異常な状況では,信号は手動でチェックされ,パラメータは再調整され,戦略は一時停止することができます.

  2. パラメータ最適化: 系統的な最適化のために遺伝子アルゴリズムのような より科学的で客観的な方法が用いられる.

  3. 波動性調整停止ストップ・ロスの範囲は,変動を考慮してATRの1-3倍に設定できます.

増進 の 機会

この戦略は,次の分野においてさらに改善できる.

  1. より堅牢なストップ・ロスト・メカニズム: 移動平均値に基づくストップ損失またはストップ損失を組み込むことができます.

  2. 音量フィルター: 誤ったブレイクを避けるためにボリューム指標を追加する.

  3. ダイナミックパラメータ移動平均期や帯域幅などのパラメータを 市場状況の変化に基づいて 自動的に最適化します

  4. 機械学習: LSTM,RNN,その他のアルゴリズムは,パラメータのダイナミック最適化を可能にします.

結論

モメントブレイアウト移動平均戦略は,複数の技術指標を組み合わせた強みを活用し,長期および短期間の確認により適正な収益性を達成している.良好なリスク管理手順の実施により,この戦略は,より一貫したアルファリターンを達成するためにストップ損失メカニズムや信号フィルタリングなどの分野でのさらなる改善の可能性が豊富である.


/*backtest
start: 2022-11-20 00:00:00
end: 2023-11-26 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=5
strategy("Improved Custom Strategy", shorttitle="ICS", overlay=true)

// Volatility
volatility = ta.atr(14)

// EMA/MA Crossover
fast_length = 9
slow_length = 21
fast_ma = ta.ema(close, fast_length)
slow_ma = ta.sma(close, slow_length)
crossover_signal = ta.crossover(fast_ma, slow_ma)

// MACD
[macdLine, signalLine, macdHistogram] = ta.macd(close, 12, 26, 9)
macd_signal = crossover_signal and (macdHistogram > 0)

// Bollinger Bands
source = close
basis = ta.sma(source, 20)
upper = basis + 2 * ta.stdev(source, 20)
lower = basis - 2 * ta.stdev(source, 20)

// Fractal-based Support and Resistance levels
isFractalHigh = high[2] < high[1] and high[1] > high[0]
isFractalLow = low[2] > low[1] and low[1] < low[0]
resistance = ta.valuewhen(isFractalHigh, high[1], 0)
support = ta.valuewhen(isFractalLow, low[1], 0)

// StockRSI
length = 14
K = 100 * (close - ta.lowest(close, length)) / (ta.highest(close, length) - ta.lowest(close, length))
D = ta.sma(K, 3)
overbought = 80
oversold = 20
stockrsi_signal = ((K < D) and (K < oversold)) or ((K > D) and (K > overbought))

// Buy and sell conditions
mandatory_buy_conditions = (crossover_signal ? 1 : 0) + (macd_signal ? 1 : 0) + (stockrsi_signal ? 1 : 0)

// Long-term Trend Check
long_term_ma = ta.sma(close, 200)
long_term_bullish = close > long_term_ma
long_term_bearish = close < long_term_ma

// Plot the long-term MA for visual clarity
plot(long_term_ma, color=color.gray, title="200-Day MA", linewidth=1)

// Simplified Buy and Sell conditions
buy_condition = long_term_bullish and (mandatory_buy_conditions >= 2) and (close > lower) and (close < upper)
sell_condition = (macdHistogram < 0) and (K > D) and (K > overbought)


// Potential SL and TP based on volatility
potential_SL = close - volatility
potential_TP = close + 2 * volatility

plot(potential_SL, title="SL Level", color=color.red, linewidth=1, style=plot.style_linebr)
plot(potential_TP, title="TP Level", color=color.green, linewidth=1, style=plot.style_linebr)

// ... (rest of your code above)

// State variable to track if we're in a position, a counter for trades, and a delayed counter for plotting
var bool inPosition = false
var tradeCounter = 0
var tradeCounterDelayed = 0 // Declaration of the variable

// Buy logic: Check if tradeCounter is 0 and the buy condition is met
if tradeCounter == 0 and buy_condition
    strategy.entry("BUY", strategy.long, stop=potential_SL, limit=potential_TP)
    inPosition := true
    tradeCounter := tradeCounter + 1

// Sell logic: Check if tradeCounter is 1, the sell condition is met, and we are in a position
if tradeCounter == 1 and inPosition and sell_condition
    strategy.close("BUY")
    inPosition := false
    tradeCounter := tradeCounter - 1

// Update the delayed trade counter:
tradeCounterDelayed := tradeCounter

// Plotting
bgcolor(buy_condition ? color.new(color.green, 90) : sell_condition ? color.new(color.red, 90) : na)
plotshape(series=buy_condition and tradeCounterDelayed == 0, style=shape.labelup, location=location.belowbar, color=color.green, text="BUY", size=size.small)
plotshape(series=sell_condition and tradeCounterDelayed == 1, style=shape.labeldown, location=location.abovebar, color=color.red, text="SELL", size=size.small)

// ... (rest of your code if any)


もっと