From 83a999d16ed200f10dcd045b86fd48d314f41bbc Mon Sep 17 00:00:00 2001 From: Gerald Lonlas Date: Sat, 6 Jan 2018 13:10:59 -0800 Subject: [PATCH] Change Bollinger bands for qtpylib.bollinger_bands --- freqtrade/analyze.py | 20 ++++++++++++-------- freqtrade/optimize/hyperopt.py | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/freqtrade/analyze.py b/freqtrade/analyze.py index 8cc4c7b38..ba29dd705 100644 --- a/freqtrade/analyze.py +++ b/freqtrade/analyze.py @@ -107,21 +107,25 @@ def populate_indicators(dataframe: DataFrame) -> DataFrame: # Overlap Studies # ------------------------------------ + # Previous Bollinger bands + # Because ta.BBANDS implementation is broken with small numbers, it actually + # returns middle band for all the three bands. Switch to qtpylib.bollinger_bands + # and use middle band instead. + dataframe['blower'] = ta.BBANDS(dataframe, nbdevup=2, nbdevdn=2)['lowerband'] + """ # Bollinger bands - bollinger = ta.BBANDS(dataframe, nbdevup=2, nbdevdn=2) - dataframe['bb_lowerband'] = bollinger['lowerband'] - """ - dataframe['bb_middleband'] = bollinger['middleband'] - dataframe['bb_upperband'] = bollinger['upperband'] + bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) + dataframe['bb_lowerband'] = bollinger['lower'] + dataframe['bb_middleband'] = bollinger['mid'] + dataframe['bb_upperband'] = bollinger['upper'] """ + # EMA - Exponential Moving Average dataframe['ema5'] = ta.EMA(dataframe, timeperiod=5) dataframe['ema10'] = ta.EMA(dataframe, timeperiod=10) dataframe['ema50'] = ta.EMA(dataframe, timeperiod=50) dataframe['ema100'] = ta.EMA(dataframe, timeperiod=100) - """ - dataframe['ema200'] = ta.EMA(dataframe, timeperiod=200) - """ + # SAR Parabol dataframe['sar'] = ta.SAR(dataframe) diff --git a/freqtrade/optimize/hyperopt.py b/freqtrade/optimize/hyperopt.py index fb86d0fd0..d0d0916f8 100644 --- a/freqtrade/optimize/hyperopt.py +++ b/freqtrade/optimize/hyperopt.py @@ -189,7 +189,7 @@ def buy_strategy_generator(params): # TRIGGERS triggers = { - 'lower_bb': dataframe['tema'] <= dataframe['bb_lowerband'], + 'lower_bb': dataframe['tema'] <= dataframe['blower'], 'faststoch10': (crossed_above(dataframe['fastd'], 10.0)), 'ao_cross_zero': (crossed_above(dataframe['ao'], 0.0)), 'ema5_cross_ema10': (crossed_above(dataframe['ema5'], dataframe['ema10'])),