Backtrader Community

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

    Can't assign custom indicator output to lines

    Indicators/Strategies/Analyzers
    1
    2
    27
    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.
    • O
      omryzci last edited by

      Hi, I need to backtest my custom indicator.

      It returns two lines upper and lower bands.
      types are numpy array.

      def custom_ind(close,length,some parameterssss):
          close=np.array(close)
          y=[]
          sum_e=0.0
          e=2.718281
      #Some code blocks here calculates upband,downband#
      return upband,downband
      

      I want to assign those upband and downband arrays into self.l.up and self.l.down

      class custom_indicator(bt.Indicator):
      
          lines = ('upper','lower')
          params = (('period', 100),)
          def __init__(self):
              [upband,downband] = custon_ind(self.data,100,3,2)
              self.l.upper=upper
      

      The error I go is as follows:

      can you please help me with that:

      TypeError: 'numpy.ndarray' object is not callable

      O 1 Reply Last reply Reply Quote 0
      • O
        omryzci @omryzci last edited by

        @omryzci

        correction

        self.l.upper=upband
        

        error raises here

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