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



  • 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!


  • administrators

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



  • 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?


Log in to reply
 

});