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/

    Developing an indicator with other indicators

    Indicators/Strategies/Analyzers
    1
    1
    33
    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.
    • Joe 0
      Joe 0 last edited by

      Hey, I would like to make an indicator for the following formulas:

      SMA - 0.2ATR, SMA + 0.2ATR
      

      I can source the value for SMA with bt.indicators.MovingAverageSimple and for ATR at bt.indicators.atr.AverageTrueRange my question is how can I combine them to make a sub-indicator that accounts both of these values?

      It appears that SMA calculates the values on next() here

          def next(self):
              self.line[0] = \
                  math.fsum(self.data.get(size=self.p.period)) / self.p.period
      

      But ATR calculates it here:

              self.lines.atr = self.p.movav(TR(self.data), period=self.p.period)
      

      (I tried to backtrack what self.p.movav is supposed to be but that wasn't so obvious)

      How do I go about making this integrated indicator?

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