Plot indicators which are inside other indicator



  • Hi,
    I created an indicator. After it, I created another one using the first one and some others. How can I plot indicators which are inside the outer one? Additionally, can I have some of them in a subplot and some of them not? (I know I can just repeat the lines for them in an outer one, but it doesn't seem clean and I can't find a way to subplot some of them in such situation).


  • administrators

    @mpskowron said in Plot indicators which are inside other indicator:

    How can I plot indicators which are inside the outer one?

    By assigning the values of such sub-indicators to lines defined in the enclosing indicator.

    @mpskowron said in Plot indicators which are inside other indicator:

    Additionally, can I have some of them in a subplot and some of them not?

    sub-indicators are not meant to be plotted. As stated above you can pass the values to lines of the enclosing indicator. You can then in turn put the values of those lines in external indicators which can then be, so to say, sub-plotted

    The latter can be achieved in different ways:

    • For example using LinePlotterIndicator (see Docs - Using Indicators, section Indicator Plotting)
      or
    • Put the line simply inside a SimpleMovingAverage of period 1
    myind = MyIndicatorWithSubIndicators()
    tosubplot = bt.LinePlotterIndicator(myind.line_to_sub_plot, name='the name to assigne', subplot=True)
    


  • Thanks for they reply, sorry for not answering earlier, but I just forgot that I made this question here. I just wanted to write how did I solve it. I finally ended up with extracting those indicators from outer ones and then adding to strategy indicators using bt.Strategy.addindicator() method in the strategy stop() method.


Log in to reply
 

Looks like your connection to Backtrader Community was lost, please wait while we try to reconnect.