Z-Score Distance From VWAP

Category: Indicators By: Nicolas Created: January 8, 2019, 2:32 PM
January 8, 2019, 2:32 PM
Indicators
11 Comments

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).

//PRC_VWAP Z-score
//08.01.2019
//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)
else
 VWAP = SUMMATION[d](volume*customclose)/SUMMATION[d](volume)
endif

sd = SUMMATION[max(SDminPeriod,d)](max(abs(high-vwap),abs(vwap-low)))/max(SDminPeriod,d)

if smoothZscore then 
 zscore=average[3]((close-vwap)/sd)
else
 zscore = (close-vwap)/sd
endif

if zscore>=2 then 
 drawcandle(2,2.5,2,2.5) coloured(255,0,0,100) bordercolor(0,0,0,0)
endif
if zscore<=-2 then 
 drawcandle(-2,-2.5,-2,-2.5) coloured(0,255,0,100) bordercolor(0,0,0,0)
endif

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)

 

Download
Filename: PRC_VWAP-Z-score.itf
Downloads: 583
Nicolas Master
I created ProRealCode because I believe in the power of shared knowledge. I spend my time coding new tools and helping members solve complex problems. If you are stuck on a code or need a fresh perspective on a strategy, I am always willing to help. Welcome to the community!
Author’s Profile

Comments

Logo Logo
Loading...