Back

How to get current lower resolution incomplete bar

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.

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 Fabien,

It is possible to get the TradeBar a TradeBarConsolidator is currently consolidating by accessing its WorkingBar property.

Best,
Derek Melchin

1

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 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?

0

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

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.


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;

 

1

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