# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement # isort: skip_file import numpy as np # noqa import pandas as pd # noqa from freqtrade.strategy import IStrategy, merge_informative_pair from pandas import DataFrame # Add your lib to import here import talib.abstract as ta import freqtrade.vendor.qtpylib.indicators as qtpylib class Reco_1(IStrategy): minimal_roi = { "0": 1 } # Stoploss stoploss = -0.05 # Trailing stoploss trailing_stop = True trailing_only_offset_is_reached = True trailing_stop_positive = 0.015 trailing_stop_positive_offset = 0.02 # Optimal ticker interval for the strategy. timeframe = '5m' # These values can be overridden in the "ask_strategy" section in the config. use_sell_signal = False sell_profit_only = False ignore_roi_if_buy_signal = False # Optional order type mapping. order_types = { 'buy': 'market', 'sell': 'market', 'stoploss': 'market', 'stoploss_on_exchange': True } # Optional order time in force. order_time_in_force = { 'buy': 'gtc', 'sell': 'gtc' } def informative_pairs(self): # get access to all pairs available in whitelist. pairs = self.dp.current_whitelist() # Assign tf to each pair so they can be downloaded and cached for strategy. informative_pairs = [(pair, '6h') for pair in pairs] # Optionally Add additional "static" pairs informative_pairs += [("ETH/USDT", "5m"), ("BTC/TUSD", "5m"), ("ALGO/BTC", "5m"), ("ATOM/BTC", "5m"), ("BAT/BTC", "5m"), ("BCH/BTC", "5m"), ("BRD/BTC", "5m"), ("EOS/BTC", "5m"), ("ETH/BTC", "5m"), ("IOTA/BTC", "5m"), ("LINK/BTC", "5m"), ("LTC/BTC", "5m"), ("NEO/BTC", "5m"), ("NXS/BTC", "5m"), ("XMR/BTC", "5m"), ("XRP/BTC", "5m"), ("XTZ/BTC", "5m"), ] return informative_pairs def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: if not self.dp: # Don't do anything if DataProvider is not available. return dataframe inf_tf = '6h' # Get the informative pair informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe = inf_tf) # Get the 18 hours 3WHITESOLDIERS informative['CDL3WHITESOLDIERS'] = ta.CDL3WHITESOLDIERS(informative, timeperiod=3) # Use the helper function merge_informative_pair to safely merge the pair # Automatically renames the columns and merges a shorter timeframe dataframe and a longer timeframe informative pair dataframe = merge_informative_pair(dataframe, informative, self.timeframe, inf_tf, ffill = True) # Calculate 3WHITESOLDIERS of the original dataframe (5m timeframe) dataframe['CDL3WHITESOLDIERS'] = ta.CDL3WHITESOLDIERS(dataframe, timeperiod=3) # Momentum Indicators # MFI dataframe['mfi'] = ta.MFI(dataframe) # # Chart type # # Heikin Ashi Strategy heikinashi = qtpylib.heikinashi(dataframe) dataframe['ha_open'] = heikinashi['open'] dataframe['ha_close'] = heikinashi['close'] dataframe['ha_high'] = heikinashi['high'] dataframe['ha_low'] = heikinashi['low'] return dataframe def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( (qtpylib.crossed_above(dataframe['mfi'] > 18)) & (dataframe['CDL3WHITESOLDIERS_6h'] == True) & (dataframe['volume'] > 0) ), 'buy'] = 1 return dataframe def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( ), 'sell'] = 1 return dataframe