Z-Score 가격 유출 전략

저자:차오장, 날짜: 2023-12-07 15:17:43
태그:

img

전반적인 설명

Z 스코어 가격 브레이크아웃 전략은 현재 가격이 비정상적인 상태에 있는지 여부를 결정하기 위해 가격의 z 스코어 지표를 사용하여 거래 신호를 생성합니다. 가격의 z 스코어가 한 임계보다 높거나 낮을 때 가격은 비정상적인 상태에 들어갔다는 것을 의미합니다. 이 시점에서 긴 또는 짧은 포지션을 취할 수 있습니다.

전략 원칙

이 전략의 핵심 지표는 다음과 같이 계산되는 가격의 z 점수입니다.

Z_score = (C - SMA(n)) / StdDev(C,n)

여기서 C는 종료 가격이고, SMA (n) 는 n 기간의 단순한 이동 평균이며, StdDev (C,n) 는 n 기간의 종료 가격의 표준편차입니다.

z 점수는 현재 가격과 평균 가격의 오차 정도를 나타냅니다. 가격 z 점수가 특정 긍정적 인 임계 (예를 들어 +2) 보다 크면 현재 가격이 평균 가격보다 2 표준 오차가 높다는 것을 의미합니다. 상대적으로 높은 수준입니다. 특정 부정적인 임계 (예를 들어 -2) 보다 작을 때 현재 가격이 평균 가격보다 2 표준 오차가 낮다는 것을 의미합니다.

이 전략은 먼저 가격의 z 점수를 계산하고, 그 다음 양적 및 음적 임계치를 설정합니다. 예를 들어 0 및 0. z 점수가 양적 임계치보다 높을 때 구매 신호를 생성합니다. 부정적인 임계치보다 낮을 때 판매 신호를 생성합니다.

이점 분석

  • 가격 z 점수를 사용하여 가격 이상성을 판단하는 것은 일반적이고 효과적인 수치적 방법입니다.
  • 긴 거래와 짧은 거래를 쉽게 달성합니다.
  • 유연한 매개 변수 설정, 조절 가능한 사이클, 임계 등
  • 다른 지표와 결합하여 거래 시스템을 형성할 수 있습니다.

위험 분석

  • z점 전략은 원시적이고 잘못된 신호에 취약합니다.
  • 사이클과 문턱과 같은 적절한 매개 변수를 설정해야 합니다
  • 위험을 통제하기 위해 스톱 로스 전략을 고려해야 합니다.

최적화 방향

  • 최적의 사이클을 찾기 위해 사이클 매개 변수를 최적화
  • 잘못된 신호를 줄이기 위해 긍정적 및 부정적 문턱을 최적화하십시오.
  • 필터 조건을 추가, 다른 표시기와 결합
  • 스톱 로스 전략을 추가

요약

z 점수 가격 브레이크아웃 전략은 현재 가격이 비정상적인 상태에 있는지 판단하고 가격 z 점수의 양적 및 부정적에 따라 거래합니다. 이 전략은 간단하고 구현하기가 쉽습니다. 쌍방향 거래를 허용하지만 또한 약간의 위험이 있습니다. 매개 변수를 최적화하고 스톱 로스를 추가하고 다른 지표와 결합함으로써이 전략을 향상시켜 완전한 양적 거래 시스템을 형성 할 수 있습니다.


/*backtest
start: 2023-11-29 00:00:00
end: 2023-12-04 19:00:00
period: 15m
basePeriod: 5m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

//@version=2
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 18/01/2017
// The author of this indicator is Veronique Valcu. The z-score (z) for a data 
// item x measures the distance (in standard deviations StdDev) and direction 
// of the item from its mean (U):
//     z = (x-StdDev) / U
// A value of zero indicates that the data item x is equal to the mean U, while 
// positive or negative values show that the data item is above (x>U) or below 
// (x Values of +2 and -2 show that the data item is two standard deviations 
// above or below the chosen mean, respectively, and over 95.5% of all data 
// items are contained within these two horizontal references (see Figure 1).
// We substitute x with the closing price C, the mean U with simple moving 
// average (SMA) of n periods (n), and StdDev with the standard deviation of 
// closing prices for n periods, the above formula becomes:
//     Z_score = (C - SMA(n)) / StdDev(C,n)
// The z-score indicator is not new, but its use can be seen as a supplement to 
// Bollinger bands. It offers a simple way to assess the position of the price 
// vis-a-vis its resistance and support levels expressed by the Bollinger Bands. 
// In addition, crossings of z-score averages may signal the start or the end of 
// a tradable trend. Traders may take a step further and look for stronger signals 
// by identifying common crossing points of z-score, its average, and average of average. 
//
// You can change long to short in the Input Settings
// Please, use it only for learning or paper trading. Do not for real trading.
////////////////////////////////////////////////////////////
strategy(title="Z-Score Strategy", shorttitle="Z-Score Strategy")
Period = input(20, minval=1)
Trigger = input(0)
reverse = input(false, title="Trade reverse")
hline(Trigger, color=purple, linestyle=line)
xStdDev = stdev(close, Period)
xMA = sma(close, Period)
nRes = (close - xMA) / xStdDev
pos = iff(nRes > Trigger, 1,
	   iff(nRes < Trigger, -1, nz(pos[1], 0))) 
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)	   	    
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(nRes, color=blue, title="Z-Score")

더 많은