Z distance from VWAP [LazyBear]

This calculates normal distance of price from VWAP . This is a mean reverting idea (something like ZScore), but using both "volume" and "close".

Useful for finding OB/OS areas and potential turning points.

Complete list of my indicators:
סקריפט קוד פתוח

ברוח TradingView אמיתית, מחבר סקריפט זה פרסם אותו עם קוד פתוח, כך שסוחרים יוכלו להבין ולאמת זאת. הידד למחבר! אתה יכול להשתמש בו בחינם, אך שימוש חוזר בקוד זה בפרסום הנו בכפוף ל כללי הבית . אתה יכול להגדירו כמועדף ולהשתמש בו בגרף.

רוצה להשתמש בסקריפ זה בגרף?
// @author LazyBear 
// List of all my indicators:
study("Z distance from VWAP [LazyBear]", shorttitle="ZVWAP_LB")

calc_zvwap(pds) =>
	mean = sum(volume*close,pds)/sum(volume,pds)
	vwapsd = sqrt(sma(pow(close-mean, 2), pds) )


plot(1, style=3, color=gray), plot(-1, style=3, color=gray)
ul1=plot(upperTop, "OB High")
ul2=plot(upperBottom, "OB Low")
fill(ul1,ul2, color=red)
ll1=plot(lowerTop, "OS High")
ll2=plot(lowerBottom, "OS Low")
fill(ll1,ll2, color=green)
plot(calc_zvwap(length),title="ZVWAP",color=maroon, linewidth=2)

List of my free indicators:
List of my indicators at Appstore:


This seems really interesting/powerful used in conjunction with MACD/Derivative Oscillator as well as your WT_LB indicator. Could you talk a bit here about how you use it? It seems in backtesting that it gives a good leading indicator of possible MACD crosses.

(am newb, thanks much)
+13 השב
How do I add this to thinkorswim? Copy/paste isn't working. Thanks!
+5 השב
t_todua Special_Grant
@Special_Grant, it needs ThinkOrSwim programmer.
Great !...The big boys come in when price deviates 4% from VWAP ;)
+2 השב
Nice..thanks for the info :)
Hey, curious if there was a reason you used "close" as the source instead of "vwap" when calculating the vwap deviation? (Genuine question - I am learning a lot from these open source scripts). Thanks!
Hi, this is a very good indicator.
I have scanned around 3 years data manually, and it is doing great.

I wanted to tweak a little of your great code, to just be able to show the difference between the last and yesterday value of ZVWAP
so that I could tell the slope of the line from bar to bar.

since I am newbie in coding.

I tried to input --> plot calc_zvmap..... but it is not working.
and tried others but still no clue (tried also read the manual).

some hints or clue is very well appreciated.

excellent indicator
What does PDS define?
It doesnt seem to work for currencies and indexes... any idea ?