diff --git a/freqtrade/indicator_helpers.py b/freqtrade/indicator_helpers.py index ef2db0193..c3cc42e6a 100644 --- a/freqtrade/indicator_helpers.py +++ b/freqtrade/indicator_helpers.py @@ -1,5 +1,7 @@ from math import exp, pi, sqrt, cos +import numpy +import talib as ta from pandas import Series @@ -25,3 +27,14 @@ def ehlers_super_smoother(series: Series, smoothing: float = 6): coeff2 * filtered.iloc[i-1] + coeff3 * filtered.iloc[i-2] return filtered + + +def fishers_inverse(series: Series, smoothing: float = 0): + """ Does a smoothed fishers inverse transformation. + Can be used with any oscillator that goes from 0 to 100 like RSI or MFI """ + v1 = 0.1 * (series - 50) + if smoothing > 0: + v2 = ta.WMA(v1.values, timeperiod=smoothing) + else: + v2 = v1 + return (numpy.exp(2 * v2)-1) / (numpy.exp(2 * v2) + 1) diff --git a/freqtrade/strategy/default_strategy.py b/freqtrade/strategy/default_strategy.py index abccf065b..adfa66826 100644 --- a/freqtrade/strategy/default_strategy.py +++ b/freqtrade/strategy/default_strategy.py @@ -4,7 +4,7 @@ import talib.abstract as ta from pandas import DataFrame import freqtrade.vendor.qtpylib.indicators as qtpylib from freqtrade.strategy.interface import IStrategy - +from freqtrade.indicator_helpers import fishers_inverse class_name = 'DefaultStrategy' @@ -76,8 +76,8 @@ class DefaultStrategy(IStrategy): dataframe['rsi'] = ta.RSI(dataframe) """ # Inverse Fisher transform on RSI, values [-1.0, 1.0] (https://goo.gl/2JGGoy) - rsi = 0.1 * (dataframe['rsi'] - 50) - dataframe['fisher_rsi'] = (numpy.exp(2 * rsi) - 1) / (numpy.exp(2 * rsi) + 1) + dataframe['fisher_rsi'] = fishers_inverse(dataframe['rsi']) + # Inverse Fisher transform on RSI normalized, value [0.0, 100.0] (https://goo.gl/2JGGoy) dataframe['fisher_rsi_norma'] = 50 * (dataframe['fisher_rsi'] + 1) # Stoch