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/

    LinePlotterIndicator: plot y-axis in log scale

    Indicators/Strategies/Analyzers
    indicator
    2
    4
    313
    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.
    • J
      jf last edited by

      Dear Community,

      I succeeded in plotting a custom-built indicator with bt.LinePlotterIndicator, but I just couldn't figure out how to convert the y-axis to log-scale.

      This is my first attempt:

      signalplotter = bt.LinePlotterIndicator(self.inds['signal1'], plotlog=True)
      

      And I also tried:

      signalplotter = bt.LinePlotterIndicator(self.inds['signal1'])
      signalplotter.plotinfo.plotlog = True
      

      ... but this also did not work.

      It would be fantastic if someone could point me into the right direction!

      Thanks a lot,
      J

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

        i think plotlog should be set on the indicator level, not for LinePLotterIndicator.

        Docs - Plotting - Object-wide plotting options

        • 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
        J 1 Reply Last reply Reply Quote 1
        • J
          jf @ab_trader last edited by

          @ab_trader Thanks for your quick reply, this is highly appreciated!

          I tried to do this, but it did not work. I guess the issue is that the indicator that I plan to plot is not a plain-vanilla indicator, but rather an indicator that I divided by a value.

          import numpy as np
          

          ... (blabla)...

          self.inds['signal1'] = self.inds['signalA']/np.log(23) #just taking 23 to make things understandable, this is not what I am actually doing :-)...
          self.inds['signal1'].plotinfo.plotlog = True
          signalplotter = bt.LinePlotterIndicator(self.inds['signal1'])
          

          Without the "self.inds['signal1'].plotinfo.plotlog = True" the line is plotted nicely, just not in log scale. When I add the ".plotinfo.plotlog" then I receive the following Error:

          AttributeError: 'LinesOperation' object has no attribute 'plotinfo'

          I also tried to define the logplot for "self.inds['signalA']". While I don't get an error message there (which makes sense because it is an indicator and not a "LinesOperation"), the information seems to get lost on the way down to the LinePlotterIndicator...

          Would be amazing if you have an idea how to solve this puzzle :-)!

          Best,
          J

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

            Based on one old comment from the 'bt' author (search forum for 'lineplotterindicator') 'lineplotterindicator' was made to quickly show a line. So you may need to make an indicator from 'self.inds['signal1']' to be able to customize it's plotting.

            • 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
            1 Reply Last reply Reply Quote 0
            • 1 / 1
            • First post
              Last post
            Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors