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



  • 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?



  • @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?



  • 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.



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



  • 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?


Log in to reply
 

});