Navigation

    Backtrader Community

    • Register
    • 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/

    Which line in the data is SimpleMovingAverage based on?

    General Code/Help
    2
    2
    506
    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.
    • K
      kaluzagonzo last edited by kaluzagonzo

      In https://www.backtrader.com/docu/concepts.html , a moving average is constructed like this:

      sma = btind.SimpleMovingAverage(self.datas[0], period=self.params.period)

      Wouldn't self.datas[0] contain several lines, i.e. self.datas[0].lines.close, self.datas[0].lines.open, self.datas[0].lines.min, etc. according to whatever columns are in our data table?

      Which of these lines is the SMA based on? Follow up: does it ASSUME that we want compute SMA on "close" and are therefore required to include a "close" line in every data feed that is sent to the SMA function?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        No. If no specific line is passed, the 1st defined line is used. In the case of regular data feeds, close is defined as the 1st line to match the de-facto standard which is to do things directly on the close price.

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