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 to write an indicator wich gives back values?



  • Hello,

    I wrote an indicator (with help of an example code) wich draws the lines of an ZigZag Indicator.

    Now I can take a look on the indicator and it looks very good.

    The problem now is, that I need the values of this indicator for my strategy. But how can I write an Indicator, which gives back some values? (the indicator should give me back 2 arrays. The highPoints and the LowsPoints)

    Is it possible to write in the indicator class some lines, which allows me to use my ZigZag indicator just as simple as the SMA() indicator, which is already implemented in the backtrader? so that I can call the values for example like this:

            self.ZigZagHighPoints = bt.indicators.ZigZag(
               self.data.OHLC, 
               retracement=0.25,
               minbars=5,
               
    
            self.ZigZagLowPoints = bt.indicators.ZigZag(
               self.data.OHLC, 
               retracement=0.25,
               minbars=5,
               
    

    best regards,
    Christian



  • Look in this article and read everything about adding lines. The lines you add will show up in your strategy and you can use them.


Log in to reply
 

});