Aug 1, 2021
study("vwap", overlay=true) typicalPrice = (high + low + close) / 3 typicalPriceVolume = typicalPrice * volume cumulativePeriod1 = input(210, "Period") cumulativeTypicalPriceVolume1 = sum(typicalPriceVolume, cumulativePeriod1) cumulativeVolume1 = sum(volume, cumulativePeriod1) vwapValue1 = cumulativeTypicalPriceVolume1 / cumulativeVolume1 plot(vwapValue1,title='210',color=#35e8ff,style=circles) cumulativePeriod2 = input(400,"Period2") cumulativeTypicalPriceVolume2 = sum(typicalPriceVolume, cumulativePeriod2) cumulativeVolume2 = sum(volume, cumulativePeriod2) vwapValue2 = cumulativeTypicalPriceVolume2 / cumulativeVolume2 plot(vwapValue2,title='400',color=#f995ff,style=circles,transp=1,linewidth=1) cumulativePeriod3 = input(1700,"Period3") cumulativeTypicalPriceVolume3 = sum(typicalPriceVolume, cumulativePeriod3) cumulativeVolume3 = sum(volume, cumulativePeriod3) vwapValue3 = cumulativeTypicalPriceVolume3 / cumulativeVolume3 plot(vwapValue3,title='1700',color=#acff35,style=circles,transp=1,linewidth=1) cumulativePeriod4 = input(3100,"Period4") cumulativeTypicalPriceVolume4 = sum(typicalPriceVolume, cumulativePeriod4) cumulativeVolume4 = sum(volume, cumulativePeriod4) vwapValue4 = cumulativeTypicalPriceVolume4 / cumulativeVolume4 plot(vwapValue4,title='3100',color=#f3ff00,style=circles,transp=1)