Kase 다이내믹 스톱 로스 전략

저자:차오장, 날짜: 2023-09-13 14:08:47
태그:

이 전략은 Mr. 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 )

더 많은