Fisher Transform - Indicator



  • Are there any plans to implement Ehler's Fisher Transform in Backtrader? It would be great to have it as part of the standard repertoire of indicators than many reinventing the wheel all over again.


  • administrators

    Not at the moment



  • Can you give me some pointers to implement it?


  • administrators

    Sorry but there aren't many free resources lately.



  • I have written some code but it is not working. I believe I am missing something.

    import backtrader as bt
    import math
    
    __all__ = ['Fisher']
    
    
    class Fisher(bt.Indicator):
    
        lines = ('h', 'l', 'scaled','Fx',)
        params = (('period', 20),)
        _alpha = 0.33
    
        def __init__(self):
            self.addminperiod(self.params.period)
    
            self.l.h = bt.indicators.Highest(self.data.close, self.p.period)
            self.l.l = bt.indicators.Lowest(self.data.close, self.p.period)
    
        def next(self):
    
            d = self.data.close[0]
    
            h = self.l.h[0]
            l = self.l.l[0]
    
            scaled = self.l.scaled
            Fx = self.l.Fx
    
            scaled[0] = self._alpha * 2 * ((d - l) / (h - l) - .5) + (1-self._alpha) * scaled[1]
    
            if scaled[0] > 0.9999:
                scaled[0] = 1
            elif scaled[0] < -0.9999:
                scaled[0] = -1
    
            Fx[0] = .5 * math.log((1 + scaled[0]) / (1 - scaled[0])) + .5 * Fx[1]
    

Log in to reply
 

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