Backtrader Community

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    To datafeed number in bracket `self.datas[0].close[0]`

    Indicators/Strategies/Analyzers
    1
    1
    84
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • bkcollection
      bkcollection last edited by

      Newbie here. I would like to confirm what is the number in bracket indicate.

      print (self.datas[0].close[0])
      print (self.datas[-1].close[0])
      print (self.datas[0].close[-1])
      print (self.datas[0].close[-2])
      print (self.datas[-1].close[-1])
      print (self.datas[0].close[1])
      

      From what I tested, self.datas[0].close[0] is close of current day. self.datas[-1].close[0] is also same as self.datas[0].close[0]. self.datas[0].close[-1] is closing a day before. self.datas[0].close[1] is a day after.

      Could someone experience can share what is the first number in bracket means? Since self.datas[0].close[0] is same as self.datas[-1].close[0] from my testing.

      I am trying to set a buy in strategy if today close is higher than previous day close ans sell if today close is lower than yesterday close. So understanding the data is important.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors