For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

help using indicators

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

  • @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):
            f"Bearish {self.myfrac.fractal_bearish[0]:9.2f}, Bullish {self.myfrac.fractal_bullish[0]:9.2f}"

Log in to reply