┏━━━━━━━━━━━━┳━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━┓
┃ Strategy ┃ Trades ┃ Avg Profit % ┃ Tot Profit USDT ┃ Tot Profit % ┃ Avg Duration ┃ Win Draw Loss Win% ┃ Drawdown ┃ ┡━━━━━━━━━━━━╇━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━┩ │ EmptyShort │ 54 │ 0.75 │ 422.136 │ 42.21 │ 1 day, 5:07:00 │ 25 0 29 46.3 │ 142.938 USDT 9.86% │ └────────────┴────────┴──────────────┴─────────────────┴──────────────┴────────────────┴────────────────────────┴─────────────────────┘
This commit is contained in:
121
EmptyShort.py
121
EmptyShort.py
@@ -103,7 +103,7 @@ class EmptyShort(IStrategy):
|
||||
# trailing_only_offset_is_reached = False
|
||||
|
||||
position_adjustment_enable = True
|
||||
use_custom_stoploss = True
|
||||
use_custom_stoploss = False
|
||||
|
||||
#max_open_trades = 3
|
||||
|
||||
@@ -494,7 +494,7 @@ class EmptyShort(IStrategy):
|
||||
profit = trade.calc_profit(rate)
|
||||
force = self.pairs[pair]['force_sell']
|
||||
allow_to_sell = (last_candle['hapercent'] < 0 and profit > 0) or force \
|
||||
or (trade.enter_tag == 'short' ) or (exit_reason == 'force_exit') or (exit_reason == 'stop_loss') or (exit_reason == 'trailing_stop_loss')
|
||||
or (trade.is_short) or (exit_reason == 'force_exit') or (exit_reason == 'stop_loss') or (exit_reason == 'trailing_stop_loss')
|
||||
|
||||
minutes = int(round((current_time - trade.date_last_filled_utc).total_seconds() / 60, 0))
|
||||
|
||||
@@ -562,8 +562,7 @@ class EmptyShort(IStrategy):
|
||||
|
||||
dispo = round(self.wallets.get_available_stake_amount() + self.pairs[pair]['total_amount'])
|
||||
|
||||
is_short = (trade.enter_tag == 'short')
|
||||
if trade.enter_tag == 'short':
|
||||
if trade.is_short:
|
||||
tp_price = max(0.02, self.pairs[pair]['take_profit'])
|
||||
# if current_profit < self.sell_force_sell.value \
|
||||
# and last_candle[f"close"] > last_candle[self.sell_indicator.value]:
|
||||
@@ -572,11 +571,19 @@ class EmptyShort(IStrategy):
|
||||
#
|
||||
if current_profit > tp_price and \
|
||||
(baisse > last_candle[f"range_pos"] and last_candle[f"close"] > last_candle[self.b30_indicateur.value]) \
|
||||
and last_candle['hapercent'] > 0 and last_candle['sma12_deriv1_1h'] > -0.004:
|
||||
and last_candle['hapercent'] > 0 and last_candle['sma12_deriv2_1h'] > 0.0:
|
||||
self.pairs[pair]['force_sell'] = True
|
||||
return 'B30Sht'
|
||||
|
||||
return None
|
||||
# if current_profit < - 0.01 and last_candle['sma60_deriv1'] > 0 and last_candle['sma60_deriv2'] > 0:
|
||||
# self.pairs[pair]['force_sell'] = True
|
||||
# return 'StpSht'
|
||||
|
||||
# if last_candle['sma12_inv_1h'] == -1:
|
||||
# return 'InvSht'
|
||||
# return None
|
||||
|
||||
|
||||
# self.log_trade(
|
||||
# last_candle=last_candle,
|
||||
# date=current_time,
|
||||
@@ -655,41 +662,41 @@ class EmptyShort(IStrategy):
|
||||
|
||||
return None
|
||||
|
||||
def custom_stoploss(self, pair, trade, current_time, current_rate, current_profit, **kwargs):
|
||||
dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
|
||||
last_candle = dataframe.iloc[-1]
|
||||
profit = trade.calc_profit(current_rate)
|
||||
|
||||
candle_at_buy = self.pairs[pair]['last_candle']
|
||||
|
||||
# if candle_at_buy['range_pos'] > self.range_pos_stoploss.value and candle_at_buy[self.stoploss_indicator.value] < 0:
|
||||
# return self.stoploss_force.value
|
||||
|
||||
# # print(f'test stop loss {self.stoploss} {last_candle["stop_buying12_1h"]}')
|
||||
# if last_candle[self.stoploss_indicator.value] and (trade.nr_of_successful_entries >= 4 or self.wallets.get_available_stake_amount() < 300): # and profit < - 30 :
|
||||
# range_min = last_candle[f"min{self.stoploss_timeperiod.value}_1h"]
|
||||
# range_max = last_candle[f"max{self.stoploss_timeperiod.value}_1h"]
|
||||
#
|
||||
# if range_max == range_min:
|
||||
# print(f'ranges={range_min}')
|
||||
# return -0.1 # sécurité
|
||||
#
|
||||
# range_pos = (current_rate - range_min) / (range_max - range_min)
|
||||
#
|
||||
# if (range_pos > 1):
|
||||
# return -1
|
||||
#
|
||||
# sl_min = -0.02
|
||||
# sl_max = -0.1 #self.stoploss
|
||||
#
|
||||
# dynamic_sl = (sl_min + (1 - range_pos) * (sl_max - sl_min))
|
||||
#
|
||||
# print(f'{current_time} Loss ranges={round(range_min,0)} {round(range_max, 0)} range_pos={round(range_pos, 3)} dynamic_sl={round(dynamic_sl, 3)} '
|
||||
# f'profit={profit} current={current_profit} {self.stoploss_indicator.value} {self.stoploss_timeperiod.value} {last_candle[self.stoploss_indicator.value]}')
|
||||
#
|
||||
# return dynamic_sl
|
||||
|
||||
return -1
|
||||
# def custom_stoploss(self, pair, trade, current_time, current_rate, current_profit, **kwargs):
|
||||
# dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
|
||||
# last_candle = dataframe.iloc[-1]
|
||||
# profit = trade.calc_profit(current_rate)
|
||||
#
|
||||
# candle_at_buy = self.pairs[pair]['last_candle']
|
||||
#
|
||||
# # if candle_at_buy['range_pos'] > self.range_pos_stoploss.value and candle_at_buy[self.stoploss_indicator.value] < 0:
|
||||
# # return self.stoploss_force.value
|
||||
#
|
||||
# # # print(f'test stop loss {self.stoploss} {last_candle["stop_buying12_1h"]}')
|
||||
# # if last_candle[self.stoploss_indicator.value] and (trade.nr_of_successful_entries >= 4 or self.wallets.get_available_stake_amount() < 300): # and profit < - 30 :
|
||||
# # range_min = last_candle[f"min{self.stoploss_timeperiod.value}_1h"]
|
||||
# # range_max = last_candle[f"max{self.stoploss_timeperiod.value}_1h"]
|
||||
# #
|
||||
# # if range_max == range_min:
|
||||
# # print(f'ranges={range_min}')
|
||||
# # return -0.1 # sécurité
|
||||
# #
|
||||
# # range_pos = (current_rate - range_min) / (range_max - range_min)
|
||||
# #
|
||||
# # if (range_pos > 1):
|
||||
# # return -1
|
||||
# #
|
||||
# # sl_min = -0.02
|
||||
# # sl_max = -0.1 #self.stoploss
|
||||
# #
|
||||
# # dynamic_sl = (sl_min + (1 - range_pos) * (sl_max - sl_min))
|
||||
# #
|
||||
# # print(f'{current_time} Loss ranges={round(range_min,0)} {round(range_max, 0)} range_pos={round(range_pos, 3)} dynamic_sl={round(dynamic_sl, 3)} '
|
||||
# # f'profit={profit} current={current_profit} {self.stoploss_indicator.value} {self.stoploss_timeperiod.value} {last_candle[self.stoploss_indicator.value]}')
|
||||
# #
|
||||
# # return dynamic_sl
|
||||
#
|
||||
# return -1
|
||||
|
||||
def informative_pairs(self):
|
||||
# get access to all pairs available in whitelist.
|
||||
@@ -867,6 +874,13 @@ class EmptyShort(IStrategy):
|
||||
# Compter les baisses / hausses consécutives
|
||||
dataframe = self.calculateDownAndUp(dataframe, limit=0.0001)
|
||||
|
||||
dataframe['volume2'] = dataframe['volume']
|
||||
dataframe.loc[dataframe['hapercent'] < 0, 'volume2'] *= -1
|
||||
|
||||
# Volume confirmation
|
||||
dataframe['volume_spike'] = (abs(dataframe['volume2']) > abs(dataframe['volume2'].rolling(window=20).mean() * 5)) \
|
||||
& (dataframe['volume'].rolling(window=5).max() > 1000)
|
||||
|
||||
# récupérer le dernier trade fermé
|
||||
trades = Trade.get_trades_proxy(pair=pair,is_open=False)
|
||||
if trades:
|
||||
@@ -891,6 +905,17 @@ class EmptyShort(IStrategy):
|
||||
['enter_long', 'enter_tag']
|
||||
] = (1, 'long')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['volume_spike'] == 1)
|
||||
& (dataframe['down_count'] >= 3)
|
||||
& (dataframe['down_count'] < 15)
|
||||
& (dataframe['hapercent'] > 0)
|
||||
& (dataframe['sma60'] > dataframe['sma60'].shift(1))
|
||||
),
|
||||
['enter_long', 'enter_tag']
|
||||
] = (1, 'long_spike')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['sma12_deriv1_1h'] < -0.0005)
|
||||
@@ -903,9 +928,23 @@ class EmptyShort(IStrategy):
|
||||
)
|
||||
& (dataframe['hapercent'] < 0)
|
||||
# & (dataframe['pct_min_max_12_1d'] > 0.04)
|
||||
& (dataframe['down_count'] <= -3)
|
||||
& (dataframe['down_count'] > -15)
|
||||
),
|
||||
['enter_short', 'enter_tag']
|
||||
] = (1, 'short')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['volume_spike'] == 1)
|
||||
& (dataframe['down_count'] <= -3)
|
||||
& (dataframe['down_count'] > -15)
|
||||
& (dataframe['hapercent'] < 0)
|
||||
& (dataframe['sma60'] < dataframe['sma60'].shift(1))
|
||||
),
|
||||
['enter_short', 'enter_tag']
|
||||
] = (1, 'short_spike')
|
||||
|
||||
dataframe['short'] = np.where(dataframe['enter_short'] == 1, dataframe['close'] * 0.99, np.nan)
|
||||
dataframe['long'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user