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/

    How to get each line name in the indicator

    General Discussion
    3
    5
    120
    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.
    • E
      ezfine last edited by

      Say that an indicator sample as below:

      class MyIndicator(bt.indicator):
          lines = ('mva1', 'mva2')
      
          def __init__(self):
               self.l.mav1 = ....
               self.l.mav2 = ....
      

      My question here is how to get the names, 'mva1' 'mva2', from the existed MyIndicator? I would like to iterate myindicator.lines to get the names but it seems no such attribute, any idea?

      SVetter 1 Reply Last reply Reply Quote 0
      • SVetter
        SVetter @ezfine last edited by

        @ezfine
        Not sure why you would need that? Can you maybe give some more context? Given that you have created the lines mav1-mav2 (and given they are not generated dnyamically), why do you need to iterate instead of addressing them individually?

        1 Reply Last reply Reply Quote 0
        • E
          ezfine last edited by

          All lines in the indicator are for computing the signals, I need to dump them out for checking if there is any computing error. My idea is to dump them to a DataFrame with date as index and each line as column.

          1 Reply Last reply Reply Quote 0
          • vladisld
            vladisld last edited by

            Try to use the indicator's _getlines() method. This should return the tuple of all the line names.

            1 Reply Last reply Reply Quote 1
            • E
              ezfine last edited by

              Thanks. I can get the name list and then using _getline('name') to fetch the line object.
              By the way, I find it's not easy to get the datetime series from the indicator instance, how can I do?

              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(); }); }