Timeframe
5m
Direction
Long Only
Stoploss
-10.0%
Trailing Stop
No
ROI
0m: 5.0%
Interface Version
3
Startup Candles
N/A
Indicators
1
freqtrade/freqtrade-strategies
Strategy 003 author@: Gerald Lonlas github@: https://github.com/freqtrade/freqtrade-strategies
from freqtrade.strategy import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
class BollingerBandsBreakout(IStrategy):
INTERFACE_VERSION = 3
timeframe = '5m'
minimal_roi = {"0": 0.05}
stoploss = -0.10
startup_candle_count: int = 20
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
bollinger = ta.BBANDS(dataframe, timeperiod=20, nbdevup=2.0, nbdevdn=2.0)
dataframe['bb_lowerband'] = bollinger['lowerband']
dataframe['bb_middleband'] = bollinger['middleband']
dataframe['bb_upperband'] = bollinger['upperband']
# Squeeze detection
dataframe['bb_width'] = (dataframe['bb_upperband'] - dataframe['bb_lowerband']) / dataframe['bb_middleband']
dataframe['bb_width_ma'] = dataframe['bb_width'].rolling(20).mean()
dataframe['squeeze_on'] = dataframe['bb_width'] < dataframe['bb_width_ma']
return dataframe
def populate_entry_signal(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['squeeze_on'].rolling(5).sum() > 0) &
qtpylib.crossed_above(dataframe['close'], dataframe['bb_upperband'])
),
'enter_long'] = 1
return dataframe
def populate_exit_signal(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
qtpylib.crossed_below(dataframe['close'], dataframe['bb_lowerband'])
),
'exit_long'] = 1
return dataframe