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/

    customized indicator plot problem

    General Code/Help
    3
    6
    81
    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.
    • S
      Sam last edited by

      I customized an indicator , I wanted to plot it with main data, I wrote " self.xxx.plotinfo.plotmaster = self.data" but it doesn't work. please tell me the reason. Thank you !

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

        Can you kindly include the full block of code and the error message in your question?

        @Sam said in customized indicator plot problem:

        it doesn't work. please tell me the reason

        ...is not very informative.

        RunBacktest.com

        1 Reply Last reply Reply Quote 0
        • S
          Sam last edited by

          class LeiDa(bt.Indicator):
          lines = ('zhuli', )

          def __init__(self):
              self.addminperiod(30)
          
          
          def next(self):
              dataclose = self.data.get(size=30)
              close_ma = talib.MA(np.array(dataclose), timeperiod=7, matype=0)
          
              temp = (dataclose[-20:] - close_ma[-20:]) / close_ma[-20:] * 480
              result = talib.EMA(temp, timeperiod=2) * 5
          
              self.zhuli[0] = result[-1:]
          

          class MyStrategy(bt.Strategy):

          def __init__(self):
              self.leida = LeiDa(self.data)
              self.leida.plotinfo.plotmaster = self.data
          

          Figure_0.png

          1 Reply Last reply Reply Quote 0
          • S
            Sam last edited by

            @run-out Hi ,I just post my code, Can you help me? Why didn't my indicator plot with the main data? Thank you!

            1 Reply Last reply Reply Quote 0
            • A
              ab_trader last edited by

              your price range is 240+, your indicator shows -1.43. diagram range is set by master, therefore you can't see the indicator. I suggest to show it on the separate plot since this is type of the oscillator.

              • If my answer helped, hit reputation up arrow at lower right corner of the post.
              • Python Debugging With Pdb
              • New to python and bt - check this out
              S 1 Reply Last reply Reply Quote 2
              • S
                Sam @ab_trader last edited by

                @ab_trader Thank you!

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