Блог им. VinniPuh_3af
//@version=4 study("VWAP Stdev Bands", overlay=true) devUp1 = input(1.28, title="Stdev above (1)") devDn1 = input(1.28, title="Stdev below (1)") devUp2 = input(2.01, title="Stdev above (2)") devDn2 = input(2.01, title="Stdev below (2)") devUp3 = input(2.51, title="Stdev above (3)") devDn3 = input(2.51, title="Stdev below (3)") devUp4 = input(3.09, title="Stdev above (4)") devDn4 = input(3.09, title="Stdev below (4)") devUp5 = input(4.01, title="Stdev above (5)") devDn5 = input(4.01, title="Stdev below (5)") showDv2 = input(true, type=input.bool, title="Show second group of bands?") showDv3 = input(true, type=input.bool, title="Show third group of bands?") showDv4 = input(false, type=input.bool, title="Show fourth group of bands?") showDv5 = input(false, type=input.bool, title="Show fifth group of bands?") showPrevVWAP = input(false, type=input.bool, title="Show previous VWAP close") input_res = input("D", title = "Resolution") f_repaint()=> start = security(syminfo.tickerid, input_res, time) newSession = iff(change(start), 1, 0) float vwapsum = 0 float volumesum = 0 float v2sum = 0 vwapsum := newSession ? hl2*volume : vwapsum[1]+hl2*volume volumesum := newSession? volume : volumesum[1]+volume v2sum := newSession ? volume*hl2*hl2 : v2sum[1]+volume*hl2*hl2 myvwap = vwapsum/volumesum dev = sqrt(max(v2sum/volumesum - myvwap*myvwap, 0)) float prevwap = 0 prevwap := newSession ? myvwap[1] : prevwap[1] [vwapsum, volumesum, v2sum, myvwap, dev, prevwap] [vwapsum, volumesum, v2sum, myvwap, dev, prevwap] = if barstate.isrealtime f_repaint() else f_repaint() A=plot(myvwap, style=plot.style_circles, title="VWAP", color=#000000) U1=plot(myvwap + devUp1 * dev, style=plot.style_circles, title="VWAP Upper", color=color.gray) D1=plot(myvwap - devDn1 * dev, style=plot.style_circles, title="VWAP Lower", color=color.gray) U2=plot(showDv2 ? myvwap + devUp2 * dev : na, color=color.red, title="VWAP Upper (2)") D2=plot(showDv2 ? myvwap - devDn2 * dev : na, color=color.green, title="VWAP Lower (2)") U3=plot(showDv3 ? myvwap + devUp3 * dev : na, title="VWAP Upper (3)", color=color.red) D3=plot(showDv3 ? myvwap - devDn3 * dev : na, title="VWAP Lower (3)", color=color.green) U4=plot(showDv4 ? myvwap + devUp4 * dev : na, title="VWAP Upper (4)", color=color.red) D4=plot(showDv4 ? myvwap - devDn4 * dev : na, title="VWAP Lower (4)", color=color.green) U5=plot(showDv5 ? myvwap + devUp5 * dev : na, title="VWAP Upper (5)", color=color.red) D5=plot(showDv5 ? myvwap - devDn5 * dev : na, title="VWAP Lower (5)", color=color.green) plot(showPrevVWAP ? prevwap : na, style=plot.style_circles, color=close > prevwap ? color.green : color.red) fill(U1, U2, color=color.red, transp=90, title="Over Bought Fill 1") fill(D1, D2, color=color.green, transp=90, title="Over Sold Fill 1") fill(U2, U3, color=color.red, transp=90, title="Over Bought Fill 2") fill(D2, D3, color=color.green, transp=90, title="Over Sold Fill 2") fill(U3, U4, color=color.red, transp=90, title="Over Bought Fill 3") fill(D3, D4, color=color.green, transp=90, title="Over Sold Fill 3") fill(U4, U5, color=color.red, transp=90, title="Over Bought Fill 4") fill(D4, D5, color=color.green, transp=90, title="Over Sold Fill 4") fill(A, U1, color=color.gray, transp=90, title="Middle Fill Up") fill(A, D1, color=color.gray, transp=90, title="Middle Fill Down")
И на ренж графике не работает
Смена периода реализована.
На ренже, ренко и т.п. он не будет работать, т.к. это отличный от hl2 источник данных цены.