For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See:

Question about datas[0] and feeds

  • How the datas from csv feed go to my strategy? For example if i need creating sma, how the OHLCV datas go to init?

    I read the Platform concept article ( and didn't understand this one: "Data Feeds are automagically provided member variables to the strategy in the form of an array and shortcuts to the array positions" and "So it is. Data Feeds get added to the platform and they will show up inside the strategy in the sequential order in which they were added to the system."

  • When Cerebro engine creates the strategy instance, it passes all the data objects it knows about as a sargs argument (list type) of the strategy ctor. Instantiation sequence of the strategy is pretty involved process ( it is not just simple __new__ and __init__ calls). Most objects in Backtrader are using "meta-classes" which 'hijack' the instantiation sequence and have an ability to inject new instance variables into the instantiated class just before it is born.

    In case of strategy objects, those "meta-classes" will inject new instance variable(s) for each data object passed in the aforementioned sargs argument (actually they will do much more than that - various other "alias" will be created like data%d_%line for each %d = data index and %line = line name, and many others)

    There is another post describing this process:

  • @vladisld

    I am beginnner and I feel that I should go to learn more(very difficult for me).
    But thank you very much for answer, now i know wheare I should find it.

Log in to reply