ストカスティックモメンタム・ダブル・インディケーター戦略

作者: リン・ハーンチャオチャン, 日付: 2023年10月7日 16時45分25秒
タグ:

概要

この戦略は,長期信号と短期信号の双重ストカスティックモメント指標 (SMIとRSI) と,トレード信号選択のためのマルティンゲールおよびボディフィルターを用い,中期トレンドと価格変動を把握することを目的としています.

戦略の論理

この戦略は,SMIとRSIという2つのストカスティック指標を用いて,ロングとショートを判断する.SMIはバーレンジとクローズ価格の移動平均値に基づいて計算され,逆転点を識別することが良い.RSIは,過買いと過売りの状態を決定するために,牛と熊の力を比較する.SMIが-50未満,RSIが20以下であるとき戦略はロングになります.SMIが50を超え,RSIが80を超えるときはショートになります.

偽ブレイクをフィルタリングするために,戦略は10期ボディSMAの1/3を突破フィルター条件として使用する.ボディがSMAの1/3を突破すると,ブレイクが有効とみなされる.

さらに,この戦略はオプションのマルティンゲルを採用し,過去の損失を回復しようと,負ける取引のロットを拡大します.

バックテスト機能は,日付範囲を入力して戦略をバックテストします.

利点分析

この戦略は,反転点を効果的に特定し,中期トレンドを把握し,価格変動を追跡できる 双重ストカスティック指標とフィルターを組み合わせています.

  • SMIは反転点の認識能力が強く,過剰購入と過剰売却の条件を効果的に判断することができます.
  • RSIを追加すると,見逃した取引は避けられます.
  • 身体フィルターは 偽の突出を排除し 信号の精度を向上させる
  • 選択的なマルティンゲル戦略は損失の一部を回収することを可能にします.

リスク分析

  • SMIとRSIは遅れている指標として 高値を追いかけて低値を打つリスクがあります
  • マルティンゲルは損失を加速させる危険性があります
  • フィルターは,市場範囲内の有効なシグナルをフィルタリングすることができます.

SMIとRSIのパラメータを最適化し,追跡/殺戮の確率を下げ,スケールアップ比率と時間を制御することによって戦略的にマルティンゲールを使用し,市場状況に基づいて裁量的にフィルターを有効にすることでリスクは軽減できます.

オプティマイゼーションの方向性

  • SMIとRSIのパラメータを最適化して判断の有効性を向上させる.
  • フィルターパラメータを調整して,有効な信号をフィルタリングする確率を下げる.
  • マルティンゲルスケールアップの時間と比率を最適化します
  • トレンドに反する取引を避けるためにトレンド指標を組み込む.
  • ストップ・ロスを追加して単一の取引での損失を制限します.

概要

この戦略は,逆転点を捕捉するために二重ストキャスト指標を組み合わせ,トレードシグナル選択と追いかけるためのフィルターとマルティンゲールを組み合わせます.中期トレンドを効果的に特定し,高勝率を追求する投資家に適した価格変動を追跡することができます.指標遅れと範囲の市場リスクに注意を払い,パラメータ最適化とストップ損失によってリスクを管理します.


/*backtest
start: 2022-09-30 00:00:00
end: 2023-10-06 00:00:00
period: 2d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
// strategy(title = "CS Basic Scripts - Stochastic Special (Strategy)", shorttitle = "Stochastic Special", overlay = false, default_qty_type = strategy.percent_of_equity, default_qty_value = 100, pyramiding = 0)

//Settings 
needlong = input(true, defval = true, title = "Long")
needshort = input(true, defval = true, title = "Short")
usemar = input(false, defval = false, title = "Use Martingale")
capital = input(100, defval = 100, minval = 1, maxval = 10000, title = "Capital, %")
usesmi = input(true, defval = true, title = "Use SMI Strategy")
usersi = input(true, defval = true, title = "Use RSI Strategy")
usebod = input(true, defval = true, title = "Use Body-Filter")
a = input(5, "SMI Percent K Length")
b = input(3, "SMI Percent D Length")
limit = input(50, defval = 50, minval = 1, maxval = 100, title = "SMI Limit")

//Backtesting Input Range
fromyear = input(2017, defval = 2017, minval = 1900, maxval = 2100, title = "From Year")
toyear = input(2100, defval = 2100, minval = 1900, maxval = 2100, title = "To Year")
frommonth = input(01, defval = 01, minval = 01, maxval = 12, title = "From Month")
tomonth = input(12, defval = 12, minval = 01, maxval = 12, title = "To Month")
fromday = input(01, defval = 01, minval = 01, maxval = 31, title = "From day")
today = input(31, defval = 31, minval = 01, maxval = 31, title = "To day")

//Fast RSI
fastup = rma(max(change(close), 0), 7)
fastdown = rma(-min(change(close), 0), 7)
fastrsi = fastdown == 0 ? 100 : fastup == 0 ? 0 : 100 - (100 / (1 + fastup / fastdown))

//Stochastic Momentum Index
ll = lowest (low, a)
hh = highest (high, a)
diff = hh - ll
rdiff = close - (hh+ll)/2
avgrel = ema(ema(rdiff,b),b)
avgdiff = ema(ema(diff,b),b)
SMI = avgdiff != 0 ? (avgrel/(avgdiff/2)*100) : 0
SMIsignal = ema(SMI,b)

//Lines
plot(SMI, color = blue, linewidth = 3, title = "Stochastic Momentum Index")
plot(SMIsignal, color = red, linewidth = 3, title = "SMI Signal Line")
plot(limit, color = black, title = "Over Bought")
plot(-1 * limit, color = black, title = "Over Sold")
plot(0, color = blue, title = "Zero Line")

//Body Filter
nbody = abs(close - open)
abody = sma(nbody, 10)
body = nbody > abody / 3 or usebod == false

//Signals
up1 = SMI < -1 * limit and close < open and body and usesmi
dn1 = SMI > limit and close > open and body and usesmi
up2 = fastrsi < 20 and close < open and body and usersi
dn2 = fastrsi > 80 and close > open and body and usersi
exit = ((strategy.position_size > 0 and close > open) or (strategy.position_size < 0 and close < open)) and body

//Trading
profit = exit ? ((strategy.position_size > 0 and close > strategy.position_avg_price) or (strategy.position_size < 0 and close < strategy.position_avg_price)) ? 1 : -1 : profit[1]
mult = usemar ? exit ? profit == -1 ? mult[1] * 2 : 1 : mult[1] : 1
lot = strategy.position_size == 0 ? strategy.equity / close * capital / 100 * mult : lot[1]

if up1 or up2
    if strategy.position_size < 0
        strategy.close_all()
        
    strategy.entry("long", strategy.long, needlong == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))

if dn1 or dn2
    if strategy.position_size > 0
        strategy.close_all()
        
    strategy.entry("Short", strategy.short, needshort == false ? 0 : lot, when=(time > timestamp(fromyear, frommonth, fromday, 00, 00) and time < timestamp(toyear, tomonth, today, 23, 59)))
    
if time > timestamp(toyear, tomonth, today, 23, 59) or exit
    strategy.close_all()

もっと