[FIXED] Ichimoku: Unable to get Future cloud



  • From what I understand backtrader can be operated pseudo-vectorized using runonce=True option of Cerebro. As a result indicators are getting pre-calculated before strategy execution starts.

    Keeping that in mind accessing the current cloud using

    self.ikh = bt.indicators.Ichimoku()
    self.ikh.senkou_span_a[0]
    self.ikh.senkou_span_b[0]
    

    works as expected. Current cloud means: The cloud which is on position [0] and has been calculated -26 bars in the past (because the cloud calculation forward-pushs 26 bars).

    In a second step I would assume to access the future cloud using

    self.ikh = bt.indicators.Ichimoku()
    self.ikh.senkou_span_a[26]
    self.ikh.senkou_span_b[26]
    

    which fails with {IndexError} array index out of range.

    So is it possible to access one of the future senkou_span_a or future senkou_span_b lines which has been calculated on the [0, -1, -2 ... -26] bars?



  • Oh... Just reverted from 1.9.54.122 to 1.9.50.117 and it works like expected.

    pip3 install 'backtrader==1.9.50.117' --force-reinstall
    Collecting backtrader==1.9.50.117
      Downloading backtrader-1.9.50.117-py2.py3-none-any.whl (391kB)
        100% |████████████████████████████████| 399kB 1.3MB/s 
    Installing collected packages: backtrader
      Found existing installation: backtrader 1.9.54.122
        Uninstalling backtrader-1.9.54.122:
          Successfully uninstalled backtrader-1.9.54.122
    Successfully installed backtrader-1.9.50.117
    

  • administrators

    There is a new feature for indicators introduced with 1.9.54.x:

    • Commit Hash: 27c406ccdb37a88eb115e132ddbdbd2407b41fa1
    • Comment: Allow indicators to disable runonce

    Because HeikinAshi due to the recursive nature cannot work properly in runonce=True mode. And the testing code remained in forcing runonce=False

    Looking into the future is not possible when runonce=False.

    Corrected and pushed to the development branch.



  • @backtrader Will check it to provide feedback shortly.



  • @backtrader: Now works again as expected. Thanks!


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.