Kase ダイナミックストップ損失戦略

作者: リン・ハーンチャオチャン, 日時: 2023-09-13 14:08:47
タグ:

この戦略は,Kase氏の動的ストップ損失アプローチに基づいています. 価格の動的範囲を計算し,最適なストップ損失を見つけ,利益と損失をバランスするために利益レベルを取ります.

戦略論理:

  1. 価格の動的範囲インデックス RWH と RWL を計算する.

  2. RWHとRWLから偏差値Pkを導き出します.

  3. Pk>0の場合,偏差レベルに基づいてストップ損失を計算します. Pk<0の場合,利益を取ります.

  4. 偏差倍数は一般的に1〜3標準偏差からなる.

  5. 価格がストップ・ロスト/プロフィートに達すると反対のポジションを取ります

利点:

  1. 動的ストップ/利益は変動に適応する.

  2. ストップは太りすぎたり太り過ぎたりしない.

  3. 数学的なアプローチは 感情や主観的な判断を避けます

リスク:

  1. 停止計算の遅延で 最適停止タイミングが欠けている可能性があります

  2. パラメータ調整が必要で 止まりと標的をバランスさせる

  3. 損失の大きさに制限はありません 損失の大きな取引のリスクがあります

要約すると,このアプローチは,ある程度にストップとターゲットを賢く最適化することができますが,依然として強力なバックテストが必要です.また,主観的なリスクを完全に排除することはできません.


/*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 )

もっと