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/

    Developing an Indicator

    Blog
    2
    5
    1707
    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.
    • B
      backtrader administrators last edited by

      Use the link below to go the original post

      Click here to see the full blog post

      1 Reply Last reply Reply Quote 0
      • Maks  Gorbunov
        Maks Gorbunov last edited by

        We have new MyTrix indicator. How can we call self.lines.trix in "def next" now?
        If I try " print(self.lines.trix[0])" then:
        AttributeError: 'Lines_LineSeries_LineIterator_DataAccessor_Strateg' object has no attribute 'trix'

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

          That error message shows that your defined line is not named trix, hence the error.

          Or else you mean the strategy's next in which you obviously have to go over the variable in which you have stored the reference to the indicator.

          But with so few details not much can be said

          Maks  Gorbunov 1 Reply Last reply Reply Quote 0
          • Maks  Gorbunov
            Maks Gorbunov @backtrader last edited by

            @backtrader said in Developing an Indicator:

            That error message shows that your defined line is not named trix, hence the error.
            Or else you mean the strategy's next in which you obviously have to go over the variable in which you have stored the reference to the indicator.

            I have MyTric.py and stretegy with imported MyTrix. Now I want to use self.lines.trix in this strategy. How can i do it? This line plot's on figure, but I don't understend how to get it's values.

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

              Suggestion: read the Docs - Quickstart Access an comparison is done several times with a Simple Moving Average

              • You store the created indicator in a variable: self.myvar = bt.ind.Trix(...)
              • You access the values: self.myvar[0] which automates the process of doing self.myvar.lines.trix[0]
              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
              $(document).ready(function () { app.coldLoad(); }); }