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/

    'list' object is not callable : Error in Custom Indicator

    Indicators/Strategies/Analyzers
    3
    10
    178
    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.
    • Finnovesh Incorporation
      Finnovesh Incorporation last edited by

      I am creating one custom indicator and i want to assign a list object to lines.

      self.lines.non_none_szs = self.non_none_sz

      It is giving me following error:

      File "/Users/saurabh/Python3/vs-py-venv/lib/python3.6/site-packages/backtrader/lineseries.py", line 79, in set
      value = value(0)
      TypeError: 'list' object is not callable

      I am stuck with this since last couple pf hours but not getting a way to assign a list object to lines array.

      Any help here will be highly appreciated

      1 Reply Last reply Reply Quote 0
      • run-out
        run-out last edited by

        We would like to help you but your question is not very informative. Please Include all of your code. Please also include the full log print out that has the error. Also please follow the instructions at the very top of this page for using three back ticks to wrap around your code.

        For example:

        put code here.
        
        Finnovesh Incorporation 1 Reply Last reply Reply Quote 0
        • Finnovesh Incorporation
          Finnovesh Incorporation @run-out last edited by

          @run-out said in 'list' object is not callable : Error in Custom Indicator:

          put code here.
          Here goes my code

          class FiboFactors:
          def init(self,x,a,b,c,d):
          self.x = x
          self.a = a
          self.b = b
          self.c = c
          self.d = d
          self.xab = (abs(b - a) / max(0.01, abs(x - a)))
          self.xad = (abs(a - d) / max(0.01, abs(x - a)))
          self.abc = (abs(b - c) / max(0.01, abs(a - b)))
          self.bcd = (abs(c - d) / max(0.01, abs(b - c)))

          class Fibonn(Indicator):
          alias = ('FIB', 'Fibonn',)
          data = None
          period = None

           lines = ('non_none_szs',)
           #params = (dict(period=1, safediv=True))
          
           plotlines = dict(
                       non_none_szs=dict(_name='CP', marker='v', markersize=6.0, ls='', color='pink', _skipnan=True),
                      
          
                       )
          
           plotinfo = dict(subplot=True)
          
           def __init__(self,period,candle,interval,alt_time_frame,use_alt_timeframe):
           #   self.data=data
             self.candle=candle
             self.period=period
             self.interval=interval
             self.alt_time_frame=alt_time_frame
             self.use_alt_timeframe=use_alt_timeframe
             self.setup()
             # Before super to ensure mixins (right-hand side in subclassing)
             # can see the assignment operation and operate on the line
             
             #self.lines.is_bat=self.is_bat(1)
             self.lines.non_none_szs =  self.non_none_sz
           #   for i in range(0, len(self.non_none_sz)):
           #     self.lines.non_none_szs[0].append(bt.Max(0.0, self.non_none_sz[i]))
             #self.lines.non_none_szs = bt.Max(0.0, self.non_none_sz) 
          
             super(Fibonn, self).__init__()
          
           def setup(self):
              
               sz=self.calculate_sz()
               non_none_sz = [sz[i] for i in range(0,len(sz)) if sz[i]]
               self.non_none_sz=non_none_sz
               if len(non_none_sz) >= 5:
                   self.fibonums = FiboFactors(*non_none_sz[-5:])
                   self.lines.non_none_szs =  self.non_none_sz
          
           # def apply(self):
           #    # self.data.df['pandas_SMA_3'] = self.data.df.iloc[:,1].rolling(window=self.period).mean()
           #     return self
          
           def calculate_sz(self):
               #alt_factor = alttf_to_tf_factor(interval=self.interval, altinterval=self.alt_time_frame)
               #grouped_candle = get_grouped_candles(self.candle, self.interval, self.alt_time_frame)
               alt_factor=1
               grouped_candle=self.candle
               len_grouped_candle=len(self.candle.get('TIME')[0].array)
               sz = [None]*(alt_factor)
               for i in range(1, len_grouped_candle):
                   nextsz = None
                   if  self.candle["isup"][0][i-1]==1.0 and self.candle["isdown"][0][i]==1.0 :
                       nextsz = max(grouped_candle["High"][0][i], grouped_candle["High"][0][i-1])
                   elif  self.candle["isdown"][0][i-1]==1.0 and self.candle["isup"][0][i]==1.0:
                       nextsz = min(grouped_candle["Low"][0][i], grouped_candle["Low"][0][i-1])
                   else :
                       nextsz = None
                   
                   sz += [nextsz] + [None]*(alt_factor-1)
               sz += [None]*(alt_factor-len(sz))
               return sz
          
          run-out Finnovesh Incorporation 2 Replies Last reply Reply Quote 0
          • run-out
            run-out @Finnovesh Incorporation last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • Finnovesh Incorporation
              Finnovesh Incorporation @Finnovesh Incorporation last edited by

              @finnovesh-incorporation @run-out any help here will be quite appreciated

              Finnovesh Incorporation 2 Replies Last reply Reply Quote 0
              • Finnovesh Incorporation
                Finnovesh Incorporation @Finnovesh Incorporation last edited by

                @finnovesh-incorporation @run-out please help me out ... SOS

                1 Reply Last reply Reply Quote 0
                • Finnovesh Incorporation
                  Finnovesh Incorporation @Finnovesh Incorporation last edited by

                  @finnovesh-incorporation @run-out any update on this ?

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

                    I had a similar problem, so fuck.

                    ![0_1649070031395_c168e788-e0c2-45fd-aebc-621a92ed9ea9-image.png](正在上传 100%)

                    ![0_1649070048968_70961f45-35d9-432f-b281-292c848e7862-image.png](正在上传 100%)

                    ![0_1649070092068_73f6687a-761a-4014-aad0-4549368985bd-image.png](正在上传 100%)

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

                      I had a similar problem, so fuck.

                      ![0_1649070255010_659bc970-990c-4223-8737-4a8c716acf9a-image.png](正在上传 100%)

                      ![0_1649070259190_41b69f90-02a4-46e0-bc5d-bd9807393e77-image.png](正在上传 100%)

                      ![0_1649070262209_5d7769c0-7fd7-4012-b3aa-8d9a2095f014-image.png](正在上传 100%)

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

                        I had a similar problem, so fuck.

                        e87b64af-12ac-47be-9792-976f4c33f089-image.png

                        ee2ac1fe-7f4b-4746-8dae-246e3819bad6-image.png

                        83cace56-8e91-4b0e-8806-1644a55a13e5-image.png

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