SandroTurriate

VWAP Stdev Bands v2

This is an update to my original VWAP Stdev Bands indicator found here:
* Fixed the calculation of the opening bar
* Added two additional deviation bands
* Added horizontal line of previous VWAP close

This update adds support for two more sets of bands, allowing you to show 1st, 2nd, and 3rd deviations. These extra bands are disabled by default as to not crowd the chart, but are shown in the screenshot and can be enabled under the indicator settings. The numbers 3.09 and 1.28 were recommended by coondawg71 in a comment on the original version. The previous version started calculating VWAP on a change of day, instead of a change of session. It now correctly calculates the VWAP when a new session begins. The last addition allows you to plot the previous day's VWAP close. The VWAP is where price has found balance, which makes these levels significant among the noise.

Thanks to coondawg71 for all suggestions.

סקריפט קוד פתוח

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

כתב ויתור

המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.

רוצה להשתמש בסקריפ זה בגרף?
study("VWAP Stdev Bands v2", overlay=true)
devUp1 = input(2, title="Stdev above (1)")
devDn1 = input(2, title="Stdev below (1)")

devUp2 = input(1.28, title="Stdev above (2)")
devDn2 = input(1.28, title="Stdev below (2)")

devUp3 = input(3.09, title="Stdev above (3)")
devDn3 = input(3.09, title="Stdev below (3)")

showDv2 = input(false, type=bool, title="Show second group of bands?")
showDv3 = input(false, type=bool, title="Show third group of bands?")

showPrevVWAP = input(false, type=bool, title="Show previous VWAP close")

start = security(tickerid, "D", time)

newSession = iff(change(start), 1, 0)

vwapsum = iff(newSession, hl2*volume, vwapsum[1]+hl2*volume)
volumesum = iff(newSession, volume, volumesum[1]+volume)
v2sum = iff(newSession, volume*hl2*hl2, v2sum[1]+volume*hl2*hl2)
myvwap = vwapsum/volumesum
dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0))

plot(myvwap, title="VWAP", color=green)
plot(myvwap + devUp1 * dev, title="VWAP Upper", color=red)
plot(myvwap - devDn1 * dev, title="VWAP Lower", color=red)

plot(showDv2 ? myvwap + devUp2 * dev : na, title="VWAP Upper (2)")
plot(showDv2 ? myvwap - devDn2 * dev : na, title="VWAP Lower (2)")

plot(showDv3 ? myvwap + devUp3 * dev : na, title="VWAP Upper (3)", color=teal)
plot(showDv3 ? myvwap - devDn3 * dev : na, title="VWAP Lower (3)", color=teal)

prevwap = iff(newSession, myvwap[1], prevwap[1])
plot(showPrevVWAP ? prevwap : na, style=circles, color=close > prevwap ? green : red)