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 periods by time instead of bars

    Indicators/Strategies/Analyzers
    2
    5
    933
    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.
    • R
      Rstrong last edited by Rstrong

      Hello backtrader community,

      I was wondering if it is possible to make indicators by using time instead of bars for the "period". I think if i want to use an indicator and tick data together now, I would have to import two separate data feeds of the same data. One as ticks and one re-sampled as candles/bars.

      Anyone have any suggestions to get around having to do that?

      1 Reply Last reply Reply Quote 0
      • B
        backtrader administrators last edited by

        Nothing prevents you from having a parameter to your indicator which is quoted in time units (seconds, minutes, ...). But tha won't change what an indicator does: follow the pace of the data feed (which may be another indicator) delivery of bars.

        Your time-based indicator may choose to only deliver signals at given times based on the parameter, but it will still be delivering a value for each bar of the data feed (if you do nothing, the default value delivered by an indicator is NaN)

        1 Reply Last reply Reply Quote 0
        • R
          Rstrong last edited by

          So its impossible to get a 10m moving average indicator if you dont re-sample ticks to some denomination of minutes/second bars?

          1 Reply Last reply Reply Quote 0
          • B
            backtrader administrators last edited by backtrader

            If by 10m you mean 10-minutes, yes you are right. You need a data series which is 1-minute based to get a 10-minutes moving average. Resampling to 1-second would allow you to get a 10-seconds moving average.

            As quoted above, you can develop an indicator, take a parameter which indicates time and deliver the output yourself after 10 minutes. But the indicator will have as many data points as ticks, because it's running on the tick-based data series. It will only output a sensible value each 10-minutes though.

            There may be something from your message which is not being understood here.

            1 Reply Last reply Reply Quote 0
            • R
              Rstrong last edited by

              Ok that makes sense. Il just re-sample to something like 1 second since the amount of ticks within a certain amount of time isnt consistent.

              Thanks

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