Hello,
I am looking for a way to find the average volume over ~14 trading days for any given 5 min bar. So if it is 10:05, I want to know what the average volume of 10-10:05 would be for the last 14 days. Is there an efficient way to do this?
The only solution I've thought of so far would be to create a rolling window of 192 blocks per day (960 Min in a trading day including extended market hours / 5) and then create a variable for the last 14 trading days in increments of 192 for the rolling window and take an average.
This seems like a fairly inefficient way to get to the answer. Any thoughts on a better approach?
Thanks!
Louis Szeto
Hi Crafty
We recommend using the SMA indicator updating with volume from 5-minute TradeBarConsolidator:
Refer to this doc for details.
Best
Louis
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 Crafty, I agree with Louis' answer, and would like to add on - you can also use wap to come to your figure. It's pretty easy to calculate on that way, and you can also exploit the fact that at any point of time :- price * volume = constant, which would be helpful in your calculations. Else, using an SMA indicator with 5-minute TradebarConsolidator is always a good option. Thanks.
Best,
Manav
Crafty
Hey Manav/Louis,
I appreciate the response, but I don't see how that would get me the volume for the same period of the day. I don't want the average for the entire day. For instance, if I did it your way and compared the 9:30 5 min candle to the average then it would always look high/register as above average since your average would include pre/post market where volume is traditionally very low.
What I want to get to is a flag that tells me volume, at that point in the day, is abnormally high for what that point in the day would normally show. Does this make sense?
Louis Szeto
Hi Crafty
Sorry for misunderstanding your question. That way you'd still need a 5-minute trade bar consolidator and need a dictionary to hold 390/5 = 78 manually updating indicators. I'd recommend using the EndTime as the dictionary keys, e.g. 09:35, 09:40, …
This made each SMA indicator would just be updated by the particular 5-minute. You'll have to call History and warm up the indicator by iterating and feeding the data into the consolidator, see how to do so in here.
Best
Louis
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.
Crafty
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!