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/

    Any guidance on when to use self. ?

    General Discussion
    2
    3
    71
    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.
    • Li Mike
      Li Mike last edited by

      Hi, I see some code in strategy as follows:

      def __init__(self):
          # To control operation entries
          self.orderid = None
      
          # Create SMA on 2nd data
          sma = btind.MovAv.SMA(self.data1, period=self.p.period)
          # Create a CrossOver Signal from close an moving average
          self.signal = btind.CrossOver(self.data1.close, sma)
      

      I wonder why the sma isn't prefixed by self. while signal is. Is there any guidance tell us when to use self or not?

      Li Mike 1 Reply Last reply Reply Quote 1
      • run-out
        run-out last edited by

        When to use self is a general python coding issues and you can google or youtube it to learn it's application. If you get stuck after that let us know.

        1 Reply Last reply Reply Quote 1
        • Li Mike
          Li Mike @Li Mike last edited by

          Got it. I misunderstood something stupidly.

          1 Reply Last reply Reply Quote 1
          • 1 / 1
          • First post
            Last post
          Copyright © 2016, 2017, 2018 NodeBB Forums | Contributors
          $(document).ready(function () { app.coldLoad(); }); }