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

How could I plot Crossover Signal on master window(plotinfo.plotmaster == self.datas[0]) as triangle indicating where it happens??



  • Hi everyone.
    Currently I want to plot some Crossover Signal (bt.ind.CrossOver) on the price to gain some insight.
    I want to plot it as triangle (just like the buy and sell point) with probably different colors and directions (up-triangle indicating it's crossing up, down-triangle indicating it's crossing down), just like selling gives a red downside triangle and buying gives a green upside triangle.
    Is there anyone know how to do that?



  • I think I found some part of solution in this article.

    https://www.backtrader.com/blog/posts/2016-12-10-buysellarrows/buysellarrows/

    But this only re-defines buy-sell signal pattern, not exactly what I want.



  • You may want to create custom indicator with two lines up and down which has a CrossOver indicator inside. Something like this (not tested):

    class CrossOverWithArrows(bt.Indicator):
    
        lines = ('up', 'down')
    
        plotlines = dict(
            up=dict(marker='$\u21E7$', markersize=12.0),
            down=dict(marker='$\u21E9$', markersize=12.0)
    
        def __init__(self):
            up = bt.ind.CrossUp(smthng, smthng)
            down = bt.ind.CrossDown(smthng, smthng)
    


  • @ab_trader Cool, I'll try it latter!


Log in to reply
 

});