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/

    What am I doing wrong here?

    Indicators/Strategies/Analyzers
    1
    3
    79
    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.
    • cept0r
      cept0r last edited by

      Okay I'm a relatively noob coder but im trying to replicate my manual trading strategy and automate it. In my head from a trader's perspective its so simple but im having a really hard time coding it out. Luckily I got plenty of time.

      What am I doing wrong here;

      import btalib
      
      
      class Cstdev(btalib.stddev, btalib.linearreg_slope):
          alias = ('STDDEV',)
          lines = dict(period=14,
                       movav=btalib.linearreg_slope),
          params = (
              ('ddof', 0),
              ('period', 0)
          )
      
          def __init__(self):
              self.upper_dev1 = btalib.stddev(ddof=0.1, period=2)
              self.upper_dev2 = btalib.stddev(ddof=0.2, period=2)
              self.upper_dev3 = btalib.stddev(ddof=0.3, period=2)
              self.upper_dev4 = btalib.stddev(ddof=0.4, period=2)
              self.lower_dev1 = btalib.stddev(ddof=-0.1, period=2)
              self.lower_dev2 = btalib.stddev(ddof=-0.2, period=2)
              self.lower_dev3 = btalib.stddev(ddof=-0.3, period=2)
              self.lower_dev4 = btalib.stddev(ddof=-0.4, period=2)
      

      Getting this output:

      btalib.errors.InputsError: One (1) input is at least needed and 0 were provided
      
      1 Reply Last reply Reply Quote 0
      • cept0r
        cept0r last edited by

        What I want is to create 4x "bands" using linear regression slope as the "moving average/mean" and stddev as the bands. I don't have to use these indicators if there are easier ways to implement this.

        Thanks in advance!

        Regards,

        cept0r

        1 Reply Last reply Reply Quote 0
        • cept0r
          cept0r last edited by

          Oh just realized that I'm not supposed to use bta-lib with backtrader, I'll go back to inhereting bt.indicators and ill use ema as a mean just so I can get started.

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