# --- Do not remove these libs --- import pandas_ta as pta import copy import logging import pathlib import rapidjson import freqtrade.vendor.qtpylib.indicators as qtpylib import numpy as np import talib.abstract as ta from freqtrade.strategy.interface import IStrategy from freqtrade.strategy import merge_informative_pair, timeframe_to_minutes from freqtrade.exchange import timeframe_to_prev_date from pandas import DataFrame, Series, concat, DatetimeIndex, merge from functools import reduce import math from random import shuffle from typing import Dict, List import technical.indicators as ftt from technical.util import resample_to_interval from freqtrade.persistence import Trade from datetime import datetime, timedelta, timezone from technical.util import resample_to_interval, resampled_merge from technical.indicators import RMI, zema, VIDYA, ichimoku from freqtrade.strategy import BooleanParameter, CategoricalParameter, DecimalParameter, IStrategy, IntParameter from skopt.space import Dimension, Integer, Real import time from finta import TA as fta log = logging.getLogger(__name__) logger = logging.getLogger(__name__) # -------------------------------- def ha_typical_price(bars): res = (bars['ha_high'] + bars['ha_low'] + bars['ha_close']) / 3 return Series(index=bars.index, data=res) def VWAPB(dataframe, window_size=20, num_of_std=1): df = dataframe.copy() df['vwap'] = qtpylib.rolling_vwap(df, window=window_size) rolling_std = df['vwap'].rolling(window=window_size).std() df['vwap_low'] = df['vwap'] - rolling_std * num_of_std df['vwap_high'] = df['vwap'] + rolling_std * num_of_std return (df['vwap_low'], df['vwap'], df['vwap_high']) # Volume Weighted Moving Average def vwma(dataframe: DataFrame, length: int=10): """Indicator: Volume Weighted Moving Average (VWMA)""" # Calculate Result pv = dataframe['close'] * dataframe['volume'] vwma = Series(ta.SMA(pv, timeperiod=length) / ta.SMA(dataframe['volume'], timeperiod=length)) return vwma # Modified Elder Ray Index def moderi(dataframe: DataFrame, len_slow_ma: int=32) -> Series: slow_ma = Series(ta.EMA(vwma(dataframe, length=len_slow_ma), timeperiod=len_slow_ma)) return slow_ma >= slow_ma.shift(1) # we just need true & false for ERI trend def EWO(dataframe, ema_length=5, ema2_length=35): df = dataframe.copy() ema1 = ta.EMA(df, timeperiod=ema_length) ema2 = ta.EMA(df, timeperiod=ema2_length) emadif = (ema1 - ema2) / df['low'] * 100 return emadif def SROC(dataframe, roclen=21, emalen=13, smooth=21): df = dataframe.copy() roc = ta.ROC(df, timeperiod=roclen) ema = ta.EMA(df, timeperiod=emalen) sroc = ta.ROC(ema, timeperiod=smooth) return sroc def range_percent_change(dataframe: DataFrame, method, length: int) -> float: """ Rolling Percentage Change Maximum across interval. :param dataframe: DataFrame The original OHLC dataframe :param method: High to Low / Open to Close :param length: int The length to look back """ if method == 'HL': return (dataframe['high'].rolling(length).max() - dataframe['low'].rolling(length).min()) / dataframe['low'].rolling(length).min() elif method == 'OC': return (dataframe['open'].rolling(length).max() - dataframe['close'].rolling(length).min()) / dataframe['close'].rolling(length).min() else: raise ValueError(f'Method {method} not defined!') # Williams %R def williams_r(dataframe: DataFrame, period: int=14) -> Series: """Williams %R, or just %R, is a technical analysis oscillator showing the current closing price in relation to the high and low of the past N days (for a given N). It was developed by a publisher and promoter of trading materials, Larry Williams. Its purpose is to tell whether a stock or commodity market is trading near the high or the low, or somewhere in between, of its recent trading range. The oscillator is on a negative scale, from -100 (lowest) up to 0 (highest). """ highest_high = dataframe['high'].rolling(center=False, window=period).max() lowest_low = dataframe['low'].rolling(center=False, window=period).min() WR = Series((highest_high - dataframe['close']) / (highest_high - lowest_low), name=f'{period} Williams %R') return WR * -100 # Chaikin Money Flow def chaikin_money_flow(dataframe, n=20, fillna=False) -> Series: """Chaikin Money Flow (CMF) It measures the amount of Money Flow Volume over a specific period. http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:chaikin_money_flow_cmf Args: dataframe(pandas.Dataframe): dataframe containing ohlcv n(int): n period. fillna(bool): if fill nan values. Returns: pandas.Series: New feature generated. """ mfv = (dataframe['close'] - dataframe['low'] - (dataframe['high'] - dataframe['close'])) / (dataframe['high'] - dataframe['low']) mfv = mfv.fillna(0.0) # float division by zero mfv *= dataframe['volume'] cmf = mfv.rolling(n, min_periods=0).sum() / dataframe['volume'].rolling(n, min_periods=0).sum() if fillna: cmf = cmf.replace([np.inf, -np.inf], np.nan).fillna(0) return Series(cmf, name='cmf') def HA(dataframe, smoothing=None): df = dataframe.copy() df['HA_Close'] = (df['open'] + df['high'] + df['low'] + df['close']) / 4 df.reset_index(inplace=True) ha_open = [(df['open'][0] + df['close'][0]) / 2] [ha_open.append((ha_open[i] + df['HA_Close'].values[i]) / 2) for i in range(0, len(df) - 1)] df['HA_Open'] = ha_open df.set_index('index', inplace=True) df['HA_High'] = df[['HA_Open', 'HA_Close', 'high']].max(axis=1) df['HA_Low'] = df[['HA_Open', 'HA_Close', 'low']].min(axis=1) if smoothing is not None: sml = abs(int(smoothing)) if sml > 0: df['Smooth_HA_O'] = ta.EMA(df['HA_Open'], sml) df['Smooth_HA_C'] = ta.EMA(df['HA_Close'], sml) df['Smooth_HA_H'] = ta.EMA(df['HA_High'], sml) df['Smooth_HA_L'] = ta.EMA(df['HA_Low'], sml) return df def pump_warning(dataframe, perc=15): df = dataframe.copy() df['change'] = df['high'] - df['low'] df['test1'] = df['close'] > df['open'] df['test2'] = df['change'] / df['low'] > perc / 100 df['result'] = (df['test1'] & df['test2']).astype('int') return df['result'] def pump_warning2(dataframe, params): pct_change_timeframe = 8 pct_change_max = 0.15 pct_change_min = -0.15 pct_change_short_timeframe = 8 pct_change_short_max = 0.08 pct_change_short_min = -0.08 ispumping = 0.4 islongpumping = 0.48 isshortpumping = 0.1 ispumping_rolling = 20 islongpumping_rolling = 30 isshortpumping_rolling = 10 recentispumping_rolling = 300 if 'pct_change_timeframe' in params: pct_change_timeframe = params['pct_change_timeframe'] if 'pct_change_max' in params: pct_change_max = params['pct_change_max'] if 'pct_change_min' in params: pct_change_min = params['pct_change_min'] if 'pct_change_short_timeframe' in params: pct_change_short_timeframe = params['pct_change_short_timeframe'] if 'pct_change_short_max' in params: pct_change_short_max = params['pct_change_short_max'] if 'pct_change_short_min' in params: pct_change_short_min = params['pct_change_short_min'] if 'ispumping' in params: ispumping = params['ispumping'] if 'islongpumping' in params: islongpumping = params['islongpumping'] if 'isshortpumping' in params: isshortpumping = params['isshortpumping'] if 'ispumping_rolling' in params: ispumping_rolling = params['ispumping_rolling'] if 'isshortpumping_rolling' in params: isshortpumping_rolling = params['isshortpumping_rolling'] if 'recentispumping_rolling' in params: recentispumping_rolling = params['recentispumping_rolling'] df = dataframe.copy() df['pct_change'] = df['close'].pct_change(periods=pct_change_timeframe) df['pct_change_int'] = (df['pct_change'] > pct_change_max).astype('int') | (df['pct_change'] < pct_change_min).astype('int') df['pct_change_short'] = df['close'].pct_change(periods=pct_change_short_timeframe) df['pct_change_int_short'] = (df['pct_change_short'] > pct_change_short_max).astype('int') | (df['pct_change_short'] < pct_change_short_min).astype('int') df['ispumping'] = (df['pct_change_int'].rolling(ispumping_rolling).sum() >= ispumping).astype('int') df['islongpumping'] = (df['pct_change_int'].rolling(islongpumping_rolling).sum() >= islongpumping).astype('int') df['isshortpumping'] = (df['pct_change_int_short'].rolling(isshortpumping_rolling).sum() >= isshortpumping).astype('int') df['recentispumping'] = (df['ispumping'].rolling(recentispumping_rolling).max() > 0) | (df['islongpumping'].rolling(recentispumping_rolling).max() > 0) | (df['isshortpumping'].rolling(recentispumping_rolling).max() > 0) return df['recentispumping'] def dump_warning(dataframe, entry_threshold): df_past = dataframe.copy().shift(1) # Get recent BTC info # 5m dump protection df_past_source = (df_past['open'] + df_past['close'] + df_past['high'] + df_past['low']) / 4 # Get BTC price df_threshold = df_past_source * entry_threshold # BTC dump n% in 5 min df_past_delta = df_past['close'].shift(1) - df_past['close'] # should be positive if dump df_diff = df_threshold - df_past_delta # Need be larger than 0 dataframe['pair_threshold'] = df_threshold dataframe['pair_diff'] = df_diff # 1d dump protection df_past_1d = dataframe.copy().shift(288) df_past_source_1d = (df_past_1d['open'] + df_past_1d['close'] + df_past_1d['high'] + df_past_1d['low']) / 4 dataframe['pair_5m'] = df_past_source dataframe['pair_1d'] = df_past_source_1d dataframe['pair_5m_1d_diff'] = df_past_source - df_past_source_1d return dataframe # Elliot Wave Oscillator def ewo(dataframe, sma1_length=5, sma2_length=35): sma1 = ta.EMA(dataframe, timeperiod=sma1_length) sma2 = ta.EMA(dataframe, timeperiod=sma2_length) smadif = (sma1 - sma2) / dataframe['close'] * 100 return smadif # Exponential moving average of a volume weighted simple moving average def ema_vwma_osc(dataframe, len_slow_ma): slow_ema = Series(ta.EMA(vwma(dataframe, len_slow_ma), len_slow_ma)) return (slow_ema - slow_ema.shift(1)) / slow_ema.shift(1) * 100 def pivot_points(dataframe: DataFrame, mode='fibonacci') -> Series: hlc3_pivot = (dataframe['high'] + dataframe['low'] + dataframe['close']).shift(1) / 3 hl_range = (dataframe['high'] - dataframe['low']).shift(1) if mode == 'simple': res1 = hlc3_pivot * 2 - dataframe['low'].shift(1) sup1 = hlc3_pivot * 2 - dataframe['high'].shift(1) res2 = hlc3_pivot + (dataframe['high'] - dataframe['low']).shift() sup2 = hlc3_pivot - (dataframe['high'] - dataframe['low']).shift() res3 = hlc3_pivot * 2 + (dataframe['high'] - 2 * dataframe['low']).shift() sup3 = hlc3_pivot * 2 - (2 * dataframe['high'] - dataframe['low']).shift() elif mode == 'fibonacci': res1 = hlc3_pivot + 0.382 * hl_range sup1 = hlc3_pivot - 0.382 * hl_range res2 = hlc3_pivot + 0.618 * hl_range sup2 = hlc3_pivot - 0.618 * hl_range res3 = hlc3_pivot + 1 * hl_range sup3 = hlc3_pivot - 1 * hl_range return (hlc3_pivot, res1, res2, res3, sup1, sup2, sup3) def heikin_ashi(dataframe, smooth_inputs=False, smooth_outputs=False, length=10): df = dataframe[['open', 'close', 'high', 'low']].copy().fillna(0) if smooth_inputs: df['open_s'] = ta.EMA(df['open'], timeframe=length) df['high_s'] = ta.EMA(df['high'], timeframe=length) df['low_s'] = ta.EMA(df['low'], timeframe=length) df['close_s'] = ta.EMA(df['close'], timeframe=length) open_ha = (df['open_s'].shift(1) + df['close_s'].shift(1)) / 2 high_ha = df.loc[:, ['high_s', 'open_s', 'close_s']].max(axis=1) low_ha = df.loc[:, ['low_s', 'open_s', 'close_s']].min(axis=1) close_ha = (df['open_s'] + df['high_s'] + df['low_s'] + df['close_s']) / 4 else: open_ha = (df['open'].shift(1) + df['close'].shift(1)) / 2 high_ha = df.loc[:, ['high', 'open', 'close']].max(axis=1) low_ha = df.loc[:, ['low', 'open', 'close']].min(axis=1) close_ha = (df['open'] + df['high'] + df['low'] + df['close']) / 4 open_ha = open_ha.fillna(0) high_ha = high_ha.fillna(0) low_ha = low_ha.fillna(0) close_ha = close_ha.fillna(0) if smooth_outputs: open_sha = ta.EMA(open_ha, timeframe=length) high_sha = ta.EMA(high_ha, timeframe=length) low_sha = ta.EMA(low_ha, timeframe=length) close_sha = ta.EMA(close_ha, timeframe=length) return (open_sha, close_sha, low_sha) else: return (open_ha, close_ha, low_ha) # PMAX def pmax(df, period, multiplier, length, MAtype, src): period = int(period) multiplier = int(multiplier) length = int(length) MAtype = int(MAtype) src = int(src) mavalue = f'MA_{MAtype}_{length}' atr = f'ATR_{period}' pm = f'pm_{period}_{multiplier}_{length}_{MAtype}' pmx = f'pmX_{period}_{multiplier}_{length}_{MAtype}' # MAtype==1 --> EMA # MAtype==2 --> DEMA # MAtype==3 --> T3 # MAtype==4 --> SMA # MAtype==5 --> VIDYA # MAtype==6 --> TEMA # MAtype==7 --> WMA # MAtype==8 --> VWMA # MAtype==9 --> zema if src == 1: masrc = df['close'] elif src == 2: masrc = (df['high'] + df['low']) / 2 elif src == 3: masrc = (df['high'] + df['low'] + df['close'] + df['open']) / 4 if MAtype == 1: mavalue = ta.EMA(masrc, timeperiod=length) elif MAtype == 2: mavalue = ta.DEMA(masrc, timeperiod=length) elif MAtype == 3: mavalue = ta.T3(masrc, timeperiod=length) elif MAtype == 4: mavalue = ta.SMA(masrc, timeperiod=length) elif MAtype == 5: mavalue = VIDYA(df, length=length) elif MAtype == 6: mavalue = ta.TEMA(masrc, timeperiod=length) elif MAtype == 7: mavalue = ta.WMA(df, timeperiod=length) elif MAtype == 8: mavalue = vwma(df, length) elif MAtype == 9: mavalue = zema(df, period=length) df[atr] = ta.ATR(df, timeperiod=period) df['basic_ub'] = mavalue + multiplier / 10 * df[atr] df['basic_lb'] = mavalue - multiplier / 10 * df[atr] basic_ub = df['basic_ub'].values final_ub = np.full(len(df), 0.0) basic_lb = df['basic_lb'].values final_lb = np.full(len(df), 0.0) for i in range(period, len(df)): final_ub[i] = basic_ub[i] if basic_ub[i] < final_ub[i - 1] or mavalue[i - 1] > final_ub[i - 1] else final_ub[i - 1] final_lb[i] = basic_lb[i] if basic_lb[i] > final_lb[i - 1] or mavalue[i - 1] < final_lb[i - 1] else final_lb[i - 1] df['final_ub'] = final_ub df['final_lb'] = final_lb pm_arr = np.full(len(df), 0.0) for i in range(period, len(df)): pm_arr[i] = final_ub[i] if pm_arr[i - 1] == final_ub[i - 1] and mavalue[i] <= final_ub[i] else final_lb[i] if pm_arr[i - 1] == final_ub[i - 1] and mavalue[i] > final_ub[i] else final_lb[i] if pm_arr[i - 1] == final_lb[i - 1] and mavalue[i] >= final_lb[i] else final_ub[i] if pm_arr[i - 1] == final_lb[i - 1] and mavalue[i] < final_lb[i] else 0.0 pm = Series(pm_arr) # Mark the trend direction up/down pmx = np.where(pm_arr > 0.0, np.where(mavalue < pm_arr, 'down', 'up'), np.NaN) return (pm, pmx) # Mom DIV def momdiv(dataframe: DataFrame, mom_length: int=10, bb_length: int=20, bb_dev: float=2.0, lookback: int=30) -> DataFrame: mom: Series = ta.MOM(dataframe, timeperiod=mom_length) upperband, middleband, lowerband = ta.BBANDS(mom, timeperiod=bb_length, nbdevup=bb_dev, nbdevdn=bb_dev, matype=0) enter_long = qtpylib.crossed_below(mom, lowerband) exit_long = qtpylib.crossed_above(mom, upperband) hh = dataframe['high'].rolling(lookback).max() ll = dataframe['low'].rolling(lookback).min() coh = dataframe['high'] >= hh col = dataframe['low'] <= ll df = DataFrame({'momdiv_mom': mom, 'momdiv_upperb': upperband, 'momdiv_lowerb': lowerband, 'momdiv_entry': enter_long, 'momdiv_exit': exit_long, 'momdiv_coh': coh, 'momdiv_col': col}, index=dataframe['close'].index) return df def pct_change(a, b): return (b - a) / a def T3(dataframe, length=5): """ T3 Average by HPotter on Tradingview https://www.tradingview.com/script/qzoC9H1I-T3-Average/ """ df = dataframe.copy() df['xe1'] = ta.EMA(df['close'], timeperiod=length) df['xe2'] = ta.EMA(df['xe1'], timeperiod=length) df['xe3'] = ta.EMA(df['xe2'], timeperiod=length) df['xe4'] = ta.EMA(df['xe3'], timeperiod=length) df['xe5'] = ta.EMA(df['xe4'], timeperiod=length) df['xe6'] = ta.EMA(df['xe5'], timeperiod=length) b = 0.7 c1 = -b * b * b c2 = 3 * b * b + 3 * b * b * b c3 = -6 * b * b - 3 * b - 3 * b * b * b c4 = 1 + 3 * b + b * b * b + 3 * b * b df['T3Average'] = c1 * df['xe6'] + c2 * df['xe5'] + c3 * df['xe4'] + c4 * df['xe3'] return df['T3Average'] class BB_RPB_TSL_SMA_Tranz(IStrategy): INTERFACE_VERSION = 3 '\n BB_RPB_TSL\n @author jilv220\n Simple bollinger brand strategy inspired by this blog ( https://hacks-for-life.blogspot.com/2020/12/freqtrade-notes.html )\n RPB, which stands for Real Pull Back, taken from ( https://github.com/GeorgeMurAlkh/freqtrade-stuff/blob/main/user_data/strategies/TheRealPullbackV2.py )\n The trailing custom stoploss taken from BigZ04_TSL from Perkmeister ( modded by ilya )\n I modified it to better suit my taste and added Hyperopt for this strategy.\n ' # (1) exit rework ########################################################################## # Hyperopt result area DATESTAMP = 0 SELLMA = 1 SELL_TRIGGER = 2 # entry space ## ## ## # ## ## ## ## # # ## # # # # ## ## ## ## ## ## ## # # entry_params = {'entry_btc_safe': -250, 'entry_btc_safe_1d': -0.04, 'max_slip': 0.983, 'entry_bb_width_1h': 0.954, 'entry_roc_1h': 86, 'entry_threshold': 0.003, 'entry_bb_factor': 0.999, 'entry_bb_delta': 0.025, 'entry_bb_width': 0.095, 'entry_cci': -116, 'entry_cci_length': 25, 'entry_rmi': 49, 'entry_rmi_length': 17, 'entry_srsi_fk': 32, 'entry_closedelta': 17.922, 'entry_ema_diff': 0.026, 'entry_ema_high': 0.968, 'entry_ema_low': 0.935, 'entry_ewo': -5.001, 'entry_rsi': 23, 'entry_rsi_fast': 44, 'base_nb_candles_entry_trima': 15, 'base_nb_candles_entry_trima2': 38, 'low_offset_trima': 0.959, 'low_offset_trima2': 0.949, 'base_nb_candles_entry_hma': 70, 'base_nb_candles_entry_hma2': 12, 'low_offset_hma': 0.948, 'low_offset_hma2': 0.941, 'base_nb_candles_entry_zema': 25, 'base_nb_candles_entry_zema2': 53, 'low_offset_zema': 0.958, 'low_offset_zema2': 0.961, 'base_nb_candles_entry_ema': 9, 'base_nb_candles_entry_ema2': 75, 'low_offset_ema': 1.067, 'low_offset_ema2': 0.973, 'entry_closedelta_local_dip': 12.044, 'entry_ema_diff_local_dip': 0.024, 'entry_ema_high_local_dip': 1.014, 'entry_rsi_local_dip': 21, 'ewo_high': 2.615, 'ewo_high2': 2.188, 'ewo_low': -19.632, 'ewo_low2': -19.955, 'rsi_entry': 60, 'rsi_entry2': 45, 'pump_protection_01_pct_change_timeframe': 8, 'pump_protection_01_pct_change_max': 0.15, 'pump_protection_01_pct_change_min': -0.15, 'pump_protection_01_pct_change_short_timeframe': 8, 'pump_protection_01_pct_change_short_max': 0.1, 'pump_protection_01_pct_change_short_min': -0.1, 'pump_protection_01_ispumping': 0.2, 'pump_protection_01_islongpumping': 0.24, 'pump_protection_01_isshortpumping': 0.12, 'entry_r_deadfish_bb_factor': 1.014, 'entry_r_deadfish_bb_width': 0.299, 'entry_r_deadfish_ema': 1.054, 'entry_r_deadfish_volume_factor': 1.59, 'entry_r_deadfish_cti': -0.115, 'entry_r_deadfish_r14': -44.34, 'entry_ema_high_2': 1.04116, 'entry_ema_low_2': 0.97463, 'entry_ewo_high_2': 5.249, 'entry_rsi_ewo_2': 35, 'entry_rsi_fast_ewo_2': 45, 'lambo2_ema_14_factor': 0.981, 'lambo2_enabled': True, 'lambo2_rsi_14_limit': 39, 'lambo2_rsi_4_limit': 44, 'entry_adx': 13, 'entry_cofi_r14': -85.016, 'entry_cofi_cti': -0.892, 'entry_ema_cofi': 1.147, 'entry_ewo_high': 8.594, 'entry_fastd': 28, 'entry_fastk': 39, 'entry_gumbo_ema': 1.121, 'entry_gumbo_ewo_low': -9.442, 'entry_gumbo_cti': -0.374, 'entry_gumbo_r14': -51.971, 'entry_sqzmom_ema': 0.981, 'entry_sqzmom_ewo': -3.966, 'entry_sqzmom_r14': -45.068, 'entry_nfix_49_cti': -0.105, 'entry_nfix_49_r14': -81.827, 'base_nb_candles_ema_exit': 5, 'high_offset_exit_ema': 0.994, 'base_nb_candles_entry': 8, 'ewo_high': 4.13, 'ewo_high_2': 4.477, 'ewo_low': -19.076, 'lookback_candles': 27, 'low_offset': 0.988, 'low_offset_2': 0.974, 'profit_threshold': 1.049, 'rsi_entry': 72, 'rsi_fast_entry': 40, 'clucha_bbdelta_close': 0.04796, 'clucha_bbdelta_tail': 0.93112, 'clucha_close_bblower': 0.01645, 'clucha_closedelta_close': 0.00931, 'clucha_enabled': False, 'clucha_rocr_1h': 0.41663} # value loaded from strategy protection_params = {'low_profit_lookback': 48, 'low_profit_min_req': 0.04, 'low_profit_stop_duration': 14, 'cooldown_lookback': 2} ############################################################# ## ## ## # ############# # Enable/Disable conditions ############# exit_params = {'exit_cmf': -0.046, 'exit_ema': 0.988, 'exit_ema_close_delta': 0.022, 'exit_deadfish_profit': -0.063, 'exit_deadfish_bb_factor': 0.954, 'exit_deadfish_bb_width': 0.043, 'exit_deadfish_volume_factor': 2.37, 'exit_cti_r_cti': 0.844, 'exit_cti_r_r': -19.99, 'base_nb_candles_exit': 8, 'high_offset': 1.012, 'high_offset_2': 1.431, 'exit_condition_1_enable': True, 'exit_condition_2_enable': True, 'exit_condition_3_enable': True, 'exit_condition_4_enable': True, 'exit_condition_5_enable': True, 'exit_condition_6_enable': True, 'exit_condition_7_enable': True, 'exit_condition_8_enable': True} exit_condition_2_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_3_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_4_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_5_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_6_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_7_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_8_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) # Protection hyperspace params: class HyperOpt: @staticmethod def generate_roi_table(params: dict): """ Generate the ROI table that will be used by Hyperopt This implementation generates the default legacy Freqtrade ROI tables. Change it if you need different number of steps in the generated ROI tables or other structure of the ROI tables. Please keep it aligned with parameters in the 'roi' optimization hyperspace defined by the roi_space method. """ roi_table = {} roi_table[0] = 0.05 roi_table[params['roi_t6']] = 0.04 roi_table[params['roi_t5']] = 0.03 roi_table[params['roi_t4']] = 0.02 roi_table[params['roi_t3']] = 0.01 roi_table[params['roi_t2']] = 0.0001 roi_table[params['roi_t1']] = -10 return roi_table @staticmethod def roi_space() -> List[Dimension]: """ Values to search for each ROI steps Override it if you need some different ranges for the parameters in the 'roi' optimization hyperspace. Please keep it aligned with the implementation of the generate_roi_table method. """ return [Integer(240, 720, name='roi_t1'), Integer(120, 240, name='roi_t2'), Integer(90, 120, name='roi_t3'), Integer(60, 90, name='roi_t4'), Integer(30, 60, name='roi_t5'), Integer(1, 30, name='roi_t6')] minimal_roi = {'0': 0.10347601757573865, '3': 0.050495605759981035, '5': 0.03350898081823659, '61': 0.0275218557571848, '292': 0.005185372158403069, '399': 0} # Optimal timeframe for the strategy timeframe = '5m' inf_15m = '15m' inf_1h = '1h' # Run "populate_indicators()" only for new candle. process_only_new_candles = True # Disabled stoploss = -0.15 # Custom stoploss use_custom_stoploss = False use_exit_signal = True startup_candle_count: int = 400 ############################################################################ lambo2_ema_14_factor = DecimalParameter(0.9, 0.99, default=entry_params['lambo2_ema_14_factor'], space='entry', optimize=True) lambo2_rsi_4_limit = IntParameter(2, 50, default=entry_params['lambo2_rsi_4_limit'], space='entry', optimize=True) lambo2_rsi_14_limit = IntParameter(2, 50, default=entry_params['lambo2_rsi_14_limit'], space='entry', optimize=True) # SMAOffset base_nb_candles_entry = IntParameter(2, 20, default=entry_params['base_nb_candles_entry'], space='entry', optimize=True) base_nb_candles_exit = IntParameter(2, 25, default=exit_params['base_nb_candles_exit'], space='exit', optimize=True) low_offset = DecimalParameter(0.9, 0.99, default=entry_params['low_offset'], space='entry', optimize=True) low_offset_2 = DecimalParameter(0.9, 0.99, default=entry_params['low_offset_2'], space='entry', optimize=True) high_offset = DecimalParameter(0.95, 1.1, default=exit_params['high_offset'], space='exit', optimize=True) high_offset_2 = DecimalParameter(0.99, 1.5, default=exit_params['high_offset_2'], space='exit', optimize=True) # Multi Offset optimize_entry_ema = False base_nb_candles_entry_ema = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_ema) low_offset_ema = DecimalParameter(0.9, 1.1, default=0.958, space='entry', optimize=optimize_entry_ema) base_nb_candles_entry_ema2 = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_ema) low_offset_ema2 = DecimalParameter(0.9, 1.1, default=0.958, space='entry', optimize=optimize_entry_ema) # Protection fast_ewo = 50 slow_ewo = 200 lookback_candles = IntParameter(1, 36, default=entry_params['lookback_candles'], space='entry', optimize=True) profit_threshold = DecimalParameter(0.99, 1.05, default=entry_params['profit_threshold'], space='entry', optimize=True) ewo_low = DecimalParameter(-20.0, -8.0, default=entry_params['ewo_low'], space='entry', optimize=True) ewo_high = DecimalParameter(2.0, 12.0, default=entry_params['ewo_high'], space='entry', optimize=True) ewo_low2 = DecimalParameter(-20.0, -8.0, default=entry_params['ewo_low2'], space='entry', optimize=True) ewo_high2 = DecimalParameter(2.0, 12.0, default=entry_params['ewo_high2'], space='entry', optimize=True) ewo_high_2 = DecimalParameter(-6.0, 12.0, default=entry_params['ewo_high_2'], space='entry', optimize=True) rsi_entry = IntParameter(10, 80, default=entry_params['rsi_entry'], space='entry', optimize=True) rsi_entry2 = IntParameter(30, 70, default=entry_params['rsi_entry2'], space='entry', optimize=True) rsi_fast_entry = IntParameter(10, 50, default=entry_params['rsi_fast_entry'], space='entry', optimize=True) ## Buy params max_change_pump = 35 is_optimize_dip = False entry_rmi = IntParameter(30, 50, default=35, optimize=is_optimize_dip) entry_cci = IntParameter(-135, -90, default=-133, optimize=is_optimize_dip) entry_srsi_fk = IntParameter(30, 50, default=25, optimize=is_optimize_dip) entry_cci_length = IntParameter(25, 45, default=25, optimize=is_optimize_dip) entry_rmi_length = IntParameter(8, 20, default=8, optimize=is_optimize_dip) is_optimize_break = False entry_bb_width = DecimalParameter(0.065, 0.135, default=0.095, optimize=is_optimize_break) entry_bb_delta = DecimalParameter(0.018, 0.035, default=0.025, optimize=is_optimize_break) is_optimize_local_uptrend = False entry_ema_diff = DecimalParameter(0.022, 0.027, default=0.025, optimize=is_optimize_local_uptrend) entry_bb_factor = DecimalParameter(0.99, 0.999, default=0.995, optimize=False) entry_closedelta = DecimalParameter(12.0, 18.0, default=15.0, optimize=is_optimize_local_uptrend) is_optimize_local_dip = False entry_ema_diff_local_dip = DecimalParameter(0.022, 0.027, default=0.025, optimize=is_optimize_local_dip) entry_ema_high_local_dip = DecimalParameter(0.9, 1.2, default=0.942, optimize=is_optimize_local_dip) entry_closedelta_local_dip = DecimalParameter(12.0, 18.0, default=15.0, optimize=is_optimize_local_dip) entry_rsi_local_dip = IntParameter(15, 45, default=28, optimize=is_optimize_local_dip) entry_crsi_local_dip = IntParameter(10, 18, default=10, optimize=False) is_optimize_ewo = False entry_rsi_fast = IntParameter(35, 50, default=45, optimize=is_optimize_ewo) entry_rsi = IntParameter(15, 35, default=35, optimize=is_optimize_ewo) entry_ewo = DecimalParameter(-6.0, 5, default=-5.585, optimize=is_optimize_ewo) entry_ema_low = DecimalParameter(0.9, 0.99, default=0.942, optimize=is_optimize_ewo) entry_ema_high = DecimalParameter(0.95, 1.2, default=1.084, optimize=is_optimize_ewo) is_optimize_r_deadfish = False entry_r_deadfish_ema = DecimalParameter(0.9, 1.2, default=1.087, optimize=is_optimize_r_deadfish) entry_r_deadfish_bb_width = DecimalParameter(0.03, 0.75, default=0.05, optimize=is_optimize_r_deadfish) entry_r_deadfish_bb_factor = DecimalParameter(0.9, 1.2, default=1.0, optimize=is_optimize_r_deadfish) entry_r_deadfish_volume_factor = DecimalParameter(1, 2.5, default=1.0, optimize=is_optimize_r_deadfish) is_optimize_r_deadfish_protection = False entry_r_deadfish_cti = DecimalParameter(-0.6, -0.0, default=-0.5, optimize=is_optimize_r_deadfish_protection) entry_r_deadfish_r14 = DecimalParameter(-60, -44, default=-60, optimize=is_optimize_r_deadfish_protection) is_optimize_clucha = False entry_clucha_bbdelta_close = DecimalParameter(0.01, 0.05, default=0.02206, optimize=is_optimize_clucha) entry_clucha_bbdelta_tail = DecimalParameter(0.7, 1.2, default=1.02515, optimize=is_optimize_clucha) entry_clucha_closedelta_close = DecimalParameter(0.001, 0.05, default=0.04401, optimize=is_optimize_clucha) entry_clucha_rocr_1h = DecimalParameter(0.1, 1.0, default=0.47782, optimize=is_optimize_clucha) is_optimize_cofi = False entry_ema_cofi = DecimalParameter(0.94, 1.2, default=0.97, optimize=is_optimize_cofi) entry_fastk = IntParameter(0, 40, default=20, optimize=is_optimize_cofi) entry_fastd = IntParameter(0, 40, default=20, optimize=is_optimize_cofi) entry_adx = IntParameter(0, 30, default=30, optimize=is_optimize_cofi) entry_ewo_high = DecimalParameter(2, 12, default=3.553, optimize=is_optimize_cofi) is_optimize_cofi_protection = False entry_cofi_cti = DecimalParameter(-0.9, -0.0, default=-0.5, optimize=is_optimize_cofi_protection) entry_cofi_r14 = DecimalParameter(-100, -44, default=-60, optimize=is_optimize_cofi_protection) is_optimize_gumbo = False entry_gumbo_ema = DecimalParameter(0.9, 1.2, default=0.97, optimize=is_optimize_gumbo) entry_gumbo_ewo_low = DecimalParameter(-12.0, 5, default=-5.585, optimize=is_optimize_gumbo) is_optimize_gumbo_protection = False entry_gumbo_cti = DecimalParameter(-0.9, -0.0, default=-0.5, optimize=is_optimize_gumbo_protection) entry_gumbo_r14 = DecimalParameter(-100, -44, default=-60, optimize=is_optimize_gumbo_protection) is_optimize_sqzmom_protection = False entry_sqzmom_ema = DecimalParameter(0.9, 1.2, default=0.97, optimize=is_optimize_sqzmom_protection) entry_sqzmom_ewo = DecimalParameter(-12, 12, default=0, optimize=is_optimize_sqzmom_protection) entry_sqzmom_r14 = DecimalParameter(-100, -22, default=-50, optimize=is_optimize_sqzmom_protection) is_optimize_nfix_39 = True entry_nfix_39_ema = DecimalParameter(0.9, 1.2, default=0.97, optimize=is_optimize_nfix_39) is_optimize_nfix_49_protection = False entry_nfix_49_cti = DecimalParameter(-0.9, -0.0, default=-0.5, optimize=is_optimize_nfix_49_protection) entry_nfix_49_r14 = DecimalParameter(-100, -44, default=-60, optimize=is_optimize_nfix_49_protection) is_optimize_btc_safe = False entry_btc_safe = IntParameter(-300, 50, default=-200, optimize=is_optimize_btc_safe) entry_btc_safe_1d = DecimalParameter(-0.075, -0.025, default=-0.05, optimize=is_optimize_btc_safe) entry_threshold = DecimalParameter(0.003, 0.012, default=0.008, optimize=is_optimize_btc_safe) is_optimize_check = False entry_roc_1h = IntParameter(-25, 200, default=10, optimize=is_optimize_check) entry_bb_width_1h = DecimalParameter(0.3, 2.0, default=0.3, optimize=is_optimize_check) #BB MODDED is_optimize_ctt15_protection = False entry_ema_open_mult_15 = DecimalParameter(0.01, 0.03, default=0.024, optimize=is_optimize_ctt15_protection) entry_ma_offset_15 = DecimalParameter(0.93, 0.99, default=0.958, optimize=is_optimize_ctt15_protection) entry_rsi_15 = DecimalParameter(20.0, 36.0, default=28.0, optimize=is_optimize_ctt15_protection) entry_ema_rel_15 = DecimalParameter(0.97, 0.999, default=0.974, optimize=is_optimize_ctt15_protection) is_optimize_ctt25_protection = False entry_25_ma_offset = DecimalParameter(0.9, 0.99, default=0.922, optimize=is_optimize_ctt25_protection) entry_25_rsi_4 = DecimalParameter(26.0, 40.0, default=38.0, optimize=is_optimize_ctt25_protection) entry_25_cti = DecimalParameter(-0.99, -0.4, default=-0.76, optimize=is_optimize_ctt25_protection) #NFI 7 SMA entry_dip_threshold_10_1 = DecimalParameter(0.001, 0.05, default=0.015, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_10_2 = DecimalParameter(0.01, 0.2, default=0.1, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_10_3 = DecimalParameter(0.1, 0.3, default=0.24, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_10_4 = DecimalParameter(0.3, 0.5, default=0.42, space='entry', decimals=3, optimize=False, load=True) # Strict dips - level 20 entry_dip_threshold_20_1 = DecimalParameter(0.001, 0.05, default=0.016, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_20_2 = DecimalParameter(0.01, 0.2, default=0.11, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_20_3 = DecimalParameter(0.1, 0.4, default=0.26, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_20_4 = DecimalParameter(0.36, 0.56, default=0.44, space='entry', decimals=3, optimize=False, load=True) # Strict dips - level 30 entry_dip_threshold_30_1 = DecimalParameter(0.001, 0.05, default=0.018, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_30_2 = DecimalParameter(0.01, 0.2, default=0.12, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_30_3 = DecimalParameter(0.1, 0.4, default=0.28, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_30_4 = DecimalParameter(0.36, 0.56, default=0.46, space='entry', decimals=3, optimize=False, load=True) # Strict dips - level 40 entry_dip_threshold_40_1 = DecimalParameter(0.001, 0.05, default=0.019, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_40_2 = DecimalParameter(0.01, 0.2, default=0.13, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_40_3 = DecimalParameter(0.1, 0.4, default=0.3, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_40_4 = DecimalParameter(0.36, 0.56, default=0.48, space='entry', decimals=3, optimize=False, load=True) # Normal dips - level 50 entry_dip_threshold_50_1 = DecimalParameter(0.001, 0.05, default=0.02, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_50_2 = DecimalParameter(0.01, 0.2, default=0.14, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_50_3 = DecimalParameter(0.05, 0.4, default=0.32, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_50_4 = DecimalParameter(0.2, 0.5, default=0.5, space='entry', decimals=3, optimize=False, load=True) # Normal dips - level 60 entry_dip_threshold_60_1 = DecimalParameter(0.001, 0.05, default=0.022, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_60_2 = DecimalParameter(0.1, 0.22, default=0.18, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_60_3 = DecimalParameter(0.2, 0.4, default=0.34, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_60_4 = DecimalParameter(0.4, 0.6, default=0.56, space='entry', decimals=3, optimize=False, load=True) # Normal dips - level 70 entry_dip_threshold_70_1 = DecimalParameter(0.001, 0.05, default=0.023, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_70_2 = DecimalParameter(0.16, 0.28, default=0.2, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_70_3 = DecimalParameter(0.2, 0.4, default=0.36, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_70_4 = DecimalParameter(0.5, 0.7, default=0.6, space='entry', decimals=3, optimize=False, load=True) # Normal dips - level 80 entry_dip_threshold_80_1 = DecimalParameter(0.001, 0.05, default=0.024, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_80_2 = DecimalParameter(0.16, 0.28, default=0.22, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_80_3 = DecimalParameter(0.2, 0.4, default=0.38, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_80_4 = DecimalParameter(0.5, 0.7, default=0.66, space='entry', decimals=3, optimize=False, load=True) # Normal dips - level 70 entry_dip_threshold_90_1 = DecimalParameter(0.001, 0.05, default=0.025, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_90_2 = DecimalParameter(0.16, 0.28, default=0.23, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_90_3 = DecimalParameter(0.3, 0.5, default=0.4, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_90_4 = DecimalParameter(0.6, 0.8, default=0.7, space='entry', decimals=3, optimize=False, load=True) # Loose dips - level 100 entry_dip_threshold_100_1 = DecimalParameter(0.001, 0.05, default=0.026, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_100_2 = DecimalParameter(0.16, 0.3, default=0.24, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_100_3 = DecimalParameter(0.3, 0.5, default=0.42, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_100_4 = DecimalParameter(0.6, 1.0, default=0.8, space='entry', decimals=3, optimize=False, load=True) # Loose dips - level 110 entry_dip_threshold_110_1 = DecimalParameter(0.001, 0.05, default=0.027, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_110_2 = DecimalParameter(0.16, 0.3, default=0.26, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_110_3 = DecimalParameter(0.3, 0.5, default=0.44, space='entry', decimals=3, optimize=False, load=True) entry_dip_threshold_110_4 = DecimalParameter(0.6, 1.0, default=0.84, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 10 entry_pump_pull_threshold_10_24 = DecimalParameter(1.5, 3.0, default=2.2, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_10_24 = DecimalParameter(0.4, 1.0, default=0.42, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 10 entry_pump_pull_threshold_10_36 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_10_36 = DecimalParameter(0.4, 1.0, default=0.58, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 10 entry_pump_pull_threshold_10_48 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_10_48 = DecimalParameter(0.4, 1.0, default=0.8, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 20 entry_pump_pull_threshold_20_24 = DecimalParameter(1.5, 3.0, default=2.2, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_20_24 = DecimalParameter(0.4, 1.0, default=0.46, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 20 entry_pump_pull_threshold_20_36 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_20_36 = DecimalParameter(0.4, 1.0, default=0.6, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 20 entry_pump_pull_threshold_20_48 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_20_48 = DecimalParameter(0.4, 1.0, default=0.81, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 30 entry_pump_pull_threshold_30_24 = DecimalParameter(1.5, 3.0, default=2.2, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_30_24 = DecimalParameter(0.4, 1.0, default=0.5, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 30 entry_pump_pull_threshold_30_36 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_30_36 = DecimalParameter(0.4, 1.0, default=0.62, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 30 entry_pump_pull_threshold_30_48 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_30_48 = DecimalParameter(0.4, 1.0, default=0.82, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 40 entry_pump_pull_threshold_40_24 = DecimalParameter(1.5, 3.0, default=2.2, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_40_24 = DecimalParameter(0.4, 1.0, default=0.54, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 40 entry_pump_pull_threshold_40_36 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_40_36 = DecimalParameter(0.4, 1.0, default=0.63, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 40 entry_pump_pull_threshold_40_48 = DecimalParameter(1.5, 3.0, default=2.0, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_40_48 = DecimalParameter(0.4, 1.0, default=0.84, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 50 entry_pump_pull_threshold_50_24 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_50_24 = DecimalParameter(0.4, 1.0, default=0.6, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 50 entry_pump_pull_threshold_50_36 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_50_36 = DecimalParameter(0.4, 1.0, default=0.64, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 50 entry_pump_pull_threshold_50_48 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_50_48 = DecimalParameter(0.4, 1.0, default=0.85, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 60 entry_pump_pull_threshold_60_24 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_60_24 = DecimalParameter(0.4, 1.0, default=0.62, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 60 entry_pump_pull_threshold_60_36 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_60_36 = DecimalParameter(0.4, 1.0, default=0.66, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 60 entry_pump_pull_threshold_60_48 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_60_48 = DecimalParameter(0.4, 1.0, default=0.9, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 70 entry_pump_pull_threshold_70_24 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_70_24 = DecimalParameter(0.4, 1.0, default=0.63, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 70 entry_pump_pull_threshold_70_36 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_70_36 = DecimalParameter(0.4, 1.0, default=0.67, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 70 entry_pump_pull_threshold_70_48 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_70_48 = DecimalParameter(0.4, 1.0, default=0.95, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 80 entry_pump_pull_threshold_80_24 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_80_24 = DecimalParameter(0.4, 1.0, default=0.64, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 80 entry_pump_pull_threshold_80_36 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_80_36 = DecimalParameter(0.4, 1.0, default=0.68, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 80 entry_pump_pull_threshold_80_48 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_80_48 = DecimalParameter(0.8, 1.1, default=1.0, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 90 entry_pump_pull_threshold_90_24 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_90_24 = DecimalParameter(0.4, 1.0, default=0.65, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 90 entry_pump_pull_threshold_90_36 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_90_36 = DecimalParameter(0.4, 1.0, default=0.69, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 90 entry_pump_pull_threshold_90_48 = DecimalParameter(1.5, 3.0, default=1.75, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_90_48 = DecimalParameter(0.8, 1.2, default=1.1, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 100 entry_pump_pull_threshold_100_24 = DecimalParameter(1.5, 3.0, default=1.7, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_100_24 = DecimalParameter(0.4, 1.0, default=0.66, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 100 entry_pump_pull_threshold_100_36 = DecimalParameter(1.5, 3.0, default=1.7, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_100_36 = DecimalParameter(0.4, 1.0, default=0.7, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 100 entry_pump_pull_threshold_100_48 = DecimalParameter(1.3, 2.0, default=1.4, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_100_48 = DecimalParameter(0.4, 1.8, default=1.6, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 110 entry_pump_pull_threshold_110_24 = DecimalParameter(1.5, 3.0, default=1.7, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_110_24 = DecimalParameter(0.4, 1.0, default=0.7, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 110 entry_pump_pull_threshold_110_36 = DecimalParameter(1.5, 3.0, default=1.7, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_110_36 = DecimalParameter(0.4, 1.0, default=0.74, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 110 entry_pump_pull_threshold_110_48 = DecimalParameter(1.3, 2.0, default=1.4, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_110_48 = DecimalParameter(1.4, 2.0, default=1.8, space='entry', decimals=3, optimize=False, load=True) # 24 hours - level 120 entry_pump_pull_threshold_120_24 = DecimalParameter(1.5, 3.0, default=1.7, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_120_24 = DecimalParameter(0.4, 1.0, default=0.78, space='entry', decimals=3, optimize=False, load=True) # 36 hours - level 120 entry_pump_pull_threshold_120_36 = DecimalParameter(1.5, 3.0, default=1.7, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_120_36 = DecimalParameter(0.4, 1.0, default=0.78, space='entry', decimals=3, optimize=False, load=True) # 48 hours - level 120 entry_pump_pull_threshold_120_48 = DecimalParameter(1.3, 2.0, default=1.4, space='entry', decimals=2, optimize=False, load=True) entry_pump_threshold_120_48 = DecimalParameter(1.4, 2.8, default=2.0, space='entry', decimals=3, optimize=False, load=True) entry_min_inc_1 = DecimalParameter(0.01, 0.05, default=0.022, space='entry', decimals=3, optimize=False, load=True) entry_rsi_1h_min_1 = DecimalParameter(25.0, 40.0, default=30.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_max_1 = DecimalParameter(70.0, 90.0, default=84.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1 = DecimalParameter(20.0, 40.0, default=36.0, space='entry', decimals=1, optimize=False, load=True) entry_mfi_1 = DecimalParameter(20.0, 40.0, default=36.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_min_2 = DecimalParameter(30.0, 40.0, default=32.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_max_2 = DecimalParameter(70.0, 95.0, default=84.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_diff_2 = DecimalParameter(30.0, 50.0, default=39.0, space='entry', decimals=1, optimize=False, load=True) entry_mfi_2 = DecimalParameter(30.0, 56.0, default=49.0, space='entry', decimals=1, optimize=False, load=True) entry_bb_offset_2 = DecimalParameter(0.97, 0.999, default=0.983, space='entry', decimals=3, optimize=False, load=True) entry_bb40_bbdelta_close_3 = DecimalParameter(0.005, 0.06, default=0.059, space='entry', optimize=False, load=True) entry_bb40_closedelta_close_3 = DecimalParameter(0.01, 0.03, default=0.023, space='entry', optimize=False, load=True) entry_bb40_tail_bbdelta_3 = DecimalParameter(0.15, 0.45, default=0.418, space='entry', optimize=False, load=True) entry_ema_rel_3 = DecimalParameter(0.97, 0.999, default=0.986, space='entry', decimals=3, optimize=False, load=True) entry_bb20_close_bblowerband_4 = DecimalParameter(0.96, 0.99, default=0.98, space='entry', optimize=False, load=True) entry_bb20_volume_4 = DecimalParameter(1.0, 20.0, default=10.0, space='entry', decimals=2, optimize=False, load=True) entry_ema_open_mult_5 = DecimalParameter(0.016, 0.03, default=0.018, space='entry', decimals=3, optimize=False, load=True) entry_bb_offset_5 = DecimalParameter(0.98, 1.0, default=0.996, space='entry', decimals=3, optimize=False, load=True) entry_ema_rel_5 = DecimalParameter(0.97, 0.999, default=0.944, space='entry', decimals=3, optimize=False, load=True) entry_ema_open_mult_6 = DecimalParameter(0.02, 0.03, default=0.021, space='entry', decimals=3, optimize=False, load=True) entry_bb_offset_6 = DecimalParameter(0.98, 0.999, default=0.984, space='entry', decimals=3, optimize=False, load=True) entry_ema_open_mult_7 = DecimalParameter(0.02, 0.04, default=0.03, space='entry', decimals=3, optimize=False, load=True) entry_rsi_7 = DecimalParameter(24.0, 50.0, default=37.0, space='entry', decimals=1, optimize=False, load=True) entry_volume_8 = DecimalParameter(1.0, 6.0, default=2.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_8 = DecimalParameter(16.0, 30.0, default=29.0, space='entry', decimals=1, optimize=False, load=True) entry_tail_diff_8 = DecimalParameter(3.0, 10.0, default=3.5, space='entry', decimals=1, optimize=False, load=True) entry_ma_offset_9 = DecimalParameter(0.91, 0.94, default=0.922, space='entry', decimals=3, optimize=False, load=True) entry_bb_offset_9 = DecimalParameter(0.96, 0.98, default=0.942, space='entry', decimals=3, optimize=False, load=True) entry_rsi_1h_min_9 = DecimalParameter(26.0, 40.0, default=30.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_max_9 = DecimalParameter(70.0, 90.0, default=88.0, space='entry', decimals=1, optimize=False, load=True) entry_mfi_9 = DecimalParameter(36.0, 56.0, default=50.0, space='entry', decimals=1, optimize=False, load=True) entry_ma_offset_10 = DecimalParameter(0.93, 0.97, default=0.948, space='entry', decimals=3, optimize=False, load=True) entry_bb_offset_10 = DecimalParameter(0.97, 0.99, default=0.985, space='entry', decimals=3, optimize=False, load=True) entry_rsi_1h_10 = DecimalParameter(20.0, 40.0, default=37.0, space='entry', decimals=1, optimize=False, load=True) entry_ma_offset_11 = DecimalParameter(0.93, 0.99, default=0.934, space='entry', decimals=3, optimize=False, load=True) entry_min_inc_11 = DecimalParameter(0.005, 0.05, default=0.01, space='entry', decimals=3, optimize=False, load=True) entry_rsi_1h_min_11 = DecimalParameter(40.0, 60.0, default=55.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_max_11 = DecimalParameter(70.0, 90.0, default=84.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_11 = DecimalParameter(34.0, 50.0, default=48.0, space='entry', decimals=1, optimize=False, load=True) entry_mfi_11 = DecimalParameter(30.0, 46.0, default=36.0, space='entry', decimals=1, optimize=False, load=True) entry_ma_offset_12 = DecimalParameter(0.93, 0.97, default=0.922, space='entry', decimals=3, optimize=False, load=True) entry_rsi_12 = DecimalParameter(26.0, 40.0, default=30.0, space='entry', decimals=1, optimize=False, load=True) entry_ewo_12 = DecimalParameter(1.0, 6.0, default=1.8, space='entry', decimals=1, optimize=False, load=True) entry_ma_offset_13 = DecimalParameter(0.93, 0.98, default=0.99, space='entry', decimals=3, optimize=False, load=True) entry_ewo_13 = DecimalParameter(-14.0, -7.0, default=-11.4, space='entry', decimals=1, optimize=False, load=True) entry_ema_open_mult_14 = DecimalParameter(0.01, 0.03, default=0.014, space='entry', decimals=3, optimize=False, load=True) entry_bb_offset_14 = DecimalParameter(0.98, 1.0, default=0.988, space='entry', decimals=3, optimize=False, load=True) entry_ma_offset_14 = DecimalParameter(0.93, 0.99, default=0.98, space='entry', decimals=3, optimize=False, load=True) entry_ema_open_mult_15 = DecimalParameter(0.01, 0.03, default=0.018, space='entry', decimals=3, optimize=False, load=True) entry_ma_offset_15 = DecimalParameter(0.93, 0.99, default=0.954, space='entry', decimals=3, optimize=False, load=True) entry_rsi_15 = DecimalParameter(20.0, 36.0, default=28.0, space='entry', decimals=1, optimize=False, load=True) entry_ema_rel_15 = DecimalParameter(0.97, 0.999, default=0.988, space='entry', decimals=3, optimize=False, load=True) entry_ma_offset_16 = DecimalParameter(0.93, 0.97, default=0.952, space='entry', decimals=3, optimize=False, load=True) entry_rsi_16 = DecimalParameter(26.0, 50.0, default=31.0, space='entry', decimals=1, optimize=False, load=True) entry_ewo_16 = DecimalParameter(2.0, 6.0, default=2.8, space='entry', decimals=1, optimize=False, load=True) entry_ma_offset_17 = DecimalParameter(0.93, 0.98, default=0.952, space='entry', decimals=3, optimize=False, load=True) entry_ewo_17 = DecimalParameter(-18.0, -10.0, default=-12.8, space='entry', decimals=1, optimize=False, load=True) entry_rsi_18 = DecimalParameter(16.0, 32.0, default=26.0, space='entry', decimals=1, optimize=False, load=True) entry_bb_offset_18 = DecimalParameter(0.98, 1.0, default=0.982, space='entry', decimals=3, optimize=False, load=True) entry_rsi_1h_min_19 = DecimalParameter(40.0, 70.0, default=50.0, space='entry', decimals=1, optimize=False, load=True) entry_chop_min_19 = DecimalParameter(20.0, 60.0, default=24.1, space='entry', decimals=1, optimize=False, load=True) entry_rsi_20 = DecimalParameter(20.0, 36.0, default=27.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_20 = DecimalParameter(14.0, 30.0, default=20.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_21 = DecimalParameter(10.0, 28.0, default=23.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_21 = DecimalParameter(18.0, 40.0, default=24.0, space='entry', decimals=1, optimize=False, load=True) entry_volume_22 = DecimalParameter(0.5, 6.0, default=3.0, space='entry', decimals=1, optimize=False, load=True) entry_bb_offset_22 = DecimalParameter(0.98, 1.0, default=0.98, space='entry', decimals=3, optimize=False, load=True) entry_ma_offset_22 = DecimalParameter(0.93, 0.98, default=0.94, space='entry', decimals=3, optimize=False, load=True) entry_ewo_22 = DecimalParameter(2.0, 10.0, default=4.2, space='entry', decimals=1, optimize=False, load=True) entry_rsi_22 = DecimalParameter(26.0, 56.0, default=37.0, space='entry', decimals=1, optimize=False, load=True) entry_bb_offset_23 = DecimalParameter(0.97, 1.0, default=0.987, space='entry', decimals=3, optimize=False, load=True) entry_ewo_23 = DecimalParameter(2.0, 10.0, default=7.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_23 = DecimalParameter(20.0, 40.0, default=30.0, space='entry', decimals=1, optimize=False, load=True) entry_rsi_1h_23 = DecimalParameter(60.0, 80.0, default=70.0, space='entry', decimals=1, optimize=False, load=True) entry_24_rsi_max = DecimalParameter(26.0, 60.0, default=60.0, space='entry', decimals=1, optimize=False, load=True) entry_24_rsi_1h_min = DecimalParameter(40.0, 90.0, default=66.9, space='entry', decimals=1, optimize=False, load=True) optimize_entry_trima = False base_nb_candles_entry_trima = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_trima) low_offset_trima = DecimalParameter(0.9, 0.99, default=0.958, space='entry', optimize=optimize_entry_trima) base_nb_candles_entry_trima2 = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_trima) low_offset_trima2 = DecimalParameter(0.9, 0.99, default=0.958, space='entry', optimize=optimize_entry_trima) optimize_entry_hma = False base_nb_candles_entry_hma = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_hma) low_offset_hma = DecimalParameter(0.9, 0.99, default=0.958, space='entry', optimize=optimize_entry_hma) base_nb_candles_entry_hma2 = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_hma) low_offset_hma2 = DecimalParameter(0.9, 0.99, default=0.958, space='entry', optimize=optimize_entry_hma) optimize_entry_zema = False base_nb_candles_entry_zema = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_zema) low_offset_zema = DecimalParameter(0.9, 0.99, default=0.958, space='entry', optimize=optimize_entry_zema) base_nb_candles_entry_zema2 = IntParameter(5, 80, default=20, space='entry', optimize=optimize_entry_zema) low_offset_zema2 = DecimalParameter(0.9, 0.99, default=0.958, space='entry', optimize=optimize_entry_zema) is_optimize_slip = False max_slip = DecimalParameter(0.33, 1.0, default=0.33, decimals=3, optimize=is_optimize_slip, space='entry', load=True) is_optimize_ewo_2 = False entry_rsi_fast_ewo_2 = IntParameter(15, 50, default=45, optimize=is_optimize_ewo_2) entry_rsi_ewo_2 = IntParameter(15, 50, default=35, optimize=is_optimize_ewo_2) entry_ema_low_2 = DecimalParameter(0.9, 1.2, default=0.97, optimize=is_optimize_ewo_2) entry_ema_high_2 = DecimalParameter(0.9, 1.2, default=1.087, optimize=is_optimize_ewo_2) entry_ewo_high_2 = DecimalParameter(2, 12, default=4.179, optimize=is_optimize_ewo_2) entry_condition_12_enable = CategoricalParameter([True, False], default=True, space='entry', optimize=False, load=True) entry_12_protection__ema_fast = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__ema_fast_len = CategoricalParameter(['26', '50', '100', '200'], default='50', space='entry', optimize=False, load=True) entry_12_protection__ema_slow = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__ema_slow_len = CategoricalParameter(['26', '50', '100', '200'], default='50', space='entry', optimize=False, load=True) entry_12_protection__close_above_ema_fast = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__close_above_ema_fast_len = CategoricalParameter(['12', '20', '26', '50', '100', '200'], default='200', space='entry', optimize=False, load=True) entry_12_protection__close_above_ema_slow = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__close_above_ema_slow_len = CategoricalParameter(['15', '50', '200'], default='200', space='entry', optimize=False, load=True) entry_12_protection__sma200_rising = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__sma200_rising_val = CategoricalParameter(['20', '30', '36', '44', '50'], default='50', space='entry', optimize=False, load=True) entry_12_protection__sma200_1h_rising = CategoricalParameter([True, False], default=True, space='entry', optimize=False, load=True) entry_12_protection__sma200_1h_rising_val = CategoricalParameter(['20', '30', '36', '44', '50'], default='24', space='entry', optimize=False, load=True) entry_12_protection__safe_dips = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__safe_dips_type = CategoricalParameter(['10', '50', '100'], default='100', space='entry', optimize=False, load=True) entry_12_protection__safe_pump = CategoricalParameter([True, False], default=False, space='entry', optimize=False, load=True) entry_12_protection__safe_pump_type = CategoricalParameter(['10', '50', '100'], default='50', space='entry', optimize=False, load=True) entry_12_protection__safe_pump_period = CategoricalParameter(['24', '36', '48'], default='24', space='entry', optimize=False, load=True) ## Sell params exit_btc_safe = IntParameter(-400, -300, default=-365, optimize=False) is_optimize_exit_stoploss = False exit_cmf = DecimalParameter(-0.4, 0.0, default=0.0, optimize=is_optimize_exit_stoploss) exit_ema_close_delta = DecimalParameter(0.022, 0.027, default=0.024, optimize=is_optimize_exit_stoploss) exit_ema = DecimalParameter(0.97, 0.99, default=0.987, optimize=is_optimize_exit_stoploss) is_optimize_deadfish = False exit_deadfish_bb_width = DecimalParameter(0.03, 0.75, default=0.05, optimize=is_optimize_deadfish) exit_deadfish_profit = DecimalParameter(-0.15, -0.05, default=-0.05, optimize=is_optimize_deadfish) exit_deadfish_bb_factor = DecimalParameter(0.9, 1.2, default=1.0, optimize=is_optimize_deadfish) exit_deadfish_volume_factor = DecimalParameter(1, 2.5, default=1.0, optimize=is_optimize_deadfish) is_optimize_bleeding = False exit_bleeding_cti = DecimalParameter(-0.9, -0.0, default=-0.5, optimize=is_optimize_bleeding) exit_bleeding_r14 = DecimalParameter(-100, -44, default=-60, optimize=is_optimize_bleeding) exit_bleeding_volume_factor = DecimalParameter(1, 2.5, default=1.0, optimize=is_optimize_bleeding) is_optimize_cti_r = False exit_cti_r_cti = DecimalParameter(0.55, 1, default=0.5, optimize=is_optimize_cti_r) exit_cti_r_r = DecimalParameter(-15, 0, default=-20, optimize=is_optimize_cti_r) optimize_exit_ema = False base_nb_candles_ema_exit = IntParameter(5, 80, default=20, space='exit', optimize=False) high_offset_exit_ema = DecimalParameter(0.99, 1.1, default=1.012, space='exit', optimize=False) optimize_entry_pump_protection_01 = True pump_protection_01_pct_change_timeframe = IntParameter(5, 10, default=8, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_pct_change_max = DecimalParameter(0.05, 0.35, default=0.15, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_pct_change_min = DecimalParameter(-0.35, -0.05, default=-0.15, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_pct_change_short_timeframe = IntParameter(5, 10, default=8, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_pct_change_short_max = DecimalParameter(0.05, 0.35, default=0.08, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_pct_change_short_min = DecimalParameter(-0.35, -0.05, default=-0.08, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_ispumping = DecimalParameter(0.05, 0.35, default=0.2, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_islongpumping = DecimalParameter(0.05, 0.35, default=0.24, space='entry', optimize=optimize_entry_pump_protection_01) pump_protection_01_isshortpumping = DecimalParameter(0.05, 0.35, default=0.12, space='entry', optimize=optimize_entry_pump_protection_01) #Protections cooldown_lookback = IntParameter(2, 48, default=2, space='protection', optimize=False) low_profit_optimize = False low_profit_lookback = IntParameter(2, 60, default=20, space='protection', optimize=low_profit_optimize) low_profit_stop_duration = IntParameter(12, 200, default=20, space='protection', optimize=low_profit_optimize) low_profit_min_req = DecimalParameter(-0.05, 0.05, default=-0.05, space='protection', decimals=2, optimize=low_profit_optimize) # Sell exit_condition_1_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_2_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_3_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_4_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_5_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_6_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_7_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) exit_condition_8_enable = CategoricalParameter([True, False], default=True, space='exit', optimize=False, load=True) # 48h for pump exit checks exit_pump_threshold_48_1 = DecimalParameter(0.5, 1.2, default=0.9, space='exit', decimals=2, optimize=False, load=True) exit_pump_threshold_48_2 = DecimalParameter(0.4, 0.9, default=0.7, space='exit', decimals=2, optimize=False, load=True) exit_pump_threshold_48_3 = DecimalParameter(0.3, 0.7, default=0.5, space='exit', decimals=2, optimize=False, load=True) # 36h for pump exit checks exit_pump_threshold_36_1 = DecimalParameter(0.5, 0.9, default=0.72, space='exit', decimals=2, optimize=False, load=True) exit_pump_threshold_36_2 = DecimalParameter(3.0, 6.0, default=4.0, space='exit', decimals=2, optimize=False, load=True) exit_pump_threshold_36_3 = DecimalParameter(0.8, 1.6, default=1.0, space='exit', decimals=2, optimize=False, load=True) # 24h for pump exit checks exit_pump_threshold_24_1 = DecimalParameter(0.5, 0.9, default=0.68, space='exit', decimals=2, optimize=False, load=True) exit_pump_threshold_24_2 = DecimalParameter(0.3, 0.6, default=0.62, space='exit', decimals=2, optimize=False, load=True) exit_pump_threshold_24_3 = DecimalParameter(0.2, 0.5, default=0.88, space='exit', decimals=2, optimize=False, load=True) exit_rsi_bb_1 = DecimalParameter(60.0, 80.0, default=79.5, space='exit', decimals=1, optimize=False, load=True) exit_rsi_bb_2 = DecimalParameter(72.0, 90.0, default=81, space='exit', decimals=1, optimize=False, load=True) exit_rsi_main_3 = DecimalParameter(77.0, 90.0, default=82, space='exit', decimals=1, optimize=False, load=True) exit_dual_rsi_rsi_4 = DecimalParameter(72.0, 84.0, default=73.4, space='exit', decimals=1, optimize=False, load=True) exit_dual_rsi_rsi_1h_4 = DecimalParameter(78.0, 92.0, default=79.6, space='exit', decimals=1, optimize=False, load=True) exit_ema_relative_5 = DecimalParameter(0.005, 0.05, default=0.024, space='exit', optimize=False, load=True) exit_rsi_diff_5 = DecimalParameter(0.0, 20.0, default=4.4, space='exit', optimize=False, load=True) exit_rsi_under_6 = DecimalParameter(72.0, 90.0, default=79.0, space='exit', decimals=1, optimize=False, load=True) exit_rsi_1h_7 = DecimalParameter(80.0, 95.0, default=81.7, space='exit', decimals=1, optimize=False, load=True) exit_bb_relative_8 = DecimalParameter(1.05, 1.3, default=1.1, space='exit', decimals=3, optimize=False, load=True) exit_custom_profit_0 = DecimalParameter(0.01, 0.1, default=0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_0 = DecimalParameter(30.0, 40.0, default=34.0, space='exit', decimals=3, optimize=False, load=True) exit_custom_profit_1 = DecimalParameter(0.01, 0.1, default=0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_1 = DecimalParameter(30.0, 50.0, default=35.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_2 = DecimalParameter(0.01, 0.1, default=0.03, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_2 = DecimalParameter(30.0, 50.0, default=37.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_3 = DecimalParameter(0.01, 0.1, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_3 = DecimalParameter(30.0, 50.0, default=42.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_4 = DecimalParameter(0.01, 0.1, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_4 = DecimalParameter(35.0, 50.0, default=43.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_5 = DecimalParameter(0.01, 0.1, default=0.06, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_5 = DecimalParameter(35.0, 50.0, default=45.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_6 = DecimalParameter(0.01, 0.1, default=0.07, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_6 = DecimalParameter(38.0, 55.0, default=48.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_7 = DecimalParameter(0.01, 0.1, default=0.08, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_7 = DecimalParameter(40.0, 58.0, default=54.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_8 = DecimalParameter(0.06, 0.1, default=0.09, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_8 = DecimalParameter(40.0, 50.0, default=55.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_9 = DecimalParameter(0.05, 0.14, default=0.1, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_9 = DecimalParameter(40.0, 60.0, default=54.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_10 = DecimalParameter(0.1, 0.14, default=0.12, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_10 = DecimalParameter(38.0, 50.0, default=42.0, space='exit', decimals=2, optimize=False, load=True) exit_custom_profit_11 = DecimalParameter(0.16, 0.45, default=0.2, space='exit', decimals=3, optimize=False, load=True) exit_custom_rsi_11 = DecimalParameter(28.0, 40.0, default=34.0, space='exit', decimals=2, optimize=False, load=True) # Profit under EMA200 exit_custom_under_profit_0 = DecimalParameter(0.01, 0.4, default=0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_0 = DecimalParameter(28.0, 40.0, default=35.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_1 = DecimalParameter(0.01, 0.1, default=0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_1 = DecimalParameter(36.0, 60.0, default=56.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_2 = DecimalParameter(0.01, 0.1, default=0.03, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_2 = DecimalParameter(46.0, 66.0, default=57.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_3 = DecimalParameter(0.01, 0.1, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_3 = DecimalParameter(50.0, 68.0, default=58.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_4 = DecimalParameter(0.02, 0.1, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_4 = DecimalParameter(50.0, 68.0, default=59.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_5 = DecimalParameter(0.02, 0.1, default=0.06, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_5 = DecimalParameter(46.0, 62.0, default=60.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_6 = DecimalParameter(0.03, 0.1, default=0.07, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_6 = DecimalParameter(44.0, 60.0, default=56.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_7 = DecimalParameter(0.04, 0.1, default=0.08, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_7 = DecimalParameter(46.0, 60.0, default=54.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_8 = DecimalParameter(0.06, 0.12, default=0.09, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_8 = DecimalParameter(40.0, 58.0, default=55.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_9 = DecimalParameter(0.08, 0.14, default=0.1, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_9 = DecimalParameter(40.0, 60.0, default=54.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_10 = DecimalParameter(0.1, 0.16, default=0.12, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_10 = DecimalParameter(30.0, 50.0, default=42.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_under_profit_11 = DecimalParameter(0.16, 0.3, default=0.2, space='exit', decimals=3, optimize=False, load=True) exit_custom_under_rsi_11 = DecimalParameter(24.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) # Profit targets for pumped pairs 48h 1 exit_custom_pump_profit_1_1 = DecimalParameter(0.01, 0.03, default=0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_1_1 = DecimalParameter(26.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_1_2 = DecimalParameter(0.01, 0.6, default=0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_1_2 = DecimalParameter(36.0, 50.0, default=40.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_1_3 = DecimalParameter(0.02, 0.1, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_1_3 = DecimalParameter(38.0, 50.0, default=42.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_1_4 = DecimalParameter(0.06, 0.12, default=0.1, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_1_4 = DecimalParameter(36.0, 48.0, default=42.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_1_5 = DecimalParameter(0.14, 0.24, default=0.2, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_1_5 = DecimalParameter(20.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) # Profit targets for pumped pairs 36h 1 exit_custom_pump_profit_2_1 = DecimalParameter(0.01, 0.03, default=0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_2_1 = DecimalParameter(26.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_2_2 = DecimalParameter(0.01, 0.6, default=0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_2_2 = DecimalParameter(36.0, 50.0, default=40.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_2_3 = DecimalParameter(0.02, 0.1, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_2_3 = DecimalParameter(38.0, 50.0, default=40.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_2_4 = DecimalParameter(0.06, 0.12, default=0.1, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_2_4 = DecimalParameter(36.0, 48.0, default=42.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_2_5 = DecimalParameter(0.14, 0.24, default=0.2, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_2_5 = DecimalParameter(20.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) # Profit targets for pumped pairs 24h 1 exit_custom_pump_profit_3_1 = DecimalParameter(0.01, 0.03, default=0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_3_1 = DecimalParameter(26.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_3_2 = DecimalParameter(0.01, 0.6, default=0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_3_2 = DecimalParameter(34.0, 50.0, default=40.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_3_3 = DecimalParameter(0.02, 0.1, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_3_3 = DecimalParameter(38.0, 50.0, default=40.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_3_4 = DecimalParameter(0.06, 0.12, default=0.1, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_3_4 = DecimalParameter(36.0, 48.0, default=42.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_profit_3_5 = DecimalParameter(0.14, 0.24, default=0.2, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_rsi_3_5 = DecimalParameter(20.0, 40.0, default=34.0, space='exit', decimals=1, optimize=False, load=True) # SMA descending exit_custom_dec_profit_min_1 = DecimalParameter(0.01, 0.1, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_dec_profit_max_1 = DecimalParameter(0.06, 0.16, default=0.12, space='exit', decimals=3, optimize=False, load=True) # Under EMA100 exit_custom_dec_profit_min_2 = DecimalParameter(0.05, 0.12, default=0.07, space='exit', decimals=3, optimize=False, load=True) exit_custom_dec_profit_max_2 = DecimalParameter(0.06, 0.2, default=0.16, space='exit', decimals=3, optimize=False, load=True) # Trail 1 exit_trail_profit_min_1 = DecimalParameter(0.1, 0.2, default=0.16, space='exit', decimals=2, optimize=False, load=True) exit_trail_profit_max_1 = DecimalParameter(0.4, 0.7, default=0.6, space='exit', decimals=2, optimize=False, load=True) exit_trail_down_1 = DecimalParameter(0.01, 0.08, default=0.03, space='exit', decimals=3, optimize=False, load=True) exit_trail_rsi_min_1 = DecimalParameter(16.0, 36.0, default=20.0, space='exit', decimals=1, optimize=False, load=True) exit_trail_rsi_max_1 = DecimalParameter(30.0, 50.0, default=50.0, space='exit', decimals=1, optimize=False, load=True) # Trail 2 exit_trail_profit_min_2 = DecimalParameter(0.08, 0.16, default=0.1, space='exit', decimals=3, optimize=False, load=True) exit_trail_profit_max_2 = DecimalParameter(0.3, 0.5, default=0.4, space='exit', decimals=2, optimize=False, load=True) exit_trail_down_2 = DecimalParameter(0.02, 0.08, default=0.03, space='exit', decimals=3, optimize=False, load=True) exit_trail_rsi_min_2 = DecimalParameter(16.0, 36.0, default=20.0, space='exit', decimals=1, optimize=False, load=True) exit_trail_rsi_max_2 = DecimalParameter(30.0, 50.0, default=50.0, space='exit', decimals=1, optimize=False, load=True) # Trail 3 exit_trail_profit_min_3 = DecimalParameter(0.01, 0.12, default=0.06, space='exit', decimals=3, optimize=False, load=True) exit_trail_profit_max_3 = DecimalParameter(0.1, 0.3, default=0.2, space='exit', decimals=2, optimize=False, load=True) exit_trail_down_3 = DecimalParameter(0.01, 0.06, default=0.05, space='exit', decimals=3, optimize=False, load=True) # Under & near EMA200, accept profit exit_custom_profit_under_rel_1 = DecimalParameter(0.01, 0.04, default=0.024, space='exit', optimize=False, load=True) exit_custom_profit_under_rsi_diff_1 = DecimalParameter(0.0, 20.0, default=4.4, space='exit', optimize=False, load=True) # Under & near EMA200, take the loss exit_custom_stoploss_under_rel_1 = DecimalParameter(0.001, 0.02, default=0.004, space='exit', optimize=False, load=True) exit_custom_stoploss_under_rsi_diff_1 = DecimalParameter(0.0, 20.0, default=10.0, space='exit', optimize=False, load=True) # Long duration/recover stoploss 1 exit_custom_stoploss_long_profit_min_1 = DecimalParameter(-0.1, -0.02, default=-0.08, space='exit', optimize=False, load=True) exit_custom_stoploss_long_profit_max_1 = DecimalParameter(-0.06, -0.01, default=-0.04, space='exit', optimize=False, load=True) exit_custom_stoploss_long_recover_1 = DecimalParameter(0.05, 0.15, default=0.1, space='exit', optimize=False, load=True) exit_custom_stoploss_long_rsi_diff_1 = DecimalParameter(0.0, 20.0, default=4.0, space='exit', optimize=False, load=True) # Long duration/recover stoploss 2 exit_custom_stoploss_long_recover_2 = DecimalParameter(0.03, 0.15, default=0.06, space='exit', optimize=False, load=True) exit_custom_stoploss_long_rsi_diff_2 = DecimalParameter(30.0, 50.0, default=40.0, space='exit', optimize=False, load=True) # Pumped, descending SMA exit_custom_pump_dec_profit_min_1 = DecimalParameter(0.001, 0.04, default=0.005, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_max_1 = DecimalParameter(0.03, 0.08, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_min_2 = DecimalParameter(0.01, 0.08, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_max_2 = DecimalParameter(0.04, 0.1, default=0.06, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_min_3 = DecimalParameter(0.02, 0.1, default=0.06, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_max_3 = DecimalParameter(0.06, 0.12, default=0.09, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_min_4 = DecimalParameter(0.01, 0.05, default=0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_dec_profit_max_4 = DecimalParameter(0.02, 0.1, default=0.04, space='exit', decimals=3, optimize=False, load=True) # Pumped 48h 1, under EMA200 exit_custom_pump_under_profit_min_1 = DecimalParameter(0.02, 0.06, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_under_profit_max_1 = DecimalParameter(0.04, 0.1, default=0.09, space='exit', decimals=3, optimize=False, load=True) # Pumped trail 1 exit_custom_pump_trail_profit_min_1 = DecimalParameter(0.01, 0.12, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_trail_profit_max_1 = DecimalParameter(0.06, 0.16, default=0.07, space='exit', decimals=2, optimize=False, load=True) exit_custom_pump_trail_down_1 = DecimalParameter(0.01, 0.06, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_pump_trail_rsi_min_1 = DecimalParameter(16.0, 36.0, default=20.0, space='exit', decimals=1, optimize=False, load=True) exit_custom_pump_trail_rsi_max_1 = DecimalParameter(30.0, 50.0, default=70.0, space='exit', decimals=1, optimize=False, load=True) # Stoploss, pumped, 48h 1 exit_custom_stoploss_pump_max_profit_1 = DecimalParameter(0.01, 0.04, default=0.025, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_min_1 = DecimalParameter(-0.1, -0.01, default=-0.02, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_max_1 = DecimalParameter(-0.1, -0.01, default=-0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_ma_offset_1 = DecimalParameter(0.7, 0.99, default=0.94, space='exit', decimals=2, optimize=False, load=True) # Stoploss, pumped, 48h 1 exit_custom_stoploss_pump_max_profit_2 = DecimalParameter(0.01, 0.04, default=0.025, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_loss_2 = DecimalParameter(-0.1, -0.01, default=-0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_ma_offset_2 = DecimalParameter(0.7, 0.99, default=0.92, space='exit', decimals=2, optimize=False, load=True) # Stoploss, pumped, 36h 3 exit_custom_stoploss_pump_max_profit_3 = DecimalParameter(0.01, 0.04, default=0.008, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_loss_3 = DecimalParameter(-0.16, -0.06, default=-0.12, space='exit', decimals=3, optimize=False, load=True) exit_custom_stoploss_pump_ma_offset_3 = DecimalParameter(0.7, 0.99, default=0.88, space='exit', decimals=2, optimize=False, load=True) # Recover exit_custom_recover_profit_1 = DecimalParameter(0.01, 0.06, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_recover_min_loss_1 = DecimalParameter(0.06, 0.16, default=0.12, space='exit', decimals=3, optimize=False, load=True) exit_custom_recover_profit_min_2 = DecimalParameter(0.01, 0.04, default=0.01, space='exit', decimals=3, optimize=False, load=True) exit_custom_recover_profit_max_2 = DecimalParameter(0.02, 0.08, default=0.05, space='exit', decimals=3, optimize=False, load=True) exit_custom_recover_min_loss_2 = DecimalParameter(0.04, 0.16, default=0.06, space='exit', decimals=3, optimize=False, load=True) exit_custom_recover_rsi_2 = DecimalParameter(32.0, 52.0, default=46.0, space='exit', decimals=1, optimize=False, load=True) # Profit for long duration trades exit_custom_long_profit_min_1 = DecimalParameter(0.01, 0.04, default=0.03, space='exit', decimals=3, optimize=False, load=True) exit_custom_long_profit_max_1 = DecimalParameter(0.02, 0.08, default=0.04, space='exit', decimals=3, optimize=False, load=True) exit_custom_long_duration_min_1 = IntParameter(700, 2000, default=900, space='exit', optimize=False, load=True) ############################################################# custom_info = {} ############################################################# def get_ticker_indicator(self): return int(self.timeframe[:-1]) ############################################################# def range_percent_change(self, dataframe: DataFrame, method, length: int) -> float: """ Rolling Percentage Change Maximum across interval. :param dataframe: DataFrame The original OHLC dataframe :param method: High to Low / Open to Close :param length: int The length to look back """ df = dataframe.copy() if method == 'HL': return (df['high'].rolling(length).max() - df['low'].rolling(length).min()) / df['low'].rolling(length).min() elif method == 'OC': return (df['open'].rolling(length).max() - df['close'].rolling(length).min()) / df['close'].rolling(length).min() else: raise ValueError(f'Method {method} not defined!') def top_percent_change(self, dataframe: DataFrame, length: int) -> float: """ Percentage change of the current close from the range maximum Open price :param dataframe: DataFrame The original OHLC dataframe :param length: int The length to look back """ df = dataframe.copy() if length == 0: return (df['open'] - df['close']) / df['close'] else: return (df['open'].rolling(length).max() - df['close']) / df['close'] def range_maxgap(self, dataframe: DataFrame, length: int) -> float: """ Maximum Price Gap across interval. :param dataframe: DataFrame The original OHLC dataframe :param length: int The length to look back """ df = dataframe.copy() return df['open'].rolling(length).max() - df['close'].rolling(length).min() def range_maxgap_adjusted(self, dataframe: DataFrame, length: int, adjustment: float) -> float: """ Maximum Price Gap across interval adjusted. :param dataframe: DataFrame The original OHLC dataframe :param length: int The length to look back :param adjustment: int The adjustment to be applied """ return self.range_maxgap(dataframe, length) / adjustment def range_height(self, dataframe: DataFrame, length: int) -> float: """ Current close distance to range bottom. :param dataframe: DataFrame The original OHLC dataframe :param length: int The length to look back """ df = dataframe.copy() return df['close'] - df['close'].rolling(length).min() def safe_pump(self, dataframe: DataFrame, length: int, thresh: float, pull_thresh: float) -> bool: """ Determine if entry after a pump is safe. :param dataframe: DataFrame The original OHLC dataframe :param length: int The length to look back :param thresh: int Maximum percentage change threshold :param pull_thresh: int Pullback from interval maximum threshold """ df = dataframe.copy() return (df[f'oc_pct_change_{length}'] < thresh) | (self.range_maxgap_adjusted(df, length, pull_thresh) > self.range_height(df, length)) def safe_dips(self, dataframe: DataFrame, thresh_0, thresh_2, thresh_12, thresh_144) -> bool: """ Determine if dip is safe to enter. :param dataframe: DataFrame The original OHLC dataframe :param thresh_0: Threshold value for 0 length top pct change :param thresh_2: Threshold value for 2 length top pct change :param thresh_12: Threshold value for 12 length top pct change :param thresh_144: Threshold value for 144 length top pct change """ return (dataframe['tpct_change_0'] < thresh_0) & (dataframe['tpct_change_2'] < thresh_2) & (dataframe['tpct_change_12'] < thresh_12) & (dataframe['tpct_change_144'] < thresh_144) ############################################################################ def informative_pairs(self): pairs = self.dp.current_whitelist() informative_pairs = [(pair, self.inf_1h) for pair in pairs] informative_pairs.extend([(pair, self.inf_15m) for pair in pairs]) informative_pairs += [('BTC/USDT', '5m')] informative_pairs += [('BTC/USDT', '1d')] return informative_pairs def informative_1h_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: assert self.dp, 'DataProvider is required for multiple timeframes.' # Get the informative pair informative_1h = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe=self.inf_1h) # RSI informative_1h['rsi_14'] = ta.RSI(informative_1h, timeperiod=14) # SMA informative_1h['sma_200'] = ta.SMA(informative_1h, timeperiod=200) informative_1h['sma_200_dec_20'] = informative_1h['sma_200'] < informative_1h['sma_200'].shift(20) informative_1h['sma_200_dec_24'] = informative_1h['sma_200'] < informative_1h['sma_200'].shift(24) # EMA informative_1h['ema_8'] = ta.EMA(informative_1h, timeperiod=8) informative_1h['ema_50'] = ta.EMA(informative_1h, timeperiod=50) informative_1h['ema_100'] = ta.EMA(informative_1h, timeperiod=100) informative_1h['ema_200'] = ta.EMA(informative_1h, timeperiod=200) informative_1h['ema_20'] = ta.EMA(informative_1h, timeperiod=20) informative_1h['ema_26'] = ta.EMA(informative_1h, timeperiod=26) informative_1h['ema_12'] = ta.EMA(informative_1h, timeperiod=12) informative_1h['ema_25'] = ta.EMA(informative_1h, timeperiod=25) informative_1h['ema_35'] = ta.EMA(informative_1h, timeperiod=35) # CTI informative_1h['cti'] = pta.cti(informative_1h['close'], length=20) informative_1h['cti_40'] = pta.cti(informative_1h['close'], length=40) # BB bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(informative_1h), window=20, stds=2) informative_1h['bb20_2_low'] = bollinger['lower'] informative_1h['bb20_2_mid'] = bollinger['mid'] informative_1h['bb20_2_upp'] = bollinger['upper'] informative_1h['bb20_width'] = (informative_1h['bb20_2_upp'] - informative_1h['bb20_2_low']) / informative_1h['bb20_2_mid'] # CRSI (3, 2, 100) crsi_closechange = informative_1h['close'] / informative_1h['close'].shift(1) crsi_updown = np.where(crsi_closechange.gt(1), 1.0, np.where(crsi_closechange.lt(1), -1.0, 0.0)) informative_1h['crsi'] = (ta.RSI(informative_1h['close'], timeperiod=3) + ta.RSI(crsi_updown, timeperiod=2) + ta.ROC(informative_1h['close'], 100)) / 3 # Williams %R informative_1h['r_96'] = williams_r(informative_1h, period=96) informative_1h['r_480'] = williams_r(informative_1h, period=480) # Bollinger bands bollinger2 = qtpylib.bollinger_bands(qtpylib.typical_price(informative_1h), window=20, stds=2) informative_1h['bb_lowerband2'] = bollinger2['lower'] informative_1h['bb_middleband2'] = bollinger2['mid'] informative_1h['bb_upperband2'] = bollinger2['upper'] informative_1h['bb_width'] = (informative_1h['bb_upperband2'] - informative_1h['bb_lowerband2']) / informative_1h['bb_middleband2'] # ROC informative_1h['roc'] = ta.ROC(dataframe, timeperiod=9) # MOMDIV mom = momdiv(informative_1h) informative_1h['momdiv_entry'] = mom['momdiv_entry'] informative_1h['momdiv_exit'] = mom['momdiv_exit'] informative_1h['momdiv_coh'] = mom['momdiv_coh'] informative_1h['momdiv_col'] = mom['momdiv_col'] informative_1h['rsi'] = ta.RSI(informative_1h, timeperiod=14) # CMF informative_1h['cmf'] = chaikin_money_flow(informative_1h, 20) # Heikin Ashi inf_heikinashi = qtpylib.heikinashi(informative_1h) informative_1h['ha_close'] = inf_heikinashi['close'] informative_1h['rocr'] = ta.ROCR(informative_1h['ha_close'], timeperiod=168) # T3 Average informative_1h['T3'] = T3(informative_1h) # Elliot informative_1h['EWO'] = EWO(informative_1h, 50, 200) # nfi 37 informative_1h['hl_pct_change_5'] = range_percent_change(informative_1h, 'HL', 5) informative_1h['low_5'] = informative_1h['low'].shift().rolling(5).min() informative_1h['safe_dump_50'] = (informative_1h['hl_pct_change_5'] < 0.66) | (informative_1h['close'] < informative_1h['low_5']) | (informative_1h['close'] > informative_1h['open']) # Pump protections informative_1h['hl_pct_change_48'] = self.range_percent_change(informative_1h, 'HL', 48) informative_1h['hl_pct_change_36'] = self.range_percent_change(informative_1h, 'HL', 36) informative_1h['hl_pct_change_24'] = self.range_percent_change(informative_1h, 'HL', 24) informative_1h['oc_pct_change_48'] = self.range_percent_change(informative_1h, 'OC', 48) informative_1h['oc_pct_change_36'] = self.range_percent_change(informative_1h, 'OC', 36) informative_1h['oc_pct_change_24'] = self.range_percent_change(informative_1h, 'OC', 24) informative_1h['safe_pump_24_10'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_10_24.value, self.entry_pump_pull_threshold_10_24.value) informative_1h['safe_pump_36_10'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_10_36.value, self.entry_pump_pull_threshold_10_36.value) informative_1h['safe_pump_48_10'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_10_48.value, self.entry_pump_pull_threshold_10_48.value) informative_1h['safe_pump_24_20'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_20_24.value, self.entry_pump_pull_threshold_20_24.value) informative_1h['safe_pump_36_20'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_20_36.value, self.entry_pump_pull_threshold_20_36.value) informative_1h['safe_pump_48_20'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_20_48.value, self.entry_pump_pull_threshold_20_48.value) informative_1h['safe_pump_24_30'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_30_24.value, self.entry_pump_pull_threshold_30_24.value) informative_1h['safe_pump_36_30'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_30_36.value, self.entry_pump_pull_threshold_30_36.value) informative_1h['safe_pump_48_30'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_30_48.value, self.entry_pump_pull_threshold_30_48.value) informative_1h['safe_pump_24_40'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_40_24.value, self.entry_pump_pull_threshold_40_24.value) informative_1h['safe_pump_36_40'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_40_36.value, self.entry_pump_pull_threshold_40_36.value) informative_1h['safe_pump_48_40'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_40_48.value, self.entry_pump_pull_threshold_40_48.value) informative_1h['safe_pump_24_50'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_50_24.value, self.entry_pump_pull_threshold_50_24.value) informative_1h['safe_pump_36_50'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_50_36.value, self.entry_pump_pull_threshold_50_36.value) informative_1h['safe_pump_48_50'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_50_48.value, self.entry_pump_pull_threshold_50_48.value) informative_1h['safe_pump_24_60'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_60_24.value, self.entry_pump_pull_threshold_60_24.value) informative_1h['safe_pump_36_60'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_60_36.value, self.entry_pump_pull_threshold_60_36.value) informative_1h['safe_pump_48_60'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_60_48.value, self.entry_pump_pull_threshold_60_48.value) informative_1h['safe_pump_24_70'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_70_24.value, self.entry_pump_pull_threshold_70_24.value) informative_1h['safe_pump_36_70'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_70_36.value, self.entry_pump_pull_threshold_70_36.value) informative_1h['safe_pump_48_70'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_70_48.value, self.entry_pump_pull_threshold_70_48.value) informative_1h['safe_pump_24_80'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_80_24.value, self.entry_pump_pull_threshold_80_24.value) informative_1h['safe_pump_36_80'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_80_36.value, self.entry_pump_pull_threshold_80_36.value) informative_1h['safe_pump_48_80'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_80_48.value, self.entry_pump_pull_threshold_80_48.value) informative_1h['safe_pump_24_90'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_90_24.value, self.entry_pump_pull_threshold_90_24.value) informative_1h['safe_pump_36_90'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_90_36.value, self.entry_pump_pull_threshold_90_36.value) informative_1h['safe_pump_48_90'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_90_48.value, self.entry_pump_pull_threshold_90_48.value) informative_1h['safe_pump_24_100'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_100_24.value, self.entry_pump_pull_threshold_100_24.value) informative_1h['safe_pump_36_100'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_100_36.value, self.entry_pump_pull_threshold_100_36.value) informative_1h['safe_pump_48_100'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_100_48.value, self.entry_pump_pull_threshold_100_48.value) informative_1h['safe_pump_24_110'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_110_24.value, self.entry_pump_pull_threshold_110_24.value) informative_1h['safe_pump_36_110'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_110_36.value, self.entry_pump_pull_threshold_110_36.value) informative_1h['safe_pump_48_110'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_110_48.value, self.entry_pump_pull_threshold_110_48.value) informative_1h['safe_pump_24_120'] = self.safe_pump(informative_1h, 24, self.entry_pump_threshold_120_24.value, self.entry_pump_pull_threshold_120_24.value) informative_1h['safe_pump_36_120'] = self.safe_pump(informative_1h, 36, self.entry_pump_threshold_120_36.value, self.entry_pump_pull_threshold_120_36.value) informative_1h['safe_pump_48_120'] = self.safe_pump(informative_1h, 48, self.entry_pump_threshold_120_48.value, self.entry_pump_pull_threshold_120_48.value) informative_1h['exit_pump_48_1'] = informative_1h['hl_pct_change_48'] > self.exit_pump_threshold_48_1.value informative_1h['exit_pump_48_2'] = informative_1h['hl_pct_change_48'] > self.exit_pump_threshold_48_2.value informative_1h['exit_pump_48_3'] = informative_1h['hl_pct_change_48'] > self.exit_pump_threshold_48_3.value informative_1h['exit_pump_36_1'] = informative_1h['hl_pct_change_36'] > self.exit_pump_threshold_36_1.value informative_1h['exit_pump_36_2'] = informative_1h['hl_pct_change_36'] > self.exit_pump_threshold_36_2.value informative_1h['exit_pump_36_3'] = informative_1h['hl_pct_change_36'] > self.exit_pump_threshold_36_3.value informative_1h['exit_pump_24_1'] = informative_1h['hl_pct_change_24'] > self.exit_pump_threshold_24_1.value informative_1h['exit_pump_24_2'] = informative_1h['hl_pct_change_24'] > self.exit_pump_threshold_24_2.value informative_1h['exit_pump_24_3'] = informative_1h['hl_pct_change_24'] > self.exit_pump_threshold_24_3.value informative_1h['ema_fast'] = ta.EMA(informative_1h, timeperiod=20) informative_1h['ema_slow'] = ta.EMA(informative_1h, timeperiod=25) informative_1h['uptrend'] = (informative_1h['ema_fast'] > informative_1h['ema_slow']).astype('int') informative_1h['ema_15'] = ta.EMA(informative_1h, timeperiod=15) return informative_1h def informative_15m_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: tik = time.perf_counter() assert self.dp, 'DataProvider is required for multiple timeframes.' # Get the informative pair informative_15m = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe=self.inf_15m) # RSI informative_15m['rsi_14'] = ta.RSI(informative_15m, timeperiod=14) # EMAs informative_15m['ema_12'] = ta.EMA(informative_15m, timeperiod=12) informative_15m['ema_16'] = ta.EMA(informative_15m, timeperiod=16) informative_15m['ema_20'] = ta.EMA(informative_15m, timeperiod=20) informative_15m['ema_25'] = ta.EMA(informative_15m, timeperiod=25) informative_15m['ema_26'] = ta.EMA(informative_15m, timeperiod=26) informative_15m['ema_50'] = ta.EMA(informative_15m, timeperiod=50) informative_15m['ema_100'] = ta.EMA(informative_15m, timeperiod=100) informative_15m['ema_200'] = ta.EMA(informative_15m, timeperiod=200) # SMA informative_15m['sma_15'] = ta.SMA(informative_15m, timeperiod=15) informative_15m['sma_30'] = ta.SMA(informative_15m, timeperiod=30) informative_15m['sma_200'] = ta.SMA(informative_15m, timeperiod=200) informative_15m['sma_200_dec_20'] = informative_15m['sma_200'] < informative_15m['sma_200'].shift(20) # BB bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(informative_15m), window=20, stds=2) informative_15m['bb20_2_low'] = bollinger['lower'] informative_15m['bb20_2_mid'] = bollinger['mid'] informative_15m['bb20_2_upp'] = bollinger['upper'] # BB 40 - STD2 bb_40_std2 = qtpylib.bollinger_bands(informative_15m['close'], window=40, stds=2) informative_15m['bb40_2_low'] = bb_40_std2['lower'] informative_15m['bb40_2_mid'] = bb_40_std2['mid'] informative_15m['bb40_2_delta'] = (bb_40_std2['mid'] - informative_15m['bb40_2_low']).abs() informative_15m['closedelta'] = (informative_15m['close'] - informative_15m['close'].shift()).abs() informative_15m['tail'] = (informative_15m['close'] - informative_15m['bb40_2_low']).abs() # CMF informative_15m['cmf'] = chaikin_money_flow(informative_15m, 20) # CTI informative_15m['cti'] = pta.cti(informative_15m['close'], length=20) # Williams %R informative_15m['r_14'] = williams_r(informative_15m, period=14) informative_15m['r_64'] = williams_r(informative_15m, period=64) informative_15m['r_96'] = williams_r(informative_15m, period=96) # EWO informative_15m['ewo'] = EWO(informative_15m, 50, 200) # CCI informative_15m['cci'] = ta.CCI(informative_15m, source='hlc3', timeperiod=20) # CRSI (3, 2, 100) crsi_closechange = informative_15m['close'] / informative_15m['close'].shift(1) crsi_updown = np.where(crsi_closechange.gt(1), 1.0, np.where(crsi_closechange.lt(1), -1.0, 0.0)) informative_15m['crsi'] = (ta.RSI(informative_15m['close'], timeperiod=3) + ta.RSI(crsi_updown, timeperiod=2) + ta.ROC(informative_15m['close'], 100)) / 3 tok = time.perf_counter() log.debug(f"[{metadata['pair']}] informative_1h_indicators took: {tok - tik:0.4f} seconds.") return informative_15m # From NFIX def custom_exit(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float, current_profit: float, **kwargs): dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) last_candle = dataframe.iloc[-1].squeeze() max_profit = (trade.max_rate - trade.open_rate) / trade.open_rate max_loss = (trade.open_rate - trade.min_rate) / trade.min_rate if last_candle is not None: if (current_profit > self.exit_custom_profit_11.value) & (last_candle['rsi'] < self.exit_custom_rsi_11.value): return 'signal_profit_11' if (self.exit_custom_profit_11.value > current_profit > self.exit_custom_profit_10.value) & (last_candle['rsi'] < self.exit_custom_rsi_10.value): return 'signal_profit_10' if (self.exit_custom_profit_10.value > current_profit > self.exit_custom_profit_9.value) & (last_candle['rsi'] < self.exit_custom_rsi_9.value): return 'signal_profit_9' if (self.exit_custom_profit_9.value > current_profit > self.exit_custom_profit_8.value) & (last_candle['rsi'] < self.exit_custom_rsi_8.value): return 'signal_profit_8' if (self.exit_custom_profit_8.value > current_profit > self.exit_custom_profit_7.value) & (last_candle['rsi'] < self.exit_custom_rsi_7.value): return 'signal_profit_7' if (self.exit_custom_profit_7.value > current_profit > self.exit_custom_profit_6.value) & (last_candle['rsi'] < self.exit_custom_rsi_6.value): return 'signal_profit_6' if (self.exit_custom_profit_6.value > current_profit > self.exit_custom_profit_5.value) & (last_candle['rsi'] < self.exit_custom_rsi_5.value): return 'signal_profit_5' elif (self.exit_custom_profit_5.value > current_profit > self.exit_custom_profit_4.value) & (last_candle['rsi'] < self.exit_custom_rsi_4.value): return 'signal_profit_4' elif (self.exit_custom_profit_4.value > current_profit > self.exit_custom_profit_3.value) & (last_candle['rsi'] < self.exit_custom_rsi_3.value): return 'signal_profit_3' elif (self.exit_custom_profit_3.value > current_profit > self.exit_custom_profit_2.value) & (last_candle['rsi'] < self.exit_custom_rsi_2.value): return 'signal_profit_2' elif (self.exit_custom_profit_2.value > current_profit > self.exit_custom_profit_1.value) & (last_candle['rsi'] < self.exit_custom_rsi_1.value): return 'signal_profit_1' elif (self.exit_custom_profit_1.value > current_profit > self.exit_custom_profit_0.value) & (last_candle['rsi'] < self.exit_custom_rsi_0.value): return 'signal_profit_0' # check if close is under EMA200 elif (current_profit > self.exit_custom_under_profit_11.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_11.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_11' elif (self.exit_custom_under_profit_11.value > current_profit > self.exit_custom_under_profit_10.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_10.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_10' elif (self.exit_custom_under_profit_10.value > current_profit > self.exit_custom_under_profit_9.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_9.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_9' elif (self.exit_custom_under_profit_9.value > current_profit > self.exit_custom_under_profit_8.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_8.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_8' elif (self.exit_custom_under_profit_8.value > current_profit > self.exit_custom_under_profit_7.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_7.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_7' elif (self.exit_custom_under_profit_7.value > current_profit > self.exit_custom_under_profit_6.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_6.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_6' elif (self.exit_custom_under_profit_6.value > current_profit > self.exit_custom_under_profit_5.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_5.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_5' elif (self.exit_custom_under_profit_5.value > current_profit > self.exit_custom_under_profit_4.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_4.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_4' elif (self.exit_custom_under_profit_4.value > current_profit > self.exit_custom_under_profit_3.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_3.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_3' elif (self.exit_custom_under_profit_3.value > current_profit > self.exit_custom_under_profit_2.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_2.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_2' elif (self.exit_custom_under_profit_2.value > current_profit > self.exit_custom_under_profit_1.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_1.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_1' elif (self.exit_custom_under_profit_1.value > current_profit > self.exit_custom_under_profit_0.value) & (last_candle['rsi'] < self.exit_custom_under_rsi_0.value) & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_u_0' # check if the pair is "pumped" elif last_candle['exit_pump_48_1_1h'] & (current_profit > self.exit_custom_pump_profit_1_5.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_1_5.value): return 'signal_profit_p_1_5' elif last_candle['exit_pump_48_1_1h'] & (self.exit_custom_pump_profit_1_5.value > current_profit > self.exit_custom_pump_profit_1_4.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_1_4.value): return 'signal_profit_p_1_4' elif last_candle['exit_pump_48_1_1h'] & (self.exit_custom_pump_profit_1_4.value > current_profit > self.exit_custom_pump_profit_1_3.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_1_3.value): return 'signal_profit_p_1_3' elif last_candle['exit_pump_48_1_1h'] & (self.exit_custom_pump_profit_1_3.value > current_profit > self.exit_custom_pump_profit_1_2.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_1_2.value): return 'signal_profit_p_1_2' elif last_candle['exit_pump_48_1_1h'] & (self.exit_custom_pump_profit_1_2.value > current_profit > self.exit_custom_pump_profit_1_1.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_1_1.value): return 'signal_profit_p_1_1' elif last_candle['exit_pump_36_1_1h'] & (current_profit > self.exit_custom_pump_profit_2_5.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_2_5.value): return 'signal_profit_p_2_5' elif last_candle['exit_pump_36_1_1h'] & (self.exit_custom_pump_profit_2_5.value > current_profit > self.exit_custom_pump_profit_2_4.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_2_4.value): return 'signal_profit_p_2_4' elif last_candle['exit_pump_36_1_1h'] & (self.exit_custom_pump_profit_2_4.value > current_profit > self.exit_custom_pump_profit_2_3.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_2_3.value): return 'signal_profit_p_2_3' elif last_candle['exit_pump_36_1_1h'] & (self.exit_custom_pump_profit_2_3.value > current_profit > self.exit_custom_pump_profit_2_2.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_2_2.value): return 'signal_profit_p_2_2' elif last_candle['exit_pump_36_1_1h'] & (self.exit_custom_pump_profit_2_2.value > current_profit > self.exit_custom_pump_profit_2_1.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_2_1.value): return 'signal_profit_p_2_1' elif last_candle['exit_pump_24_1_1h'] & (current_profit > self.exit_custom_pump_profit_3_5.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_3_5.value): return 'signal_profit_p_3_5' elif last_candle['exit_pump_24_1_1h'] & (self.exit_custom_pump_profit_3_5.value > current_profit > self.exit_custom_pump_profit_3_4.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_3_4.value): return 'signal_profit_p_3_4' elif last_candle['exit_pump_24_1_1h'] & (self.exit_custom_pump_profit_3_4.value > current_profit > self.exit_custom_pump_profit_3_3.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_3_3.value): return 'signal_profit_p_3_3' elif last_candle['exit_pump_24_1_1h'] & (self.exit_custom_pump_profit_3_3.value > current_profit > self.exit_custom_pump_profit_3_2.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_3_2.value): return 'signal_profit_p_3_2' elif last_candle['exit_pump_24_1_1h'] & (self.exit_custom_pump_profit_3_2.value > current_profit > self.exit_custom_pump_profit_3_1.value) & (last_candle['rsi'] < self.exit_custom_pump_rsi_3_1.value): return 'signal_profit_p_3_1' elif (self.exit_custom_dec_profit_max_1.value > current_profit > self.exit_custom_dec_profit_min_1.value) & last_candle['sma_200_dec_20']: return 'signal_profit_d_1' elif (self.exit_custom_dec_profit_max_2.value > current_profit > self.exit_custom_dec_profit_min_2.value) & (last_candle['close'] < last_candle['ema_100']): return 'signal_profit_d_2' # Trailing elif (self.exit_trail_profit_max_1.value > current_profit > self.exit_trail_profit_min_1.value) & (self.exit_trail_rsi_min_1.value < last_candle['rsi'] < self.exit_trail_rsi_max_1.value) & (max_profit > current_profit + self.exit_trail_down_1.value): return 'signal_profit_t_1' elif (self.exit_trail_profit_max_2.value > current_profit > self.exit_trail_profit_min_2.value) & (self.exit_trail_rsi_min_2.value < last_candle['rsi'] < self.exit_trail_rsi_max_2.value) & (max_profit > current_profit + self.exit_trail_down_2.value): return 'signal_profit_t_2' elif (self.exit_trail_profit_max_3.value > current_profit > self.exit_trail_profit_min_3.value) & (max_profit > current_profit + self.exit_trail_down_3.value) & last_candle['sma_200_dec_20_1h']: return 'signal_profit_t_3' elif (last_candle['close'] < last_candle['ema_200']) & (current_profit > self.exit_trail_profit_min_3.value) & (current_profit < self.exit_trail_profit_max_3.value) & (max_profit > current_profit + self.exit_trail_down_3.value): return 'signal_profit_u_t_1' # elif (last_candle['exit_pump_48_1_1h']) & (0.06 > current_profit > 0.04) & (last_candle['rsi'] < 54.0) & (current_time - timedelta(minutes=30) < trade.open_date_utc): # return 'signal_profit_p_s_1' elif (current_profit > 0.0) & (last_candle['close'] < last_candle['ema_200']) & ((last_candle['ema_200'] - last_candle['close']) / last_candle['close'] < self.exit_custom_profit_under_rel_1.value) & (last_candle['rsi'] > last_candle['rsi_1h'] + self.exit_custom_profit_under_rsi_diff_1.value): return 'signal_profit_u_e_1' elif (current_profit < -0.0) & (last_candle['close'] < last_candle['ema_200']) & ((last_candle['ema_200'] - last_candle['close']) / last_candle['close'] < self.exit_custom_stoploss_under_rel_1.value) & (last_candle['rsi'] > last_candle['rsi_1h'] + self.exit_custom_stoploss_under_rsi_diff_1.value) & last_candle['sma_200_dec_24'] & (current_time - timedelta(minutes=720) > trade.open_date_utc): return 'signal_stoploss_u_1' elif (self.exit_custom_stoploss_long_profit_min_1.value < current_profit < self.exit_custom_stoploss_long_profit_max_1.value) & (current_profit > -max_loss + self.exit_custom_stoploss_long_recover_1.value) & (last_candle['close'] < last_candle['ema_200']) & (last_candle['rsi'] > last_candle['rsi_1h'] + self.exit_custom_stoploss_long_rsi_diff_1.value) & last_candle['sma_200_dec_24'] & (current_time - timedelta(minutes=1200) > trade.open_date_utc): return 'signal_stoploss_l_r_u_1' elif (current_profit < -0.0) & (current_profit > -max_loss + self.exit_custom_stoploss_long_recover_2.value) & (last_candle['close'] < last_candle['ema_200']) & (last_candle['rsi'] > last_candle['rsi_1h'] + self.exit_custom_stoploss_long_rsi_diff_2.value) & last_candle['sma_200_dec_24'] & (current_time - timedelta(minutes=1200) > trade.open_date_utc): return 'signal_stoploss_l_r_u_2' elif (self.exit_custom_pump_dec_profit_max_1.value > current_profit > self.exit_custom_pump_dec_profit_min_1.value) & last_candle['exit_pump_48_1_1h'] & last_candle['sma_200_dec_20'] & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_p_d_1' elif (self.exit_custom_pump_dec_profit_max_2.value > current_profit > self.exit_custom_pump_dec_profit_min_2.value) & last_candle['exit_pump_48_2_1h'] & last_candle['sma_200_dec_20'] & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_p_d_2' elif (self.exit_custom_pump_dec_profit_max_3.value > current_profit > self.exit_custom_pump_dec_profit_min_3.value) & last_candle['exit_pump_48_3_1h'] & last_candle['sma_200_dec_20'] & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_p_d_3' elif (self.exit_custom_pump_dec_profit_max_4.value > current_profit > self.exit_custom_pump_dec_profit_min_4.value) & last_candle['sma_200_dec_20'] & last_candle['exit_pump_24_2_1h']: return 'signal_profit_p_d_4' # Pumped 48h 1, under EMA200 elif (self.exit_custom_pump_under_profit_max_1.value > current_profit > self.exit_custom_pump_under_profit_min_1.value) & last_candle['exit_pump_48_1_1h'] & (last_candle['close'] < last_candle['ema_200']): return 'signal_profit_p_u_1' # Pumped 36h 2, trail 1 elif last_candle['exit_pump_36_2_1h'] & (self.exit_custom_pump_trail_profit_max_1.value > current_profit > self.exit_custom_pump_trail_profit_min_1.value) & (self.exit_custom_pump_trail_rsi_min_1.value < last_candle['rsi'] < self.exit_custom_pump_trail_rsi_max_1.value) & (max_profit > current_profit + self.exit_custom_pump_trail_down_1.value): return 'signal_profit_p_t_1' # elif (max_profit < self.exit_custom_stoploss_pump_max_profit_1.value) & (self.exit_custom_stoploss_pump_min_1.value < current_profit < self.exit_custom_stoploss_pump_max_1.value) & (last_candle['exit_pump_48_1_1h']) & (last_candle['sma_200_dec_20']) & (last_candle['close'] < (last_candle['ema_200'] * self.exit_custom_stoploss_pump_ma_offset_1.value)): # return 'signal_stoploss_p_1' elif (max_profit < self.exit_custom_stoploss_pump_max_profit_2.value) & (current_profit < self.exit_custom_stoploss_pump_loss_2.value) & last_candle['exit_pump_48_1_1h'] & last_candle['sma_200_dec_20_1h'] & (last_candle['close'] < last_candle['ema_200'] * self.exit_custom_stoploss_pump_ma_offset_2.value): return 'signal_stoploss_p_2' elif (max_profit < self.exit_custom_stoploss_pump_max_profit_3.value) & (current_profit < self.exit_custom_stoploss_pump_loss_3.value) & last_candle['exit_pump_36_3_1h'] & (last_candle['close'] < last_candle['ema_200'] * self.exit_custom_stoploss_pump_ma_offset_3.value): return 'signal_stoploss_p_3' # Recover elif (max_loss > self.exit_custom_recover_min_loss_1.value) & (current_profit > self.exit_custom_recover_profit_1.value): return 'signal_profit_r_1' elif (max_loss > self.exit_custom_recover_min_loss_2.value) & (self.exit_custom_recover_profit_max_2.value > current_profit > self.exit_custom_recover_profit_min_2.value) & (last_candle['rsi'] < self.exit_custom_recover_rsi_2.value): return 'signal_profit_r_2' # Take profit for long duration trades elif (self.exit_custom_long_profit_min_1.value < current_profit < self.exit_custom_long_profit_max_1.value) & (current_time - timedelta(minutes=self.exit_custom_long_duration_min_1.value) > trade.open_date_utc): return 'signal_profit_l_1' return None ## Confirm Entry def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) max_slip = self.max_slip.value if len(dataframe) < 1: return False dataframe = dataframe.iloc[-1].squeeze() if rate > dataframe['close']: slippage = (rate / dataframe['close'] - 1) * 100 if slippage < max_slip: return True else: return False return True ## Confirm Entry def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) max_slip = self.max_slip.value if len(dataframe) < 1: return False dataframe = dataframe.iloc[-1].squeeze() if rate > dataframe['close']: slippage = (rate / dataframe['close'] - 1) * 100 if slippage < max_slip: return True else: return False self.custom_info[pair][self.DATESTAMP] = dataframe['date'] self.custom_info[pair][self.SELLMA] = dataframe['ema_exit'] return True def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: float, rate: float, time_in_force: str, exit_reason: str, **kwargs) -> bool: self.custom_info[pair][self.SELL_TRIGGER] = 0 return True ############################################################################ def normal_tf_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe = dump_warning(dataframe, self.entry_threshold.value) # pump detector dataframe['pump'] = pump_warning(dataframe, perc=int(self.max_change_pump)) #25% di pump dataframe['recentispumping'] = pump_warning2(dataframe, {'pct_change_timeframe': self.pump_protection_01_pct_change_timeframe.value, 'pct_change_max': self.pump_protection_01_pct_change_max.value, 'pct_change_min': self.pump_protection_01_pct_change_min.value, 'pct_change_short_timeframe': self.pump_protection_01_pct_change_short_timeframe.value, 'pct_change_short_max': self.pump_protection_01_pct_change_short_max.value, 'pct_change_short_min': self.pump_protection_01_pct_change_short_min.value, 'ispumping': self.pump_protection_01_ispumping.value, 'islongpumping': self.pump_protection_01_islongpumping.value, 'isshortpumping': self.pump_protection_01_isshortpumping.value, 'ispumping_rolling': 6, 'islongpumping_rolling': 12, 'isshortpumping_rolling': 3, 'recentispumping_rolling': 60}) dataframe['rsi_4'] = ta.RSI(dataframe, timeperiod=4) dataframe['rsi_14'] = ta.RSI(dataframe, timeperiod=14) dataframe['rsi_20'] = ta.RSI(dataframe, timeperiod=20) # Calculate all ma_entry values for val in self.base_nb_candles_entry.range: dataframe[f'ma_entry_{val}'] = ta.EMA(dataframe, timeperiod=val) # Calculate all ma_exit values for val in self.base_nb_candles_exit.range: dataframe[f'ma_exit_{val}'] = ta.EMA(dataframe, timeperiod=val) dataframe['hma_50'] = qtpylib.hull_moving_average(dataframe['close'], window=50) dataframe['ema_100'] = ta.EMA(dataframe, timeperiod=100) dataframe['sma_9'] = ta.SMA(dataframe, timeperiod=9) # Elliot dataframe['EWO2'] = EWO(dataframe, self.fast_ewo, self.slow_ewo) # RSI dataframe['rsi_2'] = ta.RSI(dataframe, timeperiod=20) dataframe['rsi_fast2'] = ta.RSI(dataframe, timeperiod=5) dataframe['rsi_slow2'] = ta.RSI(dataframe, timeperiod=25) dataframe['sqzmi'] = fta.SQZMI(dataframe) # Zero-Lag EMA dataframe['zema_61'] = zema(dataframe, period=61) # Bollinger bands bollinger2 = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) dataframe['bb_lowerband2'] = bollinger2['lower'] dataframe['bb_middleband2'] = bollinger2['mid'] dataframe['bb_upperband2'] = bollinger2['upper'] bollinger3 = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=3) dataframe['bb_lowerband3'] = bollinger3['lower'] dataframe['bb_middleband3'] = bollinger3['mid'] dataframe['bb_upperband3'] = bollinger3['upper'] # BB 40 - STD2 bb_40_std2 = qtpylib.bollinger_bands(dataframe['close'], window=40, stds=2) dataframe['bb40_2_low'] = bb_40_std2['lower'] dataframe['bb40_2_mid'] = bb_40_std2['mid'] dataframe['bb40_2_delta'] = (bb_40_std2['mid'] - dataframe['bb40_2_low']).abs() dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() dataframe['tail'] = (dataframe['close'] - dataframe['bb40_2_low']).abs() # BB 20 - STD2 bb_20_std2 = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) dataframe['bb20_2_low'] = bb_20_std2['lower'] dataframe['bb20_2_mid'] = bb_20_std2['mid'] dataframe['bb20_2_upp'] = bb_20_std2['upper'] # BB 20 - STD3 bb_20_std3 = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=3) dataframe['bb20_3_low'] = bb_20_std3['lower'] dataframe['bb20_3_mid'] = bb_20_std3['mid'] dataframe['bb20_3_upp'] = bb_20_std3['upper'] ### Other BB checks dataframe['bb_width'] = (dataframe['bb_upperband2'] - dataframe['bb_lowerband2']) / dataframe['bb_middleband2'] dataframe['bb_delta'] = (dataframe['bb_lowerband2'] - dataframe['bb_lowerband3']) / dataframe['bb_lowerband2'] # CCI hyperopt for val in self.entry_cci_length.range: dataframe[f'cci_length_{val}'] = ta.CCI(dataframe, val) dataframe['cci'] = ta.CCI(dataframe, 26) dataframe['cci_long'] = ta.CCI(dataframe, 170) # RMI hyperopt for val in self.entry_rmi_length.range: dataframe[f'rmi_length_{val}'] = RMI(dataframe, length=val, mom=4) # SRSI hyperopt stoch = ta.STOCHRSI(dataframe, 15, 20, 2, 2) dataframe['srsi_fk'] = stoch['fastk'] dataframe['srsi_fd'] = stoch['fastd'] # SMA dataframe['bb9'] = ta.SMA(dataframe, timeperiod=9) dataframe['sma_15'] = ta.SMA(dataframe, timeperiod=15) dataframe['sma_20'] = ta.SMA(dataframe, timeperiod=20) dataframe['sma_21'] = ta.SMA(dataframe, timeperiod=21) dataframe['sma_28'] = ta.SMA(dataframe, timeperiod=28) dataframe['sma_30'] = ta.SMA(dataframe, timeperiod=30) dataframe['sma_75'] = ta.SMA(dataframe, timeperiod=75) # CTI dataframe['cti'] = pta.cti(dataframe['close'], length=20) # CMF dataframe['cmf'] = chaikin_money_flow(dataframe, 20) # CRSI (3, 2, 100) crsi_closechange = dataframe['close'] / dataframe['close'].shift(1) crsi_updown = np.where(crsi_closechange.gt(1), 1.0, np.where(crsi_closechange.lt(1), -1.0, 0.0)) dataframe['crsi'] = (ta.RSI(dataframe['close'], timeperiod=3) + ta.RSI(crsi_updown, timeperiod=2) + ta.ROC(dataframe['close'], 100)) / 3 # EMA dataframe['ema_4'] = ta.EMA(dataframe, timeperiod=4) dataframe['ema_8'] = ta.EMA(dataframe, timeperiod=8) dataframe['ema_12'] = ta.EMA(dataframe, timeperiod=12) dataframe['ema_13'] = ta.EMA(dataframe, timeperiod=13) dataframe['ema_14'] = ta.EMA(dataframe, timeperiod=14) dataframe['ema_16'] = ta.EMA(dataframe, timeperiod=16) dataframe['ema_20'] = ta.EMA(dataframe, timeperiod=20) dataframe['ema_25'] = ta.EMA(dataframe, timeperiod=25) dataframe['ema_26'] = ta.EMA(dataframe, timeperiod=26) dataframe['ema_50'] = ta.EMA(dataframe, timeperiod=50) dataframe['ema_100'] = ta.EMA(dataframe, timeperiod=100) dataframe['ema_200'] = ta.EMA(dataframe, timeperiod=200) dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) dataframe['rsi_fast'] = ta.RSI(dataframe, timeperiod=4) dataframe['rsi_slow'] = ta.RSI(dataframe, timeperiod=20) # Elliot dataframe['EWO'] = EWO(dataframe, 50, 200) # Williams %R dataframe['r_14'] = williams_r(dataframe, period=14) dataframe['r_32'] = williams_r(dataframe, period=32) dataframe['r_64'] = williams_r(dataframe, period=64) dataframe['r_84'] = williams_r(dataframe, period=84) dataframe['r_96'] = williams_r(dataframe, period=96) dataframe['r_112'] = williams_r(dataframe, period=112) dataframe['r_480'] = williams_r(dataframe, period=480) # Volume dataframe['volume_mean_4'] = dataframe['volume'].rolling(4).mean().shift(1) dataframe['volume_mean_12'] = dataframe['volume'].rolling(12).mean().shift(1) dataframe['volume_mean_24'] = dataframe['volume'].rolling(24).mean().shift(1) # MFI dataframe['mfi'] = ta.MFI(dataframe) # Heiken Ashi heikinashi = qtpylib.heikinashi(dataframe) dataframe['ha_open'] = heikinashi['open'] dataframe['ha_close'] = heikinashi['close'] dataframe['ha_high'] = heikinashi['high'] dataframe['ha_low'] = heikinashi['low'] ## BB 40 bollinger2_40 = qtpylib.bollinger_bands(ha_typical_price(dataframe), window=40, stds=2) dataframe['bb_lowerband2_40'] = bollinger2_40['lower'] dataframe['bb_middleband2_40'] = bollinger2_40['mid'] dataframe['bb_upperband2_40'] = bollinger2_40['upper'] # ClucHA dataframe['bb_delta_cluc'] = (dataframe['bb_middleband2_40'] - dataframe['bb_lowerband2_40']).abs() dataframe['ha_closedelta'] = (dataframe['ha_close'] - dataframe['ha_close'].shift()).abs() dataframe['tail'] = (dataframe['ha_close'] - dataframe['ha_low']).abs() dataframe['ema_slow'] = ta.EMA(dataframe['ha_close'], timeperiod=50) dataframe['rocr'] = ta.ROCR(dataframe['ha_close'], timeperiod=28) # Cofi stoch_fast = ta.STOCHF(dataframe, 5, 3, 0, 3, 0) dataframe['fastd'] = stoch_fast['fastd'] dataframe['fastk'] = stoch_fast['fastk'] dataframe['adx'] = ta.ADX(dataframe) # Profit Maximizer - PMAX dataframe['pm'], dataframe['pmx'] = pmax(heikinashi, MAtype=1, length=9, multiplier=27, period=10, src=3) dataframe['source'] = (dataframe['high'] + dataframe['low'] + dataframe['open'] + dataframe['close']) / 4 dataframe['pmax_thresh'] = ta.EMA(dataframe['source'], timeperiod=9) # MOMDIV mom = momdiv(dataframe) dataframe['momdiv_entry'] = mom['momdiv_entry'] dataframe['momdiv_exit'] = mom['momdiv_exit'] dataframe['momdiv_coh'] = mom['momdiv_coh'] dataframe['momdiv_col'] = mom['momdiv_col'] # T3 Average dataframe['T3'] = T3(dataframe) # True range dataframe['trange'] = ta.TRANGE(dataframe) # KC dataframe['range_ma_28'] = ta.SMA(dataframe['trange'], 28) dataframe['kc_upperband_28_1'] = dataframe['sma_28'] + dataframe['range_ma_28'] dataframe['kc_lowerband_28_1'] = dataframe['sma_28'] - dataframe['range_ma_28'] # KC 20 dataframe['range_ma_20'] = ta.SMA(dataframe['trange'], 20) dataframe['kc_upperband_20_2'] = dataframe['sma_20'] + dataframe['range_ma_20'] * 2 dataframe['kc_lowerband_20_2'] = dataframe['sma_20'] - dataframe['range_ma_20'] * 2 dataframe['kc_bb_delta'] = (dataframe['kc_lowerband_20_2'] - dataframe['bb_lowerband2']) / dataframe['bb_lowerband2'] * 100 # Linreg dataframe['hh_20'] = ta.MAX(dataframe['high'], 20) dataframe['ll_20'] = ta.MIN(dataframe['low'], 20) dataframe['avg_hh_ll_20'] = (dataframe['hh_20'] + dataframe['ll_20']) / 2 dataframe['avg_close_20'] = ta.SMA(dataframe['close'], 20) dataframe['avg_val_20'] = (dataframe['avg_hh_ll_20'] + dataframe['avg_close_20']) / 2 dataframe['linreg_val_20'] = ta.LINEARREG(dataframe['close'] - dataframe['avg_val_20'], 20, 0) # fisher rsi = 0.1 * (dataframe['rsi'] - 50) dataframe['fisher'] = (np.exp(2 * rsi) - 1) / (np.exp(2 * rsi) + 1) # Modified Elder Ray Index dataframe['moderi_96'] = moderi(dataframe, 96) #HA dataframe = HA(dataframe, 4) #MAMA dataframe['mama'], dataframe['fama'] = ta.MAMA(dataframe['close'], fastlimit=0.5, slowlimit=0.05) #MULTIMA dataframe['ema_offset_entry'] = ta.EMA(dataframe, int(self.base_nb_candles_entry_ema.value)) * self.low_offset_ema.value dataframe['ema_offset_entry2'] = ta.EMA(dataframe, int(self.base_nb_candles_entry_ema2.value)) * self.low_offset_ema2.value dataframe['ema_exit'] = ta.EMA(dataframe, int(self.base_nb_candles_ema_exit.value)) #HMA dataframe['hma_offset_entry'] = qtpylib.hull_moving_average(dataframe['close'], window=int(self.base_nb_candles_entry_hma.value)) * self.low_offset_hma.value dataframe['hma_offset_entry2'] = qtpylib.hull_moving_average(dataframe['close'], window=int(self.base_nb_candles_entry_hma2.value)) * self.low_offset_hma2.value #TRIMA dataframe['trima_offset_entry'] = ta.TRIMA(dataframe, int(self.base_nb_candles_entry_trima.value)) * self.low_offset_trima.value dataframe['trima_offset_entry2'] = ta.TRIMA(dataframe, int(self.base_nb_candles_entry_trima2.value)) * self.low_offset_trima2.value #ZEMA dataframe['zema_offset_entry'] = zema(dataframe, int(self.base_nb_candles_entry_zema.value)) * self.low_offset_zema.value dataframe['zema_offset_entry2'] = zema(dataframe, int(self.base_nb_candles_entry_zema2.value)) * self.low_offset_zema2.value # Modified Elder Ray Index dataframe['moderi_96'] = moderi(dataframe, 96) bb_40_std2 = qtpylib.bollinger_bands(dataframe['close'], window=40, stds=2) dataframe['bb40_2_low'] = bb_40_std2['lower'] # EMA 200 dataframe['ema_15'] = ta.EMA(dataframe, timeperiod=15) dataframe['ema_35'] = ta.EMA(dataframe, timeperiod=35) dataframe['ma_lower'] = ta.SMA(dataframe, timeperiod=15) * 0.953 dataframe['rsi_slow_descending'] = (dataframe['rsi_slow'] < dataframe['rsi_slow'].shift()).astype('int') dataframe['sma_5'] = ta.SMA(dataframe, timeperiod=5) dataframe['sma_200'] = ta.SMA(dataframe, timeperiod=200) dataframe['sma_200_dec_20'] = dataframe['sma_200'] < dataframe['sma_200'].shift(20) dataframe['sma_200_dec_24'] = dataframe['sma_200'] < dataframe['sma_200'].shift(24) # Chopiness dataframe['chop'] = qtpylib.chopiness(dataframe, 14) dataframe['zema'] = zema(dataframe, period=61) #protection dataframe['slice_close'] = dataframe.loc[[1, 8], 'close'] dataframe['slice_high'] = dataframe.loc[[1, 8], 'high'] dataframe['slice_low'] = dataframe.loc[[1, 8], 'low'] # Dip protection dataframe['tpct_change_0'] = self.top_percent_change(dataframe, 0) dataframe['tpct_change_2'] = self.top_percent_change(dataframe, 2) dataframe['tpct_change_12'] = self.top_percent_change(dataframe, 12) dataframe['tpct_change_144'] = self.top_percent_change(dataframe, 144) dataframe['safe_dips_10'] = self.safe_dips(dataframe, self.entry_dip_threshold_10_1.value, self.entry_dip_threshold_10_2.value, self.entry_dip_threshold_10_3.value, self.entry_dip_threshold_10_4.value) dataframe['safe_dips_20'] = self.safe_dips(dataframe, self.entry_dip_threshold_20_1.value, self.entry_dip_threshold_20_2.value, self.entry_dip_threshold_20_3.value, self.entry_dip_threshold_20_4.value) dataframe['safe_dips_30'] = self.safe_dips(dataframe, self.entry_dip_threshold_30_1.value, self.entry_dip_threshold_30_2.value, self.entry_dip_threshold_30_3.value, self.entry_dip_threshold_30_4.value) dataframe['safe_dips_40'] = self.safe_dips(dataframe, self.entry_dip_threshold_40_1.value, self.entry_dip_threshold_40_2.value, self.entry_dip_threshold_40_3.value, self.entry_dip_threshold_40_4.value) dataframe['safe_dips_50'] = self.safe_dips(dataframe, self.entry_dip_threshold_50_1.value, self.entry_dip_threshold_50_2.value, self.entry_dip_threshold_50_3.value, self.entry_dip_threshold_50_4.value) dataframe['safe_dips_60'] = self.safe_dips(dataframe, self.entry_dip_threshold_60_1.value, self.entry_dip_threshold_60_2.value, self.entry_dip_threshold_60_3.value, self.entry_dip_threshold_60_4.value) dataframe['safe_dips_70'] = self.safe_dips(dataframe, self.entry_dip_threshold_70_1.value, self.entry_dip_threshold_70_2.value, self.entry_dip_threshold_70_3.value, self.entry_dip_threshold_70_4.value) dataframe['safe_dips_80'] = self.safe_dips(dataframe, self.entry_dip_threshold_80_1.value, self.entry_dip_threshold_80_2.value, self.entry_dip_threshold_80_3.value, self.entry_dip_threshold_80_4.value) dataframe['safe_dips_90'] = self.safe_dips(dataframe, self.entry_dip_threshold_90_1.value, self.entry_dip_threshold_90_2.value, self.entry_dip_threshold_90_3.value, self.entry_dip_threshold_90_4.value) dataframe['safe_dips_100'] = self.safe_dips(dataframe, self.entry_dip_threshold_100_1.value, self.entry_dip_threshold_100_2.value, self.entry_dip_threshold_100_3.value, self.entry_dip_threshold_100_4.value) dataframe['safe_dips_110'] = self.safe_dips(dataframe, self.entry_dip_threshold_110_1.value, self.entry_dip_threshold_110_2.value, self.entry_dip_threshold_110_3.value, self.entry_dip_threshold_110_4.value) dataframe['volume_mean_30'] = dataframe['volume'].rolling(30).mean() return dataframe def populate_btc_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: assert self.dp, 'DataProvider is required for multiple timeframes.' # BTC info informative = self.dp.get_pair_dataframe('BTC/USDT', timeframe=self.timeframe) informative = dump_warning(informative, self.entry_threshold.value) dataframe['btc_threshold'] = informative['pair_threshold'] dataframe['btc_diff'] = informative['pair_diff'] dataframe['btc_5m'] = informative['pair_5m'] dataframe['btc_1d'] = informative['pair_1d'] dataframe['btc_5m_1d_diff'] = informative['pair_5m_1d_diff'] return dataframe def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # The indicators for the 15m informative timeframe informative_15m = self.informative_15m_indicators(dataframe, metadata) dataframe = merge_informative_pair(dataframe, informative_15m, self.timeframe, self.inf_15m, ffill=True) # The indicators for the 1h informative timeframe informative_1h = self.informative_1h_indicators(dataframe, metadata) dataframe = merge_informative_pair(dataframe, informative_1h, self.timeframe, self.inf_1h, ffill=True) # BTC dump protection dataframe = self.populate_btc_indicators(dataframe, metadata) # The indicators for the normal (5m) timeframe dataframe = self.normal_tf_indicators(dataframe, metadata) # Check if the entry already exists if not metadata['pair'] in self.custom_info: # Create empty entry for this pair {datestamp, exitma, exit_trigger} self.custom_info[metadata['pair']] = ['', 0, 0] vwap_low, vwap, vwap_high = VWAPB(dataframe, 20, 1) dataframe['vwap_low'] = vwap_low dataframe['tcp_percent_4'] = self.top_percent_change(dataframe, 4) dataframe['cti'] = pta.cti(dataframe['close'], length=20) # RSI dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) dataframe['rsi_84'] = ta.RSI(dataframe, timeperiod=84) dataframe['rsi_112'] = ta.RSI(dataframe, timeperiod=112) dataframe['perc'] = (dataframe['high'] - dataframe['low']) / dataframe['low'] * 100 dataframe['avg3_perc'] = ta.EMA(dataframe['perc'], 3) dataframe['perc_norm'] = (dataframe['perc'] - dataframe['perc'].rolling(50).min()) / (dataframe['perc'].rolling(50).max() - dataframe['perc'].rolling(50).min()) return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: conditions = [] dataframe.loc[:, 'enter_tag'] = '' entry_profit = dataframe['close_1h'].rolling(24).max() > dataframe['close'] * 1.03 nfi7_sma_protection = (dataframe[f'ema_{self.entry_12_protection__ema_fast_len.value}'] > dataframe['ema_200']) & (dataframe[f'ema_{self.entry_12_protection__ema_slow_len.value}_1h'] > dataframe['ema_200_1h']) & (dataframe['close'] > dataframe[f'ema_{self.entry_12_protection__close_above_ema_fast_len.value}']) & (dataframe['close'] > dataframe[f'ema_{self.entry_12_protection__close_above_ema_slow_len.value}_1h']) & (dataframe['sma_200'] > dataframe['sma_200'].shift(int(self.entry_12_protection__sma200_rising_val.value))) & (dataframe['sma_200_1h'] > dataframe['sma_200_1h'].shift(int(self.entry_12_protection__sma200_1h_rising_val.value))) & dataframe[f'safe_dips_{self.entry_12_protection__safe_dips_type.value}'] & dataframe[f'safe_pump_{self.entry_12_protection__safe_pump_period.value}_{self.entry_12_protection__safe_pump_type.value}_1h'] is_can_entry_smooth_ha = (dataframe['close'] < dataframe['Smooth_HA_L']) & (dataframe['Smooth_HA_O'].shift(1) < dataframe['Smooth_HA_H'].shift(1)) is_can_entry_rsi = (dataframe['rsi_fast'] < self.entry_rsi_fast.value) & (dataframe['r_84'] < 60) & (dataframe['r_112'] < 60) & ((dataframe['close'] < dataframe['ema_offset_entry']) & (dataframe['pm'] <= dataframe['pmax_thresh']) & ((dataframe['EWO'] < self.ewo_low.value) | (dataframe['EWO'] > self.ewo_high.value) & (dataframe['rsi'] < self.rsi_entry.value)) | (dataframe['close'] < dataframe['ema_offset_entry2']) & (dataframe['pm'] > dataframe['pmax_thresh']) & ((dataframe['EWO'] < self.ewo_low2.value) | (dataframe['EWO'] > self.ewo_high2.value) & (dataframe['rsi'] < self.rsi_entry2.value))) check_pump_01 = dataframe['pump'].rolling(20).max() < 1 check_pump_02 = dataframe['recentispumping'] == False #(dataframe['btc_diff'] > self.entry_btc_safe.value) & is_btc_safe = dataframe['btc_5m_1d_diff'] > dataframe['btc_1d'] * self.entry_btc_safe_1d.value #(dataframe['btc_diff'] > self.entry_btc_safe.value) & is_btc_not_safe = dataframe['btc_5m_1d_diff'] < dataframe['btc_1d'] * self.entry_btc_safe_1d.value is_real_dip = dataframe['slice_low'].min() < dataframe['low'] * 1.05 #is_real_no_pump = ( # (dataframe['slice_high'].shift(1).max() <= (dataframe['high'] * 1.1 )) # ) #is_real_dip & is_pair_safe = (dataframe['pair_diff'] > self.entry_btc_safe.value) & (dataframe['pair_5m_1d_diff'] > dataframe['pair_1d'] * self.entry_btc_safe_1d.value) is_MMA_prot = (dataframe['roc_1h'] < self.entry_roc_1h.value) & (dataframe['bb_width_1h'] < self.entry_bb_width_1h.value) & (dataframe['close_1h'].rolling(288).max() >= dataframe['close'] * 1.03) & (dataframe['close'] < dataframe['ema_exit'] * self.high_offset_exit_ema.value) & (dataframe['sqzmi'] == False) & (dataframe['volume'] > 0) & (dataframe['volume'] < dataframe['volume'].shift() * 4) is_dip = (dataframe[f'rmi_length_{self.entry_rmi_length.value}'] < self.entry_rmi.value) & (dataframe[f'cci_length_{self.entry_cci_length.value}'] <= self.entry_cci.value) & (dataframe['srsi_fk'] < self.entry_srsi_fk.value) # from BinH is_break = (dataframe['bb_delta'] > self.entry_bb_delta.value) & (dataframe['bb_width'] > self.entry_bb_width.value) & (dataframe['closedelta'] > dataframe['close'] * self.entry_closedelta.value / 1000) & (dataframe['close'] < dataframe['bb_lowerband3'] * self.entry_bb_factor.value) is_standart_prot = is_btc_safe | is_pair_safe & nfi7_sma_protection | is_MMA_prot & nfi7_sma_protection is_additional_check = (dataframe['roc_1h'] < self.entry_roc_1h.value) & (dataframe['bb_width_1h'] < self.entry_bb_width_1h.value) & (dataframe['close_1h'].rolling(288).max() >= dataframe['close'] * 1.03) & (dataframe['close'] < dataframe['ema_exit'] * self.high_offset_exit_ema.value) & (dataframe['sqzmi'] == False) & (dataframe['volume'] > 0) & (dataframe['volume'] < dataframe['volume'].shift() * 4) & check_pump_01 & check_pump_02 is_protection = (dataframe['rsi_slow_descending'].rolling(1).sum() == 1) & (dataframe['rsi_fast'] < 35) & (dataframe['uptrend_1h'] > 0) & (dataframe['close'] < dataframe['ma_lower']) & (dataframe['open'] > dataframe['ma_lower']) & (dataframe['volume'] > 0) & ((dataframe['open'] < dataframe['ema_fast_1h']) & (dataframe['low'].abs() < dataframe['ema_fast_1h']) | (dataframe['open'] > dataframe['ema_fast_1h']) & (dataframe['low'].abs() > dataframe['ema_fast_1h'])) is_sqzOff = (dataframe['bb_lowerband2'] < dataframe['kc_lowerband_28_1']) & (dataframe['bb_upperband2'] > dataframe['kc_upperband_28_1']) # from NFI next gen, credit goes to @iterativ #is_can_entry_rsi & is_local_uptrend = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_diff.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['close'] < dataframe['bb_lowerband2'] * self.entry_bb_factor.value) & (dataframe['closedelta'] > dataframe['close'] * self.entry_closedelta.value / 1000) is_local_dip = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_diff_local_dip.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['close'] < dataframe['ema_20'] * self.entry_ema_high_local_dip.value) & (dataframe['rsi'] < self.entry_rsi_local_dip.value) & (dataframe['crsi'] > self.entry_crsi_local_dip.value) & (dataframe['closedelta'] > dataframe['close'] * self.entry_closedelta_local_dip.value / 1000) is_ewo = is_standart_prot & (dataframe['rsi_fast'] < self.entry_rsi_fast.value) & (dataframe['close'] < dataframe['ema_8'] * self.entry_ema_low.value) & (dataframe['EWO'] > self.entry_ewo.value) & (dataframe['close'] < dataframe['ema_16'] * self.entry_ema_high.value) & (dataframe['rsi'] < self.entry_rsi.value) is_ewo_2 = is_standart_prot & (dataframe['ema_200_1h'] > dataframe['ema_200_1h'].shift(12)) & (dataframe['ema_200_1h'].shift(12) > dataframe['ema_200_1h'].shift(24)) & (dataframe['rsi_fast'] < self.entry_rsi_fast_ewo_2.value) & (dataframe['close'] < dataframe['ema_8'] * self.entry_ema_low_2.value) & (dataframe['EWO'] > self.entry_ewo_high_2.value) & (dataframe['close'] < dataframe['ema_16'] * self.entry_ema_high_2.value) & (dataframe['rsi'] < self.entry_rsi_ewo_2.value) is_nfix_3 = is_standart_prot & dataframe['bb40_2_low'].shift().gt(0) & dataframe['bb40_2_delta'].gt(dataframe['close'] * 0.045) & dataframe['closedelta'].gt(dataframe['close'] * 0.02) & dataframe['tail'].lt(dataframe['bb40_2_delta'] * 0.24) & dataframe['close'].lt(dataframe['bb40_2_low'].shift()) & dataframe['close'].le(dataframe['close'].shift()) & (dataframe['cti'] < -0.5) & (dataframe['r_14'] < -90.0) & (dataframe['r_96'] < -80.0) & (dataframe['cti_1h'] < -0.75) & (dataframe['r_480_1h'] < -30.0) is_r_deadfish = is_standart_prot & (dataframe['ema_100'] < dataframe['ema_200'] * self.entry_r_deadfish_ema.value) & (dataframe['bb_width'] > self.entry_r_deadfish_bb_width.value) & (dataframe['close'] < dataframe['bb_middleband2'] * self.entry_r_deadfish_bb_factor.value) & (dataframe['volume_mean_12'] > dataframe['volume_mean_24'] * self.entry_r_deadfish_volume_factor.value) & (dataframe['cti'] < self.entry_r_deadfish_cti.value) & (dataframe['r_14'] < self.entry_r_deadfish_r14.value) is_gumbo = is_standart_prot & (dataframe['EWO'] < self.entry_gumbo_ewo_low.value) & (dataframe['bb_middleband2_1h'] >= dataframe['T3_1h']) & (dataframe['T3'] <= dataframe['ema_8'] * self.entry_gumbo_ema.value) & (dataframe['cti'] < self.entry_gumbo_cti.value) & (dataframe['r_14'] < self.entry_gumbo_r14.value) is_sqzmom = is_standart_prot & is_sqzOff & (dataframe['linreg_val_20'].shift(2) > dataframe['linreg_val_20'].shift(1)) & (dataframe['linreg_val_20'].shift(1) < dataframe['linreg_val_20']) & (dataframe['linreg_val_20'] < 0) & (dataframe['close'] < dataframe['ema_13'] * self.entry_sqzmom_ema.value) & (dataframe['EWO'] < self.entry_sqzmom_ewo.value) & (dataframe['r_14'] < self.entry_sqzmom_r14.value) # NFI quick mode, credit goes to @iterativ is_nfi_13 = is_standart_prot & (dataframe['ema_50_1h'] > dataframe['ema_100_1h']) & (dataframe['close'] < dataframe['sma_30'] * 0.99) & (dataframe['cti'] < -0.92) & (dataframe['EWO'] < -5.585) & (dataframe['cti_1h'] < -0.88) & (dataframe['crsi_1h'] > 10.0) # NFIX 26 is_nfi_32 = is_standart_prot & (dataframe['rsi_slow'] < dataframe['rsi_slow'].shift(1)) & (dataframe['rsi_fast'] < 46) & (dataframe['rsi'] > 25.0) & (dataframe['close'] < dataframe['sma_15'] * 0.93) & (dataframe['cti'] < -0.9) is_nfi_33 = is_standart_prot & (dataframe['close'] < dataframe['ema_13'] * 0.978) & (dataframe['EWO'] > 8) & (dataframe['cti'] < -0.88) & (dataframe['rsi'] < 32) & (dataframe['r_14'] < -98.0) & (dataframe['volume'] < dataframe['volume_mean_4'] * 2.5) is_nfi_38 = is_standart_prot & (dataframe['pm'] > dataframe['pmax_thresh']) & (dataframe['close'] < dataframe['sma_75'] * 0.98) & (dataframe['EWO'] < -4.4) & (dataframe['cti'] < -0.95) & (dataframe['r_14'] < -97) & (dataframe['crsi_1h'] > 0.5) is_nfix_5 = is_standart_prot & (dataframe['ema_200_1h'] > dataframe['ema_200_1h'].shift(12)) & (dataframe['ema_200_1h'].shift(12) > dataframe['ema_200_1h'].shift(24)) & (dataframe['close'] < dataframe['sma_75'] * 0.932) & (dataframe['EWO'] > 3.6) & (dataframe['cti'] < -0.9) & (dataframe['r_14'] < -97.0) is_nfix_12 = is_standart_prot & (dataframe['close'] < dataframe['ema_20'] * 0.932) & (dataframe['EWO'] > 0.1) & (dataframe['rsi_14'] < 40.0) & (dataframe['cti'] < -0.9) & (dataframe['r_480_1h'] < -20.0) is_nfix_49 = is_standart_prot & (dataframe['ema_26'].shift(3) > dataframe['ema_12'].shift(3)) & (dataframe['ema_26'].shift(3) - dataframe['ema_12'].shift(3) > dataframe['open'].shift(3) * 0.032) & (dataframe['ema_26'].shift(9) - dataframe['ema_12'].shift(9) > dataframe['open'].shift(3) / 100) & (dataframe['close'].shift(3) < dataframe['ema_20'].shift(3) * 0.916) & (dataframe['rsi'].shift(3) < 32.5) & (dataframe['crsi'].shift(3) > 18.0) & (dataframe['cti'] < self.entry_nfix_49_cti.value) & (dataframe['r_14'] < self.entry_nfix_49_r14.value) is_nfi7_37 = is_standart_prot & (dataframe['pm'] > dataframe['pmax_thresh']) & (dataframe['close'] < dataframe['sma_75'] * 0.98) & (dataframe['EWO'] > 9.8) & (dataframe['rsi'] < 56.0) & (dataframe['cti'] < -0.7) & dataframe['safe_dump_50_1h'] ## BB MODDED is_nfi_ctt35 = is_standart_prot & (dataframe['pm'] <= dataframe['pmax_thresh']) & (dataframe['close'] < dataframe['sma_75'] * 0.984) & (dataframe['EWO'] > 9.6) & (dataframe['rsi_14'] < 32.0) & (dataframe['cti'] < -0.5) is_nfi_ctt25 = is_standart_prot & (dataframe['rsi_20'] < dataframe['rsi_20'].shift()) & (dataframe['rsi_4'] < self.entry_25_rsi_4.value) & (dataframe['ema_20_1h'] > dataframe['ema_26_1h']) & (dataframe['close'] < dataframe['sma_20'] * self.entry_25_ma_offset.value) & (dataframe['open'] > dataframe['sma_20'] * self.entry_25_ma_offset.value) & ((dataframe['open'] < dataframe['ema_20_1h']) & (dataframe['low'] < dataframe['ema_20_1h']) | (dataframe['open'] > dataframe['ema_20_1h']) & (dataframe['low'] > dataframe['ema_20_1h'])) & (dataframe['cti'] < self.entry_25_cti.value) is_nfi_ctt15 = is_standart_prot & (dataframe['close'] > dataframe['ema_200_1h'] * self.entry_ema_rel_15.value) & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_open_mult_15.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['rsi_14'] < self.entry_rsi_15.value) & (dataframe['close'] < dataframe['ema_20'] * self.entry_ma_offset_15.value) is_nfi_9 = is_standart_prot & (dataframe['ema_50'] > dataframe['ema_200']) & (dataframe['close'] < dataframe['ema_20'] * 0.968) & (dataframe['close'] < dataframe['bb20_2_low'] * 0.982) & (dataframe['mfi'] < 50.0) & (dataframe['cti'] < -0.85) & (dataframe['r_14'] < -94.0) & (dataframe['rsi_14_1h'] > 20.0) & (dataframe['rsi_14_1h'] < 88.0) & (dataframe['crsi_1h'] > 21.0) is_nfi_26 = is_standart_prot & (dataframe['close'] < dataframe['zema_61'] * 0.9405) & (dataframe['cti'] < -0.72) & (dataframe['cci'] < -166.0) & (dataframe['r_14'] < -98.0) & (dataframe['cti_1h'] < 0.95) & (dataframe['volume'] < dataframe['volume_mean_4'] * 2.0) is_nfix_54 = is_standart_prot & (dataframe['ema_200'] > dataframe['ema_200'].shift(12) * 1.01) & (dataframe['ema_200'] > dataframe['ema_200'].shift(48) * 1.07) & dataframe['bb40_2_low'].shift().gt(0) & dataframe['bb40_2_delta'].gt(dataframe['close'] * 0.056) & dataframe['closedelta'].gt(dataframe['close'] * 0.01) & dataframe['tail'].lt(dataframe['bb40_2_delta'] * 0.5) & dataframe['close'].lt(dataframe['bb40_2_low'].shift()) & dataframe['close'].le(dataframe['close'].shift()) & (dataframe['close'] > dataframe['ema_50'] * 0.925) is_nfix_53 = is_standart_prot & (dataframe['ema_200_1h'] > dataframe['ema_200_1h'].shift(12)) & (dataframe['ema_200_1h'].shift(12) > dataframe['ema_200_1h'].shift(24)) & (dataframe['ema_200_1h'].shift(24) > dataframe['ema_200_1h'].shift(36)) & (dataframe['ema_26_15m'] > dataframe['ema_12_15m']) & (dataframe['ema_26_15m'] - dataframe['ema_12_15m'] > dataframe['open_15m'] * 0.02) & (dataframe['ema_26_15m'].shift(3) - dataframe['ema_12_15m'].shift(3) > dataframe['open_15m'] / 100) & (dataframe['close_15m'] < dataframe['bb20_2_low_15m'] * 0.99) & (dataframe['r_14'] < -90.0) & (dataframe['cti_1h'] > -0.7) is_nfix_52 = is_standart_prot & (dataframe['ema_26_15m'] > dataframe['ema_12_15m']) & (dataframe['ema_26_15m'] - dataframe['ema_12_15m'] > dataframe['open_15m'] * 0.032) & (dataframe['ema_26_15m'].shift(3) - dataframe['ema_12_15m'].shift(3) > dataframe['open_15m'] / 100) & (dataframe['close_15m'] < dataframe['bb20_2_low_15m'] * 0.998) & (dataframe['crsi_1h'] > 10.0) is_nfix_51 = is_standart_prot & (dataframe['close_15m'] < dataframe['ema_16_15m'] * 0.944) & (dataframe['ewo_15m'] < -1.0) & (dataframe['rsi_14_15m'] > 28.0) & (dataframe['cti_15m'] < -0.84) & (dataframe['r_14_15m'] < -94.0) & (dataframe['rsi_14'] > 30.0) & (dataframe['crsi_1h'] > 1.0) is_nfix_48 = is_standart_prot & (dataframe['close_15m'].shift(3) < dataframe['sma_15_15m'].shift(3) * 0.95) & (dataframe['close_15m'] > dataframe['open_15m'].shift(3)) & (dataframe['ewo_15m'] > 2.8) & (dataframe['cti_15m'] < -0.75) & (dataframe['r_14_15m'].shift(3) < -94.0) & (dataframe['cti'] < -0.5) & (dataframe['cti_1h'] < 0.1) & (dataframe['crsi_1h'] > 18.0) is_nfix_47 = is_standart_prot & (dataframe['rsi_14_15m'] < dataframe['rsi_14_15m'].shift(3)) & (dataframe['ema_20_1h'] > dataframe['ema_25_1h']) & (dataframe['close_15m'] < dataframe['sma_15_15m'] * 0.95) & ((dataframe['open_15m'] < dataframe['ema_20_1h']) & (dataframe['low_15m'] < dataframe['ema_20_1h']) | (dataframe['open_15m'] > dataframe['ema_20_1h']) & (dataframe['low_15m'] > dataframe['ema_20_1h'])) & (dataframe['cti_15m'] < -0.9) & (dataframe['r_14_15m'] < -90.0) & (dataframe['r_14'] < -97.0) & (dataframe['cti_1h'] < 0.1) & (dataframe['crsi_1h'] > 8.0) is_nfix_41 = is_standart_prot & (dataframe['ema_12_15m'] > dataframe['ema_200_1h']) & (dataframe['ema_26_15m'] > dataframe['ema_12_15m']) & (dataframe['ema_26_15m'] - dataframe['ema_12_15m'] > dataframe['open_15m'] * 0.03) & (dataframe['ema_26_15m'].shift(3) - dataframe['ema_12_15m'].shift(3) > dataframe['open_15m'] / 100) & (dataframe['close_15m'] < dataframe['bb20_2_low_15m'] * 0.99) is_nfix_36 = is_standart_prot & (dataframe['ema_200'] > dataframe['ema_200'].shift(36) * 1.035) & (dataframe['close'] < dataframe['ema_20'] * 0.956) & (dataframe['rsi_14'] < 34.0) & (dataframe['r_64'] < -80.0) & (dataframe['cti'] < -0.5) & (dataframe['r_480_1h'] < -30.0) is_nfix_204 = is_standart_prot & (dataframe['pm'] > dataframe['pmax_thresh']) & (dataframe['close'] < dataframe['sma_75'] * 0.98) & (dataframe['EWO'] < -4.4) & (dataframe['cti'] < -0.95) & (dataframe['r_14'] < -97.0) & (dataframe['crsi_1h'] > 0.5) is_nfix_203 = is_standart_prot & (dataframe['ema_50_1h'] > dataframe['ema_100_1h']) & (dataframe['close'] < dataframe['sma_30'] * 0.99) & (dataframe['cti'] < -0.92) & (dataframe['EWO'] < -6.0) & (dataframe['cti_1h'] < -0.88) & (dataframe['crsi_1h'] > 10.0) is_nfix_202 = is_standart_prot & (dataframe['close'] > dataframe['ema_200_1h'] * 0.84) & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * 0.02) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['close'] < dataframe['bb20_2_low'] * 0.999) & (dataframe['cti'] < -0.5) & (dataframe['rsi_14'] > 25.0) & (dataframe['mfi'] > 18.0) & (dataframe['r_14'] < -94.0) & (dataframe['r_14'].shift(1) < -94.0) & (dataframe['crsi_1h'] > 12.0) & (dataframe['volume'] < dataframe['volume_mean_4'] * 1.6) is_nfix_201 = is_standart_prot & (dataframe['rsi_20'] < dataframe['rsi_20'].shift()) & (dataframe['rsi_4'] < 30.0) & (dataframe['ema_20_1h'] > dataframe['ema_26_1h']) & (dataframe['close'] < dataframe['sma_15'] * 0.953) & (dataframe['cti'] < -0.78) & (dataframe['cci'] < -200.0) is_nfix_34 = is_standart_prot & (dataframe['close'] < dataframe['ema_50']) & (dataframe['close'] < dataframe['bb20_2_low'] * 0.972) & (dataframe['cti'] < -0.8) & (dataframe['rsi_14'] < 18.0) is_nfix_28 = is_standart_prot & (dataframe['close'] < dataframe['sma_75'] * 0.96) & (dataframe['EWO'] < -8.0) & (dataframe['cti'] < -0.9) & (dataframe['r_14'] < -97.0) & (dataframe['crsi_1h'] > 14.0) is_nfix_27 = is_standart_prot & (dataframe['close'] < dataframe['sma_75'] * 0.934) & (dataframe['EWO'] > 6.4) & (dataframe['rsi_14'] < 32.0) & (dataframe['cti'] < -0.8) & (dataframe['r_14'] < -96.0) is_nfix_19 = is_standart_prot & (dataframe['ema_200_1h'] > dataframe['ema_200_1h'].shift(12)) & (dataframe['ema_200_1h'].shift(12) > dataframe['ema_200_1h'].shift(24)) & dataframe['bb40_2_low'].shift().gt(0) & dataframe['bb40_2_delta'].gt(dataframe['close'] * 0.045) & dataframe['closedelta'].gt(dataframe['close'] * 0.02) & dataframe['tail'].lt(dataframe['bb40_2_delta'] * 0.28) & dataframe['close'].lt(dataframe['bb40_2_low'].shift()) & dataframe['close'].le(dataframe['close'].shift()) & (dataframe['cti'] < -0.9) & (dataframe['cti_1h'] > -0.75) & (dataframe['cti_1h'] < 0.25) is_nfix_11 = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * 0.027) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['close'] < dataframe['ema_20'] * 0.932) & (dataframe['rsi_14'] < 25.0) is_nfix_9 = is_standart_prot & (dataframe['ema_50_1h'] > dataframe['ema_100_1h']) & (dataframe['close'] < dataframe['sma_30'] * 0.99) & (dataframe['cti'] < -0.92) & (dataframe['EWO'] < -5.0) & (dataframe['cti_1h'] < -0.88) & (dataframe['crsi_1h'] > 20.0) is_nfix_36 = is_standart_prot & (dataframe['ema_200'] > dataframe['ema_200'].shift(36) * 1.035) & (dataframe['close'] < dataframe['ema_20'] * 0.956) & (dataframe['rsi_14'] < 34.0) & (dataframe['r_64'] < -80.0) & (dataframe['cti'] < -0.5) & (dataframe['r_480_1h'] < -30.0) is_nfi_sma_2 = is_standart_prot & (dataframe['rsi'] < dataframe['rsi_1h'] - self.entry_rsi_1h_diff_2.value) & (dataframe['mfi'] < self.entry_mfi_2.value) & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_2.value) & (dataframe['volume'] > 0) is_nfi_sma_3 = is_standart_prot & dataframe['bb40_2_low'].shift().gt(0) & dataframe['bb40_2_delta'].gt(dataframe['close'] * self.entry_bb40_bbdelta_close_3.value) & dataframe['closedelta'].gt(dataframe['close'] * self.entry_bb40_closedelta_close_3.value) & dataframe['tail'].lt(dataframe['bb40_2_delta'] * self.entry_bb40_tail_bbdelta_3.value) & dataframe['close'].lt(dataframe['bb40_2_low'].shift()) & dataframe['close'].le(dataframe['close'].shift()) & (dataframe['volume'] > 0) is_nfi_sma_4 = is_standart_prot & (dataframe['close'] < dataframe['ema_50']) & (dataframe['close'] < self.entry_bb20_close_bblowerband_4.value * dataframe['bb20_2_low']) & (dataframe['volume'] < dataframe['volume_mean_30'].shift(1) * self.entry_bb20_volume_4.value) is_nfi_sma_5 = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_open_mult_5.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_5.value) & (dataframe['volume'] > 0) is_nfi_sma_6 = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_open_mult_6.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_6.value) & (dataframe['volume'] > 0) is_nfi_sma_7 = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_open_mult_7.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['rsi'] < self.entry_rsi_7.value) & (dataframe['volume'] > 0) is_nfi_sma_9 = is_standart_prot & (dataframe['close'] < dataframe['ema_20'] * self.entry_ma_offset_9.value) & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_9.value) & (dataframe['rsi_1h'] > self.entry_rsi_1h_min_9.value) & (dataframe['rsi_1h'] < self.entry_rsi_1h_max_9.value) & (dataframe['mfi'] < self.entry_mfi_9.value) & (dataframe['volume'] > 0) is_nfi_sma_10 = is_standart_prot & (dataframe['close'] < dataframe['sma_30'] * self.entry_ma_offset_10.value) & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_10.value) & (dataframe['rsi_1h'] < self.entry_rsi_1h_10.value) & (dataframe['volume'] > 0) is_nfi_sma_12 = is_standart_prot & (dataframe['close'] < dataframe['sma_30'] * self.entry_ma_offset_12.value) & (dataframe['EWO'] > self.entry_ewo_12.value) & (dataframe['rsi'] < self.entry_rsi_12.value) & (dataframe['volume'] > 0) is_nfi_sma_15 = is_standart_prot & (dataframe['ema_26'] > dataframe['ema_12']) & (dataframe['ema_26'] - dataframe['ema_12'] > dataframe['open'] * self.entry_ema_open_mult_15.value) & (dataframe['ema_26'].shift() - dataframe['ema_12'].shift() > dataframe['open'] / 100) & (dataframe['rsi'] < self.entry_rsi_15.value) & (dataframe['close'] < dataframe['ema_20'] * self.entry_ma_offset_15.value) & (dataframe['volume'] > 0) is_nfi_sma_16 = is_standart_prot & (dataframe['close'] < dataframe['ema_20'] * self.entry_ma_offset_16.value) & (dataframe['EWO'] > self.entry_ewo_16.value) & (dataframe['rsi'] < self.entry_rsi_16.value) & (dataframe['volume'] > 0) is_nfi_sma_17 = is_standart_prot & (dataframe['close'] < dataframe['ema_20'] * self.entry_ma_offset_17.value) & (dataframe['EWO'] < self.entry_ewo_17.value) & (dataframe['volume'] > 0) is_nfi_sma_22 = is_standart_prot & (dataframe['volume_mean_4'] * self.entry_volume_22.value > dataframe['volume']) & (dataframe['close'] < dataframe['sma_30'] * self.entry_ma_offset_22.value) & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_22.value) & (dataframe['EWO'] > self.entry_ewo_22.value) & (dataframe['rsi'] < self.entry_rsi_22.value) & (dataframe['volume'] > 0) is_nfi_sma_23 = is_standart_prot & (dataframe['close'] < dataframe['bb20_2_low'] * self.entry_bb_offset_23.value) & (dataframe['EWO'] > self.entry_ewo_23.value) & (dataframe['rsi'] < self.entry_rsi_23.value) & (dataframe['rsi_1h'] < self.entry_rsi_1h_23.value) & (dataframe['volume'] > 0) # Make sure Volume is not 0 is_btc_safe = (pct_change(dataframe['btc_1d'], dataframe['btc_5m']).fillna(0) > self.entry_btc_safe_1d.value) & (dataframe['volume'] > 0) is_nasos_1 = is_standart_prot & (dataframe['rsi_fast'] < self.rsi_fast_entry.value) & (dataframe['close'] < dataframe[f'ma_entry_{self.base_nb_candles_entry.value}'] * self.low_offset_2.value) & (dataframe['EWO2'] > self.ewo_high_2.value) & (dataframe['rsi'] < self.rsi_entry.value) & (dataframe['volume'] > 0) & (dataframe['close'] < dataframe[f'ma_exit_{self.base_nb_candles_exit.value}'] * self.high_offset.value) & (dataframe['rsi'] < 25) is_nasos_2 = is_standart_prot & (dataframe['rsi_fast2'] < self.rsi_fast_entry.value) & (dataframe['close'] < dataframe[f'ma_entry_{self.base_nb_candles_entry.value}'] * self.low_offset.value) & (dataframe['EWO2'] < self.ewo_low.value) & (dataframe['volume'] > 0) & (dataframe['close'] < dataframe[f'ma_exit_{self.base_nb_candles_exit.value}'] * self.high_offset.value) is_VWAP = is_standart_prot & (is_MMA_prot | nfi7_sma_protection) & (dataframe['close'] < dataframe['vwap_low']) & (dataframe['tcp_percent_4'] > 0.04) & (dataframe['cti'] < -0.8) & (dataframe['rsi'] < 35) & (dataframe['rsi_84'] < 60) & (dataframe['rsi_112'] < 60) & (dataframe['volume'] > 0) is_fama = is_btc_safe & is_pair_safe & is_can_entry_rsi & is_real_dip & nfi7_sma_protection & is_additional_check & is_can_entry_smooth_ha & entry_profit & (dataframe['close'].rolling(288).max() >= dataframe['close'] * 1.5) & qtpylib.crossed_above(dataframe['mama'], dataframe['fama']) & (dataframe['mama'].shift() > dataframe['mama'] * 0.99) is_hma = is_btc_safe & is_pair_safe & is_can_entry_rsi & is_real_dip & nfi7_sma_protection & is_additional_check & is_can_entry_smooth_ha & entry_profit & (((dataframe['close'] < dataframe['hma_offset_entry']) & (dataframe['pm'] <= dataframe['pmax_thresh']) & (dataframe['rsi'] < 35) | (dataframe['close'] < dataframe['hma_offset_entry2']) & (dataframe['pm'] > dataframe['pmax_thresh']) & (dataframe['rsi'] < 30)) & (dataframe['rsi_fast'] < 30)) is_trima = is_btc_safe & is_pair_safe & is_can_entry_rsi & is_real_dip & nfi7_sma_protection & is_additional_check & is_can_entry_smooth_ha & entry_profit & ((dataframe['close'] < dataframe['trima_offset_entry']) & (dataframe['pm'] <= dataframe['pmax_thresh']) | (dataframe['close'] < dataframe['trima_offset_entry2']) & (dataframe['pm'] > dataframe['pmax_thresh'])) is_zema = is_btc_safe & is_pair_safe & is_can_entry_rsi & is_real_dip & nfi7_sma_protection & is_additional_check & is_can_entry_smooth_ha & entry_profit & ((dataframe['close'] < dataframe['zema_offset_entry']) & (dataframe['pm'] <= dataframe['pmax_thresh']) | (dataframe['close'] < dataframe['zema_offset_entry2']) & (dataframe['pm'] > dataframe['pmax_thresh'])) is_clucHA = is_btc_safe & is_pair_safe & is_can_entry_rsi & is_real_dip & (is_MMA_prot | nfi7_sma_protection) & (dataframe['rocr_1h'] > self.entry_clucha_rocr_1h.value) & ((dataframe['bb_lowerband2_40'].shift() > 0) & (dataframe['bb_delta_cluc'] > dataframe['ha_close'] * self.entry_clucha_bbdelta_close.value) & (dataframe['ha_closedelta'] > dataframe['ha_close'] * self.entry_clucha_closedelta_close.value) & (dataframe['tail'] < dataframe['bb_delta_cluc'] * self.entry_clucha_bbdelta_tail.value) & (dataframe['ha_close'] < dataframe['bb_lowerband2_40'].shift()) & (dataframe['ha_close'] < dataframe['ha_close'].shift())) ## Condition Append conditions.append(is_local_uptrend) # ~3.28 / 92.4% / 69.72% dataframe.loc[is_local_uptrend, 'enter_tag'] += 'local_uptrend ' conditions.append(is_local_dip) # ~0.76 / 91.1% / 15.54% dataframe.loc[is_local_dip, 'enter_tag'] += 'local_dip ' conditions.append(is_ewo) # ~0.92 / 92.0% / 43.74% D dataframe.loc[is_ewo, 'enter_tag'] += 'ewo ' conditions.append(is_nfix_3) # ~2.86 / 91.5% / 33.31% D dataframe.loc[is_nfix_3, 'enter_tag'] += 'is_nfix_3 ' conditions.append(is_VWAP) # ~2.86 / 91.5% / 33.31% D dataframe.loc[is_VWAP, 'enter_tag'] += 'is_VWAP ' conditions.append(is_r_deadfish) # ~0.99 / 86.9% / 21.93% D dataframe.loc[is_r_deadfish, 'enter_tag'] += 'r_deadfish ' conditions.append(is_gumbo) # ~2.63 / 90.6% / 41.49% D dataframe.loc[is_gumbo, 'enter_tag'] += 'gumbo ' conditions.append(is_sqzmom) # ~3.14 / 92.4% / 64.14% D dataframe.loc[is_sqzmom, 'enter_tag'] += 'sqzmom ' conditions.append(is_nfi_13) # ~0.4 / 100% D dataframe.loc[is_nfi_13, 'enter_tag'] += 'nfi_13 ' conditions.append(is_nfi_32) # ~0.78 / 92.0 % / 37.41% D dataframe.loc[is_nfi_32, 'enter_tag'] += 'nfi_32 ' conditions.append(is_nfi_33) # ~0.11 / 100% D dataframe.loc[is_nfi_33, 'enter_tag'] += 'nfi_33 ' conditions.append(is_nfix_5) # ~0.25 / 97.7% / 6.53% D dataframe.loc[is_nfix_5, 'enter_tag'] += 'nfix_5 ' conditions.append(is_nfix_12) # ~5.33 / 91.8% / 58.57% D dataframe.loc[is_nfix_12, 'enter_tag'] += 'nfix_2 ' conditions.append(is_nfix_49) # ~0.33 / 100% / 0% D dataframe.loc[is_nfix_49, 'enter_tag'] += 'nfix_49 ' conditions.append(is_nfi7_37) # ~0.46 / 92.6% / 17.05% D dataframe.loc[is_nfi7_37, 'enter_tag'] += 'nfi7_37 ' conditions.append(is_nfi_ctt35) # ~2.32 / 91.1% / 46.27% D dataframe.loc[is_nfi_ctt35, 'enter_tag'] += 'nfi_ctt35 ' conditions.append(is_nfi_ctt25) # ~3.28 / 92.4% / 69.72% dataframe.loc[is_nfi_ctt25, 'enter_tag'] += 'nfi_ctt25 ' conditions.append(is_nfi_ctt15) # ~0.76 / 91.1% / 15.54% dataframe.loc[is_nfi_ctt15, 'enter_tag'] += 'nfi_ctt15 ' conditions.append(is_nfix_54) # ~0.99 / 86.9% / 21.93% D dataframe.loc[is_nfix_54, 'enter_tag'] += 'nfix_54 ' conditions.append(is_nfix_53) # ~7.2 / 92.5% / 97.98% D dataframe.loc[is_nfix_53, 'enter_tag'] += 'nfix_53 ' conditions.append(is_nfix_52) # ~0.4 / 94.4% / 9.59% D dataframe.loc[is_nfix_52, 'enter_tag'] += 'nfix_52 ' conditions.append(is_nfix_51) # ~2.63 / 90.6% / 41.49% D dataframe.loc[is_nfix_51, 'enter_tag'] += 'nfix_51 ' conditions.append(is_nfix_48) # ~3.14 / 92.4% / 64.14% D dataframe.loc[is_nfix_48, 'enter_tag'] += 'nfix_48 ' conditions.append(is_nfix_47) # ~0.4 / 100% D dataframe.loc[is_nfix_47, 'enter_tag'] += 'nfix_47 ' conditions.append(is_nfix_41) # ~0.78 / 92.0 % / 37.41% D dataframe.loc[is_nfix_41, 'enter_tag'] += 'nfix_41 ' conditions.append(is_nfix_36) # ~1.13 / 88.5% / 31.34% D dataframe.loc[is_nfix_36, 'enter_tag'] += 'nfix_36 ' conditions.append(is_nfix_204) # ~0.25 / 97.7% / 6.53% D dataframe.loc[is_nfix_204, 'enter_tag'] += 'nfix_204 ' conditions.append(is_nfix_203) # ~5.33 / 91.8% / 58.57% D dataframe.loc[is_nfix_203, 'enter_tag'] += 'nfix_203 ' conditions.append(is_nfix_202) # ~0.33 / 100% / 0% D dataframe.loc[is_nfix_202, 'enter_tag'] += 'nfix_202 ' conditions.append(is_nfix_201) # ~0.71 / 91.3% / 28.94% D dataframe.loc[is_nfix_201, 'enter_tag'] += 'nfix_201 ' conditions.append(is_nfix_34) # ~0.46 / 92.6% / 17.05% D dataframe.loc[is_nfix_34, 'enter_tag'] += 'nfix_34 ' conditions.append(is_nfix_28) # ~0.25 / 97.7% / 6.53% D dataframe.loc[is_nfix_28, 'enter_tag'] += 'nfix_28 ' conditions.append(is_nfix_27) # ~5.33 / 91.8% / 58.57% D dataframe.loc[is_nfix_27, 'enter_tag'] += 'nfix_27 ' conditions.append(is_nfix_19) # ~0.33 / 100% / 0% D dataframe.loc[is_nfix_19, 'enter_tag'] += 'nfix_19 ' conditions.append(is_nfix_11) # ~0.71 / 91.3% / 28.94% D dataframe.loc[is_nfix_11, 'enter_tag'] += 'nfix_11 ' conditions.append(is_nfix_9) # ~0.46 / 92.6% / 17.05% D dataframe.loc[is_nfix_9, 'enter_tag'] += 'nfix_9 ' conditions.append(is_nfix_36) # ~0.46 / 92.6% / 17.05% D dataframe.loc[is_nfix_36, 'enter_tag'] += 'nfix_36 ' conditions.append(is_nfi_sma_2) dataframe.loc[is_nfi_sma_2, 'enter_tag'] += 'is_nfi_sma_2 ' conditions.append(is_nfi_sma_3) dataframe.loc[is_nfi_sma_3, 'enter_tag'] += 'is_nfi_sma_3 ' conditions.append(is_nfi_sma_4) dataframe.loc[is_nfi_sma_4, 'enter_tag'] += 'is_nfi_sma_4 ' conditions.append(is_nfi_sma_5) dataframe.loc[is_nfi_sma_5, 'enter_tag'] += 'is_nfi_sma_5 ' conditions.append(is_nfi_sma_6) dataframe.loc[is_nfi_sma_6, 'enter_tag'] += 'is_nfi_sma_6 ' conditions.append(is_nfi_sma_7) dataframe.loc[is_nfi_sma_7, 'enter_tag'] += 'is_nfi_sma_7 ' conditions.append(is_nfi_sma_9) dataframe.loc[is_nfi_sma_9, 'enter_tag'] += 'is_nfi_sma_9 ' conditions.append(is_nfi_sma_10) dataframe.loc[is_nfi_sma_10, 'enter_tag'] += 'is_nfi_sma_10 ' conditions.append(is_nfi_sma_12) dataframe.loc[is_nfi_sma_12, 'enter_tag'] += 'is_nfi_sma_12 ' conditions.append(is_nfi_sma_15) dataframe.loc[is_nfi_sma_15, 'enter_tag'] += 'is_nfi_sma_15 ' conditions.append(is_nfi_sma_16) dataframe.loc[is_nfi_sma_16, 'enter_tag'] += 'is_nfi_sma_16 ' conditions.append(is_nfi_sma_17) dataframe.loc[is_nfi_sma_17, 'enter_tag'] += 'is_nfi_sma_17 ' conditions.append(is_nfi_sma_22) dataframe.loc[is_nfi_sma_22, 'enter_tag'] += 'is_nfi_sma_22 ' conditions.append(is_nfi_sma_23) dataframe.loc[is_nfi_sma_23, 'enter_tag'] += 'is_nfi_sma_23 ' conditions.append(is_nasos_1) # - dataframe.loc[is_nasos_1, 'enter_tag'] += 'is_nasos_1 ' dataframe.loc[is_clucHA, 'enter_tag'] += 'is_clucHA ' # --- conditions.append(is_clucHA) dataframe.loc[is_nasos_2, 'enter_tag'] += 'is_nasos_2 ' # --- conditions.append(is_nasos_2) conditions.append(is_hma) dataframe.loc[is_hma, 'enter_tag'] += 'is_hma ' conditions.append(is_zema) dataframe.loc[is_zema, 'enter_tag'] += 'is_zema ' conditions.append(is_trima) # - dataframe.loc[is_trima, 'enter_tag'] += 'is_trima ' dataframe.loc[is_fama, 'enter_tag'] += 'is_fama ' # --- conditions.append(is_fama) if conditions: dataframe.loc[reduce(lambda x, y: x | y, conditions), 'enter_long'] = 1 return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: conditions = [] conditions.append(self.exit_condition_1_enable.value & (dataframe['rsi'] > self.exit_rsi_bb_1.value) & (dataframe['close'] > dataframe['bb20_2_upp']) & (dataframe['close'].shift(1) > dataframe['bb20_2_upp'].shift(1)) & (dataframe['close'].shift(2) > dataframe['bb20_2_upp'].shift(2)) & (dataframe['close'].shift(3) > dataframe['bb20_2_upp'].shift(3)) & (dataframe['close'].shift(4) > dataframe['bb20_2_upp'].shift(4)) & (dataframe['close'].shift(5) > dataframe['bb20_2_upp'].shift(5)) & (dataframe['volume'] > 0)) conditions.append(self.exit_condition_2_enable.value & (dataframe['rsi'] > self.exit_rsi_bb_2.value) & (dataframe['close'] > dataframe['bb20_2_upp']) & (dataframe['close'].shift(1) > dataframe['bb20_2_upp'].shift(1)) & (dataframe['close'].shift(2) > dataframe['bb20_2_upp'].shift(2)) & (dataframe['volume'] > 0)) conditions.append(self.exit_condition_3_enable.value & (dataframe['rsi'] > self.exit_rsi_main_3.value) & (dataframe['volume'] > 0)) conditions.append(self.exit_condition_4_enable.value & (dataframe['rsi'] > self.exit_dual_rsi_rsi_4.value) & (dataframe['rsi_1h'] > self.exit_dual_rsi_rsi_1h_4.value) & (dataframe['volume'] > 0)) conditions.append(self.exit_condition_6_enable.value & (dataframe['close'] < dataframe['ema_200']) & (dataframe['close'] > dataframe['ema_50']) & (dataframe['rsi'] > self.exit_rsi_under_6.value) & (dataframe['volume'] > 0)) conditions.append(self.exit_condition_7_enable.value & (dataframe['rsi_1h'] > self.exit_rsi_1h_7.value) & qtpylib.crossed_below(dataframe['ema_12'], dataframe['ema_26']) & (dataframe['volume'] > 0)) conditions.append(self.exit_condition_8_enable.value & (dataframe['close'] > dataframe['bb20_2_upp_1h'] * self.exit_bb_relative_8.value) & (dataframe['volume'] > 0)) if conditions: dataframe.loc[reduce(lambda x, y: x | y, conditions), 'exit_long'] = 1 return dataframe class UziChanTB2(BB_RPB_TSL_SMA_Tranz): process_only_new_candles = True custom_info_trail_entry = dict() custom_info_trail_exit = dict() # Trailing entry parameters trailing_entry_order_enabled = True trailing_exit_order_enabled = True trailing_expire_seconds = 1800 #NOTE 5m timeframe #trailing_expire_seconds = 1800/5 #NOTE 1m timeframe #trailing_expire_seconds = 1800*3 #NOTE 15m timeframe # If the current candle goes above min_uptrend_trailing_profit % before trailing_expire_seconds_uptrend seconds, entry the coin trailing_entry_uptrend_enabled = True trailing_exit_uptrend_enabled = True trailing_expire_seconds_uptrend = 90 min_uptrend_trailing_profit = 0.02 debug_mode = True trailing_entry_max_stop = 0.02 # stop trailing entry if current_price > starting_price * (1+trailing_entry_max_stop) trailing_entry_max_entry = 0.0 # entry if price between uplimit (=min of serie (current_price * (1 + trailing_entry_offset())) and (start_price * 1+trailing_entry_max_entry)) trailing_exit_max_stop = 0.02 # stop trailing exit if current_price < starting_price * (1+trailing_entry_max_stop) trailing_exit_max_exit = 0.0 # exit if price between downlimit (=max of serie (current_price * (1 + trailing_exit_offset())) and (start_price * 1+trailing_exit_max_exit)) abort_trailing_when_exit_signal_triggered = False init_trailing_entry_dict = {'trailing_entry_order_started': False, 'trailing_entry_order_uplimit': 0, 'start_trailing_price': 0, 'enter_tag': None, 'start_trailing_time': None, 'offset': 0, 'allow_trailing': False} init_trailing_exit_dict = {'trailing_exit_order_started': False, 'trailing_exit_order_downlimit': 0, 'start_trailing_exit_price': 0, 'exit_tag': None, 'start_trailing_time': None, 'offset': 0, 'allow_exit_trailing': False} def trailing_entry(self, pair, reinit=False): # returns trailing entry info for pair (init if necessary) if not pair in self.custom_info_trail_entry: self.custom_info_trail_entry[pair] = dict() if reinit or not 'trailing_entry' in self.custom_info_trail_entry[pair]: self.custom_info_trail_entry[pair]['trailing_entry'] = self.init_trailing_entry_dict.copy() return self.custom_info_trail_entry[pair]['trailing_entry'] def trailing_exit(self, pair, reinit=False): # returns trailing exit info for pair (init if necessary) if not pair in self.custom_info_trail_exit: self.custom_info_trail_exit[pair] = dict() if reinit or not 'trailing_exit' in self.custom_info_trail_exit[pair]: self.custom_info_trail_exit[pair]['trailing_exit'] = self.init_trailing_exit_dict.copy() return self.custom_info_trail_exit[pair]['trailing_exit'] def trailing_entry_info(self, pair: str, current_price: float): # current_time live, dry run current_time = datetime.now(timezone.utc) if not self.debug_mode: return trailing_entry = self.trailing_entry(pair) duration = 0 try: duration = current_time - trailing_entry['start_trailing_time'] except TypeError: duration = 0 finally: logger.info(f"pair: {pair} : start: {trailing_entry['start_trailing_price']:.4f}, duration: {duration}, current: {current_price:.4f}, uplimit: {trailing_entry['trailing_entry_order_uplimit']:.4f}, profit: {self.current_trailing_entry_profit_ratio(pair, current_price) * 100:.2f}%, offset: {trailing_entry['offset']}") def trailing_exit_info(self, pair: str, current_price: float): # current_time live, dry run current_time = datetime.now(timezone.utc) if not self.debug_mode: return trailing_exit = self.trailing_exit(pair) duration = 0 try: duration = current_time - trailing_exit['start_trailing_time'] except TypeError: duration = 0 finally: logger.info(f"'\x1b[36m'SELL: pair: {pair} : start: {trailing_exit['start_trailing_exit_price']:.4f}, duration: {duration}, current: {current_price:.4f}, downlimit: {trailing_exit['trailing_exit_order_downlimit']:.4f}, profit: {self.current_trailing_exit_profit_ratio(pair, current_price) * 100:.2f}%, offset: {trailing_exit['offset']}") def current_trailing_entry_profit_ratio(self, pair: str, current_price: float) -> float: trailing_entry = self.trailing_entry(pair) if trailing_entry['trailing_entry_order_started']: return (trailing_entry['start_trailing_price'] - current_price) / trailing_entry['start_trailing_price'] else: return 0 def current_trailing_exit_profit_ratio(self, pair: str, current_price: float) -> float: trailing_exit = self.trailing_exit(pair) if trailing_exit['trailing_exit_order_started']: return (current_price - trailing_exit['start_trailing_exit_price']) / trailing_exit['start_trailing_exit_price'] else: #return 0-((trailing_exit['start_trailing_exit_price'] - current_price) / trailing_exit['start_trailing_exit_price']) return 0 def trailing_entry_offset(self, dataframe, pair: str, current_price: float): # return rebound limit before a entry in % of initial price, function of current price # return None to stop trailing entry (will start again at next entry signal) # return 'forceentry' to force immediate entry # (example with 0.5%. initial price : 100 (uplimit is 100.5), 2nd price : 99 (no entry, uplimit updated to 99.5), 3price 98 (no entry uplimit updated to 98.5), 4th price 99 -> BUY current_trailing_profit_ratio = self.current_trailing_entry_profit_ratio(pair, current_price) last_candle = dataframe.iloc[-1] adapt = last_candle['perc_norm'].round(5) default_offset = 0.0045 * (1 + adapt) #NOTE: default_offset 0.0045 <--> 0.009 trailing_entry = self.trailing_entry(pair) if not trailing_entry['trailing_entry_order_started']: return default_offset # example with duration and indicators # dry run, live only last_candle = dataframe.iloc[-1] current_time = datetime.now(timezone.utc) trailing_duration = current_time - trailing_entry['start_trailing_time'] if trailing_duration.total_seconds() > self.trailing_expire_seconds: if current_trailing_profit_ratio > 0 and last_candle['enter_long'] == 1: # more than 1h, price under first signal, entry signal still active -> entry return 'forceentry' else: # wait for next signal return None elif self.trailing_entry_uptrend_enabled and trailing_duration.total_seconds() < self.trailing_expire_seconds_uptrend and (current_trailing_profit_ratio < -1 * self.min_uptrend_trailing_profit): # less than 90s and price is rising, entry return 'forceentry' if current_trailing_profit_ratio < 0: # current price is higher than initial price return default_offset trailing_entry_offset = {0.06: 0.02, 0.03: 0.01, 0: default_offset} for key in trailing_entry_offset: if current_trailing_profit_ratio > key: return trailing_entry_offset[key] return default_offset def trailing_exit_offset(self, dataframe, pair: str, current_price: float): # return rebound limit before a entry in % of initial price, function of current price # return None to stop trailing entry (will start again at next entry signal) # return 'forceentry' to force immediate entry # (example with 0.5%. initial price : 100 (uplimit is 100.5), 2nd price : 99 (no entry, uplimit updated to 99.5), 3price 98 (no entry uplimit updated to 98.5), 4th price 99 -> BUY current_trailing_exit_profit_ratio = self.current_trailing_exit_profit_ratio(pair, current_price) last_candle = dataframe.iloc[-1] adapt = last_candle['perc_norm'].round(5) default_offset = 0.003 * (1 + adapt) #NOTE: default_offset 0.003 <--> 0.006 trailing_exit = self.trailing_exit(pair) if not trailing_exit['trailing_exit_order_started']: return default_offset # example with duration and indicators # dry run, live only last_candle = dataframe.iloc[-1] current_time = datetime.now(timezone.utc) trailing_duration = current_time - trailing_exit['start_trailing_time'] if trailing_duration.total_seconds() > self.trailing_expire_seconds: if current_trailing_exit_profit_ratio > 0 and last_candle['exit_long'] != 0: # more than 1h, price over first signal, exit signal still active -> exit return 'forceexit' else: # wait for next signal return None elif self.trailing_exit_uptrend_enabled and trailing_duration.total_seconds() < self.trailing_expire_seconds_uptrend and (current_trailing_exit_profit_ratio < -1 * self.min_uptrend_trailing_profit): # less than 90s and price is falling, exit return 'forceexit' if current_trailing_exit_profit_ratio > 0: # current price is lower than initial price return default_offset # 0.06: 0.02, # 0.03: 0.01, trailing_exit_offset = {0.1: default_offset} for key in trailing_exit_offset: if current_trailing_exit_profit_ratio < key: return trailing_exit_offset[key] return default_offset # end of trailing exit parameters # ----------------------------------------------------- def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe = super().populate_indicators(dataframe, metadata) self.trailing_entry(metadata['pair']) self.trailing_exit(metadata['pair']) return dataframe def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: val = super().confirm_trade_entry(pair, order_type, amount, rate, time_in_force, **kwargs) if val: if self.trailing_entry_order_enabled and self.config['runmode'].value in ('live', 'dry_run'): val = False dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if len(dataframe) >= 1: last_candle = dataframe.iloc[-1].squeeze() current_price = rate trailing_entry = self.trailing_entry(pair) trailing_entry_offset = self.trailing_entry_offset(dataframe, pair, current_price) if trailing_entry['allow_trailing']: if not trailing_entry['trailing_entry_order_started'] and last_candle['enter_long'] == 1: # start trailing entry trailing_entry['trailing_entry_order_started'] = True trailing_entry['trailing_entry_order_uplimit'] = last_candle['close'] trailing_entry['start_trailing_price'] = last_candle['close'] trailing_entry['enter_tag'] = last_candle['enter_tag'] trailing_entry['start_trailing_time'] = datetime.now(timezone.utc) trailing_entry['offset'] = 0 self.trailing_entry_info(pair, current_price) logger.info(f"start trailing entry for {pair} at {last_candle['close']}") elif trailing_entry['trailing_entry_order_started']: if trailing_entry_offset == 'forceentry': # entry in custom conditions val = True ratio = '%.2f' % (self.current_trailing_entry_profit_ratio(pair, current_price) * 100) self.trailing_entry_info(pair, current_price) logger.info(f'price OK for {pair} ({ratio} %, {current_price}), order may not be triggered if all slots are full') elif trailing_entry_offset is None: # stop trailing entry custom conditions self.trailing_entry(pair, reinit=True) logger.info(f'STOP trailing entry for {pair} because "trailing entry offset" returned None') elif current_price < trailing_entry['trailing_entry_order_uplimit']: # update uplimit old_uplimit = trailing_entry['trailing_entry_order_uplimit'] self.custom_info_trail_entry[pair]['trailing_entry']['trailing_entry_order_uplimit'] = min(current_price * (1 + trailing_entry_offset), self.custom_info_trail_entry[pair]['trailing_entry']['trailing_entry_order_uplimit']) self.custom_info_trail_entry[pair]['trailing_entry']['offset'] = trailing_entry_offset self.trailing_entry_info(pair, current_price) logger.info(f"update trailing entry for {pair} at {old_uplimit} -> {self.custom_info_trail_entry[pair]['trailing_entry']['trailing_entry_order_uplimit']}") elif current_price < trailing_entry['start_trailing_price'] * (1 + self.trailing_entry_max_entry): # entry ! current price > uplimit && lower thant starting price val = True ratio = '%.2f' % (self.current_trailing_entry_profit_ratio(pair, current_price) * 100) self.trailing_entry_info(pair, current_price) logger.info(f"current price ({current_price}) > uplimit ({trailing_entry['trailing_entry_order_uplimit']}) and lower than starting price price ({trailing_entry['start_trailing_price'] * (1 + self.trailing_entry_max_entry)}). OK for {pair} ({ratio} %), order may not be triggered if all slots are full") elif current_price > trailing_entry['start_trailing_price'] * (1 + self.trailing_entry_max_stop): # stop trailing entry because price is too high self.trailing_entry(pair, reinit=True) self.trailing_entry_info(pair, current_price) logger.info(f'STOP trailing entry for {pair} because of the price is higher than starting price * {1 + self.trailing_entry_max_stop}') else: # uplimit > current_price > max_price, continue trailing and wait for the price to go down self.trailing_entry_info(pair, current_price) logger.info(f'price too high for {pair} !') else: logger.info(f'Wait for next entry signal for {pair}') if val == True: self.trailing_entry_info(pair, rate) self.trailing_entry(pair, reinit=True) logger.info(f'STOP trailing entry for {pair} because I entry it') return val def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: float, rate: float, time_in_force: str, exit_reason: str, **kwargs) -> bool: val = super().confirm_trade_exit(pair, trade, order_type, amount, rate, time_in_force, exit_reason, **kwargs) if val: if self.trailing_exit_order_enabled and self.config['runmode'].value in ('live', 'dry_run'): val = False dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) if len(dataframe) >= 1: last_candle = dataframe.iloc[-1].squeeze() current_price = rate trailing_exit = self.trailing_exit(pair) trailing_exit_offset = self.trailing_exit_offset(dataframe, pair, current_price) if trailing_exit['allow_exit_trailing']: if not trailing_exit['trailing_exit_order_started'] and last_candle['exit_long'] != 0: trailing_exit['trailing_exit_order_started'] = True trailing_exit['trailing_exit_order_downlimit'] = last_candle['close'] trailing_exit['start_trailing_exit_price'] = last_candle['close'] trailing_exit['exit_tag'] = last_candle['exit_tag'] trailing_exit['start_trailing_time'] = datetime.now(timezone.utc) trailing_exit['offset'] = 0 self.trailing_exit_info(pair, current_price) logger.info(f"start trailing exit for {pair} at {last_candle['close']}") elif trailing_exit['trailing_exit_order_started']: if trailing_exit_offset == 'forceexit': # exit in custom conditions val = True ratio = '%.2f' % (self.current_trailing_exit_profit_ratio(pair, current_price) * 100) self.trailing_exit_info(pair, current_price) logger.info(f'FORCESELL for {pair} ({ratio} %, {current_price})') elif trailing_exit_offset is None: # stop trailing exit custom conditions self.trailing_exit(pair, reinit=True) logger.info(f'STOP trailing exit for {pair} because "trailing exit offset" returned None') elif current_price > trailing_exit['trailing_exit_order_downlimit']: # update downlimit old_downlimit = trailing_exit['trailing_exit_order_downlimit'] self.custom_info_trail_exit[pair]['trailing_exit']['trailing_exit_order_downlimit'] = max(current_price * (1 - trailing_exit_offset), self.custom_info_trail_exit[pair]['trailing_exit']['trailing_exit_order_downlimit']) self.custom_info_trail_exit[pair]['trailing_exit']['offset'] = trailing_exit_offset self.trailing_exit_info(pair, current_price) logger.info(f"update trailing exit for {pair} at {old_downlimit} -> {self.custom_info_trail_exit[pair]['trailing_exit']['trailing_exit_order_downlimit']}") elif current_price > trailing_exit['start_trailing_exit_price'] * (1 - self.trailing_exit_max_exit): # exit! current price < downlimit && higher than starting price val = True ratio = '%.2f' % (self.current_trailing_exit_profit_ratio(pair, current_price) * 100) self.trailing_exit_info(pair, current_price) logger.info(f"current price ({current_price}) < downlimit ({trailing_exit['trailing_exit_order_downlimit']}) but higher than starting price ({trailing_exit['start_trailing_exit_price'] * (1 + self.trailing_exit_max_exit)}). OK for {pair} ({ratio} %)") elif current_price < trailing_exit['start_trailing_exit_price'] * (1 - self.trailing_exit_max_stop): # stop trailing, exit fast, price too low val = True self.trailing_exit_info(pair, current_price) logger.info(f'STOP trailing exit for {pair} because of the price is much lower than starting price * {1 + self.trailing_exit_max_stop}') else: # uplimit > current_price > max_price, continue trailing and wait for the price to go down self.trailing_exit_info(pair, current_price) logger.info(f'price too low for {pair} !') else: logger.info(f'Wait for next exit signal for {pair}') if val == True: self.trailing_exit_info(pair, rate) self.trailing_exit(pair, reinit=True) logger.info(f'STOP trailing exit for {pair} because I SOLD it') #if (exit_reason != 'exit_signal') | (exit_reason!='force_exit'): if exit_reason != 'exit_signal': val = True return val def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe = super().populate_entry_trend(dataframe, metadata) if self.trailing_entry_order_enabled and self.config['runmode'].value in ('live', 'dry_run'): last_candle = dataframe.iloc[-1].squeeze() trailing_entry = self.trailing_entry(metadata['pair']) if last_candle['enter_long'] == 1: if not trailing_entry['trailing_entry_order_started']: open_trades = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True)]).all() if not open_trades: logger.info(f"Set 'allow_trailing' to True for {metadata['pair']} to start trailing!!!") # self.custom_info_trail_entry[metadata['pair']]['trailing_entry']['allow_trailing'] = True trailing_entry['allow_trailing'] = True initial_entry_tag = last_candle['enter_tag'] if 'enter_tag' in last_candle else 'entry signal' dataframe.loc[:, 'enter_tag'] = f"{initial_entry_tag} (start trail price {last_candle['close']})" elif trailing_entry['trailing_entry_order_started'] == True: logger.info(f"Continue trailing for {metadata['pair']}. Manually trigger entry signal!!") dataframe.loc[:, 'enter_long'] = 1 dataframe.loc[:, 'enter_tag'] = trailing_entry['enter_tag'] return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe = super().populate_exit_trend(dataframe, metadata) if self.trailing_entry_order_enabled and self.abort_trailing_when_exit_signal_triggered and (self.config['runmode'].value in ('live', 'dry_run')): last_candle = dataframe.iloc[-1].squeeze() if last_candle['exit_long'] != 0: trailing_entry = self.trailing_entry(metadata['pair']) if trailing_entry['trailing_entry_order_started']: logger.info(f"Sell signal for {metadata['pair']} is triggered!!! Abort trailing") self.trailing_entry(metadata['pair'], reinit=True) if self.trailing_exit_order_enabled and self.config['runmode'].value in ('live', 'dry_run'): last_candle = dataframe.iloc[-1].squeeze() trailing_exit = self.trailing_exit(metadata['pair']) if last_candle['exit_long'] != 0: if not trailing_exit['trailing_exit_order_started']: open_trades = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True)]).all() #if not open_trades: if open_trades: logger.info(f"Set 'allow_SELL_trailing' to True for {metadata['pair']} to start *SELL* trailing") # self.custom_info_trail_entry[metadata['pair']]['trailing_entry']['allow_trailing'] = True trailing_exit['allow_exit_trailing'] = True initial_exit_tag = last_candle['exit_tag'] if 'exit_tag' in last_candle else 'exit signal' dataframe.loc[:, 'exit_tag'] = f"{initial_exit_tag} (start trail price {last_candle['close']})" elif trailing_exit['trailing_exit_order_started'] == True: logger.info(f"Continue trailing for {metadata['pair']}. Manually trigger exit signal!") dataframe.loc[:, 'exit_long'] = 1 dataframe.loc[:, 'exit_tag'] = trailing_exit['exit_tag'] return dataframe plot_config = {'main_plot': {'uc_up': {'color': 'gray'}, 'uc_mid': {'color': 'green'}, 'uc_low': {'color': 'gray'}}, 'subplots': {}}