I basically want to know how to compare current minute price data to the open of the current hour data. Since that hour isn't complete yet I don't think I can access that bar using consolidators.
QUANTCONNECT COMMUNITY
I basically want to know how to compare current minute price data to the open of the current hour data. Since that hour isn't complete yet I don't think I can access that bar using consolidators.
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.
Derek Melchin
Hi Fabien,
It is possible to get the TradeBar a TradeBarConsolidator is currently consolidating by accessing its WorkingBar property.
Best,
Derek Melchin
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.
Fabien
Hi Derek Melchin, thanks for that. I also have an SMA that I would also like to include the current working value. What's the best way to do that?
Derek Melchin
Hi Fabien,
We can accomplish this by calculating what the SMA would be if we were to Update the SMA with the WorkingBar. Utilizing the RollingSum and Period properties, the formula looks like this:
workingBarLast = 100 s = self.sma.RollingSum.Current.Value p = self.sma.Period workingBarSMA = (s - (s / p) + workingBarLast) / p
See the attached backtest for a working example of this calculation. The example doesn't implement the consolidator. It just hard-codes its value for the sake of example.
Best,
Derek Melchin
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.
Fabien
Thanks, that was close, I just had to subtract the oldest value rather than s / p to get the desired result.
Â
var currentAvg = (sma.RollingSum.Current.Value - closePricesWindow[sma.Period - 1].Value + consolidator.WorkingBar.Value) / sma.Period;
Â
Fabien
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!