移動平均トレーリングストップ戦略


作成日: 2023-09-19 21:33:48 最終変更日: 2023-09-19 21:33:48
コピー: 2 クリック数: 691
1
フォロー
1617
フォロワー

概要

この戦略は,速いEMAで平均線を買い,ゆっくりとしたSMAで平均線を売りする交差によって買入シグナルを生成し,ATRの動的追跡ストップを活用してリスク管理を実現し,少数の取引によって買入保有戦略を上回ることを目的としている.

戦略原則

  1. 速速EMAの買入平均線と遅速SMAの買入平均線を計算し,速速線が遅速線を貫通し,一定の買入強度に達すると買入信号が生成する.

  2. 計算 速速EMAは平均線を売り,遅速SMAは平均線を売り,速速線の下が遅速線を突破すると売り信号が生成される。

  3. ATR指標のN日平均値を倍数で動的にストップ・ロスを追跡し,リスクコントロールを実現する.

  4. 分析期間中に戦略を立ち上げ,購入と販売を実行する.

  5. 各株は異なるパラメータの組み合わせを最適化し,最適なパラメータを探します.

この戦略は,移動平均指標のトレンド判断と交差信号とATRダイナミックトラッキングのストロップの優位性を融合し,パラメータを最適化して各品種の特性を適応させ,少数の精密取引によって購入と保有を超えた余剰利益を得ることを目指しています.

優位分析

  1. 速いEMAと遅いSMAの交差はトレンドを識別する取引信号を生成する.

  2. ATRストップは,市場の変動に応じてストップポジションを調整し,リスクを効果的にコントロールする.

  3. 株ごとにパラメータを最適化することで,利益率を上げることができる.

  4. シンプルな取引ロジックとルール,実行し,検証しやすい.

  5. 戦略の効果を検証するために,反射機能が整いました.

  6. 安定した生活を送るため 買い物や保有の余分な利益を 超えていくこと.

リスク分析

  1. 最適化されたパラメータは,必ずしも将来に適用されるわけではないので,定期的に再最適化が必要になるかもしれない.

  2. EMAとSMAの交差は,誤信号または信号遅延を引き起こす可能性がある.

  3. ATRの止損は過度に激進的であり,適切な止損範囲を緩めることができる.

  4. 取引頻度が低すぎると,良い取引機会が逃れることになる.

  5. 取引コストの影響を考慮する必要があります.

最適化の方向

  1. 異なるパラメータの組み合わせをテストし,最適なパラメータを探します.

  2. 信号フィルタリングの他の指標を導入してみてください.

  3. ATRの周期パラメータを最適化して,停止位の感度をバランスする.

  4. 適切な緩解の効果を評価する.

  5. 機械学習などの手法と組み合わせた自動最適化パラメータを考慮してください.

  6. 倉庫開設頻度を増やす効果を研究する.

要約する

この移動平均は,均線交差を生成するシグナルとATRのストップコントロールリスクの優位性を融合し,パラメータを最適化することで各株の特性に適応する,シンプルで実用的な超買い持有戦略の考え方である.最適化されたパラメータは,将来の効果を保証するものではないが,この戦略は,全体的な取引論理が明確で,実用的な操作性が強く,さらなる改善と検証に値し,優れた啓発的意義を持つ.

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

//@version=2
//created by XPloRR 04-03-2018

strategy("XPloRR MA-Trailing-Stop Strategy",overlay=true, initial_capital=1000,default_qty_type=strategy.percent_of_equity,default_qty_value=100)

testStartYear = input(2005, "Start Year")
testStartMonth = input(1, "Start Month")
testStartDay = input(1, "Start Day")
testPeriodStart = timestamp(testStartYear,testStartMonth,testStartDay,0,0)

testStopYear = input(2050, "Stop Year")
testStopMonth = input(12, "Stop Month")
testStopDay = input(31, "Stop Day")
testPeriodStop = timestamp(testStopYear,testStopMonth,testStopDay,0,0)

testPeriodBackground = input(title="Background", type=bool, defval=true)
testPeriodBackgroundColor = testPeriodBackground and (time >= testPeriodStart) and (time <= testPeriodStop) ? #00FF00 : na
bgcolor(testPeriodBackgroundColor, transp=97)

ema1Period = input(12, "Fast EMA Buy")
sma1Period = input(54, "Slow SMA Buy")
strength1 = input(52, "Minimum Buy Strength")

ema2Period = input(18, "Fast EMA Sell")
sma2Period = input(55, "Slow SMA Sell")
strength2 = input(100, "Minimum Sell Strength")

delta = input(8, "Trailing Stop (#ATR)")

testPeriod() => true

ema1val=ema(close,ema1Period)
sma1val=sma(close,sma1Period)
ema1strength=10000*(ema1val-ema1val[1])/ema1val[1]

ema2val=ema(close,ema2Period)
sma2val=sma(close,sma2Period)
ema2strength=10000*(ema2val-ema2val[1])/ema2val[1]

plot(ema1val,color=blue,linewidth=1)
plot(sma1val,color=orange,linewidth=1)
plot(ema2val,color=navy,linewidth=1)
plot(sma2val,color=red,linewidth=1)

long=crossover(ema1val,sma1val) and (ema1strength > strength1) 
short=crossunder(ema2val,sma2val) and (ema2strength < -strength2)

stopval=ema(close,6)
atr=sma((high-low),15)

inlong=0
buy=0
stop=0
if testPeriod()
    if (inlong[1])
        inlong:=inlong[1]
        buy:=close
        stop:=iff((stopval>(stop[1]+delta*atr)),stopval-delta*atr,stop[1])
    if (long) and (not inlong[1])
        strategy.entry("buy",strategy.long)
        inlong:=close
        buy:=close
        stop:=stopval-delta*atr
plot(buy,color=iff(close<inlong,red,lime),style=columns,transp=90,linewidth=1)
plot(stop,color=iff((short or (stopval<stop)) and (close<inlong),red,lime),style=columns,transp=60,linewidth=1)
if testPeriod()
    if (short or (stopval<stop)) and (inlong[1])
        strategy.close("buy")
        inlong:=0
        stop:=0
        buy:=0