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/

    Dictionary as Lines Problem

    Indicators/Strategies/Analyzers
    2
    3
    88
    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.
    • emmepra
      emmepra last edited by emmepra

      Hi everybody,
      I'm a newbie of Backtrader and I'm still trying to learn on my own as much as I can of how it works, but I think that asking directly to experts, could be a much faster way to learn.

      So the problem is that I'm trying to develop a new indicator that will produce a lines but to calculate this it needs to employ a much complicated data structure as a dictionary.
      In particular, it needs to store for each touched level of price how many times this price has been touched from a certain point in time to another. But as I've seen (and probably I'm wrong), there's no direct way to store something like this in an indicator:

      {price1: value1,
      price2: value2,
      price3: value3, ...}
      

      The question is simple, is there a way to store a dictionary over time?

      Thank you so much!

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

        Lines do only store floats. Nothing prevents that you store more complicated structures as member attributes of your indicator.

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

          Thank you for this reply Boss, I’m honored.
          So you are telling me that Indicators can store things that evolve over time different than Lines?

          Could it be better to create a Strategy attribute wich will be updated each next() call?

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