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

plotting indicators that are inside another indicator

  • I have build an indicator ('A') that uses other indicators for calculate itself (B, C, D). However I see only the main indicator ('A') when printing, but I want to see also the other indicators (B, C, and D). I tried adding 'plotforce' and LinePlotterIndicator like written in without success...

  • administrators

    The plotting code doesn't do recursion and doesn't see see the embedded indicators. The solutions you attempted as shown in the documentation page you linked are for the indicators and operations which happen directly in the strategy code.

    The only trick I can offer you (not tested)

    • Create your indicator.

    • Create moving averages of period 1 which use your embedded indicators as data

    Something as

    my_indicator = MyIndicator(....)
    emb_ind_1 = bt.ind.SMA(my_indicator.embedded_indicator1, period=1)

    Now, the SMA doesn't know still where to plot itself, because the indicators won't be plotted.

    Try then:

    emb_ind_1.plotinfo.plotmaster =
    emb_ind_1.plotinfo.subplot = True

    which says that they should be considered indicators of for plotting purposes and be plotted in an own sub-graph.

Log in to reply