케이스 다이내믹 스톱 로스 전략


생성 날짜: 2023-09-13 14:08:47 마지막으로 수정됨: 2023-09-13 14:08:47
복사: 0 클릭수: 737
avatar of ChaoZhang ChaoZhang
1
집중하다
1617
수행원

이 전략은 케이스 씨의 역동적인 스톱 로드 이론에 기초하여 설계되었다. 이 전략은 가격의 역동적인 변동 범위를 계산하여 최적의 스톱 로드 및 스톱 로드 가격 지점을 찾고, 이윤 손실 균형을 이룬다.

전략적 원칙:

  1. 가격의 동적 변동 범위 지수 RWH와 RWL을 계산한다.

  2. RWH와 RWL에 따라 가격 편차 정도 지수 Pk △ 를 얻는다.

  3. Pk>0일 때, 오차의 정도에 따라 중지 가격을 계산한다. Pk일 때, 중지 가격을 계산한다.

  4. 선택 가능한 정지 손해 막의 편차 배수, 일반적으로 표준 차이의 1~3배이다.

  5. 가격이 스톱로스 스톱 가격에 도달했을 때, 반전 작업을 수행한다.

이 전략의 장점:

  1. 동적으로 계산된 스톱로스 스톱포인트는 시장의 변동에 따라 조정할 수 있다.

  2. 정지점은 너무 가깝거나 너무 느슨하지 않습니다.

  3. 수학적인 계산은 주관적인 감정이 판단에 영향을 미치지 않도록 합니다.

이 전략의 위험은:

  1. 스톱로스 가격 계산에 지연이 있어 최적의 스톱로스 시점을 놓칠 수 있다.

  2. 곱하기 변수 오차를 최적화하여 스톱로스 스탠프를 균형을 잡아야 한다.

  3. 단일 손실의 크기를 제한할 수 없으며, 큰 단일 손실의 위험이 있습니다.

결론적으로, 이 전략은 Stop Loss Setup를 어느 정도 지능적으로 최적화 할 수 있지만, 그 효과는 여전히 재검토를 통해 검증되어야하며, 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 )