ケースダイナミックストップロス戦略


作成日: 2023-09-13 14:08:47 最終変更日: 2023-09-13 14:08:47
コピー: 0 クリック数: 737
1
フォロー
1617
フォロワー

この戦略は,カース氏のダイナミック・ストップ・ローズ理論に基づいて設計された.この戦略は,価格のダイナミックな波動範囲を計算し,最適なストップ・ローズとストップ・ストップ・価格のポイントを探し,利益と損失の均衡を実現する.

戦略の原則:

  1. 価格の動的波動範囲指数RWHとRWLを計算する.

  2. RWHとRWLから得られた価格偏差度指数Pk。

  3. Pk>0時,偏差度に応じてストップ・プローストを計算する.Pk時,ストップ・プローストを計算する.

  4. 選択可能な止損停止の偏差倍数,通常は標準差の1-3倍である.

  5. 価格がストップ・ストップ・ストップの値に触れたとき,逆操作を行う.

この戦略の利点は

  1. 市場変動に応じて調整可能なストップ・ストップ・ポイントの動的計算.

  2. ストップダメージポイントは,あまりにも近づいたり,あまりにも緩やかになることはありません.

  3. 数学的な計算は,主観的な感情による判断を避けます.

この戦略のリスクは

  1. ストップ・プライスの計算が遅れているため,最適のストップ・ポイントを逃す可能性があります.

  2. 倍数偏差のパラメータを最適化して,止損停止を均衡させる.

  3. 単一の損失の大きさを制限することはできません.

要するに,この戦略は,ストップ・ストップの設定を一定程度に賢明に最適化できるが,その効果は,裏返しによる検証が必要であり,SUBJECTIVE 主観的なリスクを完全に回避することはできない.

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

//@version=4
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 09/10/2019
//  The Kase Dev Stops system finds the optimal statistical balance between letting profits run, 
//  while cutting losses.  Kase DevStop seeks an ideal stop level by accounting for volatility (risk),
//  the variance in volatility (the change in volatility from bar to bar), and volatility skew 
//  (the propensity for volatility to occasionally spike incorrectly).
//
//  Kase Dev Stops are set at points at which there is an increasing probability of reversal against 
//  the trend being statistically significant based on the log normal shape of the range curve.  
//  Setting stops will help you take as much risk as necessary to stay in a good position, but not more.
//
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Kase Dev Stops Backtest", overlay = true)
Length = input(30, minval=2, maxval = 100)
Level = input(title="Trade From Level", defval=4, options=[1, 2, 3, 4])
reverse = input(false, title="Trade reverse")
RWH = (high - low[Length]) / (atr(Length) * sqrt(Length))
RWL = (high[Length] - low) / (atr(Length) * sqrt(Length))
Pk = wma((RWH-RWL),3)
AVTR = sma(highest(high,2) - lowest(low,2), 20)
SD = stdev(highest(high,2) - lowest(low,2),20)
Val4 = iff(Pk>0, highest(high-AVTR-3*SD,20), lowest(low+AVTR+3*SD,20))
Val3 = iff(Pk>0, highest(high-AVTR-2*SD,20), lowest(low+AVTR+2*SD,20))
Val2 = iff(Pk>0, highest(high-AVTR-SD,20), lowest(low+AVTR+SD,20))
Val1 = iff(Pk>0, highest(high-AVTR,20), lowest(low+AVTR,20))
ResPrice = iff(Level == 4, Val4,
             iff(Level == 3, Val3,
               iff(Level == 2, Val2,
                 iff(Level == 1, Val1, Val4))))
pos = iff(close < ResPrice , -1, 1)
possig = iff(reverse and pos == 1, -1,
          iff(reverse and pos == -1 , 1, pos))	   
if (possig == 1) 
    strategy.entry("Long", strategy.long)
if (possig == -1)
    strategy.entry("Short", strategy.short)	 
if (possig == 0) 
    strategy.close_all()
barcolor(possig == -1 ? #b50404: possig == 1 ? #079605 : #0536b3 )