Is there a Built-In Function For VWAP Upper and Lower Bands?

Back

I'm using VWAP and can't seem to find any documentation on retrieving the upper and lower band values. I know that for some other indicators that have upper and lower bands such as Bollinger Bands, the .UpperBand.Current.Value attribute is used for the indicator. However, if I use self.vwap.UpperBand.Current.Value or just self.vwap.UpperBand, it doesn't return a value. At no point does the initialization of the VWAP indicator request an input for standard deviation so I'm assuming there's no built-in function for the upper and lower bands. As of now, I'm just manually calculating the upper and lower bands with standard deviation. However, I'd still like to know if there's a built-in function that I'm missing which would certainly be helpful to learn.

Update Backtest







 
0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Hi Nathan,

Upper/Lower bands are not part of the VWAP definition, and so our VWAP indicator doesn't include this information.

Best,
Shile Wen

0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Nathan,

Would you mine sharing the formula you used to manually calculate the upper/lower bands? I am looking for the same thing.

 

0

Kevin Chaney   My implementation was a bit unique due to the different resolutions used for data and VWAP values. But I hope this helps. Basically, you need to record your VWAP values in a list, then calculate upper and lower band values from the standard deviation of that list. This gets the last 390 minutes of VWAP values which is essentially the last day's VWAP values (390 minutes in a trading day). I'd recommend setting the pre-market and post-market Resolution to true in the initialization function so that the VWAP values don't get out of wack if there is an overnight gap.

self.vwaplist = [] #Creating a list to record previous VWAP values to get std deviation from
seconds = int(str(self.Time.time())[6:8]) #My resolution was set to seconds and needed to record VWAP at each minute
if seconds == 0: #Add VWAP Value each minute to list
    self.vwaplist.insert(0, self.vwap.Current.Value)
if len(self.vwaplist) == 391: #Drop the last VWAP Value in the list if list is full
    self.vwaplist.pop()
if len(self.vwaplist) < 390: #Return if list isn't full
    return

vwaparray = np.asarray(self.vwaplist) #Change list to array so that we can calculate std deviation
upperband = self.vwap.Current.Value + 2 * vwaparray.std() #Calculate Upper Band
lowerband = self.vwap.Current.Value - 2 * vwaparray.std() #Calculate Lower Band

 

 

 

0

Thanks, Nathan! Turns out I'm using the same resolutions as you (seconds consolidated to minutes) so this will be very helpful.

0

Update Backtest





0

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.


Loading...

This discussion is closed