HPotter

Z-Score Strategy

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 to change Trigger parameter for to get best values of strategy.

Mã nguồn mở

Với tinh thần TradingView, tác giả của tập lệnh này đã xuất bản nó dưới dạng mã nguồn mở, vì vậy các nhà giao dịch có thể hiểu và xác minh nó. Chúc mừng tác giả! Bạn có thể sử dụng mã này miễn phí, nhưng việc sử dụng lại mã này trong một ấn phẩm chịu sự điều chỉnh của Nội quy nội bộ. Bạn có thể yêu thích nó để sử dụng nó trên biểu đồ.

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.

Bạn muốn sử dụng tập lệnh này trên biểu đồ?
////////////////////////////////////////////////////////////
//  Copyright by HPotter v1.0 07/07/2014
// 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. 
////////////////////////////////////////////////////////////
study(title="Z-Score Strategy", shorttitle="Z-Score Strategy")
Period = input(20, minval=1)
Trigger = input(0)
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))) 
barcolor(pos == -1 ? red: pos == 1 ? green : blue )
plot(nRes, color=blue, title="Z-Score")