Hi everyone, I currently use Tradingview for charting and their VWAP indicator has an option to also display standard deviations above/below the VWAP line. In Quantconnect, how can I calculate the 1st and standard deviations associated with the VWAP indicator in Python?
For reference, below is a snippet from my TradingView chart. The thick purple line is VWAP (14 day) and the two grey lines above and below represent 1st std deviations and 2nd std deviations. My goal is to generate these 5 data points per minute. Suggestions?
Fred Painchaud
Hi James,
You could use numpy and/or scipy/stats to compute the standard deviation of your last ‘x’ VWAP values and then add 1 x stdev, 2 x stdev, -1 x stdev and -2 x stdev to the current VWAP value to get your 5 values.
Fred
Shner
Hey James, I am trying to do the same thing, did you manage to do it ? and if so can you share the code ?
cheers mate
Vladimir
James Hawkins,
Is this what you are looking for?
If you are satisfied with my answer, please accept it and don't forget to like it.
Fred Painchaud
Hi James,
Vladimir's code but with the periods you specified (if understood properly).
Fred
P.S. Would still be much much much faster using History, then Pandas DataFrame → Numpy, then Numpy with Numba and vectorization (both vwap and std are already working on vectors (read arrays/windows/lists of values)). But I did not implement it to show you the code…
Mark Fernandes
Shouldn't it be the standard deviation of VWAP instead of the standard deviation of the symbol? Idea is to use canonical vwap and compute latest std[VWAP(Xi)] at each step(bar). It would be a moving standard deviation. Then add/subtract to get the bands.
James Hawkins
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.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!