Back

RENKO Brick Size ATR

      I am trying to set the brick size to ATR at Initilaze for Renko Consolidator but it is given  Runtime Error: Attempted to divide by zero. (Open Stacktrace) ? How Cab I assign a ATR as brick size ?

 

       #ATR NAS100USD
        self.atrNAS = self.ATR("NAS100USD", 24, MovingAverageType.Simple,Resolution.Hour)
        #RENKO NAS100USD
        self.brickNAS = self.atrNAS.Current.Value//1
        renkoCloseNAS = RenkoConsolidator(self.brickNAS)
        renkoCloseNAS.DataConsolidated += self.HandleRenkoCloseNAS
        self.SubscriptionManager.AddConsolidator("NAS100USD", renkoCloseNAS)

Update Backtest







The stacktrace was not actually linked, so determining the problem will be a little tougher. Is the algorithm warming up the indicator before it is being used? The problem could be that ATR's value is currently 0 at that time. Check the documentation on warming up an algorithm: it pumps data in from before the start date for priming technical indicators, or populating historical data arrays. This sample code warms up an EMA so that it can be using during the start of the algorithm. 

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.


def subscribe_renko(self, symbol):
if self.renkoInit is False:
renkoATR = self.ATR(symbol, 14, MovingAverageType.Simple, Resolution.Hour)
self.Log(str(renkoATR.Current.Value) + symbol)
renkoClose = RenkoConsolidator(renkoATR.Current.Value)
renkoClose.DataConsolidated += self.HandleRenkoClose
self.SubscriptionManager.AddConsolidator(symbol, renkoClose)
self.renkoInit = True

Subscribing to the renko consolidator after the init method by calling this function in OnData is a possible solution. I'm still fairly new to QC, it seems like its not possible to access historical data outside of OnData, even with a warmup period. Correct me if I'm wrong.

0

Historical data can be accessed anywhere within the algorithm using the call self.History(), as long as the data being called has been subscribed. In this example, self.History() is called during Initialize() to manually feed data into the indicators.

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.


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