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/

    indicator using a value from the data other than close

    Indicators/Strategies/Analyzers
    5
    6
    1065
    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.
    • S
      skytrading54 last edited by

      I believe most of the built in indicators are using close value from the data for computation, for example SMA indicator is using close values of all the bars to derive sma... (is this correct)
      I have following 2 scenarios to build indicators

      1. if I would like to force this to use say high values of the bar to compute the average, what would be the change.
      2. if I would like to use volume from the bar to compute volume average over a period, what would be the change.
        appreciate any example if available.
      B 1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators @skytrading54 last edited by

        @skytrading54 said in indicator using a value from the data other than close:

        I believe most of the built in indicators are using close value from the data for computation, for example SMA indicator is using close values of all the bars to derive sma... (is this correct)

        This is wrong. The SMA uses the value from the 1st line of the data feed passed to it. For regular data feeds containing prices this happens to be the close price because this is the de-facto industry standard.

        See this post from yesterday where you can see that you can pass anything which is a line to any indicator:

        • Community - Laguerre RSI

        Just pass self.data.high or self.data.volume to the indicator of your choice.

        The exception are indicators which rely on specific price points like the Stochastic which uses 3 of the for usual price components (high, low, close ... leaving open unused)

        Wayne Filkins 1 Reply Last reply Reply Quote 0
        • Wayne Filkins
          Wayne Filkins @backtrader last edited by

          @backtrader What about Fractals indicator? Actually it's under studies so idk if it works like an indicator. I'm trying to use it like Fractals(self.close) and it's not working.

          A 1 Reply Last reply Reply Quote 0
          • run-out
            run-out last edited by

            You can create the indicator lines in the init section of your strategy then call them in next.

            def __init__(self):
                self.mysma = bt.ind.SMA(self.datas[0].volume)
            def next(self):
                self.log(self.mysma[0])
            
            run-out 1 Reply Last reply Reply Quote 0
            • run-out
              run-out @run-out last edited by

              @run-out I have no idea how this ended up in the wrong question.

              1 Reply Last reply Reply Quote 0
              • A
                ab_trader @Wayne Filkins last edited by

                @Wayne-Filkins said in indicator using a value from the data other than close:

                I'm trying to use it like Fractals(self.close) and it's not working.

                It requires high and low prices, therefore the whole data feed should be passed, not only close prices.

                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(); }); }