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/

    How to get the indicators values?

    General Code/Help
    3
    3
    811
    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.
    • T
      Terrence Chen last edited by

      class SmaCross(bt.SignalStrategy):
      def init(self):
      sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
      crossover = bt.ind.CrossOver(sma1, sma2)
      self.signal_add(bt.SIGNAL_LONG, crossover)

      How can I get the value of sma1 from your example?

      B 1 Reply Last reply Reply Quote 0
      • A
        ab_trader last edited by ab_trader

        In order to get indicator values you will need to re-write the code to have self.sma1 and self.sma2 variables. Then get them in the next as all other variables.

        1 Reply Last reply Reply Quote 1
        • B
          backtrader administrators @Terrence Chen last edited by

          @terrence-chen said in How to get the indicators values?:

          How can I get the value of sma1 from your example?

          Take some advice: learn to program and learn Python before you do algotrading.

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