Back

Renko Brick Size by ATR

How can I assign Renko Brick Size as per ATR value of the asset. Like Hourly ATR of last 24 period. Is it possible ?

Update Backtest







The Renko Brick size can be assigned to to any value. The sample code below shows the RenkoConsolidator being initialized with $2.5 renko bricks, which was a fixed value. The ATR value of an asset can be determined via the ATR indicator provided by Quantconnect. The link to the documentation will show all the indicators provided. When instantiating the indicator, the Resolution can be chosen (Resolution.Hour in this specific case). In order to compare ATR's of the last 24 hour period a RollingWindow can be used, which is an array of data that allows for reverse list access semantics, where the object with index [0] refers to the most recent item in the window and index [Length-1] refers to the last item in the window. 

https://github.com/QuantConnect/Lean/blob/6b5eca2663c12914b6001626d63933908ee298bd/Algorithm.Python/RenkoConsolidatorAlgorithm.pyhttps://www.quantconnect.com/docs/algorithm-reference/indicatorshttps://www.quantconnect.com/docs/algorithm-reference/rolling-window
0

      Dear Guru,

 

      I am trying to set the brick size to ATR at Initilaze but it is given  Runtime Error: Attempted to divide by zero. (Open Stacktrace) ?

 

       #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)

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