Change Bollinger bands for qtpylib.bollinger_bands

This commit is contained in:
Gerald Lonlas 2018-01-06 13:10:59 -08:00
parent 297166fcb9
commit 83a999d16e
2 changed files with 13 additions and 9 deletions

View File

@ -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)

View File

@ -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'])),