In this indicator, the Z-Score distance is the current standard deviation from the intraday VWAP of the price.
If the exceed a certain deviation (such as 2 standard deviation), the indicator highlight an oversold or overbought area from which the price could tend to return to its mean, the VWAP.
The VWAP is the Volume Weighted Average Price, in this indicator it is compute only for intraday trading because it resets its own value on each new day.
I included a minimal period setting for the calculation of the standard deviation (default period is 100), as soon as 100 bars have elapsed the SD is calculated with the summation of all present bar during the day (such as the VWAP does too), and a smoothing function for the curve (not used by default).
//Nicolas @ www.prorealcode.com
//Sharing ProRealTime knowledge
// --- settings
SDminPeriod = 100 //minimal period to compute the Standard Deviation
smoothZscore = 0 //smooth the curve? (0=false ; 1=true)
// --- end of settings
d = max(2,intradaybarindex)//max(1, intradaybarindex)
if intradaybarindex=0 then
vwap = (volume*customclose)/(volume)
VWAP = SUMMATION[d](volume*customclose)/SUMMATION[d](volume)
sd = SUMMATION[max(SDminPeriod,d)](max(abs(high-vwap),abs(vwap-low)))/max(SDminPeriod,d)
if smoothZscore then
zscore = (close-vwap)/sd
if zscore>=2 then
drawcandle(2,2.5,2,2.5) coloured(255,0,0,100) bordercolor(0,0,0,0)
if zscore<=-2 then
drawcandle(-2,-2.5,-2,-2.5) coloured(0,255,0,100) bordercolor(0,0,0,0)
RETURN zscore style(line,2), 1 coloured(168,168,168) style(line,2), 2 coloured(210,210,210) style(line,2), -1 coloured(168,168,168) style(line,2), -2 coloured(210,210,210) style(line,2), 0 coloured(168,168,168) style(dottedline)
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.ProRealTime ITF files and other attachments :