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/

    help using indicators

    General Code/Help
    2
    2
    48
    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.
    • Wayne Filkins
      Wayne Filkins last edited by

      I'm trying to figure out how to use indicators, specifically Fractals(). How do we know how many arguments to use and what to use as arguments for each indicator? I tried

      self.fractalTest = bt.studies.Fractal(self.dataclose)
      

      but got an error: AttributeError: 'Lines_LineSeries_LineSeriesStub' object has no attribute 'high'

      Even if I do get it working, when I look at the Fractals class, I don't understand what to pass as parameters. I tried this with indicators which I have used successfully like sma and I don't understand where the parameters get used and how to figure out how many and what to set them as?

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

        @Wayne-Filkins Try passing in the full datas line, so:

        def __init__(self):
            self.myfrac = bt.studies.Fractal(self.datas[0])
        

        And call the values like this.

        def next(self):
            self.log(
                f"Bearish {self.myfrac.fractal_bearish[0]:9.2f}, Bullish {self.myfrac.fractal_bullish[0]:9.2f}"
            )
        
        1 Reply Last reply Reply Quote 2
        • 1 / 1
        • First post
          Last post
        Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
        $(document).ready(function () { app.coldLoad(); }); }