import copy
import logging
import pathlib
import rapidjson
import numpy as np
import talib.abstract as ta
import pandas as pd
from freqtrade.strategy.interface import IStrategy
from freqtrade.strategy import merge_informative_pair
from pandas import DataFrame, Series
from functools import reduce
from freqtrade.persistence import Trade, Order
from datetime import datetime, timedelta
import time
from typing import Optional
import warnings

log = logging.getLogger(__name__)
# log.setLevel(logging.DEBUG)
warnings.simplefilter(action="ignore", category=pd.errors.PerformanceWarning)


#############################################################################################################
##                 NostalgiaForInfinityX7 by iterativ                                                      ##
##            https://github.com/iterativv/NostalgiaForInfinity                                            ##
##                                                                                                         ##
##    Strategy for Freqtrade https://github.com/freqtrade/freqtrade                                        ##
##                                                                                                         ##
#############################################################################################################
##               GENERAL RECOMMENDATIONS                                                                   ##
##                                                                                                         ##
##   For optimal performance, suggested to use between 6 and 12 open trades, with unlimited stake.         ##
##   A pairlist with 40 to 80 pairs. Volume pairlist works well.                                           ##
##   Prefer stable coin (USDT, USDC etc) pairs, instead of BTC or ETH pairs.                              ##
##   Highly recommended to blacklist leveraged tokens (*BULL, *BEAR, *UP, *DOWN etc).                      ##
##   Ensure that you don't override any variables in you config.json. Especially                           ##
##   the timeframe (must be 5m).                                                                           ##
##     use_exit_signal must set to true (or not set at all).                                               ##
##     exit_profit_only must set to false (or not set at all).                                             ##
##     ignore_roi_if_entry_signal must set to true (or not set at all).                                    ##
##                                                                                                         ##
#############################################################################################################
##               DONATIONS                                                                                 ##
##                                                                                                         ##
##   BTC: bc1qvflsvddkmxh7eqhc4jyu5z5k6xcw3ay8jl49sk                                                       ##
##   ETH (ERC20): 0x83D3cFb8001BDC5d2211cBeBB8cB3461E5f7Ec91                                               ##
##   BEP20/BSC (USDT, ETH, BNB, ...): 0x86A0B21a20b39d16424B7c8003E4A7e12d78ABEe                           ##
##   TRC20/TRON (USDT, TRON, ...): TTAa9MX6zMLXNgWMhg7tkNormVHWCoq8Xk                                      ##
##                                                                                                         ##
##  Patreon: https://www.patreon.com/iterativ                                                              ##
##                                                                                                         ##
##               REFERRAL LINKS                                                                            ##
##                                                                                                         ##
##  Binance: https://www.binance.com/join?ref=C68K26A9 (20% discount on trading fees)                      ##
##  Kucoin: https://www.kucoin.com/r/af/QBSSS5J2 (20% lifetime discount on trading fees)                   ##
##  Gate: https://www.gate.io/share/nfinfinity (20% lifetime discount on trading fees)                     ##
##  OKX: https://www.okx.com/join/11749725931 (20% discount on trading fees)                               ##
##  MEXC: https://promote.mexc.com/b/nfinfinity (10% discount on trading fees)                             ##
##  ByBit: https://partner.bybit.com/b/nfi                                                                 ##
##  ByBit.EU: https://partner.bybit.eu/b/NFINFINITY                                                        ##
##  Bitget: https://bonus.bitget.com/nfinfinity (lifetime 20% +10% extra spot rebate)                      ##
##  Kraken: https://proinvite.kraken.com/rrru/m021lz9e                                                     ##
##  BitMart: https://www.bitmart.com/invite/nfinfinity (20% lifetime discount on trading fees)             ##
##  HTX: https://www.htx.com/invite/en-us/1f?invite_code=ubpt2223                                          ##
##         (Welcome Bonus worth 241 USDT upon completion of a deposit and trade)                           ##
##  Bitvavo: https://bitvavo.com/invite?a=D22103A4BC (no fees for the first € 10000)                       ##
#############################################################################################################


class NostalgiaForInfinityX7(IStrategy):
  INTERFACE_VERSION = 3

  def version(self) -> str:
    return "v17.5.200"

  stoploss = -0.99

  # Trailing stoploss (not used)
  trailing_stop = False
  trailing_only_offset_is_reached = True
  trailing_stop_positive = 0.01
  trailing_stop_positive_offset = 0.03

  use_custom_stoploss = False
  stoploss_on_exchange = False

  # Optimal timeframe for the strategy.
  timeframe = "5m"
  info_timeframes = ["15m", "1h", "4h", "1d"]

  # BTC informatives
  # btc_info_timeframes = ["5m", "15m", "1h", "4h", "1d"]
  # btc_info_timeframes = ["1h", "4h", "1d"]
  btc_info_timeframes = ["4h"]

  stable_stake_currencies = frozenset(
    ("USDT", "BUSD", "USDC", "DAI", "TUSD", "FDUSD", "PAX", "USD", "EUR", "GBP", "TRY")
  )
  informative_ohlcv_columns = frozenset(("open", "high", "low", "close", "volume"))

  # Backtest Age Filter emulation
  has_bt_agefilter = False
  bt_min_age_days = 3

  # Exchange Downtime protection
  has_downtime_protection = False

  # Do you want to use the hold feature? (with hold-trades.json)
  hold_support_enabled = True

  # Run "populate_indicators()" only for new candle.
  process_only_new_candles = True

  # These values can be overridden in the "ask_strategy" section in the config.
  use_exit_signal = True
  exit_profit_only = False
  ignore_roi_if_entry_signal = True

  # Number of candles the strategy requires before producing valid signals
  startup_candle_count: int = 800

  # Number of cores to use for pandas_ta indicators calculations
  num_cores_indicators_calc = 0

  # Long Normal mode tags
  long_normal_mode_tags = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]
  # Long Pump mode tags
  long_pump_mode_tags = ["21", "22", "23", "24", "25", "26"]
  # Long Quick mode tags
  long_quick_mode_tags = ["41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53"]
  # Long rebuy mode tags
  long_rebuy_mode_tags = ["61", "62", "63", "64", "65", "68"]
  # Long high profit mode tags
  long_high_profit_mode_tags = ["81", "82"]
  # Long rapid mode tags
  long_rapid_mode_tags = ["101", "102", "103", "104", "105", "106", "107", "108", "109", "110"]
  # Long grind mode tags
  long_grind_mode_tags = ["120"]
  # Long btc mode tags
  long_btc_mode_tags = ["121"]
  # Long top coins mode tags
  long_top_coins_mode_tags = ["141", "142", "143", "144", "145"]
  # Long scalp mode tags
  long_scalp_mode_tags = ["161", "162", "163", "164", "165", "166", "167", "168", "169", "170", "171", "172", "173"]

  long_rebuy_grind_mode_tags = long_rebuy_mode_tags + long_grind_mode_tags
  long_scalp_rebuy_grind_mode_tags = long_scalp_mode_tags + long_rebuy_mode_tags + long_grind_mode_tags
  long_rapid_rebuy_grind_mode_tags = long_rapid_mode_tags + long_rebuy_mode_tags + long_grind_mode_tags
  long_rapid_rebuy_grind_scalp_mode_tags = (
    long_rapid_mode_tags + long_rebuy_mode_tags + long_grind_mode_tags + long_scalp_mode_tags
  )
  long_adjust_mode_tags = (
    long_normal_mode_tags
    + long_pump_mode_tags
    + long_quick_mode_tags
    + long_high_profit_mode_tags
    + long_rapid_mode_tags
    + long_top_coins_mode_tags
    + long_scalp_mode_tags
  )
  long_known_mode_tags = (
    long_normal_mode_tags
    + long_pump_mode_tags
    + long_quick_mode_tags
    + long_rebuy_mode_tags
    + long_high_profit_mode_tags
    + long_rapid_mode_tags
    + long_grind_mode_tags
    + long_btc_mode_tags
    + long_top_coins_mode_tags
    + long_scalp_mode_tags
  )

  long_normal_mode_name = "long_normal"
  long_pump_mode_name = "long_pump"
  long_quick_mode_name = "long_quick"
  long_rebuy_mode_name = "long_rebuy"
  long_high_profit_mode_name = "long_hp"
  long_rapid_mode_name = "long_rapid"
  long_grind_mode_name = "long_grind"
  long_btc_mode_name = "long_btc"
  long_top_coins_mode_name = "long_tc"
  long_scalp_mode_name = "long_scalp"

  # Shorting

  # Short normal mode tags
  short_normal_mode_tags = ["501", "502", "505", "506"]
  # Short Pump mode tags
  short_pump_mode_tags = ["521", "522", "523", "524", "525", "526"]
  # Short Quick mode tags
  short_quick_mode_tags = ["541", "542", "543", "544", "545", "546", "547", "548", "549", "550"]
  # Short rebuy mode tags
  short_rebuy_mode_tags = ["561", "562", "563"]
  # Short mode tags
  short_high_profit_mode_tags = ["581", "582"]
  # Short rapid mode tags
  short_rapid_mode_tags = ["601", "602", "603", "604", "605", "606", "607", "608", "609", "610"]
  # Short grind mode tags
  short_grind_mode_tags = ["620"]
  # Short top coins mode tags
  short_top_coins_mode_tags = ["641", "642"]
  # Short scalp mode tags
  short_scalp_mode_tags = ["661", "662", "663", "664", "665", "666", "667", "670", "669", "671"]

  short_rebuy_grind_mode_tags = short_rebuy_mode_tags + short_grind_mode_tags
  short_scalp_rebuy_grind_mode_tags = short_scalp_mode_tags + short_rebuy_mode_tags + short_grind_mode_tags
  short_rapid_rebuy_grind_mode_tags = short_rapid_mode_tags + short_rebuy_mode_tags + short_grind_mode_tags
  short_adjust_mode_tags = (
    short_normal_mode_tags
    + short_pump_mode_tags
    + short_quick_mode_tags
    + short_high_profit_mode_tags
    + short_rapid_mode_tags
    + short_top_coins_mode_tags
    + short_scalp_mode_tags
  )
  short_known_mode_tags = (
    short_normal_mode_tags
    + short_pump_mode_tags
    + short_quick_mode_tags
    + short_rebuy_mode_tags
    + short_high_profit_mode_tags
    + short_rapid_mode_tags
    + short_grind_mode_tags
    + short_top_coins_mode_tags
    + short_scalp_mode_tags
  )
  short_exit_known_mode_tags = (
    short_normal_mode_tags
    + short_pump_mode_tags
    + short_quick_mode_tags
    + short_rebuy_mode_tags
    + short_high_profit_mode_tags
    + short_rapid_mode_tags
    + short_grind_mode_tags
    + short_scalp_mode_tags
  )

  short_normal_mode_name = "short_normal"
  short_pump_mode_name = "short_pump"
  short_quick_mode_name = "short_quick"
  short_rebuy_mode_name = "short_rebuy"
  short_high_profit_mode_name = "short_hp"
  short_rapid_mode_name = "short_rapid"
  short_top_coins_mode_name = "short_tc"
  short_scalp_mode_name = "short_scalp"

  is_futures_mode = False
  futures_mode_leverage = 3.0
  futures_mode_leverage_rebuy_mode = 3.0
  futures_mode_leverage_grind_mode = 3.0

  # Limit the number of long/short trades for futures (0 for no limit)
  futures_max_open_trades_long = 0
  futures_max_open_trades_short = 0

  # Based on the the first entry (regardless of rebuys)
  stop_threshold_spot = 0.10
  stop_threshold_futures = 0.10
  stop_threshold_doom_spot = 0.20
  stop_threshold_doom_futures = 0.20
  stop_threshold_spot_rebuy = 1.0
  stop_threshold_futures_rebuy = 1.0
  stop_threshold_rapid_spot = 0.20
  stop_threshold_rapid_futures = 0.20
  stop_threshold_scalp_spot = 0.20
  stop_threshold_scalp_futures = 0.20

  # user specified fees to be used for profit calculations
  custom_fee_open_rate = None
  custom_fee_close_rate = None

  # Rebuy mode minimum number of free slots
  rebuy_mode_min_free_slots = 2

  # Position adjust feature
  position_adjustment_enable = True

  # Grinding feature
  grinding_enable = True
  derisk_enable = True
  stops_enable = True
  doom_stops_enable = True
  u_e_stops_enable = False

  # Bad-trade controller. Opt-in: the measured benefit is regime- and whitelist-dependent.
  bad_trade_controller_enable = False
  bad_trade_controller_structure_break_exit_enable = True
  bad_trade_controller_long_grind_stake_boost_enable = True
  bad_trade_controller_long_grind_stake_multiplier = 1.5
  bad_trade_controller_structure_break_ema_gap_pct = 35.0
  bad_trade_controller_structure_break_min_adverse_move_pct = 25.0
  bad_trade_controller_stale_exit_enable = True
  bad_trade_controller_stale_min_age_days = 14.0
  bad_trade_controller_stale_max_daily_range_pct = 7.0
  bad_trade_controller_stale_min_adverse_move_pct = 10.0

  # Grinding
  grinding_v1_max_stake = 1.0  # ratio of first entry
  derisk_use_grind_stops = True

  grind_1_stop_grinds_spot = -0.06
  grind_1_profit_threshold_spot = 0.018
  grind_1_stakes_spot = [0.24, 0.26, 0.28]
  grind_1_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_1_stop_grinds_futures = -0.06
  grind_1_profit_threshold_futures = 0.018
  grind_1_stakes_futures = [0.24, 0.26, 0.28]
  grind_1_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grind_2_stop_grinds_spot = -0.06
  grind_2_profit_threshold_spot = 0.018
  grind_2_stakes_spot = [0.20, 0.24, 0.28]
  grind_2_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_2_stop_grinds_futures = -0.06
  grind_2_profit_threshold_futures = 0.018
  grind_2_stakes_futures = [0.20, 0.24, 0.28]
  grind_2_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grind_3_stop_grinds_spot = -0.06
  grind_3_profit_threshold_spot = 0.018
  grind_3_stakes_spot = [0.20, 0.22, 0.24]
  grind_3_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_3_stop_grinds_futures = -0.06
  grind_3_profit_threshold_futures = 0.018
  grind_3_stakes_futures = [0.20, 0.22, 0.24]
  grind_3_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grind_4_stop_grinds_spot = -0.06
  grind_4_profit_threshold_spot = 0.018
  grind_4_stakes_spot = [0.20, 0.22, 0.24]
  grind_4_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_4_stop_grinds_futures = -0.06
  grind_4_profit_threshold_futures = 0.018
  grind_4_stakes_futures = [0.20, 0.22, 0.24]
  grind_4_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grind_5_stop_grinds_spot = -0.06
  grind_5_profit_threshold_spot = 0.048
  grind_5_stakes_spot = [0.20, 0.22, 0.24]
  grind_5_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_5_stop_grinds_futures = -0.06
  grind_5_profit_threshold_futures = 0.048
  grind_5_stakes_futures = [0.20, 0.22, 0.24]
  grind_5_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grind_6_stop_grinds_spot = -0.06
  grind_6_profit_threshold_spot = 0.018
  grind_6_stakes_spot = [0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18]
  grind_6_sub_thresholds_spot = [-0.03, -0.08, -0.10, -0.12, -0.14, -0.16, -0.18, -0.20, -0.22]

  grind_6_stop_grinds_futures = -0.06
  grind_6_profit_threshold_futures = 0.018
  grind_6_stakes_futures = [0.10, 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18]
  grind_6_sub_thresholds_futures = [-0.03, -0.08, -0.10, -0.12, -0.14, -0.16, -0.18, -0.20, -0.22]

  grind_1_derisk_1_stop_grinds_spot = -0.06
  grind_1_derisk_1_profit_threshold_spot = 0.018
  grind_1_derisk_1_stakes_spot = [0.20, 0.24, 0.28]
  grind_1_derisk_1_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_1_derisk_1_stop_grinds_futures = -0.06
  grind_1_derisk_1_profit_threshold_futures = 0.018
  grind_1_derisk_1_stakes_futures = [0.20, 0.24, 0.28]
  grind_1_derisk_1_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grind_2_derisk_1_stop_grinds_spot = -0.06
  grind_2_derisk_1_profit_threshold_spot = 0.018
  grind_2_derisk_1_stakes_spot = [0.20, 0.24, 0.28]
  grind_2_derisk_1_sub_thresholds_spot = [-0.12, -0.16, -0.20]

  grind_2_derisk_1_stop_grinds_futures = -0.06
  grind_2_derisk_1_profit_threshold_futures = 0.018
  grind_2_derisk_1_stakes_futures = [0.20, 0.24, 0.28]
  grind_2_derisk_1_sub_thresholds_futures = [-0.12, -0.16, -0.20]

  grinds_stop_spot = -0.12
  grinds_stop_futures = -0.12

  # Non rebuy modes
  regular_mode_stake_multiplier_spot = [1.0]
  regular_mode_stake_multiplier_futures = [1.0]
  regular_mode_use_grind_stops = False

  regular_mode_rebuy_stakes_spot = [0.10, 0.10, 0.10]
  regular_mode_rebuy_thresholds_spot = [-0.12, -0.14, -0.16]
  regular_mode_grind_1_stakes_spot = [0.22, 0.24, 0.26]
  regular_mode_grind_1_thresholds_spot = [-0.06, -0.10, -0.12]
  regular_mode_grind_1_stop_grinds_spot = -0.20
  regular_mode_grind_1_profit_threshold_spot = 0.018
  regular_mode_grind_2_stakes_spot = [0.14, 0.20, 0.26]
  regular_mode_grind_2_thresholds_spot = [-0.04, -0.10, -0.12]
  regular_mode_grind_2_stop_grinds_spot = -0.20
  regular_mode_grind_2_profit_threshold_spot = 0.018
  regular_mode_grind_3_stakes_spot = [0.18, 0.20, 0.22]
  regular_mode_grind_3_thresholds_spot = [-0.03, -0.10, -0.12]
  regular_mode_grind_3_stop_grinds_spot = -0.20
  regular_mode_grind_3_profit_threshold_spot = 0.018
  regular_mode_grind_4_stakes_spot = [0.18, 0.20, 0.22]
  regular_mode_grind_4_thresholds_spot = [-0.03, -0.10, -0.12]
  regular_mode_grind_4_stop_grinds_spot = -0.20
  regular_mode_grind_4_profit_threshold_spot = 0.018
  regular_mode_grind_5_stakes_spot = [0.18, 0.20, 0.22]
  regular_mode_grind_5_thresholds_spot = [-0.03, -0.10, -0.12]
  regular_mode_grind_5_stop_grinds_spot = -0.20
  regular_mode_grind_5_profit_threshold_spot = 0.048
  regular_mode_grind_6_stakes_spot = [0.05, 0.057, 0.065, 0.074, 0.084, 0.095, 0.107, 0.121, 0.137]
  regular_mode_grind_6_thresholds_spot = [-0.025, -0.05, -0.06, -0.07, -0.08, -0.09, -0.10, -0.11, -0.12]
  regular_mode_grind_6_stop_grinds_spot = -0.20
  regular_mode_grind_6_profit_threshold_spot = 0.018
  regular_mode_derisk_1_spot = -0.24
  regular_mode_derisk_1_spot_old = -0.80
  regular_mode_derisk_1_reentry_spot = -0.08
  regular_mode_derisk_spot = -0.24
  regular_mode_derisk_spot_old = -1.60
  regular_mode_derisk_1_scalp_mode_spot = -0.05

  regular_mode_rebuy_stakes_futures = [0.10, 0.10, 0.10]
  regular_mode_rebuy_thresholds_futures = [-0.12, -0.14, -0.16]
  regular_mode_grind_1_stakes_futures = [0.22, 0.24, 0.26]
  regular_mode_grind_1_thresholds_futures = [-0.06, -0.10, -0.12]
  regular_mode_grind_1_stop_grinds_futures = -0.20
  regular_mode_grind_1_profit_threshold_futures = 0.018
  regular_mode_grind_2_stakes_futures = [0.14, 0.20, 0.26]
  regular_mode_grind_2_thresholds_futures = [-0.04, -0.10, -0.12]
  regular_mode_grind_2_stop_grinds_futures = -0.20
  regular_mode_grind_2_profit_threshold_futures = 0.018
  regular_mode_grind_3_stakes_futures = [0.18, 0.20, 0.22]
  regular_mode_grind_3_thresholds_futures = [-0.03, -0.10, -0.12]
  regular_mode_grind_3_stop_grinds_futures = -0.20
  regular_mode_grind_3_profit_threshold_futures = 0.018
  regular_mode_grind_4_stakes_futures = [0.18, 0.20, 0.22]
  regular_mode_grind_4_thresholds_futures = [-0.03, -0.10, -0.12]
  regular_mode_grind_4_stop_grinds_futures = -0.20
  regular_mode_grind_4_profit_threshold_futures = 0.018
  regular_mode_grind_5_stakes_futures = [0.18, 0.20, 0.22]
  regular_mode_grind_5_thresholds_futures = [-0.03, -0.10, -0.12]
  regular_mode_grind_5_stop_grinds_futures = -0.20
  regular_mode_grind_5_profit_threshold_futures = 0.048
  regular_mode_grind_6_stakes_futures = [0.05, 0.057, 0.065, 0.074, 0.084, 0.095, 0.107, 0.121, 0.137]
  regular_mode_grind_6_thresholds_futures = [-0.025, -0.05, -0.06, -0.07, -0.08, -0.09, -0.10, -0.11, -0.12]
  regular_mode_grind_6_stop_grinds_futures = -0.20
  regular_mode_grind_6_profit_threshold_futures = 0.018
  regular_mode_derisk_1_futures = -0.60
  regular_mode_derisk_1_futures_old = -0.80
  regular_mode_derisk_1_reentry_futures = -0.08  # without leverage
  regular_mode_derisk_futures = -0.60
  regular_mode_derisk_futures_old = -1.20
  regular_mode_derisk_1_scalp_mode_futures = -0.05

  # Grinding v2
  grinding_v2_max_stake = 1.0  # ratio of first entry
  grinding_v2_max_grinds_and_buybacks = 20  # current open

  grinding_v2_derisk_level_1_enable = True
  grinding_v2_derisk_level_1_spot = [-0.06, -0.15]
  grinding_v2_derisk_level_1_futures = [-0.18, -0.35]
  grinding_v2_derisk_level_2_enable = True
  grinding_v2_derisk_level_2_spot = [-0.08, -0.18]
  grinding_v2_derisk_level_2_futures = [-0.16, -0.54]
  grinding_v2_derisk_level_3_enable = True
  grinding_v2_derisk_level_3_spot = [-0.10, -0.20]
  grinding_v2_derisk_level_3_futures = [-0.30, -0.60]
  grinding_v2_derisk_level_1_stake_spot = 0.20
  grinding_v2_derisk_level_1_stake_futures = 0.20
  grinding_v2_derisk_level_2_stake_spot = 0.30
  grinding_v2_derisk_level_2_stake_futures = 0.30
  grinding_v2_derisk_level_3_stake_spot = 0.50
  grinding_v2_derisk_level_3_stake_futures = 0.50
  grinding_v2_derisk_global_enable = False
  grinding_v2_derisk_global_spot = -0.10
  grinding_v2_derisk_global_futures = -0.30

  grinding_v2_grind_1_enable = True
  grinding_v2_grind_1_stakes_spot = [0.20, 0.22, 0.24, 0.26, 0.28]
  grinding_v2_grind_1_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  grinding_v2_grind_1_stakes_futures = [0.20, 0.22, 0.24, 0.26, 0.28]
  grinding_v2_grind_1_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  grinding_v2_grind_1_profit_threshold_spot = 0.02
  grinding_v2_grind_1_profit_threshold_futures = 0.02
  grinding_v2_grind_1_use_derisk = True
  grinding_v2_grind_1_derisk_spot = -0.26
  grinding_v2_grind_1_derisk_futures = -0.26

  grinding_v2_grind_2_enable = True
  grinding_v2_grind_2_stakes_spot = [0.10, 0.12, 0.14, 0.16, 0.18]
  grinding_v2_grind_2_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  grinding_v2_grind_2_stakes_futures = [0.10, 0.12, 0.14, 0.16, 0.18]
  grinding_v2_grind_2_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  grinding_v2_grind_2_profit_threshold_spot = 0.02
  grinding_v2_grind_2_profit_threshold_futures = 0.02
  grinding_v2_grind_2_use_derisk = True
  grinding_v2_grind_2_derisk_spot = -0.26
  grinding_v2_grind_2_derisk_futures = -0.26

  grinding_v2_grind_3_enable = True
  grinding_v2_grind_3_stakes_spot = [0.10, 0.12, 0.14, 0.16, 0.18]
  grinding_v2_grind_3_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  grinding_v2_grind_3_stakes_futures = [0.10, 0.12, 0.14, 0.16, 0.18]
  grinding_v2_grind_3_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  grinding_v2_grind_3_profit_threshold_spot = 0.02
  grinding_v2_grind_3_profit_threshold_futures = 0.02
  grinding_v2_grind_3_use_derisk = True
  grinding_v2_grind_3_derisk_spot = -0.26
  grinding_v2_grind_3_derisk_futures = -0.26

  grinding_v2_grind_4_enable = True
  grinding_v2_grind_4_stakes_spot = [0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11]
  grinding_v2_grind_4_thresholds_spot = [-0.06, -0.07, -0.09, -0.12, -0.16, -0.21, -0.27]
  grinding_v2_grind_4_stakes_futures = [0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11]
  grinding_v2_grind_4_thresholds_futures = [-0.06, -0.07, -0.09, -0.12, -0.16, -0.21, -0.27]
  grinding_v2_grind_4_profit_threshold_spot = 0.10
  grinding_v2_grind_4_profit_threshold_futures = 0.10
  grinding_v2_grind_4_use_derisk = True
  grinding_v2_grind_4_derisk_spot = -0.26
  grinding_v2_grind_4_derisk_futures = -0.26

  grinding_v2_grind_5_enable = True
  grinding_v2_grind_5_stakes_spot = [0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11]
  grinding_v2_grind_5_thresholds_spot = [-0.06, -0.07, -0.09, -0.12, -0.16, -0.21, -0.27]
  grinding_v2_grind_5_stakes_futures = [0.05, 0.06, 0.07, 0.08, 0.09, 0.10, 0.11]
  grinding_v2_grind_5_thresholds_futures = [-0.06, -0.07, -0.09, -0.12, -0.16, -0.21, -0.27]
  grinding_v2_grind_5_profit_threshold_spot = 0.10
  grinding_v2_grind_5_profit_threshold_futures = 0.10
  grinding_v2_grind_5_use_derisk = True
  grinding_v2_grind_5_derisk_spot = -0.26
  grinding_v2_grind_5_derisk_futures = -0.26

  grinding_v2_buyback_1_enable = True
  grinding_v2_buyback_1_stake_spot = 0.10
  grinding_v2_buyback_1_stake_futures = 0.10
  grinding_v2_buyback_1_distance_ratio_spot = -0.06
  grinding_v2_buyback_1_distance_ratio_futures = -0.06
  grinding_v2_buyback_1_profit_threshold_spot = 0.05
  grinding_v2_buyback_1_profit_threshold_futures = 0.05
  grinding_v2_buyback_1_use_derisk = True
  grinding_v2_buyback_1_derisk_spot = -0.26
  grinding_v2_buyback_1_derisk_futures = -0.26

  grinding_v2_buyback_2_enable = True
  grinding_v2_buyback_2_stake_spot = 0.10
  grinding_v2_buyback_2_stake_futures = 0.10
  grinding_v2_buyback_2_distance_ratio_spot = -0.12
  grinding_v2_buyback_2_distance_ratio_futures = -0.12
  grinding_v2_buyback_2_profit_threshold_spot = 0.05
  grinding_v2_buyback_2_profit_threshold_futures = 0.05
  grinding_v2_buyback_2_use_derisk = True
  grinding_v2_buyback_2_derisk_spot = -0.26
  grinding_v2_buyback_2_derisk_futures = -0.26

  grinding_v2_buyback_3_enable = True
  grinding_v2_buyback_3_stake_spot = 0.10
  grinding_v2_buyback_3_stake_futures = 0.10
  grinding_v2_buyback_3_distance_ratio_spot = -0.16
  grinding_v2_buyback_3_distance_ratio_futures = -0.16
  grinding_v2_buyback_3_profit_threshold_spot = 0.05
  grinding_v2_buyback_3_profit_threshold_futures = 0.05
  grinding_v2_buyback_3_use_derisk = True
  grinding_v2_buyback_3_derisk_spot = -0.26
  grinding_v2_buyback_3_derisk_futures = -0.26

  # System v3
  system_v3_name = "system_v3"
  system_v3_1_name = "system_v3_1"
  system_v3_2_name = "system_v3_2"
  system_name_use = system_v3_2_name

  system_v3_max_stake = 1.0  # ratio of first entry
  system_v3_1_max_stake = 3.0  # ratio of first entry

  system_v3_stop_threshold_doom_spot = 0.14
  system_v3_stop_threshold_doom_futures = 0.35
  system_v3_stop_threshold_spot_rebuy = 0.70
  system_v3_stop_threshold_futures_rebuy = 1.75
  system_v3_stop_threshold_rapid_spot = 0.14
  system_v3_stop_threshold_rapid_futures = 0.35
  system_v3_stop_threshold_scalp_spot = 0.14
  system_v3_stop_threshold_scalp_futures = 0.35

  system_v3_1_stop_threshold_doom_spot = 0.24
  system_v3_1_stop_threshold_doom_futures = 0.70
  system_v3_1_stop_threshold_spot_rebuy = 0.47
  system_v3_1_stop_threshold_futures_rebuy = 1.40
  system_v3_1_stop_threshold_rapid_spot = 0.24
  system_v3_1_stop_threshold_rapid_futures = 0.70
  system_v3_1_stop_threshold_scalp_spot = 0.24
  system_v3_1_stop_threshold_scalp_futures = 0.70

  system_v3_2_stops_enable = False
  system_v3_2_stop_threshold_doom_spot = 0.12
  system_v3_2_stop_threshold_doom_futures = 0.35
  system_v3_2_stop_threshold_spot_rebuy = 0.48
  system_v3_2_stop_threshold_futures_rebuy = 1.40
  system_v3_2_stop_threshold_rapid_spot = 0.12
  system_v3_2_stop_threshold_rapid_futures = 0.35
  system_v3_2_stop_threshold_scalp_spot = 0.12
  system_v3_2_stop_threshold_scalp_futures = 0.35

  system_v3_1_stake_multiplier = 0.50
  system_v3_1_rebuy_stakes_spot = [0.5, 0.5]
  system_v3_1_rebuy_stakes_futures = [0.5, 0.5]
  system_v3_1_rebuy_thresholds_spot = [-0.25, -0.16, -0.16, -0.20]
  system_v3_1_rebuy_thresholds_futures = [-0.25, -0.16, -0.16, -0.20]

  system_v3_derisk_level_1_enable = True
  system_v3_derisk_level_1_spot = [-0.04, -0.06]
  system_v3_derisk_level_1_futures = [-0.12, -0.18]
  system_v3_derisk_level_1_stake_spot = 0.10
  system_v3_derisk_level_1_stake_futures = 0.10
  system_v3_derisk_level_2_enable = True
  system_v3_derisk_level_2_spot = [-0.06, -0.08]
  system_v3_derisk_level_2_futures = [-0.18, -0.24]
  system_v3_derisk_level_2_stake_spot = 0.10
  system_v3_derisk_level_2_stake_futures = 0.10
  system_v3_derisk_level_3_enable = True
  system_v3_derisk_level_3_spot = [-0.08, -0.10]
  system_v3_derisk_level_3_futures = [-0.24, -0.30]
  system_v3_derisk_level_3_stake_spot = 0.10
  system_v3_derisk_level_3_stake_futures = 0.10

  system_v3_2_stake_multiplier = 1.0
  system_v3_2_derisk_level_1_enable = True
  system_v3_2_derisk_level_1_spot = [-0.06, -0.12]
  system_v3_2_derisk_level_1_futures = [-0.18, -0.35]
  system_v3_2_derisk_level_1_stake_spot = 0.20
  system_v3_2_derisk_level_1_stake_futures = 0.20
  system_v3_2_derisk_level_2_enable = True
  system_v3_2_derisk_level_2_spot = [-0.08, -0.18]
  system_v3_2_derisk_level_2_futures = [-0.24, -0.54]
  system_v3_2_derisk_level_2_stake_spot = 0.30
  system_v3_2_derisk_level_2_stake_futures = 0.30
  system_v3_2_derisk_level_3_enable = True
  system_v3_2_derisk_level_3_spot = [-0.10, -0.20]
  system_v3_2_derisk_level_3_futures = [-0.30, -0.60]
  system_v3_2_derisk_level_3_stake_spot = 0.50
  system_v3_2_derisk_level_3_stake_futures = 0.50
  system_v3_2_derisk_level_4_enable = False
  system_v3_2_derisk_level_4_spot = [-0.02, -0.08]
  system_v3_2_derisk_level_4_futures = [-0.06, -0.24]
  system_v3_2_derisk_level_4_stake_spot = 1.0
  system_v3_2_derisk_level_4_stake_futures = 1.0

  system_v3_grind_1_enable = True
  system_v3_grind_1_stakes_spot = [0.20, 0.20, 0.20, 0.20, 0.20]
  system_v3_grind_1_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_1_stakes_futures = [0.20, 0.20, 0.20, 0.20, 0.20]
  system_v3_grind_1_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_1_profit_threshold_spot = 0.025
  system_v3_grind_1_profit_threshold_futures = 0.025
  system_v3_grind_1_use_derisk = True
  system_v3_grind_1_derisk_spot = -0.22
  system_v3_grind_1_derisk_futures = -0.22

  system_v3_grind_2_enable = True
  system_v3_grind_2_stakes_spot = [0.10, 0.12, 0.14, 0.16, 0.18]
  system_v3_grind_2_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_2_stakes_futures = [0.10, 0.12, 0.14, 0.16, 0.18]
  system_v3_grind_2_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_2_profit_threshold_spot = 0.035
  system_v3_grind_2_profit_threshold_futures = 0.035
  system_v3_grind_2_use_derisk = True
  system_v3_grind_2_derisk_spot = -0.22
  system_v3_grind_2_derisk_futures = -0.22

  system_v3_grind_3_enable = True
  system_v3_grind_3_stakes_spot = [0.10, 0.12, 0.14, 0.16, 0.18]
  system_v3_grind_3_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_3_stakes_futures = [0.10, 0.12, 0.14, 0.16, 0.18]
  system_v3_grind_3_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_3_profit_threshold_spot = 0.04
  system_v3_grind_3_profit_threshold_futures = 0.04
  system_v3_grind_3_use_derisk = True
  system_v3_grind_3_derisk_spot = -0.22
  system_v3_grind_3_derisk_futures = -0.22

  system_v3_grind_4_enable = True
  system_v3_grind_4_stakes_spot = [0.05, 0.06, 0.07, 0.08, 0.09]
  system_v3_grind_4_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_4_stakes_futures = [0.05, 0.06, 0.07, 0.08, 0.09]
  system_v3_grind_4_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_4_profit_threshold_spot = 0.05
  system_v3_grind_4_profit_threshold_futures = 0.05
  system_v3_grind_4_use_derisk = True
  system_v3_grind_4_derisk_spot = -0.22
  system_v3_grind_4_derisk_futures = -0.22

  system_v3_grind_5_enable = True
  system_v3_grind_5_stakes_spot = [0.05, 0.06, 0.07, 0.08, 0.09]
  system_v3_grind_5_thresholds_spot = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_5_stakes_futures = [0.05, 0.06, 0.07, 0.08, 0.09]
  system_v3_grind_5_thresholds_futures = [-0.06, -0.07, -0.08, -0.09, -0.10]
  system_v3_grind_5_profit_threshold_spot = 0.06
  system_v3_grind_5_profit_threshold_futures = 0.06
  system_v3_grind_5_use_derisk = True
  system_v3_grind_5_derisk_spot = -0.22
  system_v3_grind_5_derisk_futures = -0.22

  system_v3_buyback_1_enable = False
  system_v3_buyback_1_stake_spot = 1.00
  system_v3_buyback_1_stake_futures = 1.00
  system_v3_buyback_1_distance_ratio_negative_spot = -0.04
  system_v3_buyback_1_distance_ratio_negative_futures = -0.04
  system_v3_buyback_1_distance_ratio_positive_spot = 0.02
  system_v3_buyback_1_distance_ratio_positive_futures = 0.02
  # system_v3_buyback_1_profit_threshold_spot = 0.05
  # system_v3_buyback_1_profit_threshold_futures = 0.05
  system_v3_buyback_1_use_derisk = True
  system_v3_buyback_1_derisk_spot = -0.08
  system_v3_buyback_1_derisk_futures = -0.08

  # Rebuy mode
  rebuy_mode_stake_multiplier = 0.35
  rebuy_mode_derisk_spot = -0.60
  rebuy_mode_derisk_futures = -0.60
  rebuy_mode_stakes_spot = [1.0, 1.0]
  rebuy_mode_stakes_futures = [1.0, 1.0]
  rebuy_mode_thresholds_spot = [-0.08, -0.10]
  rebuy_mode_thresholds_futures = [-0.08, -0.10]

  # Rebuy mode v3
  system_v3_rebuy_mode_stake_multiplier = 0.25
  system_v3_rebuy_mode_derisk_spot = -0.48
  system_v3_rebuy_mode_derisk_futures = -1.40
  system_v3_rebuy_mode_stakes_spot = [1.0, 1.0, 1.0, 1.0]
  system_v3_rebuy_mode_stakes_futures = [1.0, 1.0, 1.0, 1.0]
  system_v3_rebuy_mode_thresholds_spot = [-0.08, -0.12, -0.16, -0.20]
  system_v3_rebuy_mode_thresholds_futures = [-0.08, -0.12, -0.16, -0.20]

  # Rapid mode
  rapid_mode_stake_multiplier_spot = [0.75]
  rapid_mode_stake_multiplier_futures = [0.75]

  # Scalp mode
  min_free_slots_scalp_mode = 1

  # Grind mode
  grind_mode_stake_multiplier_spot = [0.20, 0.30, 0.40, 0.50, 0.60, 0.70]
  grind_mode_stake_multiplier_futures = [0.20, 0.30, 0.40, 0.50]
  grind_mode_first_entry_profit_threshold_spot = 0.018
  grind_mode_first_entry_profit_threshold_futures = 0.018
  grind_mode_first_entry_stop_threshold_spot = -0.20
  grind_mode_first_entry_stop_threshold_futures = -0.20
  grind_mode_max_slots = 1
  grind_mode_coins = [
    "AAVE",
    "ADA",
    "ALGO",
    "APE",
    "APT",
    "ARB",
    "ATOM",
    "AVAX",
    "BCH",
    "BNB",
    "BTC",
    "CAKE",
    "CRV",
    "DOGE",
    "DYDX",
    "ETC",
    "ETH",
    "FIL",
    "GALA",
    "HBAR",
    "HYPE",
    "ICP",
    "INJ",
    "IOTA",
    "JUP",
    "KAS",
    "LDO",
    "LINK",
    "LTC",
    "NEAR",
    "NEO",
    "OP",
    "POL",
    "RENDER",
    "RUNE",
    "SAND",
    "SEI",
    "SOL",
    "SUI",
    "THETA",
    "TIA",
    "TON",
    "TRX",
    "UNI",
    "VET",
    "XLM",
    "XMR",
    "XRP",
    "XTZ",
    "ZEC",
  ]

  btc_mode_max_slots = 0
  btc_mode_coins = [
    "BTC",
  ]

  # Top coins mode coins
  top_coins_mode_coins = [
    "1INCH",
    "AAVE",
    "ADA",
    "ALGO",
    "APE",
    "APT",
    "ARB",
    "ATOM",
    "AVAX",
    "BCH",
    "BNB",
    "BTC",
    "CAKE",
    "CRV",
    "DASH",
    "DOGE",
    "DOT",
    "DYDX",
    "ETC",
    "ETH",
    "FIL",
    "GALA",
    "HBAR",
    "HYPE",
    "ICP",
    "INJ",
    "IOTA",
    "JUP",
    "KAS",
    "LDO",
    "LINK",
    "LTC",
    "NEAR",
    "NEO",
    "ONDO",
    "OP",
    "POL",
    "RENDER",
    "RUNE",
    "SAND",
    "SEI",
    "SOL",
    "SUI",
    "THETA",
    "TIA",
    "TON",
    "TRX",
    "UNI",
    "VET",
    "WLD",
    "XLM",
    "XMR",
    "XRP",
    "XTZ",
    "ZEC",
  ]

  # Profit max thresholds
  profit_max_thresholds = [0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.05, 0.05]

  # Max allowed buy "slippage", how high to buy on the candle
  max_slippage = 0.02

  # BTC/ETH stakes
  btc_stakes = ["BTC", "ETH"]

  #############################################################
  # Buy side configuration

  long_entry_signal_params = {
    # Enable/Disable conditions
    # -------------------------------------------------------
    "long_entry_condition_1_enable": True,
    "long_entry_condition_2_enable": True,
    "long_entry_condition_3_enable": True,
    "long_entry_condition_4_enable": True,
    "long_entry_condition_5_enable": True,
    "long_entry_condition_6_enable": True,
    "long_entry_condition_7_enable": False,
    "long_entry_condition_8_enable": False,
    "long_entry_condition_9_enable": False,
    "long_entry_condition_10_enable": False,
    "long_entry_condition_11_enable": False,
    "long_entry_condition_21_enable": True,
    "long_entry_condition_41_enable": True,
    "long_entry_condition_42_enable": True,
    "long_entry_condition_43_enable": True,
    "long_entry_condition_44_enable": True,
    "long_entry_condition_45_enable": True,
    "long_entry_condition_46_enable": True,
    "long_entry_condition_47_enable": True,
    "long_entry_condition_61_enable": True,
    "long_entry_condition_62_enable": True,
    "long_entry_condition_63_enable": True,
    "long_entry_condition_64_enable": True,
    "long_entry_condition_65_enable": True,
    "long_entry_condition_68_enable": False,
    "long_entry_condition_101_enable": True,
    "long_entry_condition_102_enable": True,
    "long_entry_condition_103_enable": True,
    "long_entry_condition_104_enable": True,
    "long_entry_condition_105_enable": False,
    "long_entry_condition_120_enable": True,
    "long_entry_condition_121_enable": False,
    "long_entry_condition_141_enable": True,
    "long_entry_condition_142_enable": True,
    "long_entry_condition_143_enable": True,
    "long_entry_condition_144_enable": True,
    "long_entry_condition_145_enable": True,
    "long_entry_condition_161_enable": True,
    "long_entry_condition_162_enable": True,
    "long_entry_condition_163_enable": True,
    "long_entry_condition_164_enable": False,
    "long_entry_condition_165_enable": False,
    "long_entry_condition_166_enable": False,
    "long_entry_condition_167_enable": False,
    "long_entry_condition_168_enable": False,
    "long_entry_condition_169_enable": False,
    "long_entry_condition_170_enable": False,
    "long_entry_condition_171_enable": False,
    "long_entry_condition_172_enable": False,
    "long_entry_condition_173_enable": False,
    "long_entry_condition_192_enable": False,
    "long_entry_condition_193_enable": False,
  }

  short_entry_signal_params = {
    # Enable/Disable conditions
    # -------------------------------------------------------
    "short_entry_condition_501_enable": True,
    "short_entry_condition_502_enable": True,
    # "short_entry_condition_503_enable": True,
    # "short_entry_condition_504_enable": True,
    "short_entry_condition_505_enable": False,
    "short_entry_condition_506_enable": False,
    # "short_entry_condition_541_enable": True,
    "short_entry_condition_542_enable": True,
    "short_entry_condition_543_enable": False,
    "short_entry_condition_544_enable": False,
    "short_entry_condition_545_enable": False,
    "short_entry_condition_546_enable": False,
    "short_entry_condition_561_enable": False,
    "short_entry_condition_562_enable": True,
    "short_entry_condition_563_enable": False,
    "short_entry_condition_592_enable": False,
    "short_entry_condition_593_enable": False,
    # "short_entry_condition_603_enable": True,
    "short_entry_condition_605_enable": False,
    # "short_entry_condition_641_enable": True,
    # "short_entry_condition_642_enable": True,
    # "short_entry_condition_661_enable": True,
    "short_entry_condition_662_enable": False,
    "short_entry_condition_663_enable": False,
    "short_entry_condition_664_enable": False,
    "short_entry_condition_665_enable": False,
    "short_entry_condition_666_enable": False,
    "short_entry_condition_667_enable": False,
    "short_entry_condition_669_enable": False,
    "short_entry_condition_670_enable": False,
    "short_entry_condition_671_enable": False,
  }

  #############################################################
  # CACHES

  hold_trades_cache = None
  target_profit_cache = None
  #############################################################
  #
  #
  #  $$$$$$\   $$$$$$\  $$\      $$\ $$\      $$\  $$$$$$\  $$\   $$\
  # $$  __$$\ $$  __$$\ $$$\    $$$ |$$$\    $$$ |$$  __$$\ $$$\  $$ |
  # $$ /  \__|$$ /  $$ |$$$$\  $$$$ |$$$$\  $$$$ |$$ /  $$ |$$$$\ $$ |
  # $$ |      $$ |  $$ |$$\$$\$$ $$ |$$\$$\$$ $$ |$$ |  $$ |$$ $$\$$ |
  # $$ |      $$ |  $$ |$$ \$$$  $$ |$$ \$$$  $$ |$$ |  $$ |$$ \$$$$ |
  # $$ |  $$\ $$ |  $$ |$$ |\$  /$$ |$$ |\$  /$$ |$$ |  $$ |$$ |\$$$ |
  # \$$$$$$  | $$$$$$  |$$ | \_/ $$ |$$ | \_/ $$ | $$$$$$  |$$ | \$$ |
  #  \______/  \______/ \__|     \__|\__|     \__| \______/ \__|  \__|
  #
  #
  #
  # $$$$$$$$\ $$\   $$\ $$\   $$\  $$$$$$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\  $$$$$$\
  # $$  _____|$$ |  $$ |$$$\  $$ |$$  __$$\\__$$  __|\_$$  _|$$  __$$\ $$$\  $$ |$$  __$$\
  # $$ |      $$ |  $$ |$$$$\ $$ |$$ /  \__|  $$ |     $$ |  $$ /  $$ |$$$$\ $$ |$$ /  \__|
  # $$$$$\    $$ |  $$ |$$ $$\$$ |$$ |        $$ |     $$ |  $$ |  $$ |$$ $$\$$ |\$$$$$$\
  # $$  __|   $$ |  $$ |$$ \$$$$ |$$ |        $$ |     $$ |  $$ |  $$ |$$ \$$$$ | \____$$\
  # $$ |      $$ |  $$ |$$ |\$$$ |$$ |  $$\   $$ |     $$ |  $$ |  $$ |$$ |\$$$ |$$\   $$ |
  # $$ |      \$$$$$$  |$$ | \$$ |\$$$$$$  |  $$ |   $$$$$$\  $$$$$$  |$$ | \$$ |\$$$$$$  |
  # \__|       \______/ \__|  \__| \______/   \__|   \______| \______/ \__|  \__| \______/
  #
  #

  ###############################################################################################
  # COMMON FUNCTIONS FOR BOTH LONG AND SHORT SIDE STARTS HERE
  ###############################################################################################

  def __init__(self, config: dict) -> None:
    # A list of parameters that can be changed through the config.
    NFI_SAFE_PARAMETERS = [
      "num_cores_indicators_calc",
      "custom_fee_open_rate",
      "custom_fee_close_rate",
      "futures_mode_leverage",
      "futures_mode_leverage_rebuy_mode",
      "futures_mode_leverage_grind_mode",
      "futures_max_open_trades_long",
      "futures_max_open_trades_short",
      "stop_threshold_doom_spot",
      "stop_threshold_doom_futures",
      "stop_threshold_rapid_spot",
      "stop_threshold_rapid_futures",
      "stop_threshold_scalp_spot",
      "stop_threshold_scalp_futures",
      "derisk_enable",
      "stops_enable",
      "regular_mode_derisk_1_spot",
      "regular_mode_derisk_spot",
      "regular_mode_derisk_1_futures",
      "regular_mode_derisk_futures",
      "grind_mode_max_slots",
      "grind_mode_coins",
      "max_slippage",
      "bad_trade_controller_enable",
      "bad_trade_controller_structure_break_exit_enable",
      "bad_trade_controller_long_grind_stake_boost_enable",
      "bad_trade_controller_long_grind_stake_multiplier",
      "bad_trade_controller_structure_break_ema_gap_pct",
      "bad_trade_controller_structure_break_min_adverse_move_pct",
      "bad_trade_controller_stale_exit_enable",
      "bad_trade_controller_stale_min_age_days",
      "bad_trade_controller_stale_max_daily_range_pct",
      "bad_trade_controller_stale_min_adverse_move_pct",
    ]

    exchange_config = config["exchange"]
    if "ccxt_config" not in exchange_config:
      exchange_config["ccxt_config"] = {}
    if "ccxt_async_config" not in exchange_config:
      exchange_config["ccxt_async_config"] = {}

    options = {
      "brokerId": None,
      "broker": {"spot": None, "margin": None, "future": None, "delivery": None},
      "partner": {
        "spot": {"id": None, "key": None},
        "future": {"id": None, "key": None},
        "id": None,
        "key": None,
      },
    }

    exchange_config["ccxt_config"]["options"] = options
    exchange_config["ccxt_async_config"]["options"] = options
    super().__init__(config)
    self._grind_entry_tag = ""
    strategy_config = self.config
    if ("exit_profit_only" in strategy_config and strategy_config["exit_profit_only"]) or (
      "sell_profit_only" in strategy_config and strategy_config["sell_profit_only"]
    ):
      self.exit_profit_only = True

    # Advanced configuration mode. Allows to change any parameter.
    is_config_advanced_mode = "nfi_advanced_mode" in strategy_config and strategy_config["nfi_advanced_mode"] == True
    if is_config_advanced_mode:
      log.warning("The advanced configuration mode is enabled. I hope you know what you are doing.")

    # Configuration from the nfi_parameters block. New config style.
    nfi_parameters = strategy_config.get("nfi_parameters")
    if type(nfi_parameters) is dict:
      for nfi_param in nfi_parameters:
        if nfi_param in ["long_entry_signal_params", "short_entry_signal_params"]:
          continue
        if (nfi_param in NFI_SAFE_PARAMETERS or is_config_advanced_mode) and hasattr(self, nfi_param):
          log.info(
            f'Parameter {nfi_param} changed from "{getattr(self, nfi_param)}" to "{nfi_parameters[nfi_param]}".'
          )
          setattr(self, nfi_param, nfi_parameters[nfi_param])
        else:
          log.warning(f"Invalid or unsafe parameter: {nfi_param}.")

      self.update_signals_from_config(nfi_parameters)

    # Parameter settings. Backward compatibility with the old configuration style.
    for nfi_param in NFI_SAFE_PARAMETERS:
      if (nfi_param in strategy_config) and hasattr(self, nfi_param):
        setattr(self, nfi_param, strategy_config[nfi_param])

    if self.target_profit_cache is None:
      bot_name = ""
      if "bot_name" in strategy_config:
        bot_name = strategy_config["bot_name"] + "-"
      exchange_name = strategy_config["exchange"]["name"]
      runmode_value = strategy_config["runmode"].value
      self.target_profit_cache = Cache(
        strategy_config["user_data_dir"]
        / (
          "nfix7-profit_max-"
          + bot_name
          + exchange_name
          + "-"
          + strategy_config["stake_currency"]
          + ("-(backtest)" if (runmode_value == "backtest") else "")
          + ("-(hyperopt)" if (runmode_value == "hyperopt") else "")
          + ".json"
        )
      )
    else:
      exchange_name = strategy_config["exchange"]["name"]

    # OKX, Kraken provides a lower number of candle data per API call
    if exchange_name in ["okx", "okex"]:
      self.startup_candle_count = 480
    elif exchange_name == "kraken":
      self.startup_candle_count = 710
    elif exchange_name == "bybit":
      self.startup_candle_count = 199
    elif exchange_name == "bitget":
      self.startup_candle_count = 499
    elif exchange_name == "bingx":
      self.startup_candle_count = 499

    if ("trading_mode" in strategy_config) and (strategy_config["trading_mode"] in ["futures", "margin"]):
      self.is_futures_mode = True
      self.can_short = True

    # If the cached data hasn't changed, it's a no-op
    self.target_profit_cache.save()

    # Parameter settings. Backward compatibility with the old configuration style.
    self.update_signals_from_config(strategy_config)

  # Plot configuration for FreqUI
  # ---------------------------------------------------------------------------------------------
  @property
  def plot_config(self):
    plot_config = {}

    plot_config["main_plot"] = {
      "EMA_12": {"color": "LightGreen"},
      "EMA_26": {"color": "Yellow"},
      "EMA_50": {"color": "DodgerBlue"},
      "EMA_200": {"color": "DarkRed"},
    }

    plot_config["subplots"] = {
      "long_pump_protection": {"global_protections_long_pump": {"color": "green"}},
      "long_dump_protection": {"global_protections_long_dump": {"color": "red"}},
    }

    return plot_config

  # Get Ticker Indicator
  # ---------------------------------------------------------------------------------------------
  def get_ticker_indicator(self):
    return int(self.timeframe[:-1])

  # Mark Profit Target
  # ---------------------------------------------------------------------------------------------
  def mark_profit_target(
    self,
    mode_name: str,
    pair: str,
    sell: bool,
    signal_name: str,
    trade: Trade,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    last_candle,
    previous_candle_1,
  ) -> tuple:
    if sell and (signal_name is not None):
      return pair, signal_name

    return None, None

  # Exit Profit Target
  # ---------------------------------------------------------------------------------------------
  def exit_profit_target(
    self,
    mode_name: str,
    pair: str,
    trade: Trade,
    current_time: datetime,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    last_candle,
    previous_candle_1,
    previous_rate,
    previous_profit,
    previous_sell_reason,
    previous_time_profit_reached,
    enter_tags,
  ) -> tuple:
    remove_profit_target = self._remove_profit_target
    derisk_enable = self.derisk_enable
    is_futures_mode = self.is_futures_mode
    long_rapid_mode_tags = self.long_rapid_mode_tags
    long_rebuy_mode_tags = self.long_rebuy_mode_tags
    long_rebuy_grind_mode_tags = self.long_rebuy_grind_mode_tags
    long_scalp_mode_tags = self.long_scalp_mode_tags
    long_scalp_rebuy_grind_mode_tags = self.long_scalp_rebuy_grind_mode_tags
    trade_leverage = trade.leverage
    select_filled_orders = trade.select_filled_orders

    is_backtest = self.is_backtest_mode()
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    is_derisk = False
    if previous_sell_reason in [
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      filled_entries = select_filled_orders(trade.entry_side)
      filled_exits = select_filled_orders(trade.exit_side)
      first_filled_entry = filled_entries[0]
      has_order_tags = hasattr(first_filled_entry, "ft_order_tag")
      for order in filled_exits:
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag.partition(" ")[0]
        if order_tag in ["d", "d1", "derisk_level_1", "derisk_level_2", "derisk_level_3"]:
          is_derisk = True
          break
      if not is_derisk:
        is_derisk = trade.amount < (first_filled_entry.safe_filled * 0.95)
    if previous_sell_reason in [f"exit_{mode_name}_stoploss_doom", f"exit_{mode_name}_stoploss"]:
      # return right away for system v3
      if is_system_v3 or is_system_v3_1 or is_system_v3_2:
        return True, previous_sell_reason

      is_rapid_mode = all(c in long_rapid_mode_tags for c in enter_tags)
      is_rebuy_mode = all(c in long_rebuy_mode_tags for c in enter_tags) or (
        any(c in long_rebuy_mode_tags for c in enter_tags) and all(c in long_rebuy_grind_mode_tags for c in enter_tags)
      )
      is_scalp_mode = all(c in long_scalp_mode_tags for c in enter_tags) or (
        any(c in long_scalp_mode_tags for c in enter_tags)
        and all(c in long_scalp_rebuy_grind_mode_tags for c in enter_tags)
      )
      if profit_init_ratio > 0.0:
        # profit is over the threshold, don't exit
        remove_profit_target(pair)
        return False, None
      elif is_derisk:
        remove_profit_target(pair)
        return False, None
      elif derisk_enable and (current_time - timedelta(minutes=60) > previous_time_profit_reached):
        if profit_ratio < previous_profit:
          return True, previous_sell_reason
        elif profit_ratio > previous_profit:
          remove_profit_target(pair)
          return False, None
      elif (
        not derisk_enable
        and not is_rapid_mode
        and not is_rebuy_mode
        and not is_scalp_mode
        and (
          profit_init_ratio
          <= -(self.stop_threshold_doom_futures if is_futures_mode else self.stop_threshold_doom_spot)
        )
      ):
        return True, previous_sell_reason
      elif (
        not derisk_enable
        and is_rapid_mode
        and (
          profit_init_ratio
          <= -(self.stop_threshold_rapid_futures if is_futures_mode else self.stop_threshold_rapid_spot)
        )
      ):
        return True, previous_sell_reason
      elif (
        not derisk_enable
        and is_rebuy_mode
        and (
          profit_init_ratio
          <= -(self.stop_threshold_futures_rebuy if is_futures_mode else self.stop_threshold_spot_rebuy)
        )
      ):
        return True, previous_sell_reason
      elif (
        not derisk_enable
        and is_scalp_mode
        and (
          profit_init_ratio
          <= -(self.stop_threshold_scalp_futures if is_futures_mode else self.stop_threshold_scalp_spot)
        )
      ):
        return True, previous_sell_reason
    elif previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
      if profit_init_ratio > 0.0:
        # profit is over the threshold, don't exit
        remove_profit_target(pair)
        return False, None
      elif is_derisk:
        remove_profit_target(pair)
        return False, None
      elif profit_ratio < (previous_profit - (0.04 / trade_leverage)):
        return True, previous_sell_reason
    elif previous_sell_reason == f"exit_profit_{mode_name}_max":
      if profit_init_ratio < -0.08:
        # profit is under the threshold, cancel it
        remove_profit_target(pair)
        return False, None

      last_rsi_14 = last_candle["RSI_14"]
      previous_rsi_14 = previous_candle_1["RSI_14"]
      last_cmf_20 = last_candle["CMF_20"]
      last_cmf_20_1h = last_candle["CMF_20_1h"]
      last_cmf_20_4h = last_candle["CMF_20_4h"]
      last_roc_9_4h = last_candle["ROC_9_4h"]
      last_cmf_20_gt_0 = last_cmf_20 > 0.0
      last_cmf_20_1h_gt_0 = last_cmf_20_1h > 0.0
      last_cmf_20_4h_gt_0 = last_cmf_20_4h > 0.0
      last_rsi_14_gt_50 = last_rsi_14 > 50.0
      last_rsi_14_lt_50 = last_rsi_14 < 50.0
      last_roc_9_4h_gt_40 = last_roc_9_4h > 40.0
      last_roc_9_4h_lt_neg_40 = last_roc_9_4h < -40.0
      if trade.is_short:
        is_scalp_mode = all(c in self.short_scalp_mode_tags for c in enter_tags)
        if is_scalp_mode:
          if 0.001 <= profit_init_ratio < 0.01:
            if profit_init_ratio < (previous_profit - 0.008):
              return True, f"exit_profit_{mode_name}_t_0_1"
          elif 0.01 <= profit_init_ratio < 0.02:
            if profit_init_ratio < (previous_profit - 0.01):
              return True, f"exit_profit_{mode_name}_t_1_1"
          elif 0.02 <= profit_init_ratio < 0.03:
            if profit_init_ratio < (previous_profit - 0.01):
              return True, f"exit_profit_{mode_name}_t_2_1"
          elif 0.03 <= profit_init_ratio < 0.04:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_3_1"
          elif 0.04 <= profit_init_ratio < 0.05:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_4_1"
          elif 0.05 <= profit_init_ratio < 0.06:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_5_1"
          elif 0.06 <= profit_init_ratio < 0.07:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_6_1"
          elif 0.07 <= profit_init_ratio < 0.08:
            if profit_init_ratio < (previous_profit - 0.02):
              return True, f"exit_profit_{mode_name}_t_7_1"
          elif 0.08 <= profit_init_ratio < 0.09:
            if profit_init_ratio < (previous_profit - 0.02):
              return True, f"exit_profit_{mode_name}_t_8_1"
          elif 0.09 <= profit_init_ratio < 0.10:
            if profit_init_ratio < (previous_profit - 0.02):
              return True, f"exit_profit_{mode_name}_t_9_1"
          elif 0.10 <= profit_init_ratio < 0.11:
            if profit_init_ratio < (previous_profit - 0.025):
              return True, f"exit_profit_{mode_name}_t_10_1"
          elif 0.11 <= profit_init_ratio < 0.12:
            if profit_init_ratio < (previous_profit - 0.025):
              return True, f"exit_profit_{mode_name}_t_11_1"
          elif 0.12 <= profit_init_ratio:
            if profit_init_ratio < (previous_profit - 0.025):
              return True, f"exit_profit_{mode_name}_t_12_1"
        elif 0.001 <= profit_init_ratio < 0.01:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_0_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_0_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_0_3"
        elif 0.01 <= profit_init_ratio < 0.02:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_1_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_1_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_1_3"
        elif 0.02 <= profit_init_ratio < 0.03:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_2_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_2_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_2_3"
        elif 0.03 <= profit_init_ratio < 0.04:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_3_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_3_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_3_3"
        elif 0.04 <= profit_init_ratio < 0.05:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_4_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_4_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_4_3"
        elif 0.05 <= profit_init_ratio < 0.06:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_5_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_5_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_5_3"
        elif 0.06 <= profit_init_ratio < 0.07:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_6_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_6_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_6_3"
        elif 0.07 <= profit_init_ratio < 0.08:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_7_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_7_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_7_3"
        elif 0.08 <= profit_init_ratio < 0.09:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_8_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_8_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_8_3"
        elif 0.09 <= profit_init_ratio < 0.10:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_9_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_9_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_9_3"
        elif 0.10 <= profit_init_ratio < 0.11:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_10_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_10_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_10_3"
        elif 0.11 <= profit_init_ratio < 0.12:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_11_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_11_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_11_3"
        elif 0.12 <= profit_init_ratio:
          if (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_rsi_14_gt_50)
            and (last_rsi_14 > previous_rsi_14)
            and (last_cmf_20_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_12_1"
          elif (
            profit_init_ratio < (previous_profit - 0.03)
            and (last_cmf_20_gt_0)
            and (last_cmf_20_1h_gt_0)
            and (last_cmf_20_4h_gt_0)
          ):
            return True, f"exit_profit_{mode_name}_t_12_2"
          elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_lt_neg_40):
            return True, f"exit_profit_{mode_name}_t_12_3"
      else:
        is_scalp_mode = all(c in long_scalp_mode_tags for c in enter_tags)
        if is_scalp_mode:
          if 0.001 <= profit_init_ratio < 0.01:
            if profit_init_ratio < (previous_profit - 0.008):
              return True, f"exit_profit_{mode_name}_t_0_1"
          elif 0.01 <= profit_init_ratio < 0.02:
            if profit_init_ratio < (previous_profit - 0.01):
              return True, f"exit_profit_{mode_name}_t_1_1"
          elif 0.02 <= profit_init_ratio < 0.03:
            if profit_init_ratio < (previous_profit - 0.01):
              return True, f"exit_profit_{mode_name}_t_2_1"
          elif 0.03 <= profit_init_ratio < 0.04:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_3_1"
          elif 0.04 <= profit_init_ratio < 0.05:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_4_1"
          elif 0.05 <= profit_init_ratio < 0.06:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_5_1"
          elif 0.06 <= profit_init_ratio < 0.07:
            if profit_init_ratio < (previous_profit - 0.015):
              return True, f"exit_profit_{mode_name}_t_6_1"
          elif 0.07 <= profit_init_ratio < 0.08:
            if profit_init_ratio < (previous_profit - 0.02):
              return True, f"exit_profit_{mode_name}_t_7_1"
          elif 0.08 <= profit_init_ratio < 0.09:
            if profit_init_ratio < (previous_profit - 0.02):
              return True, f"exit_profit_{mode_name}_t_8_1"
          elif 0.09 <= profit_init_ratio < 0.10:
            if profit_init_ratio < (previous_profit - 0.02):
              return True, f"exit_profit_{mode_name}_t_9_1"
          elif 0.10 <= profit_init_ratio < 0.11:
            if profit_init_ratio < (previous_profit - 0.025):
              return True, f"exit_profit_{mode_name}_t_10_1"
          elif 0.11 <= profit_init_ratio < 0.12:
            if profit_init_ratio < (previous_profit - 0.025):
              return True, f"exit_profit_{mode_name}_t_11_1"
          elif 0.12 <= profit_init_ratio:
            if profit_init_ratio < (previous_profit - 0.025):
              return True, f"exit_profit_{mode_name}_t_12_1"
        else:
          if 0.001 <= profit_init_ratio < 0.01:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_0_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_0_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_0_3"
          elif 0.01 <= profit_init_ratio < 0.02:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_1_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_1_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_1_3"
          elif 0.02 <= profit_init_ratio < 0.03:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_2_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_2_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_2_3"
          elif 0.03 <= profit_init_ratio < 0.04:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_3_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_3_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_3_3"
          elif 0.04 <= profit_init_ratio < 0.05:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_4_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_4_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_4_3"
          elif 0.05 <= profit_init_ratio < 0.06:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_5_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_5_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_5_3"
          elif 0.06 <= profit_init_ratio < 0.07:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_6_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_6_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_6_3"
          elif 0.07 <= profit_init_ratio < 0.08:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_7_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_7_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_7_3"
          elif 0.08 <= profit_init_ratio < 0.09:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_8_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_8_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_8_3"
          elif 0.09 <= profit_init_ratio < 0.10:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_9_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_9_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_9_3"
          elif 0.10 <= profit_init_ratio < 0.11:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_10_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_10_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_10_3"
          elif 0.11 <= profit_init_ratio < 0.12:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_11_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_11_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_11_3"
          elif 0.12 <= profit_init_ratio:
            if (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_rsi_14_lt_50)
              and (last_rsi_14 < previous_rsi_14)
              and (last_cmf_20 < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_12_1"
            elif (
              profit_init_ratio < (previous_profit - 0.03)
              and (last_cmf_20 < -0.0)
              and (last_cmf_20_1h < -0.0)
              and (last_cmf_20_4h < -0.0)
            ):
              return True, f"exit_profit_{mode_name}_t_12_2"
            elif profit_init_ratio < (previous_profit - 0.05) and (last_roc_9_4h_gt_40):
              return True, f"exit_profit_{mode_name}_t_12_3"
    else:
      return False, None

    return False, None

  # Filled Order Snapshot
  # ---------------------------------------------------------------------------------------------
  def filled_order_snapshot(self, trade: "Trade") -> tuple:
    filled_orders = trade.select_filled_orders()
    filled_entries = []
    filled_exits = []
    append_entry = filled_entries.append
    append_exit = filled_exits.append
    entry_side = trade.entry_side
    exit_side = trade.exit_side
    for order in filled_orders:
      order_side = order.ft_order_side
      if order_side == entry_side:
        append_entry(order)
      elif order_side == exit_side:
        append_exit(order)
    return filled_orders, filled_entries, filled_exits

  @staticmethod
  def _bad_trade_controller_ema_gap_and_adverse_move(
    trade: "Trade", current_rate: float, last_candle, filled_entries: "Orders"
  ) -> tuple:
    """Return position-signed daily EMA gap and adverse move from the first filled entry."""
    ema_50_1d = last_candle.get("EMA_50_1d")
    ema_200_1d = last_candle.get("EMA_200_1d")
    if (
      ema_50_1d is None
      or ema_200_1d is None
      or not np.isfinite(ema_50_1d)
      or not np.isfinite(ema_200_1d)
      or ema_200_1d <= 0.0
    ):
      daily_ema_gap_pct = None
    else:
      daily_ema_gap_pct = (ema_50_1d / ema_200_1d - 1.0) * 100.0
      if trade.is_short:
        daily_ema_gap_pct = -daily_ema_gap_pct

    if not filled_entries:
      return daily_ema_gap_pct, None
    first_entry_rate = filled_entries[0].safe_price
    if first_entry_rate is None or not np.isfinite(first_entry_rate) or first_entry_rate <= 0.0:
      return daily_ema_gap_pct, None
    first_entry_adverse_move_pct = (
      ((current_rate - first_entry_rate) if trade.is_short else (first_entry_rate - current_rate))
      / first_entry_rate
      * 100.0
    )
    return daily_ema_gap_pct, first_entry_adverse_move_pct

  def _bad_trade_controller_exit_reason(
    self,
    trade: "Trade",
    current_time: "datetime",
    current_rate: float,
    last_candle,
    filled_entries: "Orders",
  ) -> Optional[str]:
    """Return an opt-in structure-break or stale-position exit reason."""
    daily_ema_gap_pct, first_entry_adverse_move_pct = self._bad_trade_controller_ema_gap_and_adverse_move(
      trade, current_rate, last_candle, filled_entries
    )
    if first_entry_adverse_move_pct is None or not np.isfinite(first_entry_adverse_move_pct):
      return None
    if (
      self.bad_trade_controller_structure_break_exit_enable
      and daily_ema_gap_pct is not None
      and daily_ema_gap_pct <= -self.bad_trade_controller_structure_break_ema_gap_pct
      and first_entry_adverse_move_pct >= self.bad_trade_controller_structure_break_min_adverse_move_pct
    ):
      return f"exit_bad_trade_broken_{first_entry_adverse_move_pct:.0f}pct"

    daily_range_pct_14_1d = last_candle.get("RANGE_PCT_14_1d")
    trade_age_days = (current_time - trade.open_date_utc).total_seconds() / 86400.0
    if (
      self.bad_trade_controller_stale_exit_enable
      and daily_range_pct_14_1d is not None
      and np.isfinite(daily_range_pct_14_1d)
      and daily_range_pct_14_1d < self.bad_trade_controller_stale_max_daily_range_pct
      and first_entry_adverse_move_pct >= self.bad_trade_controller_stale_min_adverse_move_pct
      and trade_age_days >= self.bad_trade_controller_stale_min_age_days
    ):
      return f"exit_bad_trade_abandon_{trade_age_days:.0f}d"
    return None

  def _boost_bad_trade_long_grind_stake(self, trade: "Trade", current_rate: float, max_stake: float, grind_adjustment):
    """Boost positive long-grind entries only, preserving the adjustment tag and limits."""
    if (
      not self.bad_trade_controller_enable
      or not self.bad_trade_controller_long_grind_stake_boost_enable
      or trade.is_short
      or grind_adjustment is None
    ):
      return grind_adjustment
    grind_stake = grind_adjustment[0] if isinstance(grind_adjustment, tuple) else grind_adjustment
    if grind_stake <= 0.0:
      return grind_adjustment
    analyzed_dataframe, _ = self.dp.get_analyzed_dataframe(trade.pair, self.timeframe)
    if len(analyzed_dataframe) < 1:
      return grind_adjustment
    filled_entries = trade.select_filled_orders(trade.entry_side)
    daily_ema_gap_pct, _ = self._bad_trade_controller_ema_gap_and_adverse_move(
      trade, current_rate, analyzed_dataframe.iloc[-1], filled_entries
    )
    if daily_ema_gap_pct is None or daily_ema_gap_pct <= 0.0:
      return grind_adjustment
    boosted_grind_stake = min(grind_stake * self.bad_trade_controller_long_grind_stake_multiplier, max_stake)
    if boosted_grind_stake <= grind_stake:
      return grind_adjustment
    log.info(
      "Bad-trade long-grind stake boost [%s] | tag %s | %.2f -> %.2f | daily EMA gap %.1f%%",
      trade.pair,
      trade.enter_tag,
      grind_stake,
      boosted_grind_stake,
      daily_ema_gap_pct,
    )
    return (boosted_grind_stake, *grind_adjustment[1:]) if isinstance(grind_adjustment, tuple) else boosted_grind_stake

  def trade_order_state(self, trade: "Trade") -> tuple:
    orders = trade.orders

    last_order = orders[-1] if orders else None
    return (
      len(orders),
      getattr(last_order, "id", None),
      getattr(last_order, "status", None),
      getattr(last_order, "filled", None),
    )

  def cache_backtest_profit_snapshot(
    self,
    trade: "Trade",
    current_time: "datetime",
    exit_rate: float,
    filled_orders: "Orders",
    filled_entries: "Orders",
    filled_exits: "Orders",
    profit_values: tuple,
  ) -> None:
    if not self.is_backtest_mode():
      return

    trade_key = trade.id if trade.id is not None else id(trade)
    self._backtest_profit_snapshot = (
      trade_key,
      current_time,
      exit_rate,
      self.trade_order_state(trade),
      filled_orders,
      filled_entries,
      filled_exits,
      profit_values,
    )

  def backtest_profit_snapshot(self, trade: "Trade", current_time: "datetime", exit_rate: float) -> tuple | None:
    if not self.is_backtest_mode():
      return None

    snapshot = getattr(self, "_backtest_profit_snapshot", None)
    if snapshot is None:
      return None

    (
      snapshot_trade_id,
      snapshot_time,
      snapshot_exit_rate,
      snapshot_order_state,
      filled_orders,
      filled_entries,
      filled_exits,
      profit_values,
    ) = snapshot
    trade_key = trade.id if trade.id is not None else id(trade)
    if (
      snapshot_trade_id == trade_key
      and snapshot_time == current_time
      and snapshot_exit_rate == exit_rate
      and snapshot_order_state == self.trade_order_state(trade)
    ):
      return filled_orders, filled_entries, filled_exits, profit_values

    return None

  def profit_or_order_snapshot(self, trade: "Trade", current_time: "datetime", exit_rate: float) -> tuple:
    profit_snapshot = self.backtest_profit_snapshot(trade, current_time, exit_rate)
    if profit_snapshot is not None:
      return profit_snapshot

    filled_orders, filled_entries, filled_exits = self.filled_order_snapshot(trade)
    return filled_orders, filled_entries, filled_exits, None

  # Calc Total Profit
  # ---------------------------------------------------------------------------------------------
  def calc_total_profit(
    self, trade: "Trade", filled_entries: "Orders", filled_exits: "Orders", exit_rate: float
  ) -> tuple:
    """
    Calculates the absolute profit for open trades.

    :param trade: trade object.
    :param filled_entries: Filled entries list.
    :param filled_exits: Filled exits list.
    :param exit_rate: The exit rate.
    :return tuple: The total profit in stake, ratio, ratio based on current stake, and ratio based on the first entry stake.
    """
    custom_fee_open_rate = self.custom_fee_open_rate
    custom_fee_close_rate = self.custom_fee_close_rate
    is_futures_mode = self.is_futures_mode

    fee_open_rate = trade.fee_open if custom_fee_open_rate is None else custom_fee_open_rate
    fee_close_rate = trade.fee_close if custom_fee_close_rate is None else custom_fee_close_rate

    total_amount = 0.0
    total_stake = 0.0
    total_profit = 0.0
    if trade.is_short:
      fee_open_multiplier = 1 - fee_open_rate
      fee_close_multiplier = 1 + fee_close_rate
      for entry_order in filled_entries:
        filled = entry_order.safe_filled
        entry_stake = filled * entry_order.safe_price * fee_open_multiplier
        total_amount += filled
        total_stake += entry_stake
        total_profit += entry_stake
      for exit_order in filled_exits:
        filled = exit_order.safe_filled
        exit_stake = filled * exit_order.safe_price * fee_close_multiplier
        total_amount -= filled
        total_profit -= exit_stake
      current_stake = total_amount * exit_rate * fee_close_multiplier
      total_profit -= current_stake
    else:
      fee_open_multiplier = 1 + fee_open_rate
      fee_close_multiplier = 1 - fee_close_rate
      for entry_order in filled_entries:
        filled = entry_order.safe_filled
        entry_stake = filled * entry_order.safe_price * fee_open_multiplier
        total_amount += filled
        total_stake += entry_stake
        total_profit -= entry_stake
      for exit_order in filled_exits:
        filled = exit_order.safe_filled
        exit_stake = filled * exit_order.safe_price * fee_close_multiplier
        total_amount -= filled
        total_profit += exit_stake
      current_stake = total_amount * exit_rate * fee_close_multiplier
      total_profit += current_stake
    if is_futures_mode and trade.funding_fees is not None:
      total_profit += trade.funding_fees
    total_profit_ratio = total_profit / total_stake
    current_profit_ratio = total_profit / current_stake
    init_profit_ratio = total_profit / (filled_entries[0].safe_filled * filled_entries[0].safe_price)
    return total_profit, total_profit_ratio, current_profit_ratio, init_profit_ratio

  @staticmethod
  def scale_stakes_for_min_stake(stakes, slice_amount, min_stake, stake_leverage, trade_leverage):
    if (slice_amount * stakes[0] / stake_leverage) >= min_stake:
      return stakes

    multi = min_stake / slice_amount / stakes[0] * trade_leverage
    return [stake * multi for stake in stakes]

  # Custom Exit
  # ---------------------------------------------------------------------------------------------
  def custom_exit(
    self, pair: str, trade: "Trade", current_time: "datetime", current_rate: float, current_profit: float, **kwargs
  ):
    trade_is_short = trade.is_short

    long_normal_mode_tags = self.long_normal_mode_tags
    long_pump_mode_tags = self.long_pump_mode_tags
    long_quick_mode_tags = self.long_quick_mode_tags
    long_rebuy_mode_tags = self.long_rebuy_mode_tags
    long_rebuy_grind_mode_tags = self.long_rebuy_grind_mode_tags
    long_high_profit_mode_tags = self.long_high_profit_mode_tags
    long_rapid_mode_tags = self.long_rapid_mode_tags
    long_rapid_rebuy_grind_scalp_mode_tags = self.long_rapid_rebuy_grind_scalp_mode_tags
    long_grind_mode_tags = self.long_grind_mode_tags
    long_btc_mode_tags = self.long_btc_mode_tags
    long_top_coins_mode_tags = self.long_top_coins_mode_tags
    long_scalp_mode_tags = self.long_scalp_mode_tags
    long_scalp_rebuy_grind_mode_tags = self.long_scalp_rebuy_grind_mode_tags
    long_known_mode_tags = self.long_known_mode_tags
    short_normal_mode_tags = self.short_normal_mode_tags
    short_pump_mode_tags = self.short_pump_mode_tags
    short_quick_mode_tags = self.short_quick_mode_tags
    short_rebuy_mode_tags = self.short_rebuy_mode_tags
    short_high_profit_mode_tags = self.short_high_profit_mode_tags
    short_rapid_mode_tags = self.short_rapid_mode_tags
    short_scalp_mode_tags = self.short_scalp_mode_tags
    short_scalp_rebuy_grind_mode_tags = self.short_scalp_rebuy_grind_mode_tags
    short_exit_known_mode_tags = self.short_exit_known_mode_tags

    calc_total_profit = self.calc_total_profit
    cache_backtest_profit_snapshot = self.cache_backtest_profit_snapshot
    filled_order_snapshot = self.filled_order_snapshot
    long_exit_normal = self.long_exit_normal
    long_exit_pump = self.long_exit_pump
    long_exit_quick = self.long_exit_quick
    short_exit_normal = self.short_exit_normal

    df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    previous_candle_1 = df.iloc[-2]

    enter_tag = "empty"
    if hasattr(trade, "enter_tag"):
      trade_enter_tag = trade.enter_tag
      if trade_enter_tag is not None:
        enter_tag = trade_enter_tag
    enter_tags = enter_tag.split()

    filled_orders, filled_entries, filled_exits = filled_order_snapshot(trade)

    profit_stake = 0.0
    profit_ratio = 0.0
    profit_current_stake_ratio = 0.0
    profit_init_ratio = 0.0
    profit_values = calc_total_profit(trade, filled_entries, filled_exits, current_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values
    cache_backtest_profit_snapshot(
      trade, current_time, current_rate, filled_orders, filled_entries, filled_exits, profit_values
    )

    if self.bad_trade_controller_enable and current_profit < 0.0:
      bad_trade_exit_reason = self._bad_trade_controller_exit_reason(
        trade, current_time, current_rate, last_candle, filled_entries
      )
      if bad_trade_exit_reason is not None:
        return f"{bad_trade_exit_reason} ( {enter_tag})"

    # Signal 192 (Quad pullback long) tight doom stop: every 192 loss bottoms at a
    # 11.8-14% price drop (the shared 0.35 doom threshold) while winners' max adverse
    # excursion sits below 9.63% price. Scoping 192's doom to -0.30 margin (~10% price
    # at 3x, ~30% at 1x) flips the tag net-positive. NOTE: this fires on ANY trade
    # carrying 192 as one of several tags, and it returns before long_exit_normal, so
    # for 192 it pre-empts the de-risk ladder (measured on a gms0 replica with derisk
    # off; production runs derisk on, where the ladder exists for exactly this zone).
    # On spot the -0.30 is looser than the existing doom thresholds (0.12 spot / 0.35
    # futures) and effectively never binds.
    if "192" in enter_tags and current_profit <= -0.30:
      return f"exit_long_normal_stoploss_doom ( {enter_tag})"

    max_profit = 0.0
    max_loss = 0.0

    # Long Normal mode
    if any(c in long_normal_mode_tags for c in enter_tags):
      sell, signal_name = long_exit_normal(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long Pump mode
    if any(c in long_pump_mode_tags for c in enter_tags):
      sell, signal_name = long_exit_pump(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long Quick mode
    if any(c in long_quick_mode_tags for c in enter_tags):
      sell, signal_name = long_exit_quick(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long Rebuy mode
    if all(c in long_rebuy_mode_tags for c in enter_tags) or (
      any(c in long_rebuy_mode_tags for c in enter_tags) and all(c in long_rebuy_grind_mode_tags for c in enter_tags)
    ):
      sell, signal_name = self.long_exit_rebuy(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long high profit mode
    if any(c in long_high_profit_mode_tags for c in enter_tags):
      sell, signal_name = self.long_exit_high_profit(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long rapid mode
    if all(c in long_rapid_mode_tags for c in enter_tags) or (
      any(c in long_rapid_mode_tags for c in enter_tags)
      and all(c in long_rapid_rebuy_grind_scalp_mode_tags for c in enter_tags)
    ):
      sell, signal_name = self.long_exit_rapid(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long grind mode
    if all(c in long_grind_mode_tags for c in enter_tags):
      sell, signal_name = self.long_exit_grind(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long btc mode
    if all(c in long_btc_mode_tags for c in enter_tags):
      sell, signal_name = self.long_exit_btc(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long Top Coins mode
    if any(c in long_top_coins_mode_tags for c in enter_tags):
      sell, signal_name = self.long_exit_top_coins(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Long scalp mode
    if all(c in long_scalp_mode_tags for c in enter_tags) or (
      any(c in long_scalp_mode_tags for c in enter_tags)
      and all(c in long_scalp_rebuy_grind_mode_tags for c in enter_tags)
    ):
      sell, signal_name = self.long_exit_scalp(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short normal mode
    if any(c in short_normal_mode_tags for c in enter_tags):
      sell, signal_name = short_exit_normal(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short Pump mode
    if any(c in short_pump_mode_tags for c in enter_tags):
      sell, signal_name = self.short_exit_pump(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short Quick mode
    if any(c in short_quick_mode_tags for c in enter_tags):
      sell, signal_name = self.short_exit_quick(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short Rebuy mode
    if all(c in short_rebuy_mode_tags for c in enter_tags):
      sell, signal_name = self.short_exit_rebuy(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short high profit mode
    if any(c in short_high_profit_mode_tags for c in enter_tags):
      sell, signal_name = self.short_exit_high_profit(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short rapid mode
    if any(c in short_rapid_mode_tags for c in enter_tags):
      sell, signal_name = self.short_exit_rapid(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Short scalp mode
    if all(c in short_scalp_mode_tags for c in enter_tags) or (
      any(c in short_scalp_mode_tags for c in enter_tags)
      and all(c in short_scalp_rebuy_grind_mode_tags for c in enter_tags)
    ):
      sell, signal_name = self.short_exit_scalp(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Trades not opened by X7
    if not trade_is_short and (not any(c in long_known_mode_tags for c in enter_tags)):
      # use normal mode for such trades
      sell, signal_name = long_exit_normal(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    # Trades not opened by X7
    if trade_is_short and (not any(c in short_exit_known_mode_tags for c in enter_tags)):
      # use normal mode for such trades
      sell, signal_name = short_exit_normal(
        pair,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
      if sell and (signal_name is not None):
        return f"{signal_name} ( {enter_tag})"

    return None

  # Custom Stake Amount
  # ---------------------------------------------------------------------------------------------
  def custom_stake_amount(
    self,
    pair: str,
    current_time: datetime,
    current_rate: float,
    proposed_stake: float,
    min_stake: Optional[float],
    max_stake: float,
    leverage: float,
    entry_tag: Optional[str],
    side: str,
    **kwargs,
  ) -> float:
    long_rebuy_mode_tags = self.long_rebuy_mode_tags
    long_rebuy_grind_mode_tags = self.long_rebuy_grind_mode_tags
    system_v3_rebuy_mode_stake_multiplier = self.system_v3_rebuy_mode_stake_multiplier
    system_v3_name = self.system_v3_name
    system_v3_2_name = self.system_v3_2_name
    system_v3_2_stake_multiplier = self.system_v3_2_stake_multiplier
    system_v3_1_name = self.system_v3_1_name
    system_v3_1_stake_multiplier = self.system_v3_1_stake_multiplier
    long_rapid_mode_tags = self.long_rapid_mode_tags
    short_rebuy_mode_tags = self.short_rebuy_mode_tags
    short_rebuy_grind_mode_tags = self.short_rebuy_grind_mode_tags
    short_rapid_mode_tags = self.short_rapid_mode_tags
    long_rapid_rebuy_grind_mode_tags = self.long_rapid_rebuy_grind_mode_tags
    long_grind_mode_tags = self.long_grind_mode_tags
    long_btc_mode_tags = self.long_btc_mode_tags
    short_rapid_rebuy_grind_mode_tags = self.short_rapid_rebuy_grind_mode_tags
    short_grind_mode_tags = self.short_grind_mode_tags

    enter_tags = entry_tag.split()
    is_futures_mode = self.is_futures_mode
    system_name_use = self.system_name_use
    system_name_is_v3 = system_name_use == system_v3_name
    system_name_is_v3_1 = system_name_use == system_v3_1_name
    system_name_is_v3_2 = system_name_use == system_v3_2_name
    grind_mode_stake_multiplier_futures = self.grind_mode_stake_multiplier_futures
    grind_mode_stake_multiplier_spot = self.grind_mode_stake_multiplier_spot
    rapid_mode_stake_multiplier_futures = self.rapid_mode_stake_multiplier_futures
    rapid_mode_stake_multiplier_spot = self.rapid_mode_stake_multiplier_spot
    regular_mode_stake_multiplier_futures = self.regular_mode_stake_multiplier_futures
    regular_mode_stake_multiplier_spot = self.regular_mode_stake_multiplier_spot
    grind_mode_stake_multipliers = (
      grind_mode_stake_multiplier_futures if is_futures_mode else grind_mode_stake_multiplier_spot
    )
    rapid_mode_stake_multipliers = (
      rapid_mode_stake_multiplier_futures if is_futures_mode else rapid_mode_stake_multiplier_spot
    )
    regular_mode_stake_multipliers = (
      regular_mode_stake_multiplier_futures if is_futures_mode else regular_mode_stake_multiplier_spot
    )

    def scaled_stake(stake_multiplier: float) -> float:
      stake = proposed_stake * stake_multiplier
      return stake if (min_stake is None) or (stake > min_stake) else min_stake

    if side == "long":
      # Rebuy mode
      if all(c in long_rebuy_mode_tags for c in enter_tags) or (
        any(c in long_rebuy_mode_tags for c in enter_tags) and all(c in long_rebuy_grind_mode_tags for c in enter_tags)
      ):
        return scaled_stake(system_v3_rebuy_mode_stake_multiplier)
      # Rapid mode
      if system_name_is_v3 and (
        all(c in long_rapid_mode_tags for c in enter_tags)
        or (
          any(c in long_rapid_mode_tags for c in enter_tags)
          and all(c in long_rapid_rebuy_grind_mode_tags for c in enter_tags)
        )
      ):
        return scaled_stake(rapid_mode_stake_multipliers[0])
      # Grind mode
      elif all(c in long_grind_mode_tags for c in enter_tags):
        for item in grind_mode_stake_multipliers:
          stake = proposed_stake * item
          if (min_stake is None) or (stake > min_stake):
            return stake
      # Btc mode
      elif all(c in long_btc_mode_tags for c in enter_tags):
        return proposed_stake * grind_mode_stake_multipliers[0]
      else:
        if system_name_is_v3_2:
          return scaled_stake(system_v3_2_stake_multiplier)
        elif system_name_is_v3_1:
          return scaled_stake(system_v3_1_stake_multiplier)
        else:
          return scaled_stake(regular_mode_stake_multipliers[0])
    else:
      # Rebuy mode
      if all(c in short_rebuy_mode_tags for c in enter_tags) or (
        any(c in short_rebuy_mode_tags for c in enter_tags)
        and all(c in short_rebuy_grind_mode_tags for c in enter_tags)
      ):
        return scaled_stake(system_v3_rebuy_mode_stake_multiplier)
      # Grind mode
      elif all(c in short_grind_mode_tags for c in enter_tags):
        for item in grind_mode_stake_multipliers:
          stake = proposed_stake * item
          if (min_stake is None) or (stake > min_stake):
            return stake
      # Rapid mode
      if system_name_is_v3 and (
        all(c in short_rapid_mode_tags for c in enter_tags)
        or (
          any(c in short_rapid_mode_tags for c in enter_tags)
          and all(c in short_rapid_rebuy_grind_mode_tags for c in enter_tags)
        )
      ):
        return scaled_stake(rapid_mode_stake_multipliers[0])
      else:
        if system_name_is_v3_2:
          return scaled_stake(system_v3_2_stake_multiplier)
        elif system_name_is_v3_1:
          return scaled_stake(system_v3_1_stake_multiplier)
        else:
          return scaled_stake(regular_mode_stake_multipliers[0])

    return proposed_stake

  # Order filled Callback
  # ---------------------------------------------------------------------------------------------
  def order_filled(self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs) -> None:
    # Check if it's the first entry
    system_name_use = self.system_name_use
    system_v3_2_name = self.system_v3_2_name
    system_v3_1_name = self.system_v3_1_name
    system_v3_name = self.system_v3_name
    set_custom_data = trade.set_custom_data

    if trade.nr_of_successful_entries == 1:
      if system_name_use == system_v3_2_name:
        set_custom_data(key="system_version", value=system_v3_2_name)
      elif system_name_use == system_v3_1_name:
        set_custom_data(key="system_version", value=system_v3_1_name)
      elif system_name_use == system_v3_name:
        set_custom_data(key="system_version", value=system_v3_name)
        # set initial data for the trade
        # trade.set_custom_data(key="grind_1_cluster_max_profit_stake", value=0.0)
        # trade.set_custom_data(key="grind_1_cluster_max_profit_rate", value=0.0)

        # trade.set_custom_data(key="grind_2_cluster_max_profit_stake", value=0.0)
        # trade.set_custom_data(key="grind_2_cluster_max_profit_rate", value=0.0)

        # trade.set_custom_data(key="grind_3_cluster_max_profit_stake", value=0.0)
        # trade.set_custom_data(key="grind_3_cluster_max_profit_rate", value=0.0)

        # trade.set_custom_data(key="grind_4_cluster_max_profit_stake", value=0.0)
        # trade.set_custom_data(key="grind_4_cluster_max_profit_rate", value=0.0)

        # trade.set_custom_data(key="grind_5_cluster_max_profit_stake", value=0.0)
        # trade.set_custom_data(key="grind_5_cluster_max_profit_rate", value=0.0)

    if system_name_use == system_v3_2_name:
      filled_entries = trade.select_filled_orders(trade.entry_side)

      order_tag = order.ft_order_tag
      if order_tag is None:
        return None
      order_mode = order_tag.split(" ", 1)
      order_tags = []
      if len(order_mode) > 0:
        order_mode = order_mode[0]
      order_tags = order_tag.split(" ")
      if len(order_tags) > 1:
        order_tags = order_tags[1:]
      if order_mode in ["derisk_level_1"]:
        trade.set_custom_data(key="derisk_level_1", value=True)
      elif order_mode in ["derisk_level_2"]:
        trade.set_custom_data(key="derisk_level_2", value=True)
      elif order_mode in ["derisk_level_3"]:
        trade.set_custom_data(key="derisk_level_3", value=True)

      # elif order_mode in ["grind_1_entry"]:
      # elif order_mode in ["grind_1_exit"]:
      #  trade.set_custom_data(key="grind_1_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_1_cluster_max_profit_rate", value=0.0)
      # elif order_mode in ["grind_1_derisk"]:
      #  trade.set_custom_data(key="grind_1_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_1_cluster_max_profit_rate", value=0.0)

      # elif order_mode in ["grind_2_exit"]:
      #  trade.set_custom_data(key="grind_2_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_2_cluster_max_profit_rate", value=0.0)
      # elif order_mode in ["grind_2_derisk"]:
      #  trade.set_custom_data(key="grind_2_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_2_cluster_max_profit_rate", value=0.0)

      # elif order_mode in ["grind_3_exit"]:
      #  trade.set_custom_data(key="grind_3_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_3_cluster_max_profit_rate", value=0.0)
      # elif order_mode in ["grind_3_derisk"]:
      #  trade.set_custom_data(key="grind_3_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_3_cluster_max_profit_rate", value=0.0)

      # elif order_mode in ["grind_4_exit"]:
      #  trade.set_custom_data(key="grind_4_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_4_cluster_max_profit_rate", value=0.0)
      # elif order_mode in ["grind_4_derisk"]:
      #  trade.set_custom_data(key="grind_4_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_4_cluster_max_profit_rate", value=0.0)

      # elif order_mode in ["grind_5_exit"]:
      #  trade.set_custom_data(key="grind_5_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_5_cluster_max_profit_rate", value=0.0)
      # elif order_mode in ["grind_5_derisk"]:
      #  trade.set_custom_data(key="grind_5_cluster_max_profit_stake", value=0.0)
      #  trade.set_custom_data(key="grind_5_cluster_max_profit_rate", value=0.0)

    return None

  # Adjust Trade Position
  # ---------------------------------------------------------------------------------------------
  def adjust_trade_position(
    self,
    trade: Trade,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    # =========================================================================
    # FAST EXIT
    # =========================================================================
    if not self.position_adjustment_enable:
      return None

    # =========================================================================
    # BASIC TRADE STATE
    # =========================================================================
    trade_is_short = trade.is_short
    enter_tag = "empty"
    if hasattr(trade, "enter_tag"):
      trade_enter_tag = trade.enter_tag
      if trade_enter_tag is not None:
        enter_tag = trade_enter_tag
    enter_tags = enter_tag.split()

    # =========================================================================
    # SYSTEM VERSION
    # =========================================================================
    is_backtest = self.is_backtest_mode()
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    is_system_v3_family = is_system_v3 or is_system_v3_1 or is_system_v3_2

    if is_backtest:
      is_v2_date = True
    else:
      is_v2_date = trade.open_date_utc.replace(tzinfo=None) >= datetime(2025, 2, 13)

    # =========================================================================
    # ARGS
    # =========================================================================
    args = (
      trade,
      enter_tags,
      current_time,
      current_rate,
      current_profit,
      min_stake,
      max_stake,
      current_entry_rate,
      current_exit_rate,
      current_entry_profit,
      current_exit_profit,
    )

    # =========================================================================
    # LONG
    # =========================================================================
    if not trade_is_short:
      # -----------------------------------------------------------------------
      # REBUY MODE
      # -----------------------------------------------------------------------
      is_long_rebuy = all(c in self.long_rebuy_mode_tags for c in enter_tags)
      if not is_long_rebuy:
        is_long_rebuy = any(c in self.long_rebuy_mode_tags for c in enter_tags) and all(
          c in self.long_rebuy_grind_mode_tags for c in enter_tags
        )

      if is_long_rebuy:
        if is_system_v3_family:
          return self.long_rebuy_adjust_trade_position_v3(*args)
        return self.long_rebuy_adjust_trade_position(*args)

      # -----------------------------------------------------------------------
      # LONG MODE CLASSIFICATION
      # -----------------------------------------------------------------------
      is_long_grind_mode = all(c in self.long_grind_mode_tags for c in enter_tags)
      is_long_btc_mode = all(c in self.long_btc_mode_tags for c in enter_tags)

      # -----------------------------------------------------------------------
      # V3 GRIND
      # -----------------------------------------------------------------------
      if is_system_v3_family:
        if not is_long_grind_mode and not is_long_btc_mode:
          is_long_adjust_mode = any(c in self.long_adjust_mode_tags for c in enter_tags)
          is_long_known_mode = any(c in self.long_known_mode_tags for c in enter_tags)

          if is_long_adjust_mode or not is_long_known_mode:
            grind_adjustment = self.long_grind_adjust_trade_position_v3(*args)
            return self._boost_bad_trade_long_grind_stake(trade, current_rate, max_stake, grind_adjustment)

        # ---------------------------------------------------------------------
        # LEGACY GRIND
        # ---------------------------------------------------------------------
        elif is_long_grind_mode or is_long_btc_mode or not is_v2_date:
          grind_adjustment = self.long_grind_adjust_trade_position(*args)
          return self._boost_bad_trade_long_grind_stake(trade, current_rate, max_stake, grind_adjustment)

      # -----------------------------------------------------------------------
      # V2 / LEGACY ROUTING
      # -----------------------------------------------------------------------
      if is_long_grind_mode or is_long_btc_mode or not is_v2_date:
        grind_adjustment = self.long_grind_adjust_trade_position(*args)
        return self._boost_bad_trade_long_grind_stake(trade, current_rate, max_stake, grind_adjustment)

      is_long_adjust_mode = any(c in self.long_adjust_mode_tags for c in enter_tags)
      is_long_known_mode = any(c in self.long_known_mode_tags for c in enter_tags)

      if is_long_adjust_mode or not is_long_known_mode:
        grind_adjustment = self.long_grind_adjust_trade_position_v2(*args)
        return self._boost_bad_trade_long_grind_stake(trade, current_rate, max_stake, grind_adjustment)

    # =========================================================================
    # SHORT
    # =========================================================================
    else:
      # -----------------------------------------------------------------------
      # REBUY MODE
      # -----------------------------------------------------------------------
      is_short_rebuy = all(c in self.short_rebuy_mode_tags for c in enter_tags)
      if not is_short_rebuy:
        is_short_rebuy = any(c in self.short_rebuy_mode_tags for c in enter_tags) and all(
          c in self.short_rebuy_grind_mode_tags for c in enter_tags
        )
      if is_short_rebuy:
        if is_system_v3_family:
          return self.short_rebuy_adjust_trade_position_v3(*args)
        return self.short_rebuy_adjust_trade_position(*args)

      # -----------------------------------------------------------------------
      # SHORT MODE CLASSIFICATION
      # -----------------------------------------------------------------------
      is_short_grind_mode = all(c in self.short_grind_mode_tags for c in enter_tags)

      # -----------------------------------------------------------------------
      # V3 GRIND
      # -----------------------------------------------------------------------
      if is_system_v3_family:
        if not is_short_grind_mode:
          is_short_adjust_mode = any(c in self.short_adjust_mode_tags for c in enter_tags)
          is_short_known_mode = any(c in self.short_known_mode_tags for c in enter_tags)

          if is_short_adjust_mode or not is_short_known_mode:
            return self.short_grind_adjust_trade_position_v3(*args)

        # ---------------------------------------------------------------------
        # LEGACY GRIND
        # ---------------------------------------------------------------------
        elif is_short_grind_mode or not is_v2_date:
          return self.short_grind_adjust_trade_position(*args)

      # -----------------------------------------------------------------------
      # V2 / LEGACY ROUTING
      # -----------------------------------------------------------------------
      if is_short_grind_mode or not is_v2_date:
        return self.short_grind_adjust_trade_position(*args)

      is_short_adjust_mode = any(c in self.short_adjust_mode_tags for c in enter_tags)
      is_short_known_mode = any(c in self.short_known_mode_tags for c in enter_tags)

      if is_short_adjust_mode or not is_short_known_mode:
        return self.short_grind_adjust_trade_position_v2(*args)

    return None

  def notification_msg(
    self,
    msg_type: str,
    tag: str,
    pair: str,
    rate: float,
    stake_amount: float,
    profit_stake: float,
    profit_ratio: float,
    grind_profit_stake: float = None,
    grind_profit_pct: float = None,
    stake_currency: str = None,
    coin_amount: float = None,
  ) -> str:
    """
    Generate a formatted notification message for trade events.

    This function is designed to standardize trade-related notifications
    such as grinding entries, exits, stop-losses, buybacks, and re-entries.
    It builds a Markdown-formatted message with emojis for readability.

    Parameters
    ----------
    msg_type : str
        Type of notification. Must be one of:
        - "grinding-entry"
        - "grinding-exit"
        - "grinding-derisk"
        - "grinding-stop"
        - "buyback-entry"
        - "buyback-exit"
        - "buyback-derisk"
        - "re-entry"
        - "de-risk"
        - "rebuy-derisk"
        - "rebuy"
    tag : str
        Identifier or label for the trade step (e.g., "g1", "dl1").
    pair : str
        Pair (e.g., "BTC/USDT").
    rate : float
        Entry or exit rate for the trade.
    stake_amount : float
        Amount of stake used in the trade.
    profit_stake : float
        Profit expressed in stake currency.
    profit_ratio : float
        Profit ratio (decimal form, e.g. 0.05 = 5%).
    grind_profit_stake : float, optional
        Grind profit expressed in stake currency (default: None).
    grind_profit_pct : float, optional
        Grind profit ratio (decimal form, e.g. 0.02 = 2%) (default: None).
    stake_currency : str, optional
        Symbol of the stake currency (e.g., "USDT"). If None, only numeric values are shown.
    coin_amount : float, optional
        Amount of base coins involved in the trade (e.g., exit/stop cases).

    Returns
    -------
    str
        A formatted multi-line string with trade details.
        Example:
        ```
        ✅ **Grinding entry:** `(dl1)`
        🏦 **Exchange:** `Binance`
        🪙 **Pair:** `BTC/USDT`
        〽️ **Rate:** `20000.0`
        💰 **Stake amount:** `100.00 USDT`
        💵 **Profit (stake):** `5.00 USDT`
        💸 **Profit (percent):** `5.00%`
        💶 **Grind profit (stake):** `2.00 USDT`
        💸 **Grind profit (percent):** `2.00%`
        ```

    Notes
    -----
    - The function uses Markdown formatting (e.g., **bold**, `inline code`)
      for compatibility with Discord, Telegram, etc.
    - If `grind_profit_stake` or `grind_profit_pct` are not provided,
      the related fields are omitted.
    - If `stake_currency` is provided, it will be appended to amounts.
    """
    # Skip in backtesting / hyperopt
    if self.is_backtest_mode():
      return ""

    # Headers for different message types
    header_labels = {
      "grinding-entry": "✅ ​**Grinding entry:** ",
      "grinding-exit": "❎​ ​**Grinding exit:** ",
      "grinding-derisk": "❌​​ ​**Grinding de-risk:** ",
      "grinding-stop": "❌ ​**Grinding stop exit:** ",
      "buyback-entry": "✅ ​**Buyback entry:** ",
      "buyback-exit": "❎​​ ​**Buyback exit:** ",
      "buyback-derisk": "❌​​ ​**Buyback de-risk:** ",
      "re-entry": "✅ ​**Re-entry:** ",
      "de-risk": "❌​​ ​**De-risk:** ",
      "rebuy-derisk": "❌​​ ​**Rebuy de-risk:** ",
      "rebuy": "✅ ​**Rebuy:** ",
    }

    # Start with the header
    header_label = header_labels.get(msg_type, None)
    msg = None if header_label is None else f"{header_label}`({tag})`\n"

    # Add exchange information
    exchange_name = getattr(self, "config", {}).get("exchange", {}).get("name", "Unknown").capitalize()
    msg += f"🏦 **Exchange:** `{exchange_name}`\n"

    # Common fields
    msg += (
      f"🪙 **Pair:** `{pair}`\n"
      f"〽️ **Rate:** `{rate}`\n"
      f"💰 **Stake amount:** `{stake_amount:.2f}{'' if stake_currency is None else ' ' + stake_currency}`\n"
    )

    # Add coin amount if available (exit/stop cases)
    if coin_amount is not None:
      msg += f"🪙 **Coin amount:** `{coin_amount}`\n"

    # Profit section
    profit_pct = profit_ratio * 100
    msg += (
      f"💵 **Profit (stake):** `{profit_stake:.2f}{'' if stake_currency is None else ' ' + stake_currency}`\n"
      f"💸 **Profit (percent):** `{profit_pct:.2f}%`\n"
    )

    # Grind profit calculation
    if grind_profit_stake is not None and grind_profit_stake != 0:
      msg += f"💶 **Grind profit (stake):** `{grind_profit_stake:.2f}{'' if stake_currency is None else ' ' + stake_currency}`\n"
    if grind_profit_pct is not None and grind_profit_pct != 0:
      msg += f"💸 **Grind profit (percent):** `{(grind_profit_pct * 100.0):.2f}%`"

    return msg

  def btc_informative_pair(self) -> str:
    stake_currency = self.config["stake_currency"]
    is_futures = self.config.get("trading_mode") in ("futures", "margin")

    if stake_currency in self.stable_stake_currencies:
      return f"BTC/{stake_currency}:{stake_currency}" if is_futures else f"BTC/{stake_currency}"

    return "BTC/USDT:USDT" if is_futures else "BTC/USDT"

  def prepare_informative_merge(self, informative: DataFrame, keep_ohlcv=None) -> DataFrame:
    if informative.empty:
      return informative

    keep_ohlcv = keep_ohlcv or ()
    keep_cols = [
      column
      for column in informative.columns
      if column == "date" or column not in self.informative_ohlcv_columns or column in keep_ohlcv
    ]

    return informative[keep_cols]

  # Informative Pairs
  # ---------------------------------------------------------------------------------------------
  def informative_pairs(self):
    # get access to all pairs available in whitelist.
    pairs = self.dp.current_whitelist()

    # Use set to automatically avoid duplicates
    informative_pairs = set()

    # Assign tf to each pair so they can be downloaded and cached for strategy.
    for info_timeframe in self.info_timeframes:
      informative_pairs.update((pair, info_timeframe) for pair in pairs)

    btc_info_pair = self.btc_informative_pair()

    informative_pairs.update((btc_info_pair, btc_info_timeframe) for btc_info_timeframe in self.btc_info_timeframes)

    return list(informative_pairs)

  @staticmethod
  def chaikin_money_flow(high, low, close, volume, timeperiod=20):
    hl_range = high - low
    mfm = np.zeros_like(close, dtype=np.float64)
    valid = hl_range != 0
    mfm[valid] = ((close[valid] - low[valid]) - (high[valid] - close[valid])) / hl_range[valid]
    mfv = mfm * volume

    stacked = np.vstack([mfv, volume])
    stacked_clean = np.nan_to_num(stacked, nan=0.0)
    csum = np.cumsum(stacked_clean, axis=1)
    csum[:, timeperiod:] -= csum[:, :-timeperiod]

    out = np.full(stacked.shape, np.nan, dtype=np.float64)
    out[:, timeperiod - 1 :] = csum[:, timeperiod - 1 :]
    mfv_sum, vol_sum = out[0], out[1]
    vol_sum = np.where(vol_sum == 0, np.nan, vol_sum)
    return mfv_sum / vol_sum

  @staticmethod
  def fast_pct_change(arr: np.ndarray) -> np.ndarray:
    """
    Compute the percentage change between consecutive values.

    The first element is set to NaN. Division-by-zero cases also
    return NaN instead of producing invalid or infinite values.
    """
    arr = np.asarray(arr, dtype=np.float64)
    out = np.full(arr.shape, np.nan, dtype=np.float64)
    prev = arr[:-1]
    np.divide((arr[1:] - prev), prev, out=out[1:], where=prev != 0)
    out[1:] *= 100.0

    return out

  @staticmethod
  def stochrsi_k(rsi_14: np.ndarray, ta_min: np.ndarray, ta_max: np.ndarray, ta_sma: np.ndarray) -> np.ndarray:
    """
    Calculate the %K line of the Stochastic RSI.

    Stochastic RSI normalizes RSI values relative to their recent
    14-period range, then applies a 3-period SMA smoothing.

    Periods where the RSI range is zero are marked as NaN to prevent
    invalid values from producing misleading momentum signals.
    """
    rsi_min = ta_min(rsi_14, timeperiod=14)
    rsi_max = ta_max(rsi_14, timeperiod=14)
    denom = rsi_max - rsi_min
    denom = np.where(denom == 0, np.nan, denom)
    stochrsi = ((rsi_14 - rsi_min) / denom) * 100.0

    return ta_sma(stochrsi, timeperiod=3)

  @staticmethod
  def calc_kst(close: np.ndarray, ta_roc, ta_sma) -> tuple[np.ndarray, np.ndarray]:
    roc10 = ta_roc(close, 10)
    roc15 = ta_roc(close, 15)
    roc20 = ta_roc(close, 20)
    roc30 = ta_roc(close, 30)
    kst1 = ta_sma(roc10, 10)
    kst2 = ta_sma(roc15, 10)
    kst3 = ta_sma(roc20, 10)
    kst4 = ta_sma(roc30, 15)
    kst_main = kst1 + (2.0 * kst2) + (3.0 * kst3) + (4.0 * kst4)
    kst_signal = ta_sma(kst_main, 9)

    return kst_main, kst_signal

  @staticmethod
  def validate_indicators(df: pd.DataFrame, columns: list[str], pair: str, timeframe: str) -> None:
    expected_len = len(df)
    for col in columns:
      # Missing column
      if col not in df.columns:
        log.warning(f"[{pair}] [{timeframe}] Missing column: {col}")
        continue

      series = df[col]

      # Length check
      if len(series) != expected_len:
        log.warning(f"[{pair}] [{timeframe}] {col} length mismatch: {len(series)} != {expected_len}")

      # Dtype check
      if not pd.api.types.is_numeric_dtype(series):
        log.warning(f"[{pair}] [{timeframe}] {col} non-numeric dtype: {series.dtype}")
        continue

      arr = series.to_numpy(copy=False)

      # Empty array protection
      if arr.size == 0:
        log.warning(f"[{pair}] [{timeframe}] {col} empty array")
        continue

      # Inf check
      inf_count = np.isinf(arr).sum()

      if inf_count:
        log.warning(f"[{pair}] [{timeframe}] {col} contains {inf_count} inf values")

      # NaN diagnostics
      nan_count = np.isnan(arr).sum()

      if nan_count == expected_len:
        log.warning(f"[{pair}] [{timeframe}] {col} is ALL NaN")

      elif nan_count:
        nan_pct = (nan_count / expected_len) * 100.0

        if nan_pct > 50.0:
          log.warning(f"[{pair}] [{timeframe}] {col} has {nan_pct:.1f}% NaN")
        else:
          log.debug("[%s] [%s] %s NaNs: %s (%.1f%%)", pair, timeframe, col, nan_count, nan_pct)

  @staticmethod
  def np_shift(arr, periods):
    out = np.empty_like(arr)
    out[:periods] = np.nan
    out[periods:] = arr[:-periods]
    return out

  # Informative 1d Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def informative_1d_indicators(self, metadata: dict, info_timeframe) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp
    fast_pct_change = self.fast_pct_change
    stochrsi_k_func = self.stochrsi_k
    chaikin_money_flow = self.chaikin_money_flow
    ta_rsi = ta.RSI
    ta_aroon = ta.AROON
    ta_roc = ta.ROC
    ta_min = ta.MIN
    ta_max = ta.MAX
    ta_sma = ta.SMA

    assert dp, "DataProvider is required for multiple timeframes."

    # Get dataframe
    metadata_pair = metadata["pair"]
    informative_1d = dp.get_pair_dataframe(pair=metadata_pair, timeframe=info_timeframe)

    # Empty dataframe protection
    if informative_1d.empty:
      return informative_1d

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = informative_1d["close"].to_numpy(copy=False)
    high_np = informative_1d["high"].to_numpy(copy=False)
    low_np = informative_1d["low"].to_numpy(copy=False)
    open_np = informative_1d["open"].to_numpy(copy=False)
    volume_np = informative_1d["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_3 = ta_rsi(close_np, timeperiod=3)
    rsi_14 = ta_rsi(close_np, timeperiod=14)
    aroon_down, aroon_up = ta_aroon(high_np, low_np, timeperiod=14)

    # =========================================================================
    # STOCH
    # =========================================================================
    _, stoch_k = ta.STOCHF(high_np, low_np, close_np, fastk_period=14, fastd_period=3, fastd_matype=0)
    stochrsi_k = stochrsi_k_func(rsi_14, ta_min, ta_max, ta_sma)

    # =========================================================================
    # MONEY FLOW
    # =========================================================================
    mfi_14 = ta.MFI(high_np, low_np, close_np, volume_np, timeperiod=14)
    cmf_20 = chaikin_money_flow(high_np, low_np, close_np, volume_np, timeperiod=20)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    willr_14 = ta.WILLR(high_np, low_np, close_np, timeperiod=14)
    roc_2 = ta_roc(close_np, timeperiod=2)
    roc_9 = ta_roc(close_np, timeperiod=9)

    # =========================================================================
    # RSI CHANGE %
    # =========================================================================
    rsi3_change = fast_pct_change(rsi_3)

    # =========================================================================
    # CANDLE %
    # =========================================================================
    open_safe = np.where(open_np == 0, np.nan, open_np)
    change_pct = ((close_np - open_np) / open_safe) * 100.0

    # =========================================================================
    # WICK %
    # =========================================================================
    max_oc = np.maximum(open_np, close_np)
    min_oc = np.minimum(open_np, close_np)
    max_oc_calc = np.where(max_oc == 0, np.nan, max_oc)
    min_oc_calc = np.where(min_oc == 0, np.nan, min_oc)
    top_wick_pct = ((high_np - max_oc) / max_oc_calc) * 100.0
    bot_wick_pct = np.abs(((low_np - min_oc) / min_oc_calc) * 100.0)

    # =========================================================================
    # HIGH / LOW ROLLING
    # =========================================================================
    high_max_6 = ta_max(high_np, timeperiod=6)
    high_max_12 = ta_max(high_np, timeperiod=12)
    high_max_20 = ta_max(high_np, timeperiod=20)
    high_max_30 = ta_max(high_np, timeperiod=30)
    low_min_6 = ta_min(low_np, timeperiod=6)
    low_min_12 = ta_min(low_np, timeperiod=12)
    low_min_20 = ta_min(low_np, timeperiod=20)
    low_min_30 = ta_min(low_np, timeperiod=30)

    bad_trade_controller_indicators = {}
    if self.bad_trade_controller_enable:
      nonzero_low_np = np.where(low_np == 0.0, np.nan, low_np)
      daily_range_pct_np = (high_np - low_np) / nonzero_low_np * 100.0
      bad_trade_controller_indicators = {
        "EMA_50": ta.EMA(close_np, timeperiod=50),
        "EMA_200": ta.EMA(close_np, timeperiod=200),
        "RANGE_PCT_14": ta_sma(daily_range_pct_np, timeperiod=14),
      }

    # =========================================================================
    # ASSIGN DATAFRAME
    # =========================================================================
    new_cols = pd.DataFrame(
      {
        "RSI_3": rsi_3,
        "RSI_14": rsi_14,
        "STOCHk_14_3_3": stoch_k,
        "STOCHRSIk_14_14_3_3": stochrsi_k,
        "MFI_14": mfi_14,
        "CMF_20": cmf_20,
        "WILLR_14": willr_14,
        "AROONU_14": aroon_up,
        "AROOND_14": aroon_down,
        "ROC_2": roc_2,
        "ROC_9": roc_9,
        "RSI_3_change_pct": rsi3_change,
        "change_pct": change_pct,
        "top_wick_pct": top_wick_pct,
        "bot_wick_pct": bot_wick_pct,
        "high_max_6": high_max_6,
        "high_max_12": high_max_12,
        "high_max_20": high_max_20,
        "high_max_30": high_max_30,
        "low_min_6": low_min_6,
        "low_min_12": low_min_12,
        "low_min_20": low_min_20,
        "low_min_30": low_min_30,
        **bad_trade_controller_indicators,
      },
      index=informative_1d.index,
    )
    informative_1d = pd.concat([informative_1d, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "RSI_3",
        "RSI_14",
        "STOCHk_14_3_3",
        "STOCHRSIk_14_14_3_3",
        "MFI_14",
        "CMF_20",
        "WILLR_14",
        "AROONU_14",
        "AROOND_14",
        "ROC_2",
        "ROC_9",
        "RSI_3_change_pct",
        "change_pct",
        "top_wick_pct",
        "bot_wick_pct",
        "high_max_6",
        "high_max_12",
        "high_max_20",
        "high_max_30",
        "low_min_6",
        "low_min_12",
        "low_min_20",
        "low_min_30",
      ]
      if self.bad_trade_controller_enable:
        debug_cols.extend(["EMA_50", "EMA_200", "RANGE_PCT_14"])

      self.validate_indicators(df=informative_1d, columns=debug_cols, pair=metadata_pair, timeframe=info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] informative_1d_indicators took: %.4f seconds.", metadata_pair, tok - tik)

    return informative_1d

  # Informative 4h Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def informative_4h_indicators(self, metadata: dict, info_timeframe) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp
    fast_pct_change = self.fast_pct_change
    stochrsi_k_func = self.stochrsi_k
    chaikin_money_flow = self.chaikin_money_flow
    calc_kst = self.calc_kst
    ta_rsi = ta.RSI
    ta_aroon = ta.AROON
    ta_sma = ta.SMA
    ta_roc = ta.ROC
    ta_ema = ta.EMA
    ta_max = ta.MAX
    ta_min = ta.MIN
    ta_bbands = ta.BBANDS

    assert dp, "DataProvider is required for multiple timeframes."

    # Get dataframe
    metadata_pair = metadata["pair"]
    informative_4h = dp.get_pair_dataframe(pair=metadata_pair, timeframe=info_timeframe)

    # Empty dataframe protection
    if informative_4h.empty:
      return informative_4h

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = informative_4h["close"].to_numpy(copy=False)
    high_np = informative_4h["high"].to_numpy(copy=False)
    low_np = informative_4h["low"].to_numpy(copy=False)
    open_np = informative_4h["open"].to_numpy(copy=False)
    volume_np = informative_4h["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_3 = ta_rsi(close_np, timeperiod=3)
    rsi_14 = ta_rsi(close_np, timeperiod=14)
    aroon_down, aroon_up = ta_aroon(high_np, low_np, timeperiod=14)
    bb_upper_20, _, bb_lower_20 = ta_bbands(close_np, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
    bbp_20 = (close_np - bb_lower_20) / np.where(bb_upper_20 - bb_lower_20 == 0, np.nan, bb_upper_20 - bb_lower_20)

    # =========================================================================
    # STOCH
    # =========================================================================
    _, stoch_k = ta.STOCHF(high_np, low_np, close_np, fastk_period=14, fastd_period=3, fastd_matype=0)
    stochrsi_k = stochrsi_k_func(rsi_14, ta_min, ta_max, ta_sma)

    # =========================================================================
    # KST
    # =========================================================================
    kst_main, kst_signal = calc_kst(close_np, ta_roc, ta_sma)

    # =========================================================================
    # MONEY FLOW
    # =========================================================================
    mfi_14 = ta.MFI(high_np, low_np, close_np, volume_np, timeperiod=14)
    cmf_20 = chaikin_money_flow(high_np, low_np, close_np, volume_np, timeperiod=20)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_12 = ta_ema(close_np, timeperiod=12)
    ema_50 = ta_ema(close_np, timeperiod=50)
    ema_100 = ta_ema(close_np, timeperiod=100)
    ema_200 = ta_ema(close_np, timeperiod=200)
    willr_14 = ta.WILLR(high_np, low_np, close_np, timeperiod=14)
    uo = ta.ULTOSC(high_np, low_np, close_np)
    roc_2 = ta_roc(close_np, timeperiod=2)
    roc_9 = ta_roc(close_np, timeperiod=9)
    cci_20 = ta.CCI(high_np, low_np, close_np, timeperiod=20)

    # =========================================================================
    # CHANGE %
    # =========================================================================
    rsi_3_change = fast_pct_change(rsi_3)
    rsi_14_change = fast_pct_change(rsi_14)
    stochrsi_change = fast_pct_change(stochrsi_k)
    cci_change = fast_pct_change(cci_20)

    # =========================================================================
    # CANDLE %
    # =========================================================================
    open_safe = np.where(open_np == 0, np.nan, open_np)
    change_pct = ((close_np - open_np) / open_safe) * 100.0

    # =========================================================================
    # WICK %
    # =========================================================================
    max_oc = np.maximum(open_np, close_np)
    max_oc_calc = np.where(max_oc == 0, np.nan, max_oc)
    top_wick_pct = ((high_np - max_oc) / max_oc_calc) * 100.0

    # =========================================================================
    # ROLLING
    # =========================================================================
    high_max_6 = ta_max(high_np, timeperiod=6)
    high_max_12 = ta_max(high_np, timeperiod=12)
    high_max_24 = ta_max(high_np, timeperiod=24)
    low_min_12 = ta_min(low_np, timeperiod=12)
    low_min_24 = ta_min(low_np, timeperiod=24)

    # ADX/DMI — trend strength + direction (signals 7/505 experimental; NFI's first ADX use)
    adx_14 = ta.ADX(high_np, low_np, close_np, timeperiod=14)
    plus_di_14 = ta.PLUS_DI(high_np, low_np, close_np, timeperiod=14)
    minus_di_14 = ta.MINUS_DI(high_np, low_np, close_np, timeperiod=14)

    # =========================================================================
    # ASSIGN DATAFRAME
    # =========================================================================
    new_cols = pd.DataFrame(
      {
        "RSI_3": rsi_3,
        "RSI_14": rsi_14,
        "ADX_14": adx_14,
        "PLUS_DI_14": plus_di_14,
        "MINUS_DI_14": minus_di_14,
        "AROONU_14": aroon_up,
        "AROOND_14": aroon_down,
        "BBP_20_2.0": bbp_20,
        "STOCHk_14_3_3": stoch_k,
        "STOCHRSIk_14_14_3_3": stochrsi_k,
        "KST_10_15_20_30_10_10_10_15": kst_main,
        "KSTs_9": kst_signal,
        "MFI_14": mfi_14,
        "CMF_20": cmf_20,
        "EMA_12": ema_12,
        "EMA_50": ema_50,
        "EMA_100": ema_100,
        "EMA_200": ema_200,
        "WILLR_14": willr_14,
        "UO_7_14_28": uo,
        "ROC_2": roc_2,
        "ROC_9": roc_9,
        "CCI_20": cci_20,
        "STOCHRSIk_14_14_3_3_change_pct": stochrsi_change,
        "CCI_20_change_pct": cci_change,
        "RSI_3_change_pct": rsi_3_change,
        "RSI_14_change_pct": rsi_14_change,
        "change_pct": change_pct,
        "top_wick_pct": top_wick_pct,
        "high_max_6": high_max_6,
        "high_max_12": high_max_12,
        "high_max_24": high_max_24,
        "low_min_12": low_min_12,
        "low_min_24": low_min_24,
      },
      index=informative_4h.index,
    )

    informative_4h = pd.concat([informative_4h, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "RSI_3",
        "RSI_14",
        "AROONU_14",
        "AROOND_14",
        "STOCHk_14_3_3",
        "STOCHRSIk_14_14_3_3",
        "KST_10_15_20_30_10_10_10_15",
        "KSTs_9",
        "MFI_14",
        "CMF_20",
        "EMA_12",
        "EMA_50",
        "EMA_100",
        "EMA_200",
        "WILLR_14",
        "UO_7_14_28",
        "ROC_2",
        "ROC_9",
        "CCI_20",
        "STOCHRSIk_14_14_3_3_change_pct",
        "CCI_20_change_pct",
        "RSI_3_change_pct",
        "RSI_14_change_pct",
        "OBV_change_pct",
        "change_pct",
        "high_max_6",
        "high_max_12",
        "high_max_24",
        "low_min_12",
        "low_min_24",
      ]

      self.validate_indicators(df=informative_4h, columns=debug_cols, pair=metadata_pair, timeframe=info_timeframe)
    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] informative_4h_indicators took: %.4f seconds.", metadata_pair, tok - tik)

    return informative_4h

  # Informative 1h Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def informative_1h_indicators(self, metadata: dict, info_timeframe) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp
    fast_pct_change = self.fast_pct_change
    stochrsi_k_func = self.stochrsi_k
    chaikin_money_flow = self.chaikin_money_flow
    calc_kst = self.calc_kst
    ta_rsi = ta.RSI
    ta_bbands = ta.BBANDS
    ta_aroon = ta.AROON
    ta_sma = ta.SMA
    ta_roc = ta.ROC
    ta_ema = ta.EMA
    ta_willr = ta.WILLR
    ta_max = ta.MAX
    ta_min = ta.MIN

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================

    metadata_pair = metadata["pair"]
    informative_1h = dp.get_pair_dataframe(pair=metadata_pair, timeframe=info_timeframe)

    # Empty dataframe protection
    if informative_1h.empty:
      return informative_1h

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = informative_1h["close"].to_numpy(copy=False)
    high_np = informative_1h["high"].to_numpy(copy=False)
    low_np = informative_1h["low"].to_numpy(copy=False)
    open_np = informative_1h["open"].to_numpy(copy=False)
    volume_np = informative_1h["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_3 = ta_rsi(close_np, timeperiod=3)
    rsi_14 = ta_rsi(close_np, timeperiod=14)
    bb_upper, bb_middle, bb_lower = ta_bbands(close_np, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
    bb_middle_safe = np.where(bb_middle == 0, np.nan, bb_middle)
    aroon_down, aroon_up = ta_aroon(high_np, low_np, timeperiod=14)

    # =========================================================================
    # STOCH
    # =========================================================================
    _, stoch_k = ta.STOCHF(high_np, low_np, close_np, fastk_period=14, fastd_period=3, fastd_matype=0)
    stochrsi_k = stochrsi_k_func(rsi_14, ta_min, ta_max, ta_sma)

    # =========================================================================
    # KST
    # =========================================================================
    kst_main, kst_signal = calc_kst(close_np, ta_roc, ta_sma)

    # =========================================================================
    # MONEY FLOW
    # =========================================================================
    mfi_14 = ta.MFI(high_np, low_np, close_np, volume_np, timeperiod=14)
    cmf_20 = chaikin_money_flow(high_np, low_np, close_np, volume_np, timeperiod=20)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_12 = ta_ema(close_np, timeperiod=12)
    ema_200 = ta_ema(close_np, timeperiod=200)
    sma_16 = ta_sma(close_np, timeperiod=16)
    willr_14 = ta_willr(high_np, low_np, close_np, timeperiod=14)
    willr_84 = ta_willr(high_np, low_np, close_np, timeperiod=84)
    uo = ta.ULTOSC(high_np, low_np, close_np)
    roc_2 = ta_roc(close_np, timeperiod=2)
    roc_9 = ta_roc(close_np, timeperiod=9)
    cci_20 = ta.CCI(high_np, low_np, close_np, timeperiod=20)

    # =========================================================================
    # CHANGE %
    # =========================================================================
    rsi_3_change = fast_pct_change(rsi_3)
    rsi_14_change = fast_pct_change(rsi_14)
    cci_change = fast_pct_change(cci_20)

    # =========================================================================
    # CANDLE %
    # =========================================================================
    open_safe = np.where(open_np == 0, np.nan, open_np)
    change_pct = ((close_np - open_np) / open_safe) * 100.0

    # =========================================================================
    # ROLLING
    # =========================================================================
    high_max_6 = ta_max(high_np, timeperiod=6)
    high_max_12 = ta_max(high_np, timeperiod=12)
    high_max_24 = ta_max(high_np, timeperiod=24)
    low_min_6 = ta_min(low_np, timeperiod=6)
    low_min_12 = ta_min(low_np, timeperiod=12)
    low_min_24 = ta_min(low_np, timeperiod=24)

    new_cols = pd.DataFrame(
      {
        "RSI_3": rsi_3,
        "RSI_14": rsi_14,
        "RSI_3_change_pct": rsi_3_change,
        "RSI_14_change_pct": rsi_14_change,
        "EMA_12": ema_12,
        "EMA_200": ema_200,
        "SMA_16": sma_16,
        "BBL_20_2.0": bb_lower,
        "BBU_20_2.0": bb_upper,
        "BBB_20_2.0": ((bb_upper - bb_lower) / bb_middle_safe) * 100.0,
        "MFI_14": mfi_14,
        "CMF_20": cmf_20,
        "WILLR_14": willr_14,
        "WILLR_84": willr_84,
        "AROONU_14": aroon_up,
        "AROOND_14": aroon_down,
        "STOCHk_14_3_3": stoch_k,
        "STOCHRSIk_14_14_3_3": stochrsi_k,
        "KST_10_15_20_30_10_10_10_15": kst_main,
        "KSTs_9": kst_signal,
        "UO_7_14_28": uo,
        "ROC_2": roc_2,
        "ROC_9": roc_9,
        "CCI_20": cci_20,
        "CCI_20_change_pct": cci_change,
        "change_pct": change_pct,
        "high_max_6": high_max_6,
        "high_max_12": high_max_12,
        "high_max_24": high_max_24,
        "low_min_6": low_min_6,
        "low_min_12": low_min_12,
        "low_min_24": low_min_24,
      },
      index=informative_1h.index,
    )

    informative_1h = pd.concat([informative_1h, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "RSI_3",
        "RSI_14",
        "RSI_3_change_pct",
        "RSI_14_change_pct",
        "EMA_12",
        "EMA_200",
        "SMA_16",
        "BBL_20_2.0",
        "BBU_20_2.0",
        "BBB_20_2.0",
        "MFI_14",
        "CMF_20",
        "WILLR_14",
        "WILLR_84",
        "AROONU_14",
        "AROOND_14",
        "STOCHk_14_3_3",
        "STOCHRSIk_14_14_3_3",
        "KST_10_15_20_30_10_10_10_15",
        "KSTs_9",
        "UO_7_14_28",
        "ROC_2",
        "ROC_9",
        "CCI_20",
        "CCI_20_change_pct",
        "change_pct",
        "high_max_6",
        "high_max_12",
        "high_max_24",
        "low_min_6",
        "low_min_12",
        "low_min_24",
      ]

      self.validate_indicators(df=informative_1h, columns=debug_cols, pair=metadata_pair, timeframe=info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] informative_1h_indicators took: %.4f seconds.", metadata_pair, tok - tik)

    return informative_1h

  # Informative 15m Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def informative_15m_indicators(self, metadata: dict, info_timeframe) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp
    fast_pct_change = self.fast_pct_change
    stochrsi_k_func = self.stochrsi_k
    chaikin_money_flow = self.chaikin_money_flow
    ta_rsi = ta.RSI
    ta_aroon = ta.AROON
    ta_ema = ta.EMA
    ta_min = ta.MIN
    ta_max = ta.MAX
    ta_sma = ta.SMA

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================

    metadata_pair = metadata["pair"]
    informative_15m = dp.get_pair_dataframe(pair=metadata_pair, timeframe=info_timeframe)

    # Empty dataframe protection
    if informative_15m.empty:
      return informative_15m

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = informative_15m["close"].to_numpy(copy=False)
    high_np = informative_15m["high"].to_numpy(copy=False)
    low_np = informative_15m["low"].to_numpy(copy=False)
    open_np = informative_15m["open"].to_numpy(copy=False)
    volume_np = informative_15m["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_3 = ta_rsi(close_np, timeperiod=3)
    rsi_14 = ta_rsi(close_np, timeperiod=14)
    aroon_down, aroon_up = ta_aroon(high_np, low_np, timeperiod=14)

    # =========================================================================
    # STOCH
    # =========================================================================
    _, stoch_k = ta.STOCHF(high_np, low_np, close_np, fastk_period=14, fastd_period=3, fastd_matype=0)
    stochrsi_k = stochrsi_k_func(rsi_14, ta_min, ta_max, ta_sma)

    # =========================================================================
    # MONEY FLOW
    # =========================================================================
    mfi_14 = ta.MFI(high_np, low_np, close_np, volume_np, timeperiod=14)
    cmf_20 = chaikin_money_flow(high_np, low_np, close_np, volume_np, timeperiod=20)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_12 = ta_ema(close_np, timeperiod=12)
    ema_20 = ta_ema(close_np, timeperiod=20)
    ema_26 = ta_ema(close_np, timeperiod=26)
    ema_50 = ta_ema(close_np, timeperiod=50)
    ema_200 = ta_ema(close_np, timeperiod=200)
    willr_14 = ta.WILLR(high_np, low_np, close_np, timeperiod=14)
    uo = ta.ULTOSC(high_np, low_np, close_np)
    obv = ta.OBV(close_np, volume_np)
    roc_9 = ta.ROC(close_np, timeperiod=9)
    cci_20 = ta.CCI(high_np, low_np, close_np, timeperiod=20)

    # =========================================================================
    # CHANGE %
    # =========================================================================
    rsi_3_change = fast_pct_change(rsi_3)
    rsi_14_change = fast_pct_change(rsi_14)
    uo_change = fast_pct_change(uo)
    obv_change = fast_pct_change(obv)
    cci_change = fast_pct_change(cci_20)

    # =========================================================================
    # CANDLE %
    # =========================================================================
    open_safe = np.where(open_np == 0, np.nan, open_np)
    change_pct = ((close_np - open_np) / open_safe) * 100.0

    new_cols = pd.DataFrame(
      {
        "RSI_3": rsi_3,
        "RSI_14": rsi_14,
        "RSI_3_change_pct": rsi_3_change,
        "RSI_14_change_pct": rsi_14_change,
        "EMA_12": ema_12,
        "EMA_20": ema_20,
        "EMA_26": ema_26,
        "EMA_50": ema_50,
        "EMA_200": ema_200,
        "MFI_14": mfi_14,
        "CMF_20": cmf_20,
        "WILLR_14": willr_14,
        "AROONU_14": aroon_up,
        "AROOND_14": aroon_down,
        "STOCHk_14_3_3": stoch_k,
        "STOCHRSIk_14_14_3_3": stochrsi_k,
        "UO_7_14_28": uo,
        "UO_7_14_28_change_pct": uo_change,
        "OBV_change_pct": obv_change,
        "ROC_9": roc_9,
        "CCI_20": cci_20,
        "CCI_20_change_pct": cci_change,
        "change_pct": change_pct,
      },
      index=informative_15m.index,
    )

    informative_15m = pd.concat([informative_15m, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "RSI_3",
        "RSI_14",
        "RSI_3_change_pct",
        "RSI_14_change_pct",
        "EMA_12",
        "EMA_20",
        "EMA_26",
        "EMA_50",
        "EMA_200",
        "MFI_14",
        "CMF_20",
        "WILLR_14",
        "AROONU_14",
        "AROOND_14",
        "STOCHk_14_3_3",
        "STOCHRSIk_14_14_3_3",
        "UO_7_14_28",
        "UO_7_14_28_change_pct",
        "OBV_change_pct",
        "ROC_9",
        "CCI_20",
        "CCI_20_change_pct",
        "change_pct",
      ]

      self.validate_indicators(df=informative_15m, columns=debug_cols, pair=metadata_pair, timeframe=info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] informative_15m_indicators took: %.4f seconds.", metadata_pair, tok - tik)

    return informative_15m

  # Coin Pair Base Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def base_tf_5m_indicators(self, metadata: dict, df: DataFrame) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    metadata_pair = metadata["pair"]
    fast_pct_change = self.fast_pct_change
    stochrsi_k_func = self.stochrsi_k
    chaikin_money_flow = self.chaikin_money_flow
    calc_kst = self.calc_kst
    np_shift = self.np_shift
    ta_rsi = ta.RSI
    ta_bbands = ta.BBANDS
    ta_aroon = ta.AROON
    ta_sma = ta.SMA
    ta_roc = ta.ROC
    ta_willr = ta.WILLR
    ta_ema = ta.EMA
    ta_max = ta.MAX
    ta_min = ta.MIN
    ta_stochf = ta.STOCHF
    ta_obv = ta.OBV
    ta_mfi = ta.MFI
    ta_sum = ta.SUM
    ta_stddev = ta.STDDEV

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = df["close"].to_numpy(copy=False)
    high_np = df["high"].to_numpy(copy=False)
    low_np = df["low"].to_numpy(copy=False)
    open_np = df["open"].to_numpy(copy=False)
    volume_np = df["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_3 = ta_rsi(close_np, timeperiod=3)
    rsi_4 = ta_rsi(close_np, timeperiod=4)
    rsi_14 = ta_rsi(close_np, timeperiod=14)
    rsi_20 = ta_rsi(close_np, timeperiod=20)
    bb_upper_20, bb_middle_20, bb_lower_20 = ta_bbands(close_np, timeperiod=20, nbdevup=2.0, nbdevdn=2.0, matype=0)
    bb_middle_20_safe = np.where(bb_middle_20 == 0, np.nan, bb_middle_20)
    bb_above_mask = close_np > bb_upper_20
    bb_below_mask = close_np < bb_lower_20
    idx = np.arange(close_np.size)
    last_false_above_idx = np.maximum.accumulate(np.where(bb_above_mask, -1, idx))
    bb_above_count = idx - last_false_above_idx
    last_false_below_idx = np.maximum.accumulate(np.where(bb_below_mask, -1, idx))
    bb_below_count = idx - last_false_below_idx
    bb_upper_40, bb_middle_40, bb_lower_40 = ta_bbands(close_np, timeperiod=40, nbdevup=2.0, nbdevdn=2.0, matype=0)
    aroon_down, aroon_up = ta_aroon(high_np, low_np, timeperiod=14)

    # =========================================================================
    # STOCH RSI
    # =========================================================================
    stochrsi_k = stochrsi_k_func(rsi_14, ta_min, ta_max, ta_sma)

    # =========================================================================
    # KST
    # =========================================================================
    kst_main, kst_signal = calc_kst(close_np, ta_roc, ta_sma)

    # =========================================================================
    # MONEY FLOW
    # =========================================================================
    mfi_14 = ta_mfi(high_np, low_np, close_np, volume_np, timeperiod=14)
    cmf_20 = chaikin_money_flow(high_np, low_np, close_np, volume_np, timeperiod=20)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_9 = ta_ema(close_np, timeperiod=9)
    ema_12 = ta_ema(close_np, timeperiod=12)
    ema_16 = ta_ema(close_np, timeperiod=16)
    ema_20 = ta_ema(close_np, timeperiod=20)
    ema_26 = ta_ema(close_np, timeperiod=26)
    ema_50 = ta_ema(close_np, timeperiod=50)
    ema_100 = ta_ema(close_np, timeperiod=100)
    ema_200 = ta_ema(close_np, timeperiod=200)
    sma_9 = ta_sma(close_np, timeperiod=9)
    sma_16 = ta_sma(close_np, timeperiod=16)
    sma_21 = ta_sma(close_np, timeperiod=21)
    sma_30 = ta_sma(close_np, timeperiod=30)
    sma_200 = ta_sma(close_np, timeperiod=200)
    willr_14 = ta_willr(high_np, low_np, close_np, timeperiod=14)
    willr_480 = ta_willr(high_np, low_np, close_np, timeperiod=480)
    roc_2 = ta_roc(close_np, timeperiod=2)
    roc_9 = ta_roc(close_np, timeperiod=9)
    obv = ta_obv(close_np, volume_np)

    # =========================================================================
    # CHANGE %
    # =========================================================================
    rsi_14_change = fast_pct_change(rsi_14)
    obv_change = fast_pct_change(obv)

    # =========================================================================
    # CANDLE %
    # =========================================================================
    open_safe = np.where(open_np == 0, np.nan, open_np)
    change_pct = ((close_np - open_np) / open_safe) * 100.0

    # =========================================================================
    # Close delta
    # =========================================================================
    close_delta = np.empty_like(close_np, dtype=np.float64)
    close_delta[0] = np.nan
    close_delta[1:] = np.abs(np.diff(close_np))

    # =========================================================================
    # Rolling values
    # =========================================================================
    close_max_6 = ta_max(close_np, timeperiod=6)
    close_max_12 = ta_max(close_np, timeperiod=12)
    close_max_48 = ta_max(close_np, timeperiod=48)
    close_min_6 = ta_min(close_np, timeperiod=6)
    close_min_12 = ta_min(close_np, timeperiod=12)
    close_min_48 = ta_min(close_np, timeperiod=48)
    num_empty_288 = ta_sum((volume_np <= 0).astype(np.float64), timeperiod=288)

    # =========================================================================
    # Leviathan volume/CVD-imitation columns
    # =========================================================================
    vol_ema_20 = ta_ema(volume_np, timeperiod=20)
    # _vol_std_20 = pd.Series(volume_np).rolling(20).std().to_numpy()
    # TA-Lib uses population std; adjust to match Pandas rolling std (ddof=1)
    vol_std_20 = ta_stddev(volume_np, timeperiod=20, nbdev=1.0) * np.sqrt(20.0 / 19.0)
    large_bubble_thr = vol_ema_20 + 3.0 * vol_std_20
    hl_range = high_np - low_np
    hl_range_safe = np.where(hl_range == 0.0, np.nan, hl_range)
    cvd_buy_vol = volume_np * (close_np - low_np) / hl_range_safe
    cvd_sell_vol = volume_np * (high_np - close_np) / hl_range_safe

    # =========================================================================
    # QUAD ROTATION STOCHASTICS + pivot windows (signals 192/193 long, 592/593 short — experimental)
    # =========================================================================
    quad_s93 = ta_stochf(high_np, low_np, close_np, fastk_period=9, fastd_period=3, fastd_matype=0)[0]
    quad_s143 = ta_stochf(high_np, low_np, close_np, fastk_period=14, fastd_period=3, fastd_matype=0)[0]
    quad_s44 = ta_stochf(high_np, low_np, close_np, fastk_period=4, fastd_period=4, fastd_matype=0)[0]
    quad_s6010 = ta_stochf(high_np, low_np, close_np, fastk_period=60, fastd_period=10, fastd_matype=0)[0]
    quad_low_min_12 = ta_min(low_np, timeperiod=12)
    quad_high_max_12 = ta_max(high_np, timeperiod=12)
    quad_s93_min_12 = ta_min(quad_s93, timeperiod=12)
    quad_s93_max_12 = ta_max(quad_s93, timeperiod=12)
    # quad_low_min_12 = pd.Series(low_np).rolling(12).min().to_numpy()
    # quad_high_max_12 = pd.Series(high_np).rolling(12).max().to_numpy()
    # quad_s93_min_12 = pd.Series(quad_s93).rolling(12).min().to_numpy()
    # quad_s93_max_12 = pd.Series(quad_s93).rolling(12).max().to_numpy()

    # =========================================================================
    # 4H OPENING RANGE (UTC day) — signals 164/662 (experimental, Data Trader port)
    # =========================================================================
    _or_day = df["date"].dt.floor("1D")
    _or_first4h = df["date"].dt.hour < 4
    _or_valid = df["date"].dt.hour >= 4
    orange_h_col = df["high"].where(_or_first4h).groupby(_or_day).transform("max").where(_or_valid).to_numpy()
    orange_l_col = df["low"].where(_or_first4h).groupby(_or_day).transform("min").where(_or_valid).to_numpy()

    # =========================================================================
    # SQUEEZE MOMENTUM (LazyBear) — signals 166/664 (experimental): BB inside Keltner = coil
    # =========================================================================
    _sq_ma = ta_sma(close_np, timeperiod=20)
    _sq_rng = ta_sma(high_np - low_np, timeperiod=20)
    _sq_kc_u = _sq_ma + 1.5 * _sq_rng
    _sq_kc_l = _sq_ma - 1.5 * _sq_rng
    sqz_on_col = ((bb_lower_20 > _sq_kc_l) & (bb_upper_20 < _sq_kc_u)).astype(np.float64)
    sqz_cnt24_col = ta_sum(sqz_on_col, timeperiod=24)
    # _sq_ma = pd.Series(close_np).rolling(20).mean()
    # _sq_rng = pd.Series(high_np - low_np).rolling(20).mean()
    # _sq_kc_u = (_sq_ma + 1.5 * _sq_rng).to_numpy()
    # _sq_kc_l = (_sq_ma - 1.5 * _sq_rng).to_numpy()
    # sqz_on_col = ((bb_lower_20 > _sq_kc_l) & (bb_upper_20 < _sq_kc_u)).astype(float)
    # sqz_cnt24_col = pd.Series(sqz_on_col).rolling(24).sum().to_numpy()

    # =========================================================================
    # Engulfing candle pattern — signals 167/665 (experimental): opposite-color body engulf
    # =========================================================================
    _eng_po = np.empty_like(open_np)
    _eng_pc = np.empty_like(close_np)
    _eng_po[0] = _eng_pc[0] = np.nan
    _eng_po[1:] = open_np[:-1]
    _eng_pc[1:] = close_np[:-1]
    engulf_bull_col = (
      (_eng_pc < _eng_po) & (close_np > open_np) & (close_np >= _eng_po) & (open_np <= _eng_pc)
    ).astype(float)
    engulf_bear_col = (
      (_eng_pc > _eng_po) & (close_np < open_np) & (close_np <= _eng_po) & (open_np >= _eng_pc)
    ).astype(float)

    # _eng_po = pd.Series(open_np).shift(1).to_numpy()
    # _eng_pc = pd.Series(close_np).shift(1).to_numpy()
    # engulf_bull_col = (
    # (_eng_pc < _eng_po) & (close_np > open_np) & (close_np >= _eng_po) & (open_np <= _eng_pc)
    # ).astype(float)
    # engulf_bear_col = (
    # (_eng_pc > _eng_po) & (close_np < open_np) & (close_np <= _eng_po) & (open_np >= _eng_pc)
    # ).astype(float)

    # =========================================================================
    # Swing-failure pattern (SFP) — signals 168/666 (experimental): sweep & reclaim of the prior 48-candle extreme
    # =========================================================================
    _sfp_prev_low = np_shift(ta_min(low_np, timeperiod=48), 1)
    _sfp_prev_high = np_shift(ta_max(high_np, timeperiod=48), 1)
    sfp_bull_col = ((low_np < _sfp_prev_low) & (close_np > _sfp_prev_low)).astype(float)
    sfp_bear_col = ((high_np > _sfp_prev_high) & (close_np < _sfp_prev_high)).astype(float)
    # _sfp_prev_low = pd.Series(low_np).rolling(48).min().shift(1).to_numpy()
    # _sfp_prev_high = pd.Series(high_np).rolling(48).max().shift(1).to_numpy()
    # sfp_bull_col = ((low_np < _sfp_prev_low) & (close_np > _sfp_prev_low)).astype(float)
    # sfp_bear_col = ((high_np > _sfp_prev_high) & (close_np < _sfp_prev_high)).astype(float)

    # =========================================================================
    # 1h inside-bar breakout — signals 169/667 (experimental): source insists on 1h+ candles
    # =========================================================================
    _ib_hr = df["date"].dt.floor("1h")
    _ib_agg = df.groupby(_ib_hr).agg(_ib_hh=("high", "max"), _ib_ll=("low", "min"))
    _ib_agg["_ib_flag"] = (_ib_agg["_ib_hh"] < _ib_agg["_ib_hh"].shift(1)) & (
      _ib_agg["_ib_ll"] > _ib_agg["_ib_ll"].shift(1)
    )
    _ib_agg["_ib_mh"] = _ib_agg["_ib_hh"].shift(1)
    _ib_agg["_ib_ml"] = _ib_agg["_ib_ll"].shift(1)
    _ib_prev_hr = _ib_hr - pd.Timedelta(hours=1)
    ib_ready_col = _ib_prev_hr.map(_ib_agg["_ib_flag"]).eq(True).astype(float).to_numpy()
    ib_mother_h_col = _ib_prev_hr.map(_ib_agg["_ib_mh"]).to_numpy()
    ib_mother_l_col = _ib_prev_hr.map(_ib_agg["_ib_ml"]).to_numpy()

    # =========================================================================
    # Crash-bounce hunter — signal 170 (experimental): rolling 24h return for capitulation context
    # =========================================================================
    roc_288_col = ta_roc(close_np, timeperiod=288)
    # relative volume: current candle volume vs its 24h average (confirmation qualifier, not a trigger)
    _vol_ma = ta_sma(volume_np, timeperiod=288)
    # _vol_ma = pd.Series(volume_np).rolling(288).mean().to_numpy()
    vol_rel_col = np.divide(volume_np, _vol_ma, out=np.full_like(_vol_ma, np.nan), where=_vol_ma > 0)

    # =========================================================================
    # Pump hunter — signal 171 (experimental): rolling 24h return + relative volume + first-fire dedup
    # =========================================================================
    _ph_prev_max = np_shift(ta_max(close_np, timeperiod=48), 1)
    _ph_cross = ((close_np > _ph_prev_max) & (np_shift(close_np, 1) <= _ph_prev_max)).astype(float)
    _ph_cross[0] = 0.0
    ph_cross_cnt12_col = ta_sum(_ph_cross, timeperiod=12)
    # Pump character: height above the 24h low
    _ph_low288 = ta_min(low_np, timeperiod=288)
    ph_base_pos_col = (
      np.divide(close_np - _ph_low288, close_np, out=np.full_like(close_np, np.nan), where=close_np > 0) * 100.0
    )
    # Prior 12-candle range, excluding current candle
    _ph_h12 = np_shift(ta_max(high_np, timeperiod=12), 1)
    _ph_l12 = np_shift(ta_min(low_np, timeperiod=12), 1)
    ph_pre_tight_col = (
      np.divide(_ph_h12 - _ph_l12, close_np, out=np.full_like(close_np, np.nan), where=close_np > 0) * 100.0
    )

    # _ph_prev_max = pd.Series(close_np).rolling(48).max().shift(1).to_numpy()
    # _ph_cross = ((close_np > _ph_prev_max) & (np.roll(close_np, 1) <= _ph_prev_max)).astype(float)
    # _ph_cross[0] = 0.0
    # ph_cross_cnt12_col = pd.Series(_ph_cross).rolling(12).sum().to_numpy()
    # pump character: height above the 24h low + prior-hour activity (both PRE-ignition)
    # _ph_low288 = pd.Series(low_np).rolling(288).min().to_numpy()
    # ph_base_pos_col = (
    # np.divide(close_np - _ph_low288, close_np, out=np.full_like(close_np, np.nan), where=close_np > 0) * 100.0
    # )
    # _ph_h12 = pd.Series(high_np).rolling(12).max().shift(1).to_numpy()
    # _ph_l12 = pd.Series(low_np).rolling(12).min().shift(1).to_numpy()
    # ph_pre_tight_col = (
    # np.divide(_ph_h12 - _ph_l12, close_np, out=np.full_like(close_np, np.nan), where=close_np > 0) * 100.0
    # )

    # =========================================================================
    # Marubozu — signals 172/670 (experimental): full-body candle = pure momentum ignition
    # =========================================================================
    _mrb_rng = high_np - low_np
    _mrb_body_ratio = np.divide(np.abs(close_np - open_np), _mrb_rng, out=np.zeros_like(_mrb_rng), where=_mrb_rng > 0)
    _mrb_body_pct = np.divide(np.abs(close_np - open_np), close_np, out=np.zeros_like(close_np), where=close_np > 0)
    mrb_bull_col = ((close_np > open_np) & (_mrb_body_ratio > 0.9) & (_mrb_body_pct > 0.005)).astype(float)
    mrb_bear_col = ((close_np < open_np) & (_mrb_body_ratio > 0.9) & (_mrb_body_pct > 0.005)).astype(float)

    # =========================================================================
    # Dump hunter — signal 669 (experimental): mirror of the pump hunter (171)
    # =========================================================================
    dh_prev_min_col = np_shift(ta_min(close_np, timeperiod=48), 1)
    # Pin-bar / hammer
    _pb_body = np.abs(close_np - open_np)
    _pb_lower = np.minimum(open_np, close_np) - low_np
    _pb_upper = high_np - np.maximum(open_np, close_np)
    _pb_body_safe = np.where(_pb_body > 0, _pb_body, np.nan)
    hammer_col = (
      (_pb_lower > 2.0 * _pb_body_safe) & (_pb_upper < 0.5 * _pb_body_safe) & (_pb_lower > close_np * 0.004)
    ).astype(float)
    star_col = (
      (_pb_upper > 2.0 * _pb_body_safe) & (_pb_lower < 0.5 * _pb_body_safe) & (_pb_upper > close_np * 0.004)
    ).astype(float)

    # dh_prev_min_col = pd.Series(close_np).rolling(48).min().shift(1).to_numpy()
    # Pin-bar / hammer — signals 173/671 (experimental): long rejection wick = a completed fact
    # _pb_body = np.abs(close_np - open_np)
    # _pb_lower = np.minimum(open_np, close_np) - low_np
    # _pb_upper = high_np - np.maximum(open_np, close_np)
    # _pb_body_safe = np.where(_pb_body > 0, _pb_body, np.nan)
    # hammer_col = np.nan_to_num(
    # ((_pb_lower > 2.0 * _pb_body_safe) & (_pb_upper < 0.5 * _pb_body_safe) & (_pb_lower > close_np * 0.004)).astype(
    #    float
    #  )
    # )
    # star_col = np.nan_to_num(
    #  ((_pb_upper > 2.0 * _pb_body_safe) & (_pb_lower < 0.5 * _pb_body_safe) & (_pb_upper > close_np * 0.004)).astype(
    #    float
    #  )
    # )

    # =========================================================================
    # Donchian 7-day channel — signals 8/506 (experimental): turtle-style macro breakout
    # =========================================================================
    dc_high_7d_col = np_shift(ta_max(close_np, timeperiod=2016), 1)
    dc_low_7d_col = np_shift(ta_min(close_np, timeperiod=2016), 1)
    # dc_high_7d_col = pd.Series(close_np).rolling(2016).max().shift(1).to_numpy()
    # dc_low_7d_col = pd.Series(close_np).rolling(2016).min().shift(1).to_numpy()

    # =========================================================================
    # Assign dataframes
    # =========================================================================
    new_cols = pd.DataFrame(
      {
        "RSI_3": rsi_3,
        "RSI_4": rsi_4,
        "IB_READY": ib_ready_col,
        "IB_MOTHER_H": ib_mother_h_col,
        "IB_MOTHER_L": ib_mother_l_col,
        "ROC_288": roc_288_col,
        "VOL_REL": vol_rel_col,
        "PH_CROSS_CNT_12": ph_cross_cnt12_col,
        "PH_BASE_POS": ph_base_pos_col,
        "PH_PRE_TIGHT": ph_pre_tight_col,
        "MRB_BULL": mrb_bull_col,
        "MRB_BEAR": mrb_bear_col,
        "DH_PREV_MIN": dh_prev_min_col,
        "PB_HAMMER": hammer_col,
        "PB_STAR": star_col,
        "DC_HIGH_7D": dc_high_7d_col,
        "DC_LOW_7D": dc_low_7d_col,
        "ENGULF_BULL": engulf_bull_col,
        "ENGULF_BEAR": engulf_bear_col,
        "SFP_BULL": sfp_bull_col,
        "SFP_BEAR": sfp_bear_col,
        "RSI_14": rsi_14,
        "RSI_20": rsi_20,
        "RSI_14_change_pct": rsi_14_change,
        "EMA_9": ema_9,
        "EMA_12": ema_12,
        "EMA_16": ema_16,
        "EMA_20": ema_20,
        "EMA_26": ema_26,
        "EMA_50": ema_50,
        "EMA_100": ema_100,
        "EMA_200": ema_200,
        "SMA_9": sma_9,
        "SMA_16": sma_16,
        "SMA_21": sma_21,
        "SMA_30": sma_30,
        "SMA_200": sma_200,
        "BBL_20_2.0": bb_lower_20,
        "BBU_20_2.0": bb_upper_20,
        "BBB_20_2.0": ((bb_upper_20 - bb_lower_20) / bb_middle_20_safe) * 100.0,
        "BBL_40_2.0": bb_lower_40,
        "BBD_40_2.0": np.abs(bb_middle_40 - bb_lower_40),
        "BBT_40_2.0": np.abs(close_np - bb_lower_40),
        "BB_ABOVE_COUNT": bb_above_count,
        "BB_BELOW_COUNT": bb_below_count,
        "MFI_14": mfi_14,
        "CMF_20": cmf_20,
        "WILLR_14": willr_14,
        "WILLR_480": willr_480,
        "AROONU_14": aroon_up,
        "AROOND_14": aroon_down,
        "STOCHRSIk_14_14_3_3": stochrsi_k,
        "KST_10_15_20_30_10_10_10_15": kst_main,
        "KSTs_9": kst_signal,
        "ROC_2": roc_2,
        "ROC_9": roc_9,
        "change_pct": change_pct,
        "OBV_change_pct": obv_change,
        "close_delta": close_delta,
        "close_max_6": close_max_6,
        "close_max_12": close_max_12,
        "close_max_48": close_max_48,
        "close_min_6": close_min_6,
        "close_min_12": close_min_12,
        "close_min_48": close_min_48,
        "num_empty_288": num_empty_288,
        "LARGE_BUBBLE_THR": large_bubble_thr,
        "CVD_BUY_VOL": cvd_buy_vol,
        "CVD_SELL_VOL": cvd_sell_vol,
        "ORANGE_H": orange_h_col,
        "ORANGE_L": orange_l_col,
        "SQZ_ON": sqz_on_col,
        "SQZ_CNT_24": sqz_cnt24_col,
        "STOCH_9_3": quad_s93,
        "STOCH_14_3": quad_s143,
        "STOCH_4_4": quad_s44,
        "STOCH_60_10": quad_s6010,
        "QUAD_LOW_MIN_12": quad_low_min_12,
        "QUAD_HIGH_MAX_12": quad_high_max_12,
        "QUAD_S93_MIN_12": quad_s93_min_12,
        "QUAD_S93_MAX_12": quad_s93_max_12,
      },
      index=df.index,
    )

    df = pd.concat([df, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "RSI_3",
        "RSI_4",
        "RSI_14",
        "RSI_20",
        "RSI_14_change_pct",
        "EMA_9",
        "EMA_12",
        "EMA_16",
        "EMA_20",
        "EMA_26",
        "EMA_50",
        "EMA_100",
        "EMA_200",
        "SMA_9",
        "SMA_16",
        "SMA_21",
        "SMA_30",
        "SMA_200",
        "BBL_20_2.0",
        "BBU_20_2.0",
        "BBB_20_2.0",
        "BBL_40_2.0",
        "BBD_40_2.0",
        "BBT_40_2.0",
        "MFI_14",
        "CMF_20",
        "WILLR_14",
        "WILLR_480",
        "AROONU_14",
        "AROOND_14",
        "STOCHRSIk_14_14_3_3",
        "KST_10_15_20_30_10_10_10_15",
        "KSTs_9",
        "ROC_2",
        "ROC_9",
        "change_pct",
        "close_delta",
        "close_max_6",
        "close_max_12",
        "close_max_48",
        "close_min_6",
        "close_min_12",
        "close_min_48",
        "num_empty_288",
        "LARGE_BUBBLE_THR",
        "CVD_BUY_VOL",
        "CVD_SELL_VOL",
      ]

      self.validate_indicators(df=df, columns=debug_cols, pair=metadata_pair, timeframe=self.timeframe)

    # =========================================================================
    # GLOBAL PROTECTIONS
    # =========================================================================
    if not self.config["runmode"].value in ("live", "dry_run"):
      df["bt_agefilter_ok"] = False
      df.loc[df.index > (12 * 24 * self.bt_min_age_days), "bt_agefilter_ok"] = True
    else:
      df["live_data_ok"] = ta_min(volume_np, timeperiod=72) > 0

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] base_tf_5m_indicators took: %.4f seconds.", metadata_pair, tok - tik)

    return df

  # BTC Informative 1d Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def btc_informative_1d_indicators(self, btc_pair: str, btc_info_timeframe: str) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================
    btc_informative_1d = dp.get_pair_dataframe(pair=btc_pair, timeframe=btc_info_timeframe)

    # Empty dataframe protection
    if btc_informative_1d.empty:
      return btc_informative_1d

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = btc_informative_1d["close"].to_numpy(copy=False)
    # high_np = btc_informative_1d["high"].to_numpy(copy=False)
    # low_np = btc_informative_1d["low"].to_numpy(copy=False)
    # open_np = btc_informative_1d["open"].to_numpy(copy=False)
    # volume_np = btc_informative_1d["volume"].to_numpy(copy=False)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_200 = ta.EMA(close_np, timeperiod=200)
    new_cols = pd.DataFrame(
      {
        "BTC_EMA_200": ema_200,
      },
      index=btc_informative_1d.index,
    )

    btc_informative_1d = pd.concat([btc_informative_1d, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "BTC_EMA_200",
      ]

      self.validate_indicators(df=btc_informative_1d, columns=debug_cols, pair=btc_pair, timeframe=btc_info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] btc_informative_1d_indicators took: %.4f seconds.", btc_pair, tok - tik)

    return btc_informative_1d

  # BTC Informative 4h Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def btc_informative_4h_indicators(self, btc_pair: str, btc_info_timeframe: str) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================
    btc_informative_4h = dp.get_pair_dataframe(pair=btc_pair, timeframe=btc_info_timeframe)

    # Empty dataframe protection
    if btc_informative_4h.empty:
      return btc_informative_4h

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = btc_informative_4h["close"].to_numpy(copy=False)
    # high_np = btc_informative_4h["high"].to_numpy(copy=False)
    # low_np = btc_informative_4h["low"].to_numpy(copy=False)
    # open_np = btc_informative_4h["open"].to_numpy(copy=False)
    # volume_np = btc_informative_4h["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_14 = ta.RSI(close_np, timeperiod=14)

    new_cols = pd.DataFrame(
      {
        "BTC_RSI_14": rsi_14,
      },
      index=btc_informative_4h.index,
    )

    btc_informative_4h = pd.concat([btc_informative_4h, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "BTC_RSI_14",
      ]

      self.validate_indicators(df=btc_informative_4h, columns=debug_cols, pair=btc_pair, timeframe=btc_info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] btc_informative_4h_indicators took: %.4f seconds.", btc_pair, tok - tik)

    return btc_informative_4h

  # BTC Informative 1h Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def btc_informative_1h_indicators(self, btc_pair: str, btc_info_timeframe: str) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================
    btc_informative_1h = dp.get_pair_dataframe(pair=btc_pair, timeframe=btc_info_timeframe)

    # Empty dataframe protection
    if btc_informative_1h.empty:
      return btc_informative_1h

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = btc_informative_1h["close"].to_numpy(copy=False)
    # high_np = btc_informative_1h["high"].to_numpy(copy=False)
    # low_np = btc_informative_1h["low"].to_numpy(copy=False)
    # open_np = btc_informative_1h["open"].to_numpy(copy=False)
    # volume_np = btc_informative_1h["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_14 = ta.RSI(close_np, timeperiod=14)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_20 = ta.EMA(close_np, timeperiod=20)
    roc_3 = ta.ROC(close_np, timeperiod=3)

    new_cols = pd.DataFrame(
      {
        "BTC_RSI_14": rsi_14,
        "BTC_EMA_20": ema_20,
        "BTC_ROC_3": roc_3,
      },
      index=btc_informative_1h.index,
    )

    btc_informative_1h = pd.concat([btc_informative_1h, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "BTC_RSI_14",
        "BTC_EMA_20",
        "BTC_ROC_3",
      ]

      self.validate_indicators(df=btc_informative_1h, columns=debug_cols, pair=btc_pair, timeframe=btc_info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] btc_informative_1h_indicators took: %.4f seconds.", btc_pair, tok - tik)

    return btc_informative_1h

  # BTC Informative 15m Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def btc_informative_15m_indicators(self, btc_pair: str, btc_info_timeframe: str) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================
    btc_informative_15m = dp.get_pair_dataframe(pair=btc_pair, timeframe=btc_info_timeframe)

    # Empty dataframe protection
    if btc_informative_15m.empty:
      return btc_informative_15m

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = btc_informative_15m["close"].to_numpy(copy=False)
    # high_np = btc_informative_15m["high"].to_numpy(copy=False)
    # low_np = btc_informative_15m["low"].to_numpy(copy=False)
    # open_np = btc_informative_15m["open"].to_numpy(copy=False)
    # volume_np = btc_informative_15m["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_14 = ta.RSI(close_np, timeperiod=14)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_20 = ta.EMA(close_np, timeperiod=20)
    roc_3 = ta.ROC(close_np, timeperiod=3)

    new_cols = pd.DataFrame(
      {
        "BTC_RSI_14": rsi_14,
        "BTC_EMA_20": ema_20,
        "BTC_ROC_3": roc_3,
      },
      index=btc_informative_15m.index,
    )

    btc_informative_15m = pd.concat([btc_informative_15m, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "BTC_RSI_14",
        "BTC_EMA_20",
        "BTC_ROC_3",
      ]

      self.validate_indicators(df=btc_informative_15m, columns=debug_cols, pair=btc_pair, timeframe=btc_info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] btc_informative_15m_indicators took: %.4f seconds.", btc_pair, tok - tik)

    return btc_informative_15m

  # BTC Informative 5m Timeframe Indicators
  # ---------------------------------------------------------------------------------------------
  def btc_informative_5m_indicators(self, btc_pair: str, btc_info_timeframe: str) -> DataFrame:
    debug_time = False
    if debug_time:
      tik = time.perf_counter()
    dp = self.dp

    assert dp, "DataProvider is required for multiple timeframes."

    # =========================================================================
    # GET DATAFRAME
    # =========================================================================
    btc_informative_5m = dp.get_pair_dataframe(pair=btc_pair, timeframe=btc_info_timeframe)

    # Empty dataframe protection
    if btc_informative_5m.empty:
      return btc_informative_5m

    # =========================================================================
    # BASE DATA
    # =========================================================================
    close_np = btc_informative_5m["close"].to_numpy(copy=False)
    # high_np = btc_informative_5m["high"].to_numpy(copy=False)
    # low_np = btc_informative_5m["low"].to_numpy(copy=False)
    # open_np = btc_informative_5m["open"].to_numpy(copy=False)
    # volume_np = btc_informative_5m["volume"].to_numpy(copy=False)

    # =========================================================================
    # CORE INDICATORS
    # =========================================================================
    rsi_14 = ta.RSI(close_np, timeperiod=14)

    # =========================================================================
    # MOMENTUM
    # =========================================================================
    ema_20 = ta.EMA(close_np, timeperiod=20)
    roc_3 = ta.ROC(close_np, timeperiod=3)

    new_cols = pd.DataFrame(
      {
        "BTC_RSI_14": rsi_14,
        "BTC_EMA_20": ema_20,
        "BTC_ROC_3": roc_3,
      },
      index=btc_informative_5m.index,
    )

    btc_informative_5m = pd.concat([btc_informative_5m, new_cols], axis=1, copy=False)

    # Enable ONLY during debugging
    debug = False
    if debug:
      debug_cols = [
        "BTC_RSI_14",
        "BTC_EMA_20",
        "BTC_ROC_3",
      ]

      self.validate_indicators(df=btc_informative_5m, columns=debug_cols, pair=btc_pair, timeframe=btc_info_timeframe)

    # =========================================================================
    # LOGGING
    # =========================================================================
    if debug_time:
      tok = time.perf_counter()
      log.debug("[%s] btc_informative_5m_indicators took: %.4f seconds.", btc_pair, tok - tik)

    return btc_informative_5m

  # Coin Pair Indicator Switch Case
  # ---------------------------------------------------------------------------------------------
  def info_switcher(self, metadata: dict, info_timeframe) -> DataFrame:
    if info_timeframe == "1d":
      return self.informative_1d_indicators(metadata, info_timeframe)
    elif info_timeframe == "4h":
      return self.informative_4h_indicators(metadata, info_timeframe)
    elif info_timeframe == "1h":
      return self.informative_1h_indicators(metadata, info_timeframe)
    elif info_timeframe == "15m":
      return self.informative_15m_indicators(metadata, info_timeframe)
    else:
      raise RuntimeError(f"{info_timeframe} not supported as informative timeframe for BTC pair.")

  # BTC Indicator Switch Case
  # ---------------------------------------------------------------------------------------------
  def btc_info_switcher(self, btc_pair: str, btc_info_timeframe) -> DataFrame:
    # if btc_info_timeframe == "1d":
    # return self.btc_informative_1d_indicators(btc_pair, btc_info_timeframe)
    if btc_info_timeframe == "4h":
      return self.btc_informative_4h_indicators(btc_pair, btc_info_timeframe)
    # elif btc_info_timeframe == "1h":
    # return self.btc_informative_1h_indicators(btc_pair, btc_info_timeframe)
    # elif btc_info_timeframe == "15m":
    # return self.btc_informative_15m_indicators(btc_pair, btc_info_timeframe)
    # elif btc_info_timeframe == "5m":
    # return self.btc_informative_5m_indicators(btc_pair, btc_info_timeframe)
    else:
      raise RuntimeError(f"{btc_info_timeframe} not supported as informative timeframe for BTC pair.")

  # Populate Indicators
  # ---------------------------------------------------------------------------------------------
  def populate_indicators(self, df: DataFrame, metadata: dict) -> DataFrame:
    debug = False
    debug_time = True
    if debug_time:
      tik = time.perf_counter()
    base_timeframe = self.timeframe
    prepare_informative_merge = self.prepare_informative_merge
    metadata_pair = metadata["pair"]

    # ============================================================
    # BTC INFORMATIVE (BATCH PREPARATION)
    # ============================================================
    btc_info_pair = self.btc_informative_pair()
    btc_info_timeframes = self.btc_info_timeframes
    btc_info_switcher = self.btc_info_switcher
    btc_frames = {}
    for btc_tf in btc_info_timeframes:
      btc_df = btc_info_switcher(btc_info_pair, btc_tf)
      if btc_df.empty:
        continue

      btc_df = prepare_informative_merge(btc_df)
      btc_frames[btc_tf] = btc_df

    # ============================================================
    # INFO TF (BATCH PREPARATION)
    # ============================================================
    info_timeframes = self.info_timeframes
    info_switcher = self.info_switcher
    info_frames = {}
    for info_tf in info_timeframes:
      info_df = info_switcher(metadata, info_tf)
      if info_df.empty:
        continue

      keep_ohlcv = {"open", "close"} if info_tf == "15m" else set()
      info_df = prepare_informative_merge(info_df, keep_ohlcv)
      info_frames[info_tf] = info_df

    # ============================================================
    # BTC MERGE
    # ============================================================
    for tf, frame in btc_frames.items():
      df = merge_informative_pair(df, frame, base_timeframe, tf, ffill=False)
      # BTC date is not needed. only info_tf needs it because of add_informative_ready (not yet implemented) validation(Current PR not affected by this).
      col = f"date_{tf}"
      if col in df.columns:
        df = df.drop(columns=col)

    # ============================================================
    # NORMAL INFORMATIVE MERGE
    # ============================================================
    for tf, frame in info_frames.items():
      df = merge_informative_pair(df, frame, base_timeframe, tf, ffill=False)

    # ============================================================
    # FINAL FILL ONLY AFTER ALL MERGES
    # ============================================================
    df = df.ffill()

    # ============================================================
    # POST-FFILL VALIDATION
    # ============================================================
    if debug:
      groups = {
        "INFO": self.info_timeframes,
        "BTC": self.btc_info_timeframes,
      }

      for source, tfs in groups.items():
        for tf in tfs:
          if source == "BTC":
            tf_cols = [c for c in df.columns if c.startswith("BTC_") and c.endswith(f"_{tf}")]
          else:
            tf_cols = [c for c in df.columns if not c.startswith("BTC_") and c.endswith(f"_{tf}")]

          if not tf_cols:
            continue

          recent = df[tf_cols].tail(500)
          total_nans = recent.isna().sum().sum()

          if total_nans > 0:
            log.warning("[%s] %s %s recent500 contains %s NaNs", metadata_pair, source, tf, total_nans)
          else:
            log.info("[%s] %s %s merge OK", metadata_pair, source, tf)

    # ============================================================
    # BASE TF (LAST)
    # ============================================================
    df = self.base_tf_5m_indicators(metadata, df)

    # ============================================================
    # FINAL INDICATOR VALIDATION
    # ============================================================
    if debug:
      recent = df.tail(500)
      final_nan = recent.isna().sum()
      final_nan = final_nan[final_nan > 0]
      if not final_nan.empty:
        log.warning(
          "[%s] Unexpected indicator NaNs in recent candles:\n%s",
          metadata_pair,
          final_nan.sort_values(ascending=False).to_string(),
        )

    if debug_time:
      tok_before_protections = time.perf_counter()

    np_view = lambda c: df[c].to_numpy(copy=False)
    np_shift = self.np_shift
    protection_rsi_3 = np_view("RSI_3")
    protection_rsi_3_15m = np_view("RSI_3_15m")
    protection_rsi_3_1h = np_view("RSI_3_1h")
    protection_rsi_3_4h = np_view("RSI_3_4h")
    protection_rsi_3_1d = np_view("RSI_3_1d")
    protection_rsi_14_1h = np_view("RSI_14_1h")
    protection_rsi_14_4h = np_view("RSI_14_4h")
    protection_rsi_14_1d = np_view("RSI_14_1d")
    protection_cci_20_1h = np_view("CCI_20_1h")
    protection_cci_20_4h = np_view("CCI_20_4h")
    protection_rsi_14_15m = np_view("RSI_14_15m")
    protection_stochrsik_14_14_3_3_15m = np_view("STOCHRSIk_14_14_3_3_15m")
    protection_stochrsik_14_14_3_3_1d = np_view("STOCHRSIk_14_14_3_3_1d")
    protection_aroonu_14_15m = np_view("AROONU_14_15m")
    protection_cmf_20_15m = np_view("CMF_20_15m")
    protection_aroonu_14_4h = np_view("AROONU_14_4h")
    protection_roc_9_1d = np_view("ROC_9_1d")
    protection_aroonu_14_1h = np_view("AROONU_14_1h")
    protection_stochrsik_14_14_3_3_1h = np_view("STOCHRSIk_14_14_3_3_1h")
    protection_stochrsik_14_14_3_3_4h = np_view("STOCHRSIk_14_14_3_3_4h")
    protection_roc_9_4h = np_view("ROC_9_4h")
    protection_cmf_20_1d = np_view("CMF_20_1d")
    protection_roc_9_15m = np_view("ROC_9_15m")
    protection_roc_9_1h = np_view("ROC_9_1h")
    protection_cmf_20_1h = np_view("CMF_20_1h")
    protection_cmf_20_4h = np_view("CMF_20_4h")
    protection_aroonu_14_1d = np_view("AROONU_14_1d")
    protection_mfi_14_1d = np_view("MFI_14_1d")
    protection_roc_2_1d = np_view("ROC_2_1d")
    protection_mfi_14_1h = np_view("MFI_14_1h")
    protection_mfi_14_4h = np_view("MFI_14_4h")
    protection_stochk_14_3_3_1h = np_view("STOCHk_14_3_3_1h")
    protection_stochk_14_3_3_4h = np_view("STOCHk_14_3_3_4h")
    protection_cci_20_change_pct_4h = np_view("CCI_20_change_pct_4h")
    protection_change_pct_4h = np_view("change_pct_4h")
    protection_change_pct_4h_shift_48 = np_shift(protection_change_pct_4h, 48)
    protection_top_wick_pct_4h = np_view("top_wick_pct_4h")
    protection_change_pct_1d = np_view("change_pct_1d")
    protection_change_pct_1d_shift_288 = np_shift(protection_change_pct_1d, 288)
    protection_top_wick_pct_1d = np_view("top_wick_pct_1d")
    protection_top_wick_pct_1d_shift_288 = np_shift(protection_top_wick_pct_1d, 288)
    protection_high_max_6_1d = np_view("high_max_6_1d")
    protection_low_min_6_1d = np_view("low_min_6_1d")
    protection_close = np_view("close")
    protection_high_max_6_4h = np_view("high_max_6_4h")
    protection_high_max_12_1d = np_view("high_max_12_1d")
    protection_low_min_12_1d = np_view("low_min_12_1d")
    protection_high_max_24_4h = np_view("high_max_24_4h")
    protection_high_max_30_1d = np_view("high_max_30_1d")
    protection_low_min_30_1d = np_view("low_min_30_1d")
    protection_close_max_48 = np_view("close_max_48")
    protection_high_max_12_1h = np_view("high_max_12_1h")
    protection_high_max_20_1d = np_view("high_max_20_1d")
    protection_cci_20_15m = np_view("CCI_20_15m")
    protection_aroond_14_4h = np_view("AROOND_14_4h")
    protection_aroond_14_1d = np_view("AROOND_14_1d")
    protection_willr_14_4h = np_view("WILLR_14_4h")
    protection_willr_14_15m = np_view("WILLR_14_15m")
    protection_stochk_14_3_3_15m = np_view("STOCHk_14_3_3_15m")
    protection_willr_14_1h = np_view("WILLR_14_1h")
    protection_mfi_14_15m = np_view("MFI_14_15m")
    protection_cci_20_change_pct_1h = np_view("CCI_20_change_pct_1h")
    protection_willr_14_1d = np_view("WILLR_14_1d")
    protection_aroond_14_1h = np_view("AROOND_14_1h")
    protection_stochk_14_3_3_1d = np_view("STOCHk_14_3_3_1d")
    protection_uo_7_14_28_15m = np_view("UO_7_14_28_15m")
    protection_uo_7_14_28_change_pct_15m = np_view("UO_7_14_28_change_pct_15m")
    protection_uo_7_14_28_1h = np_view("UO_7_14_28_1h")
    protection_uo_7_14_28_4h = np_view("UO_7_14_28_4h")
    protection_roc_2_4h = np_view("ROC_2_4h")
    protection_aroond_14_15m = np_view("AROOND_14_15m")

    # Reused protection comparison masks
    aroonu_14_15m_lt_30 = protection_aroonu_14_15m < 30.0
    aroonu_14_15m_lt_40 = protection_aroonu_14_15m < 40.0
    aroonu_14_15m_lt_50 = protection_aroonu_14_15m < 50.0
    aroonu_14_15m_lt_60 = protection_aroonu_14_15m < 60.0
    aroonu_14_15m_lt_70 = protection_aroonu_14_15m < 70.0
    aroonu_14_1h_lt_100 = protection_aroonu_14_1h < 100.0
    aroonu_14_1h_lt_20 = protection_aroonu_14_1h < 20.0
    aroonu_14_1h_lt_25 = protection_aroonu_14_1h < 25.0
    aroonu_14_1h_lt_30 = protection_aroonu_14_1h < 30.0
    aroonu_14_1h_lt_40 = protection_aroonu_14_1h < 40.0
    aroonu_14_1h_lt_50 = protection_aroonu_14_1h < 50.0
    aroonu_14_1h_lt_60 = protection_aroonu_14_1h < 60.0
    aroonu_14_1h_lt_70 = protection_aroonu_14_1h < 70.0
    aroonu_14_1h_lt_75 = protection_aroonu_14_1h < 75.0
    aroonu_14_1h_lt_80 = protection_aroonu_14_1h < 80.0
    aroonu_14_1h_lt_85 = protection_aroonu_14_1h < 85.0
    aroonu_14_1h_lt_90 = protection_aroonu_14_1h < 90.0
    aroonu_14_4h_lt_100 = protection_aroonu_14_4h < 100.0
    aroonu_14_4h_lt_20 = protection_aroonu_14_4h < 20.0
    aroonu_14_4h_lt_25 = protection_aroonu_14_4h < 25.0
    aroonu_14_4h_lt_30 = protection_aroonu_14_4h < 30.0
    aroonu_14_4h_lt_40 = protection_aroonu_14_4h < 40.0
    aroonu_14_4h_lt_50 = protection_aroonu_14_4h < 50.0
    aroonu_14_4h_lt_60 = protection_aroonu_14_4h < 60.0
    aroonu_14_4h_lt_70 = protection_aroonu_14_4h < 70.0
    aroonu_14_4h_lt_75 = protection_aroonu_14_4h < 75.0
    aroonu_14_4h_lt_80 = protection_aroonu_14_4h < 80.0
    aroonu_14_4h_lt_85 = protection_aroonu_14_4h < 85.0
    aroonu_14_4h_lt_90 = protection_aroonu_14_4h < 90.0
    cmf_20_15m_gt_neg_0 = protection_cmf_20_15m > -0.0
    cmf_20_15m_gt_neg_010 = protection_cmf_20_15m > -0.10
    cmf_20_15m_gt_neg_015 = protection_cmf_20_15m > -0.15
    cmf_20_15m_gt_neg_02 = protection_cmf_20_15m > -0.2
    cmf_20_15m_gt_neg_020 = protection_cmf_20_15m > -0.20
    cmf_20_15m_gt_neg_025 = protection_cmf_20_15m > -0.25
    cmf_20_15m_gt_neg_03 = protection_cmf_20_15m > -0.3
    cmf_20_15m_gt_neg_030 = protection_cmf_20_15m > -0.30
    cmf_20_15m_gt_neg_035 = protection_cmf_20_15m > -0.35
    cmf_20_15m_gt_neg_040 = protection_cmf_20_15m > -0.40
    cmf_20_15m_gt_neg_05 = protection_cmf_20_15m > -0.5
    cmf_20_15m_gt_neg_050 = protection_cmf_20_15m > -0.50
    cmf_20_1h_gt_neg_0 = protection_cmf_20_1h > -0.0
    cmf_20_1h_gt_neg_010 = protection_cmf_20_1h > -0.10
    cmf_20_1h_gt_neg_015 = protection_cmf_20_1h > -0.15
    cmf_20_1h_gt_neg_02 = protection_cmf_20_1h > -0.2
    cmf_20_1h_gt_neg_020 = protection_cmf_20_1h > -0.20
    cmf_20_1h_gt_neg_025 = protection_cmf_20_1h > -0.25
    cmf_20_1h_gt_neg_03 = protection_cmf_20_1h > -0.3
    cmf_20_1h_gt_neg_030 = protection_cmf_20_1h > -0.30
    cmf_20_1h_gt_neg_04 = protection_cmf_20_1h > -0.4
    cmf_20_1h_gt_neg_040 = protection_cmf_20_1h > -0.40
    cmf_20_1h_gt_neg_05 = protection_cmf_20_1h > -0.5
    cmf_20_4h_gt_neg_0 = protection_cmf_20_4h > -0.0
    cmf_20_4h_gt_neg_01 = protection_cmf_20_4h > -0.1
    cmf_20_4h_gt_neg_010 = protection_cmf_20_4h > -0.10
    cmf_20_4h_gt_neg_015 = protection_cmf_20_4h > -0.15
    cmf_20_4h_gt_neg_02 = protection_cmf_20_4h > -0.2
    cmf_20_4h_gt_neg_020 = protection_cmf_20_4h > -0.20
    cmf_20_4h_gt_neg_025 = protection_cmf_20_4h > -0.25
    cmf_20_4h_gt_neg_03 = protection_cmf_20_4h > -0.3
    cmf_20_4h_gt_neg_030 = protection_cmf_20_4h > -0.30
    cmf_20_4h_gt_neg_035 = protection_cmf_20_4h > -0.35
    cmf_20_4h_gt_neg_04 = protection_cmf_20_4h > -0.4
    cmf_20_4h_gt_neg_040 = protection_cmf_20_4h > -0.40
    cmf_20_4h_gt_neg_05 = protection_cmf_20_4h > -0.5
    roc_9_1d_lt_100 = protection_roc_9_1d < 100.0
    roc_9_1d_lt_15 = protection_roc_9_1d < 15.0
    roc_9_1d_lt_150 = protection_roc_9_1d < 150.0
    roc_9_1d_lt_20 = protection_roc_9_1d < 20.0
    roc_9_1d_lt_200 = protection_roc_9_1d < 200.0
    roc_9_1d_lt_25 = protection_roc_9_1d < 25.0
    roc_9_1d_lt_250 = protection_roc_9_1d < 250.0
    roc_9_1d_lt_30 = protection_roc_9_1d < 30.0
    roc_9_1d_lt_40 = protection_roc_9_1d < 40.0
    roc_9_1d_lt_50 = protection_roc_9_1d < 50.0
    roc_9_1d_lt_60 = protection_roc_9_1d < 60.0
    roc_9_1d_lt_70 = protection_roc_9_1d < 70.0
    roc_9_1d_lt_75 = protection_roc_9_1d < 75.0
    roc_9_1d_lt_80 = protection_roc_9_1d < 80.0
    roc_9_1h_gt_neg_10 = protection_roc_9_1h > -10.0
    roc_9_1h_gt_neg_15 = protection_roc_9_1h > -15.0
    roc_9_1h_gt_neg_20 = protection_roc_9_1h > -20.0
    roc_9_1h_gt_neg_25 = protection_roc_9_1h > -25.0
    roc_9_1h_gt_neg_30 = protection_roc_9_1h > -30.0
    roc_9_1h_gt_neg_50 = protection_roc_9_1h > -50.0
    roc_9_1h_gt_neg_60 = protection_roc_9_1h > -60.0
    roc_9_1h_lt_10 = protection_roc_9_1h < 10.0
    roc_9_1h_lt_15 = protection_roc_9_1h < 15.0
    roc_9_1h_lt_20 = protection_roc_9_1h < 20.0
    roc_9_1h_lt_30 = protection_roc_9_1h < 30.0
    roc_9_1h_lt_40 = protection_roc_9_1h < 40.0
    roc_9_1h_lt_50 = protection_roc_9_1h < 50.0
    roc_9_1h_lt_70 = protection_roc_9_1h < 70.0
    roc_9_1h_lt_80 = protection_roc_9_1h < 80.0
    roc_9_4h_gt_neg_10 = protection_roc_9_4h > -10.0
    roc_9_4h_gt_neg_15 = protection_roc_9_4h > -15.0
    roc_9_4h_gt_neg_20 = protection_roc_9_4h > -20.0
    roc_9_4h_gt_neg_25 = protection_roc_9_4h > -25.0
    roc_9_4h_gt_neg_30 = protection_roc_9_4h > -30.0
    roc_9_4h_gt_neg_35 = protection_roc_9_4h > -35.0
    roc_9_4h_gt_neg_40 = protection_roc_9_4h > -40.0
    roc_9_4h_gt_neg_50 = protection_roc_9_4h > -50.0
    roc_9_4h_gt_neg_60 = protection_roc_9_4h > -60.0
    roc_9_4h_gt_neg_70 = protection_roc_9_4h > -70.0
    roc_9_4h_lt_10 = protection_roc_9_4h < 10.0
    roc_9_4h_lt_100 = protection_roc_9_4h < 100.0
    roc_9_4h_lt_120 = protection_roc_9_4h < 120.0
    roc_9_4h_lt_130 = protection_roc_9_4h < 130.0
    roc_9_4h_lt_15 = protection_roc_9_4h < 15.0
    roc_9_4h_lt_20 = protection_roc_9_4h < 20.0
    roc_9_4h_lt_25 = protection_roc_9_4h < 25.0
    roc_9_4h_lt_250 = protection_roc_9_4h < 250.0
    roc_9_4h_lt_30 = protection_roc_9_4h < 30.0
    roc_9_4h_lt_300 = protection_roc_9_4h < 300.0
    roc_9_4h_lt_35 = protection_roc_9_4h < 35.0
    roc_9_4h_lt_40 = protection_roc_9_4h < 40.0
    roc_9_4h_lt_50 = protection_roc_9_4h < 50.0
    roc_9_4h_lt_60 = protection_roc_9_4h < 60.0
    roc_9_4h_lt_70 = protection_roc_9_4h < 70.0
    roc_9_4h_lt_75 = protection_roc_9_4h < 75.0
    roc_9_4h_lt_80 = protection_roc_9_4h < 80.0
    rsi_14_15m_gt_70 = protection_rsi_14_15m > 70.0
    rsi_14_15m_gt_80 = protection_rsi_14_15m > 80.0
    rsi_14_15m_gt_85 = protection_rsi_14_15m > 85.0
    rsi_14_15m_gt_90 = protection_rsi_14_15m > 90.0
    rsi_14_15m_gt_95 = protection_rsi_14_15m > 95.0
    rsi_14_1h_gt_70 = protection_rsi_14_1h > 70.0
    rsi_14_1h_gt_75 = protection_rsi_14_1h > 75.0
    rsi_14_1h_gt_80 = protection_rsi_14_1h > 80.0
    rsi_14_1h_gt_85 = protection_rsi_14_1h > 85.0
    rsi_14_1h_gt_90 = protection_rsi_14_1h > 90.0
    rsi_14_1h_gt_95 = protection_rsi_14_1h > 95.0
    rsi_14_4h_gt_60 = protection_rsi_14_4h > 60.0
    rsi_14_4h_gt_70 = protection_rsi_14_4h > 70.0
    rsi_14_4h_gt_80 = protection_rsi_14_4h > 80.0
    rsi_14_4h_gt_90 = protection_rsi_14_4h > 90.0
    rsi_14_4h_gt_95 = protection_rsi_14_4h > 95.0
    rsi_3_15m_lt_70 = protection_rsi_3_15m < 70.0
    rsi_3_15m_lt_75 = protection_rsi_3_15m < 75.0
    rsi_3_15m_lt_80 = protection_rsi_3_15m < 80.0
    rsi_3_15m_lt_85 = protection_rsi_3_15m < 85.0
    rsi_3_15m_lt_90 = protection_rsi_3_15m < 90.0
    rsi_3_1d_gt_10 = protection_rsi_3_1d > 10.0
    rsi_3_1d_gt_15 = protection_rsi_3_1d > 15.0
    rsi_3_1d_gt_20 = protection_rsi_3_1d > 20.0
    rsi_3_1d_gt_25 = protection_rsi_3_1d > 25.0
    rsi_3_1d_gt_3 = protection_rsi_3_1d > 3.0
    rsi_3_1d_gt_30 = protection_rsi_3_1d > 30.0
    rsi_3_1d_gt_35 = protection_rsi_3_1d > 35.0
    rsi_3_1d_gt_40 = protection_rsi_3_1d > 40.0
    rsi_3_1d_gt_45 = protection_rsi_3_1d > 45.0
    rsi_3_1d_gt_5 = protection_rsi_3_1d > 5.0
    rsi_3_1d_gt_50 = protection_rsi_3_1d > 50.0
    rsi_3_1d_gt_55 = protection_rsi_3_1d > 55.0
    rsi_3_1d_gt_60 = protection_rsi_3_1d > 60.0
    rsi_3_1d_gt_65 = protection_rsi_3_1d > 65.0
    rsi_3_1h_gt_20 = protection_rsi_3_1h > 20.0
    rsi_3_1h_gt_25 = protection_rsi_3_1h > 25.0
    rsi_3_1h_gt_35 = protection_rsi_3_1h > 35.0
    rsi_3_1h_gt_40 = protection_rsi_3_1h > 40.0
    rsi_3_1h_gt_45 = protection_rsi_3_1h > 45.0
    rsi_3_1h_gt_50 = protection_rsi_3_1h > 50.0
    rsi_3_1h_gt_55 = protection_rsi_3_1h > 55.0
    rsi_3_1h_lt_60 = protection_rsi_3_1h < 60.0
    rsi_3_1h_lt_70 = protection_rsi_3_1h < 70.0
    rsi_3_1h_lt_75 = protection_rsi_3_1h < 75.0
    rsi_3_1h_lt_80 = protection_rsi_3_1h < 80.0
    rsi_3_1h_lt_85 = protection_rsi_3_1h < 85.0
    rsi_3_1h_lt_90 = protection_rsi_3_1h < 90.0
    rsi_3_4h_gt_20 = protection_rsi_3_4h > 20.0
    rsi_3_4h_gt_25 = protection_rsi_3_4h > 25.0
    rsi_3_4h_gt_30 = protection_rsi_3_4h > 30.0
    rsi_3_4h_gt_35 = protection_rsi_3_4h > 35.0
    rsi_3_4h_gt_40 = protection_rsi_3_4h > 40.0
    rsi_3_4h_gt_45 = protection_rsi_3_4h > 45.0
    rsi_3_4h_gt_50 = protection_rsi_3_4h > 50.0
    rsi_3_4h_gt_55 = protection_rsi_3_4h > 55.0
    rsi_3_4h_gt_65 = protection_rsi_3_4h > 65.0
    stochrsi_k_15m_lt_10 = protection_stochrsik_14_14_3_3_15m < 10.0
    stochrsi_k_15m_lt_20 = protection_stochrsik_14_14_3_3_15m < 20.0
    stochrsi_k_15m_lt_30 = protection_stochrsik_14_14_3_3_15m < 30.0
    stochrsi_k_15m_lt_40 = protection_stochrsik_14_14_3_3_15m < 40.0
    stochrsi_k_15m_lt_50 = protection_stochrsik_14_14_3_3_15m < 50.0
    stochrsi_k_15m_lt_60 = protection_stochrsik_14_14_3_3_15m < 60.0
    stochrsi_k_15m_lt_70 = protection_stochrsik_14_14_3_3_15m < 70.0
    stochrsi_k_15m_lt_80 = protection_stochrsik_14_14_3_3_15m < 80.0
    stochrsi_k_15m_lt_90 = protection_stochrsik_14_14_3_3_15m < 90.0
    stochrsi_k_1h_lt_15 = protection_stochrsik_14_14_3_3_1h < 15.0
    stochrsi_k_1h_lt_20 = protection_stochrsik_14_14_3_3_1h < 20.0
    stochrsi_k_1h_lt_30 = protection_stochrsik_14_14_3_3_1h < 30.0
    stochrsi_k_1h_lt_40 = protection_stochrsik_14_14_3_3_1h < 40.0
    stochrsi_k_1h_lt_50 = protection_stochrsik_14_14_3_3_1h < 50.0
    stochrsi_k_1h_lt_60 = protection_stochrsik_14_14_3_3_1h < 60.0
    stochrsi_k_1h_lt_70 = protection_stochrsik_14_14_3_3_1h < 70.0
    stochrsi_k_1h_lt_80 = protection_stochrsik_14_14_3_3_1h < 80.0
    stochrsi_k_1h_lt_85 = protection_stochrsik_14_14_3_3_1h < 85.0
    stochrsi_k_1h_lt_90 = protection_stochrsik_14_14_3_3_1h < 90.0
    stochrsi_k_4h_lt_10 = protection_stochrsik_14_14_3_3_4h < 10.0
    stochrsi_k_4h_lt_15 = protection_stochrsik_14_14_3_3_4h < 15.0
    stochrsi_k_4h_lt_20 = protection_stochrsik_14_14_3_3_4h < 20.0
    stochrsi_k_4h_lt_30 = protection_stochrsik_14_14_3_3_4h < 30.0
    stochrsi_k_4h_lt_40 = protection_stochrsik_14_14_3_3_4h < 40.0
    stochrsi_k_4h_lt_50 = protection_stochrsik_14_14_3_3_4h < 50.0
    stochrsi_k_4h_lt_60 = protection_stochrsik_14_14_3_3_4h < 60.0
    stochrsi_k_4h_lt_70 = protection_stochrsik_14_14_3_3_4h < 70.0
    stochrsi_k_4h_lt_80 = protection_stochrsik_14_14_3_3_4h < 80.0
    stochrsi_k_4h_lt_85 = protection_stochrsik_14_14_3_3_4h < 85.0
    stochrsi_k_4h_lt_90 = protection_stochrsik_14_14_3_3_4h < 90.0

    # Reused long-global RSI comparison masks
    rsi_14_15m_lt_30 = protection_rsi_14_15m < 30.0
    rsi_14_1h_lt_40 = protection_rsi_14_1h < 40.0
    rsi_14_4h_lt_50 = protection_rsi_14_4h < 50.0
    rsi_14_15m_lt_40 = protection_rsi_14_15m < 40.0
    rsi_14_4h_lt_40 = protection_rsi_14_4h < 40.0
    rsi_14_1h_lt_30 = protection_rsi_14_1h < 30.0
    rsi_14_1h_lt_50 = protection_rsi_14_1h < 50.0
    rsi_3_15m_gt_20 = protection_rsi_3_15m > 20.0
    rsi_3_15m_gt_15 = protection_rsi_3_15m > 15.0
    rsi_3_15m_gt_10 = protection_rsi_3_15m > 10.0
    rsi_3_15m_gt_25 = protection_rsi_3_15m > 25.0
    rsi_14_4h_lt_30 = protection_rsi_14_4h < 30.0
    rsi_3_15m_gt_30 = protection_rsi_3_15m > 30.0
    rsi_3_1h_gt_30 = protection_rsi_3_1h > 30.0
    rsi_14_15m_lt_20 = protection_rsi_14_15m < 20.0
    rsi_3_4h_gt_60 = protection_rsi_3_4h > 60.0
    rsi_3_15m_gt_5 = protection_rsi_3_15m > 5.0
    rsi_3_15m_gt_35 = protection_rsi_3_15m > 35.0
    rsi_3_15m_gt_40 = protection_rsi_3_15m > 40.0
    rsi_3_15m_gt_45 = protection_rsi_3_15m > 45.0
    rsi_3_1h_gt_5 = protection_rsi_3_1h > 5.0
    rsi_3_1h_gt_10 = protection_rsi_3_1h > 10.0
    rsi_3_1h_gt_15 = protection_rsi_3_1h > 15.0
    rsi_3_1h_gt_60 = protection_rsi_3_1h > 60.0
    rsi_3_1h_gt_65 = protection_rsi_3_1h > 65.0
    rsi_3_4h_gt_3 = protection_rsi_3_4h > 3.0
    rsi_3_4h_gt_5 = protection_rsi_3_4h > 5.0
    rsi_3_4h_gt_10 = protection_rsi_3_4h > 10.0
    rsi_3_4h_gt_15 = protection_rsi_3_4h > 15.0
    rsi_14_4h_lt_20 = protection_rsi_14_4h < 20.0
    rsi_14_4h_lt_60 = protection_rsi_14_4h < 60.0
    rsi_14_4h_lt_70 = protection_rsi_14_4h < 70.0
    rsi_14_4h_lt_80 = protection_rsi_14_4h < 80.0
    rsi_14_1h_lt_20 = protection_rsi_14_1h < 20.0
    rsi_14_1h_lt_60 = protection_rsi_14_1h < 60.0
    rsi_14_1h_lt_70 = protection_rsi_14_1h < 70.0
    rsi_14_15m_lt_50 = protection_rsi_14_15m < 50.0

    # Global protections Long
    # Reused protection RSI and ROC masks
    rsi_3_15m_gt_3 = protection_rsi_3_15m > 3.0
    rsi_3_4h_lt_80 = protection_rsi_3_4h < 80.0
    rsi_3_4h_lt_90 = protection_rsi_3_4h < 90.0
    roc_9_1d_gt_neg_50 = protection_roc_9_1d > -50.0
    top_wick_pct_1d_lt_10 = protection_top_wick_pct_1d < 10.0
    rsi_3_4h_lt_70 = protection_rsi_3_4h < 70.0
    aroonu_14_15m_lt_20 = protection_aroonu_14_15m < 20.0
    aroonu_14_15m_lt_25 = protection_aroonu_14_15m < 25.0
    rsi_3_4h_lt_60 = protection_rsi_3_4h < 60.0
    rsi_3_gt_10 = protection_rsi_3 > 10.0
    rsi_14_15m_lt_10 = protection_rsi_14_15m < 10.0
    roc_9_1d_gt_neg_40 = protection_roc_9_1d > -40.0
    change_pct_1d_lt_10 = protection_change_pct_1d < 10.0
    top_wick_pct_1d_lt_20 = protection_top_wick_pct_1d < 20.0
    rsi_3_1h_gt_3 = protection_rsi_3_1h > 3.0
    rsi_3_gt_5 = protection_rsi_3 > 5.0
    roc_9_1d_gt_neg_30 = protection_roc_9_1d > -30.0
    change_pct_1d_gt_neg_10 = protection_change_pct_1d > -10.0
    change_pct_1d_lt_30 = protection_change_pct_1d < 30.0
    cci_20_4h_lt_neg_200 = protection_cci_20_4h < -200.0
    cci_20_1h_gt_250 = protection_cci_20_1h > 250.0
    top_wick_pct_1d_lt_25 = protection_top_wick_pct_1d < 25.0
    stochrsik_14_14_3_3_1h_gt_70 = protection_stochrsik_14_14_3_3_1h > 70.0
    roc_9_1d_gt_neg_15 = protection_roc_9_1d > -15.0
    change_pct_1d_lt_50 = protection_change_pct_1d < 50.0
    cci_20_4h_gt_200 = protection_cci_20_4h > 200.0
    cci_20_15m_gt_250 = protection_cci_20_15m > 250.0
    aroonu_14_15m_lt_80 = protection_aroonu_14_15m < 80.0
    rsi_3_15m_lt_95 = protection_rsi_3_15m < 95.0
    rsi_14_4h_lt_75 = protection_rsi_14_4h < 75.0
    rsi_14_4h_lt_45 = protection_rsi_14_4h < 45.0
    rsi_14_1h_lt_35 = protection_rsi_14_1h < 35.0
    rsi_14_1d_gt_50 = protection_rsi_14_1d > 50.0
    rsi_14_15m_lt_25 = protection_rsi_14_15m < 25.0
    roc_9_1d_gt_neg_25 = protection_roc_9_1d > -25.0
    roc_9_15m_lt_10 = protection_roc_9_15m < 10.0
    cmf_20_1d_gt_neg_0_20 = protection_cmf_20_1d > -0.20
    change_pct_1d_gt_neg_20 = protection_change_pct_1d > -20.0
    cci_20_1h_lt_neg_250 = protection_cci_20_1h < -250.0
    aroond_14_4h_lt_50 = protection_aroond_14_4h < 50.0
    willr_14_4h_gt_neg_10 = protection_willr_14_4h > -10.0
    top_wick_pct_4h_lt_10 = protection_top_wick_pct_4h < 10.0
    top_wick_pct_1d_lt_50 = protection_top_wick_pct_1d < 50.0
    stochrsik_14_14_3_3_4h_gt_80 = protection_stochrsik_14_14_3_3_4h > 80.0
    stochrsik_14_14_3_3_4h_gt_60 = protection_stochrsik_14_14_3_3_4h > 60.0

    df["protections_long_global"] = (
      # 5m & 15m & 1h & 4h & 1d down move, 1h & 4h & 1d still not low enough
      (
        (protection_rsi_3 > 1.0)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | rsi_3_1d_gt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (protection_rsi_14_1d < 30.0)
        | (cci_20_1h_lt_neg_250)
        | (cci_20_4h_lt_neg_200)
      )
      # 5m & 4h & 1d down move, 15m & 1h & 4h still not low enough, 1d still high
      & (
        (protection_rsi_3 > 1.0)
        | (rsi_3_4h_gt_10)
        | rsi_3_1d_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_15m_lt_20
        | (protection_stochrsik_14_14_3_3_1d < 50.0)
      )
      # 5m down move, 15m & 1h & 4h still high, 15m high
      & (
        (protection_rsi_3 > 3.0)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_70
        | stochrsi_k_15m_lt_70
      )
      # 1h & 4h down move, 15m & 1h & 4h downtrend, 1h still high
      & (
        (rsi_3_gt_5)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_55
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_4h_lt_60
        | roc_9_1d_lt_80
      )
      # 5m & 15m & 1h down move, 1h & 4h still high, 15m still high, 1h high
      & (
        (rsi_3_gt_5)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_85
        | stochrsi_k_1h_lt_70
      )
      # 5m & 15m & 1h & 4h down move, 4h high
      & (
        (rsi_3_gt_5)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_55
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_70
      )
      # 5m & 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 4h high
      & (
        (rsi_3_gt_5)
        | rsi_3_15m_gt_30
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_80
      )
      # 5m & 15m & 4h down move, 15m & 1h & 4h still high, 15m & 1h still high
      & (
        (rsi_3_gt_5)
        | rsi_3_15m_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_50
      )
      # 5m & 4h & 1d down move, 15m high
      & ((rsi_3_gt_5) | (rsi_3_4h_gt_10) | rsi_3_1d_gt_15 | aroonu_14_15m_lt_60 | stochrsi_k_15m_lt_70)
      # 5m & 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h stil high, 15m & 4h high
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | stochrsi_k_15m_lt_60
        | stochrsi_k_4h_lt_70
      )
      # 5m & 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h high
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | stochrsi_k_15m_lt_50
      )
      # 5m & 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m high
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_60
      )
      # 5m & 15m & 1h down move, 15m & 1h still high, 4h high, 15m still not low enough, 5h overbought
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_25
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_80
        | stochrsi_k_15m_lt_20
        | roc_9_4h_lt_80
      )
      # 5m & 15m & 1h & 1d down move, 1h & 4h still high, 1d downtrend
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_25
        | (rsi_3_1h_gt_65)
        | rsi_3_1d_gt_25
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_1d_gt_neg_0_20)
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_15)
      )
      # 5m & 15m & 4h down move, 15m & 1h still not low enough, 4h still high, 15m & 4h high
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
        | stochrsi_k_15m_lt_60
      )
      # 5m & 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 15m & 4h high
      & (
        (rsi_3_gt_10)
        | rsi_3_15m_gt_30
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
        | stochrsi_k_15m_lt_30
        | stochrsi_k_4h_lt_50
      )
      # 5m & 15m & 1h down move, 15m still high, 1h & 4h high, 4h high & overbought
      & (
        (protection_rsi_3 > 15.0)
        | rsi_3_15m_gt_30
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_40
        | aroonu_14_4h_lt_80
        | stochrsi_k_15m_lt_20
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h down move, 1h still high, 15m & 1h downtrend
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_3)
        | rsi_3_4h_gt_20
        | aroonu_14_1h_lt_50
        | (protection_roc_9_15m > -10.0)
        | roc_9_1h_gt_neg_15
      )
      # 15m & 1h & 4h down move, 15m downtrend, 1h still high, 4h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_30
        | (cmf_20_15m_gt_neg_020)
        | aroonu_14_1h_lt_50
        | stochrsi_k_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m downtrend, 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m downtrend, 15m & 1h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | (cmf_20_15m_gt_neg_030)
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_20
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 15m downtrend, 4h overbought
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_35
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_020)
        | roc_9_4h_lt_15
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_40
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_30
      )
      # 15m & 1h & 4h down move, 4h still high, 1h downtrend, 4h still high
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_45
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_030)
        | aroonu_14_4h_lt_40
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m downtrend
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_25
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_4h_lt_25
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m still not low enough
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_45
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (aroonu_14_15m_lt_25)
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m & 1h & 4h downtrend, 1h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_025)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_1h_lt_30
      )
      # 15m & 1h & 4h & 1d down move, 1h still high, 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_50
        | aroonu_14_1h_lt_50
        | (cci_20_1h_lt_neg_250)
        | (protection_cci_20_4h < -250.0)
      )
      # 15m & 1h & 4h down move, 4h downtrend, 15m & 1h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | (cmf_20_4h_gt_neg_030)
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_30
      )
      # 15m & 4h down move, 15m & 1h & 4h still not low enough, 1h still not low enough
      & (
        (rsi_3_15m_gt_3)
        | (rsi_3_4h_gt_10)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | stochrsi_k_1h_lt_30
      )
      # 15m & 4h down move, 1h & 4h still high, 15m still not low enough, 1h still high
      & (
        (rsi_3_15m_gt_3)
        | rsi_3_4h_gt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (aroonu_14_15m_lt_25)
        | stochrsi_k_1h_lt_50
      )
      # 15m down move, 15m & 1h high
      & ((rsi_3_15m_gt_3) | aroonu_14_15m_lt_70 | aroonu_14_1h_lt_90 | stochrsi_k_15m_lt_50 | stochrsi_k_1h_lt_90)
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 1h & 4h still not low enough, 4h downtrend
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_20
        | cmf_20_15m_gt_neg_015
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_015)
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_20
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 1h still high, 15m still not low enough, 15m & 1h downtrend
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_20
        | (cmf_20_15m_gt_neg_020)
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_40
        | stochrsi_k_15m_lt_30
        | (protection_roc_9_15m > -15.0)
        | roc_9_1h_gt_neg_15
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 15m & 4h still not low enough
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_20
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_025)
        | stochrsi_k_15m_lt_20
        | stochrsi_k_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 15m still not low enough
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_20
        | cmf_20_15m_gt_neg_040
        | (cmf_20_1h_gt_neg_040)
        | stochrsi_k_15m_lt_20
      )
      # 5m & 1h & 4h down move, 1h & 4h downtrend, 15m still high, 4h still not low enough
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_20
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_10
      )
      # 15m & 1h & 4h & 1d down move, 15m downtrend, 15m still not low enough, 1h downtrend
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_30
        | (cmf_20_15m_gt_neg_020)
        | stochrsi_k_15m_lt_10
        | roc_9_1h_gt_neg_10
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 15m still not low enough
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_25
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_030)
        | (cmf_20_4h_gt_neg_030)
        | stochrsi_k_15m_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 15m still high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_25
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | aroonu_14_15m_lt_50
      )
      # 15m & 1h & 4h & 1d down move, 15m downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_40
        | (cmf_20_15m_gt_neg_030)
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 15m & 4h still not low enough
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_30
        | cmf_20_15m_gt_neg_015
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_020)
        | stochrsi_k_15m_lt_10
        | stochrsi_k_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 1h still not low enugh, 4h still high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_40
        | cmf_20_15m_gt_neg_010
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 4h still high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_5)
        | (rsi_14_1h_lt_20)
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_040)
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 1h still high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_30
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_030)
        | stochrsi_k_1h_lt_50
      )
      # 15m & 1h & 4h & 1d down move, 15m downtrend, 1h still high, 1h & 4h still not low enough, 4h overbought
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_55
        | rsi_3_1d_gt_55
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_1h_lt_40
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_20
        | roc_9_4h_lt_10
      )
      # 15m & 1h down move, 1h & 4h still not low enough, 4h high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_10)
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_20
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_90
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m & 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_25
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_025)
        | (cmf_20_4h_gt_neg_015)
      )
      # 15m & 1h & 4h down move, 1h & 4h stil not low enough, 15m & 1h & 4h downtrend, 1h still high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_1h_lt_50
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m & 4h still not low enough, 15m & 4h still not low
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_35
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_010
        | (cmf_20_4h_gt_neg_020)
        | stochrsi_k_15m_lt_20
        | stochrsi_k_4h_lt_30
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m still high
      & (
        (rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | rsi_3_4h_gt_55 | rsi_14_1h_lt_30 | rsi_14_4h_lt_40 | aroonu_14_15m_lt_50
      )
      # 15m & 1h down move, 1h high, 4h high
      & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | aroonu_14_1h_lt_80 | stochrsi_k_4h_lt_80)
      # 15m & 1h & 4h down move, 1h still not low enough, 4h still high, 15m still not low enough, 1d high & overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_35
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | stochrsi_k_15m_lt_20
        | (protection_stochrsik_14_14_3_3_1d < 90.0)
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m downtrend, 1h still high, 15m still not low enough
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_40
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_20
      )
      # 15m & 1h down move, 1h & 4h high
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_20
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h & 1d down move, 15m downtrend
      & ((rsi_3_15m_gt_5) | rsi_3_1h_gt_20 | rsi_3_4h_gt_25 | rsi_3_1d_gt_5 | cmf_20_15m_gt_neg_040)
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 15m still high, 4h overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_20
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_50
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 15m downtrend, 4h high
      & ((rsi_3_15m_gt_5) | rsi_3_1h_gt_25 | rsi_3_4h_gt_25 | (cmf_20_15m_gt_neg_030) | aroonu_14_4h_lt_80)
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 4h downtrend, 4h high
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_4h_gt_neg_020)
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 1h high, 4h downtrend
      & ((rsi_3_15m_gt_5) | rsi_3_1h_gt_30 | rsi_3_4h_gt_40 | aroonu_14_1h_lt_70 | roc_9_4h_gt_neg_40)
      # 15m & 1h & 4h down move, 1h & 4h still high, 15m downtrend
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_50
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_4h_lt_50
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high, 1h high, 4h overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_80
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h & 4h still high, 15m still high
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_50
        | stochrsi_k_15m_lt_50
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 4h high
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_60
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_80
      )
      # 15m & 1h & 3h down move, 1h & 4h still not low enough, 15m downtrend, 1h still high
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_030)
        | stochrsi_k_1h_lt_50
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_1d_lt_70
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | stochrsi_k_1h_lt_70
        | roc_9_1d_lt_60
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m still not low enough
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | (rsi_14_15m_lt_10)
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_30
        | stochrsi_k_15m_lt_20
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_75
        | aroonu_14_4h_lt_90
        | roc_9_1h_lt_10
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 15m downtrend, 1h still high
      & (
        (rsi_3_15m_gt_5)
        | (rsi_3_1h_gt_65)
        | rsi_3_4h_gt_65
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | cmf_20_15m_gt_neg_040
        | aroonu_14_1h_lt_50
      )
      # 15m & 4h down move, 15m & 1h still not low enough, 4h still high, 1h & 4h still not low enough, 1d overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_3_4h_gt_20
        | (rsi_14_15m_lt_10)
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_20
        | roc_9_1d_lt_20
      )
      # 15m down move, 15m still not low enough, 1h & 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_10
      )
      # 15m down move, 15m still not low enough, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_5)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_70
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m & 1h & 4h downtrend, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_10)
        | (protection_rsi_14_1h < 10.0)
        | (rsi_14_4h_lt_20)
        | cmf_20_15m_gt_neg_015
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_015)
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 4h still high, 15m & 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 4h still high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | (cmf_20_15m_gt_neg_025)
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_015)
        | aroonu_14_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h downtrend, 15m still high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_040)
        | stochrsi_k_15m_lt_50
      )
      # 15m & 1h & 4h down move, 1h & 4h downtrend, 1h still high, 1h downtrend
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | (cmf_20_1h_gt_neg_030)
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_1h_lt_50
        | roc_9_1h_gt_neg_15
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m still high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | (rsi_3_4h_gt_15)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_30
        | stochrsi_k_15m_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 15m still high, 4h still not low enough
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_20
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_025)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_20
      )
      # 15m & 1h & 4h down move, 1h & 15m still high, 1h downtrend
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_20
        | aroonu_14_1h_lt_40
        | stochrsi_k_15m_lt_50
        | roc_9_1h_gt_neg_10
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 4h high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_25
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_4h_lt_70
      )
      # 15m & 1h & 4h down move, 4h still not low enough, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_25
        | rsi_14_4h_lt_30
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h downtrend, 15m still not low enough
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_30
        | (rsi_14_15m_lt_10)
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_020)
        | cmf_20_1h_gt_neg_015
        | stochrsi_k_15m_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h downtrend, 4h still high, 4h downtrend
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_015
        | (cmf_20_1h_gt_neg_025)
        | aroonu_14_4h_lt_40
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 15m & 1h downtrend
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (protection_roc_9_15m > -10.0)
        | roc_9_1h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | roc_9_1d_lt_200
      )
      # 15m & 1h down move, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_10)
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_80)
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_20
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h downtrend, 15m still not low enough
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_025)
        | stochrsi_k_15m_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h & 4h downtrend, 1h still not low enough
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_025)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_1h_lt_30
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 4h high, 1d overbought
      & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | rsi_3_4h_gt_45 | rsi_14_1h_lt_30 | (rsi_14_4h_lt_60) | roc_9_1d_lt_200)
      # 15m & 1h & 4h down move, 1h downtrend, 4h high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_55
        | rsi_14_4h_lt_50
        | cmf_20_1h_gt_neg_04
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 1h & 4h downtrend, 15m & 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_020)
        | (aroonu_14_15m_lt_25)
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 15m still high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_030)
        | (cmf_20_4h_gt_neg_030)
        | stochrsi_k_15m_lt_50
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 4h still high, 1h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_025)
        | aroonu_14_4h_lt_50
        | (protection_cci_20_1h < -200.0)
        | (protection_cci_20_4h < -0.0)
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_25
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h & 1d down move, 1h still not low enough, 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_45
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_80
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h stil high, 1h & 4h downtrend, 1h & 4h still not low
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_45
        | (rsi_14_15m_lt_10)
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | stochrsi_k_1h_lt_40
        | roc_9_1d_lt_100
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_90
        | roc_9_4h_lt_25
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high, 1h & 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_20
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_10
        | roc_9_1d_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 1h & 4h still high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_020)
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low, 4h still high, 15m & 1h downtrend, 4h not low, 4h downtrend
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | cmf_20_15m_gt_neg_010
        | (cmf_20_1h_gt_neg_020)
        | aroonu_14_4h_lt_20
        | roc_9_4h_gt_neg_10
      )
      # 15m & 1h & 4h down move, 1h & 4h not low enouhg, 15m downtrend, 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_4h_lt_60
        | roc_9_1d_lt_25
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h still not low enough, 4h still high. 1d high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (protection_aroonu_14_1d < 70.0)
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 1h & 4h still not low enough, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_1h_lt_25
        | aroonu_14_4h_lt_25
        | roc_9_1h_gt_neg_10
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 1d down move, 1h still not low enough, 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_1d_gt_25
        | rsi_14_1h_lt_30
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_90
        | roc_9_1h_gt_neg_20
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 1d down move, 15m still not low enough, 1h & 4h still high, 1h high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_25
        | rsi_3_1d_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_70
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 15m & 1h downtrend
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_025)
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_45
        | (protection_rsi_14_1h < 45.0)
        | (protection_rsi_14_4h < 55.0)
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_25
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 15m downtrend, 4h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_60
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_4h_lt_80
      )
      # 15m & 1h down move, 4h high, 1d downtrend, 1h still not low enough, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_30
        | (rsi_14_4h_lt_70)
        | (protection_cmf_20_1d > -0.3)
        | aroonu_14_1h_lt_30
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h not low enough, 4h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_15
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_35)
        | stochrsi_k_15m_lt_30
        | stochrsi_k_4h_lt_85
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1 & 4h still not low enough, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_60
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h & 4h downtrend, 1h still high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_030)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | stochrsi_k_1h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h still high, 1d downtrend
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (protection_aroonu_14_15m < 10.0)
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h down move, 4h still high, 15m downtrend, 1h & 1d high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_40
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_03
        | aroonu_14_1h_lt_60
        | (protection_aroonu_14_1d < 90.0)
        | (protection_stochrsik_14_14_3_3_1d < 80.0)
      )
      # 15m & 1h down move, 15m & 1h still high, 1h & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 1h & 4h sitll high, 15m & 1h & 4h downtrend, 1h & 4h still high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_65
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m stil not low enough, 1h & 4h still high, 15m & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_1d_lt_200
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h downtrend, 1h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_1h_lt_70
      )
      # 15m & 1h & 4h down move, 1h & 4h still not low enough, 15m & 4h downtrend, 1h & 4h still high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_040
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_1h_lt_40
        | stochrsi_k_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 14h & 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | roc_9_4h_lt_20
        | roc_9_1d_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | (rsi_14_4h_lt_70)
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_30
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_20
        | roc_9_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h downtrend, 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_4h_lt_80
        | roc_9_1h_lt_10
      )
      # 15m & 1h & 4h down move, 1h & 4h downtrend, 15m still high, 1h high
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | cmf_20_1h_gt_neg_0
        | cmf_20_4h_gt_neg_04
        | aroonu_14_15m_lt_50
        | stochrsi_k_1h_lt_90
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_40
        | roc_9_1d_lt_200
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_10
        | roc_9_1d_lt_50
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 15m still not low enough, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | (protection_aroonu_14_15m < 10.0)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 15m & 1h high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_1h_gt_neg_0
        | cmf_20_4h_gt_neg_0
        | aroonu_14_15m_lt_50
        | stochrsi_k_1h_lt_80
      )
      # 15m & 1h down move, 15m & 4h high, 4h overbought
      & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_65) | (aroonu_14_15m_lt_80) | aroonu_14_4h_lt_85 | roc_9_4h_lt_100)
      # 15m & 1h down move, 15m & 1h & 4h still high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_20
        | roc_9_4h_lt_30
      )
      # 15m & 4h & 1d down move, 15m high, 15m & 4h still high
      & (
        (rsi_3_15m_gt_10)
        | (rsi_3_4h_gt_15)
        | rsi_3_1d_gt_20
        | aroonu_14_15m_lt_70
        | stochrsi_k_15m_lt_40
        | stochrsi_k_4h_lt_50
      )
      # 15m & 4h & 1d down move, 15m & 1h still not low enough, 1h still high, 4h & 1d downtrend
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_4h_gt_20
        | rsi_3_1d_gt_20
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | stochrsi_k_1h_lt_40
        | roc_9_4h_gt_neg_25
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 4h down move, 1h & 4h stil high, 15m high, 4h overbought
      & ((rsi_3_15m_gt_10) | rsi_3_4h_gt_60 | rsi_14_1h_lt_50 | rsi_14_4h_lt_50 | aroonu_14_15m_lt_70 | roc_9_4h_lt_30)
      # 15m down move, 15m still not low enough, 1h & 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_30
        | roc_9_4h_lt_80
      )
      # 15m down move, 15m & 1h & 4h still high, 15m still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_80
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_15)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_35
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h high, 15m still not low enough
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_15)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | aroonu_14_1h_lt_70
        | stochrsi_k_15m_lt_30
      )
      # 15m & 1h & 4h & 1d down move, 1h & 4h still not low enough, 1h & 4h downtrend, 4h still high
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_25
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_4h_lt_40
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h & 1d down move, 1h still not low enough, 4h still high, 4h downtrend, 1h still not low enough
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_50
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_40
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_1h_lt_20
      )
      # 15m & 1h & 4h & 1d down move, 15m downtrend, 15m & 4h high, 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_50
        | (cmf_20_15m_gt_neg_020)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | (roc_9_1d_gt_neg_40)
      )
      # 15m & 1h & 4h & 1d down move, 4h still not low enough, 15m & 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_40
        | rsi_3_1d_gt_40
        | (protection_rsi_14_15m > 20.0)
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_020)
        | cmf_20_4h_gt_neg_0
        | aroonu_14_4h_lt_20
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 4h high, 1h downtrend
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_45
        | rsi_14_1h_lt_30
        | (rsi_14_4h_lt_45)
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_90
        | roc_9_1h_gt_neg_30
      )
      # 15m & 1h & 4h down move, 4h high, 1d overbought
      & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | rsi_3_4h_gt_45 | aroonu_14_4h_lt_80 | roc_9_1d_lt_150)
      # 15m & 1h down move, 15m & 1h still not low enough, 4h still high, 4h high
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_60
        | stochrsi_k_4h_lt_90
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high. 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_15)
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 15m downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_050)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m high, 1h still high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_60
        | stochrsi_k_1h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 15m downtrend, 4h high, 1h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_4h_lt_60
        | roc_9_1h_gt_neg_10
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_85
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h & 4h downtrend, 1h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_040)
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_70
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_20
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
        | stochrsi_k_4h_lt_90
      )
      # 15m & 1h & 4h & 1d down move, 15m still not low enough, 1h & 4h still high, 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_60
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_50
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | stochrsi_k_1h_lt_50
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 1d down move, 15m & 1h still not low enough, 4h high, 1d downtrend, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_25
        | rsi_3_1d_gt_25
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | (rsi_14_4h_lt_60)
        | aroonu_14_4h_lt_85
        | roc_9_1h_gt_neg_10
        | roc_9_4h_lt_30
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_25
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 15m still high 4h & 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_30
        | (rsi_14_15m_lt_25)
        | (protection_rsi_14_1h < 25.0)
        | (protection_rsi_14_4h < 25.0)
        | aroonu_14_15m_lt_50
        | roc_9_4h_gt_neg_15
        | (roc_9_1d_gt_neg_15)
      )
      # 15m & 1h & 4h down move, 15m downtrend, 15m & 1h still not low enough, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | (cmf_20_15m_gt_neg_020)
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_20
        | roc_9_1h_gt_neg_10
        | roc_9_4h_gt_neg_15
      )
      # 15m & 1h & 4h down move, 1h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_45
        | (rsi_14_1h_lt_35)
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_25
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 4h still high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_25
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_45)
        | roc_9_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high, 4h high & overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_15
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 1d downtrend, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | (protection_cmf_20_1d > -0.10)
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_20
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h down move, 15m still high, 1h & dh high, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_40
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 1d high, 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_40
        | rsi_3_1d_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (protection_rsi_14_1d < 40.0)
        | (protection_aroonu_14_1d < 70.0)
        | roc_9_4h_gt_neg_40
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h high, 1d downtrend, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_1h_gt_neg_20
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h high & overbought, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_20
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h high, 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_70
        | (protection_roc_9_1d > -20.0)
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_20
        | roc_9_4h_lt_40
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 1d downtrend, 1h & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (protection_cmf_20_1d > -0.1)
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_90
        | roc_9_1d_lt_20
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_85
        | stochrsi_k_4h_lt_85
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h & 1d down move, 1h still high, 4h still not low enough, 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_20
        | rsi_3_1d_gt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_1h_lt_50
        | (cci_20_1h_lt_neg_250)
        | (protection_cci_20_4h < -250.0)
        | roc_9_4h_gt_neg_15
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h downtrend, 1h & 4h still not low enough, 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_30
        | (rsi_14_1h_lt_35)
        | (protection_rsi_14_4h < 35.0)
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_030)
        | (cmf_20_4h_gt_neg_030)
        | (protection_cci_20_1h < -200.0)
        | (cci_20_4h_lt_neg_200)
        | (roc_9_1d_gt_neg_25)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h overbought, 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_30
        | roc_9_1h_lt_10
        | roc_9_4h_gt_neg_10
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h still high, 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_80
      )
      # 15m & 1h & 4h down move, 4h downtrend, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | (cmf_20_4h_gt_neg_010)
        | stochrsi_k_1h_lt_70
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h & 1d still high, 1h downtrend, 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (protection_rsi_14_1d < 40.0)
        | cmf_20_1h_gt_neg_015
        | stochrsi_k_15m_lt_10
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_40
        | (roc_9_1d_gt_neg_25)
      )
      # 15m down move, 15m still not low enough, 1h & 4h still high, 15m still high, 1h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_85
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h downtrend, 15m & 4h still not low, 1h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_1h_gt_neg_025)
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_30
        | stochrsi_k_1h_lt_70
      )
      # 15m ^ 1h down move, 15m & 1h & 4h still not low enough, 1h & 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_1h_lt_70
        | stochrsi_k_4h_lt_80
        | roc_9_1h_lt_10
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 15m still high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_85
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_70
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m still high, 1h & 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_85
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_60
        | stochrsi_k_1h_lt_70
        | stochrsi_k_4h_lt_70
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 1d down move, 15m still not low enough, 1h & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_55
        | rsi_3_1d_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1d_lt_50
      )
      # 14m & 1h down move, 15m & 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (protection_rsi_14_4h < 65.0)
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_35
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 5h still high, 15m still high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_50
        | roc_9_4h_lt_20
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 1d down move, 15m still not low enough, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_60)
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_70
        | roc_9_1d_lt_80
      )
      # 15m & 1h down move, 15m & 1h stil high, 4h high, 15m & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_70
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_100
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 15m downtrend, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_25
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 1h & 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_90
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_15
      )
      # 15m & 4h down move, 15m high, 4h downtrend
      & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_3) | stochrsi_k_15m_lt_70 | roc_9_4h_gt_neg_15)
      # 15m & 4h down move, 15m & 1h & 4h still not low enough, 15m & 4h downtrend, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_4h_gt_5)
        | (rsi_14_15m_lt_10)
        | (protection_rsi_14_1h < 10.0)
        | (protection_rsi_14_4h < 10.0)
        | cmf_20_15m_gt_neg_010
        | (cmf_20_4h_gt_neg_020)
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_20
        | roc_9_1h_gt_neg_15
        | roc_9_4h_gt_neg_15
      )
      # 15m & 4h & 1d down move, 15m & 1h & 4h still not low enough, 15m & 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_4h_gt_15)
        | rsi_3_1d_gt_25
        | (protection_rsi_14_15m > 25.0)
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_03
        | (protection_cmf_20_1d > -0.3)
        | aroonu_14_15m_lt_30
      )
      # 15m & 4h down move, 15m & 1h still high, 1h high, 1h over
      & (
        (rsi_3_15m_gt_15)
        | (rsi_3_4h_gt_15)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | aroonu_14_1h_lt_80
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_90
        | roc_9_1h_lt_10
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h downtrend
      & (
        (rsi_3_15m_gt_15)
        | (protection_rsi_3_4h > 20)
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_40
      )
      # 15m & 4h down move, 15m & 1h & 4h still not low enough, 15m & 4h high, 4h downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_80
        | roc_9_4h_gt_neg_20
      )
      # 15m & 4h down move, 1h high & overbought
      & ((rsi_3_15m_gt_15) | rsi_3_4h_gt_45 | stochrsi_k_1h_lt_90 | roc_9_1h_lt_10)
      # 15m & 4h down move, 15m & 1h & 4h still high, 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_1h_lt_10
        | roc_9_4h_lt_10
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_4h_lt_70
        | stochrsi_k_15m_lt_50
        | roc_9_4h_lt_10
      )
      # 15m & 1d down move, 15m still not low enough, 1h & 4h high
      & ((rsi_3_15m_gt_15) | rsi_3_1d_gt_5 | rsi_14_15m_lt_30 | stochrsi_k_1h_lt_70 | stochrsi_k_4h_lt_70)
      # 15m & 1d down move, 15m still not low enough, 1h & 4h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_80
      )
      # 15m down move, 15m & 1h & 4h still not low enough, 15m & 1h downtrend, 15m & 1h high
      & (
        (rsi_3_15m_gt_15)
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
      )
      # 15m down move, 15m still not low enough, 1h & 4h high, 1d downtrend, 1h & 4h high
      & (
        (rsi_3_15m_gt_15)
        | (protection_rsi_14_15m < 35.0)
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_70)
        | (protection_cmf_20_1d > -0.1)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
      )
      # 15m down move, 15m still not low enough, 1h & 4h high, 1d overbought
      & ((rsi_3_15m_gt_15) | aroonu_14_15m_lt_30 | aroonu_14_1h_lt_85 | aroonu_14_4h_lt_100 | roc_9_1d_lt_250)
      # 15m down move, 15m & 1h still high, 1h high, 1h overbought, 4h & 1d downtrend
      & (
        (rsi_3_15m_gt_15)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_85
        | roc_9_1h_lt_40
        | roc_9_4h_gt_neg_50
        | (roc_9_1d_gt_neg_50)
      )
      # 15m down move, 15m still high, 1h & 4h high, 1h & 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | roc_9_1h_lt_40
        | roc_9_1d_lt_100
      )
      # 15m down move, 15m still not low enough, 1h & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_85
        | roc_9_4h_lt_20
        | roc_9_1d_lt_50
      )
      # 15m down move, 15m & 1h & 4h still high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_15)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_80
        | stochrsi_k_4h_lt_90
        | roc_9_1h_lt_20
        | roc_9_4h_lt_20
      )
      # 15m down move, 15m high, 1h & 4h overbought
      & ((rsi_3_15m_gt_15) | (protection_aroonu_14_15m < 75.0) | roc_9_1h_lt_50 | roc_9_4h_lt_80)
      # 15m & 1h & 4h down move, 1h still high, 15m still not low enough, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_5)
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_20
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 4h & 1d down move, 15m downtrend, 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_45
        | cmf_20_15m_gt_neg_040
        | aroonu_14_1h_lt_20
        | stochrsi_k_1h_lt_15
        | stochrsi_k_4h_lt_15
        | (protection_cci_20_1h < -350.0)
        | (cci_20_4h_lt_neg_200)
      )
      # 15m & 1h & 4h down move, 15m downtrend, 1h & 4h till high, 15m still high, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | cmf_20_15m_gt_neg_03
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_50
        | stochrsi_k_15m_lt_40
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h & 1d down move, 4h & 1d still not low enough, 1d downtrend, 1h & 4h still high, 1d downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_20
        | rsi_3_1d_gt_25
        | rsi_14_4h_lt_30
        | (protection_rsi_14_1d < 30.0)
        | (cmf_20_1d_gt_neg_0_20)
        | aroonu_14_1h_lt_40
        | stochrsi_k_4h_lt_40
        | (roc_9_1d_gt_neg_15)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 1h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_70
        | (protection_cci_20_1h < -200.0)
        | (cci_20_4h_lt_neg_200)
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 1d overbought
      & ((rsi_3_15m_gt_20) | rsi_3_1h_gt_20 | rsi_3_4h_gt_30 | aroonu_14_1h_lt_25 | roc_9_1d_lt_200)
      # 15m & 1h & 4h & 1d down move, 1h & 4h still not low enough, 1d still high, 1d downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_45
        | rsi_14_4h_lt_30
        | (protection_rsi_14_1d < 50.0)
        | (protection_cmf_20_1d > -0.0)
        | (protection_mfi_14_1d < 70.0)
        | (cci_20_1h_lt_neg_250)
        | (cci_20_4h_lt_neg_200)
        | roc_9_4h_gt_neg_10
        | roc_9_1d_lt_15
      )
      # 15m & 1h & 4h & 1d down move, 1h & 4h still not low enough, 15m & 1h downtrend, 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_50
        | rsi_3_1d_gt_50
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_040
        | (cmf_20_1h_gt_neg_025)
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_10
      )
      # 15m & 1h down move, 15m & 1h still not low enough, 4h still high, 15m still not low enough, 1h & 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_20
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h & 4h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_010
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 4h still high, 1h high, 1h & 4h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_70
        | roc_9_1h_gt_neg_10
        | roc_9_4h_gt_neg_10
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_010
        | cmf_20_1h_gt_neg_015
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h & 4h downtrend, 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_015
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_015)
        | stochrsi_k_4h_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m & 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (protection_aroonu_14_15m < 75.0)
        | stochrsi_k_4h_lt_90
      )
      # 15m & 1h down move, 1h still not low enough, 1h still high, 4h high & overbought, 1d downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_90
        | roc_9_4h_lt_40
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | stochrsi_k_1h_lt_50
        | roc_9_1d_lt_150
      )
      # 15m & 1h & 1d down move, 1h & 4h still high, 15m downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_25
        | rsi_3_1d_gt_55
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_03
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h still high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_30
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_50
        | roc_9_4h_gt_neg_70
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 4h still high, 1h & 4h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_40
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | aroonu_14_4h_lt_40
        | roc_9_1h_gt_neg_15
        | roc_9_4h_gt_neg_30
        | roc_9_1d_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m stil high, 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_70
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 4h downtrend, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_1h_lt_70
        | roc_9_4h_gt_neg_40
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 15m & 1h downtrend, 1h & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_20
        | roc_9_1d_lt_25
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_20
        | roc_9_1d_lt_50
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_20
        | roc_9_1d_lt_200
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_4h_lt_70
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_40
      )
      # 15m & 1h down move, 1h still high, 1h & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_20
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 4h still not low enough, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_30
        | roc_9_4h_gt_neg_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 4h still high, 15m still not low enough, 1h still high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_40
        | cmf_20_15m_gt_neg_010
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_4h_lt_40
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_40
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 4h & 1d down move, 1d still high, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_25
        | (protection_mfi_14_1d < 50.0)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
      )
      # 15m & 1h & 4h & 1d down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_55
        | rsi_3_1d_gt_55
        | (rsi_14_15m_lt_25)
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_010
        | aroonu_14_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_20
      )
      # 15m & 1h down move, 15m & 1h & 4h still not low enough, 15m still high, 1h high, 1h & 4h still high, 1d downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_90
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m still not lowenough, 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (aroonu_14_15m_lt_25)
        | aroonu_14_1h_lt_80
        | roc_9_1d_lt_80
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 15m & 1h high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
        | roc_9_4h_lt_10
      )
      # 15m & 1h down move, 15m & 1h sitll high, 4h high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_90
        | roc_9_1h_lt_20
        | roc_9_4h_lt_30
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 4h downtrend, 15m & 1h still high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_4h_gt_neg_025)
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_50
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 15m downtrend, 15m still high, 1h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | (cmf_20_15m_gt_neg_020)
        | aroonu_14_15m_lt_50
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_40
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 4d downtrend, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | (cmf_20_4h_gt_neg_040)
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 4h downtrend, 15m high, 4h & 1d downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_4h_gt_neg_040)
        | aroonu_14_15m_lt_60
        | roc_9_4h_gt_neg_20
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h down move, 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_50
        | (protection_cci_20_1h < 0.0)
        | (protection_cci_20_4h < 0.0)
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h still high, 4h high, 15m stil high, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_25
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_020)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 15m still high, 1h high, 4h & 1d downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_45
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | aroonu_14_15m_lt_40
        | stochrsi_k_1h_lt_70
        | roc_9_4h_gt_neg_25
        | (roc_9_1d_gt_neg_30)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m high, 1h still high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | stochrsi_k_1h_lt_40
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 1d down move, 15m still not low enough, 1h & 4h still high, 1h high, 4h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_45
        | rsi_3_1d_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_70
        | roc_9_4h_gt_neg_20
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low, 1h & 4h sitll high, 15m & 1h downtrend, 15m still high, 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | cmf_20_15m_gt_neg_010
        | (cmf_20_1h_gt_neg_020)
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 15m still high, 1h & 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | roc_9_1h_lt_10
        | roc_9_1d_lt_200
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 1h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_85
        | roc_9_1h_lt_10
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 15m & 1h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | (cmf_20_15m_gt_neg_025)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_90
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m still high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_50
        | roc_9_4h_gt_neg_40
      )
      # 15m & 1h & 4h down move, 1h & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_60
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_4h_lt_75
        | roc_9_4h_lt_25
        | roc_9_1d_lt_150
      )
      # 15m & 1h down move, 15m & 1h stil high, 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_4h_lt_70
        | roc_9_1h_lt_40
        | roc_9_4h_lt_50
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 15m & 1h & 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_100
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 15m & 4h high, 15m & 1h still not low enough, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (protection_rsi_14_4h < 65.0)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_80
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_30
        | roc_9_4h_lt_30
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 1h & 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_80
        | roc_9_1h_lt_15
      )
      # 15m & 1h down move, 15m still high, 1h high & overbought
      & (
        (rsi_3_15m_gt_20) | (rsi_3_1h_gt_60) | rsi_14_15m_lt_40 | rsi_14_1h_lt_50 | aroonu_14_1h_lt_70 | roc_9_1h_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_65)
        | (protection_rsi_14_15m < 35.0)
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_75)
        | aroonu_14_4h_lt_70
        | stochrsi_k_15m_lt_20
        | stochrsi_k_4h_lt_70
        | roc_9_4h_lt_100
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_020)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_90
        | roc_9_4h_lt_20
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high, 15m still high, 1h & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_1d_lt_50
      )
      # 15m & 4h down move, 15m & 1h & 4h sitll high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_15
        | roc_9_1d_lt_60
      )
      # 15m & 4h & 1d down move, 15m & 1h & 4h s till high, 15m & 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_50
        | rsi_3_1d_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
        | stochrsi_k_15m_lt_50
      )
      # 15m & 4h down move, 15m & 1h still not low enough, 15m still high, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_20
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | aroonu_14_15m_lt_40
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_25
      )
      # 15m & 4h down move, 15m & 1h still high, 4h downtrend
      & ((rsi_3_15m_gt_20) | rsi_3_4h_gt_20 | aroonu_14_15m_lt_50 | stochrsi_k_1h_lt_50 | roc_9_4h_gt_neg_30)
      # 15m &4d down move, 15m & 1h high, 4h downtrend
      & ((rsi_3_15m_gt_20) | rsi_3_4h_gt_20 | aroonu_14_15m_lt_60 | stochrsi_k_1h_lt_80 | roc_9_4h_gt_neg_30)
      # 15m & 4h down move, 4h still high, 4h downtrend, 1d overbought
      & ((rsi_3_15m_gt_20) | rsi_3_4h_gt_20 | aroonu_14_4h_lt_50 | roc_9_4h_gt_neg_30 | roc_9_1d_lt_100)
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m still not low enough, 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_40
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h still high, 15, & 4h still high, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_50
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_20
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m still high, 1h high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_100
        | roc_9_4h_lt_70
      )
      # 15m & 4h down move, 15m & 1h still not low enough, 1h still high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_60
        | (protection_rsi_14_15m < 35.0)
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_10
      )
      # 15m & 4h down move, 15m still high, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_100
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h high, 15m & 1h & 4h high
      & (
        (rsi_3_15m_gt_20)
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_90
        | aroonu_14_4h_lt_90
      )
      # 15m down move, 15m still not low enough, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_85
        | roc_9_1h_lt_50
        | roc_9_4h_lt_50
      )
      # 15m down move, 15m still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_80)
        | aroonu_14_4h_lt_80
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_90
        | roc_9_4h_lt_75
      )
      # 15m down move, 15m & 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_20)
        | (rsi_14_15m_lt_50)
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_50
        | roc_9_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_60
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m high, 1h & 4h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h & 4h high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_85
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h still not low enough, 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_55
        | (rsi_14_15m_lt_25)
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | stochrsi_k_15m_lt_20
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 1d down move, 1h & 4h still high, 1d downtrend, 1h high, 1h & 4h still high, 1d downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_3_1d_gt_25
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_1d_gt_neg_0_20)
        | aroonu_14_1h_lt_60
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_15)
      )
      # 15m & 1h down move, 15m still not low enough, 1h stil high, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_70
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h still not low enough, 4h stil high, 15m still high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | stochrsi_k_15m_lt_50
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h downtrend, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_30
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_040)
        | (cmf_20_4h_gt_neg_040)
        | roc_9_4h_gt_neg_40
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h still high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_1h_lt_50
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_1h_lt_50
        | stochrsi_k_1h_lt_50
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 4h still high, 15m downtrend, 15m still not low enough
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_030)
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h stil high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_30
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m still not low, 4h high, 1h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (aroonu_14_15m_lt_20)
        | aroonu_14_4h_lt_70
        | stochrsi_k_1h_lt_40
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m still high, 4h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_50
        | roc_9_4h_gt_neg_20
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h still high, 15m still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_40
      )
      # 15m & 1h & 4h down move, 1h still not low enough, 4h still high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_10
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h & 4h still high, 1d downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_50
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_40)
      )
      # 15m & 1h & 1d down move, 15m still not low enough, 1h & 4h still high, 1d downtrend, 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_1d_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_1d_gt_neg_0_20)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_85
        | roc_9_1d_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_20
        | roc_9_1d_lt_20
      )
      # 15m & 1h & 1d down move, 4h & 1d downtrend, 1h & 4h high, 1d downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_3_1d_gt_35
        | cmf_20_4h_gt_neg_01
        | (protection_cmf_20_1d > -0.1)
        | aroonu_14_1h_lt_75
        | stochrsi_k_4h_lt_70
        | (protection_roc_2_1d > -20.0)
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h & 4h downtrend, 4h high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_70)
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_80
        | roc_9_1d_lt_100
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_90
        | stochrsi_k_15m_lt_30
        | stochrsi_k_4h_lt_90
        | roc_9_1h_lt_20
        | roc_9_4h_lt_60
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_40
        | (rsi_3_4h_gt_10)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | cmf_20_1h_gt_neg_015
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_15m_lt_30
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
        | stochrsi_k_15m_lt_30
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_15
        | roc_9_1d_lt_50
      )
      # 15m & 1h down move, 15m sitll not low enough, 1h still high, 4h high, 15m & 1h downtrend, 15m & 1h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | aroonu_14_15m_lt_50
        | stochrsi_k_1h_lt_50
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | stochrsi_k_15m_lt_30
        | stochrsi_k_4h_lt_30
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 15m high, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_50
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 4h, 15m still not low enough, 1h & 4h still high, 15m downtrend, 15m & 4h high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_15m_lt_50
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_40
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_70
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 1d down move, 15m & 1h & 4h still high, 15m & 1d downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_3_1d_gt_55
        | rsi_14_15m_lt_40
        | (protection_rsi_14_1h < 45.0)
        | (rsi_14_4h_lt_45)
        | (aroonu_14_15m_lt_25)
        | aroonu_14_1h_lt_80
        | (protection_roc_9_15m > -40.0)
        | (roc_9_1d_gt_neg_40)
      )
      # 15m & 1h down move, 15m & 1h & 4h stil high, 15m & 1h & 4h high, 1d downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | stochrsi_k_1h_lt_60
        | stochrsi_k_4h_lt_80
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_70
        | stochrsi_k_1h_lt_70
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h still not low enough, 4h still high, 4h downtrend, 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_3_1d_gt_50
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_40
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_70
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_50
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 1h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_90
        | roc_9_4h_lt_10
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 15m & 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_40
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | roc_9_4h_lt_20
        | roc_9_1d_lt_100
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 15m & 1h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
        | roc_9_1h_lt_10
        | roc_9_4h_lt_10
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h downtrend, 4h high & overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_25
      )
      # 15m & 1h down move, 15m still high, 1h & 4h high, 1h overbought, 1d downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_90
        | roc_9_1h_lt_20
        | (roc_9_1d_gt_neg_30)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h high, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_60
        | stochrsi_k_4h_lt_80
        | roc_9_4h_gt_neg_15
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_90
        | roc_9_4h_lt_60
      )
      # 15m & 1h down move, 15m & 1hstill high, 4h downtrend, 15m still high, 1h high
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_1h_gt_60)
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_85
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_70
      )
      # 15m & 1h down move, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_1h_gt_60)
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_90
        | roc_9_4h_lt_120
      )
      # 15m & 1h down move, 15m still high, 1h & 4h high, 1h & 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_20
        | roc_9_4h_lt_50
        | roc_9_1d_lt_250
      )
      # 15m & 4h down move, 15m high, 1h still not low enough, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_4h_gt_3)
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_20
        | roc_9_4h_gt_neg_30
      )
      # 15m & 4h down move, 15m & 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_4h_gt_10)
        | aroonu_14_15m_lt_70
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_30
      )
      # 15m & 4h & 1d down move, 15m still high, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_4h_gt_15)
        | rsi_3_1d_gt_15
        | rsi_14_15m_lt_40
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_50
      )
      # 15m & 4h & 1d down move, 15m high, 1d overbought
      & ((rsi_3_15m_gt_25) | rsi_3_4h_gt_25 | rsi_3_1d_gt_30 | aroonu_14_15m_lt_60 | roc_9_1d_lt_50)
      # 15m & 4h down move, 15m & 1h still high, 15m & 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | (rsi_3_4h_gt_3)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_70
        | roc_9_4h_gt_neg_25
      )
      # 15m & 4h down move, 15m & 1h still not low enough, 4h still high,  1h & 4h downtrend, 15m & 1h & 4h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_40
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_4h_gt_25
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_50
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_30
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | roc_9_1d_lt_50
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 1h high, 1h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_85
        | stochrsi_k_1h_lt_80
        | roc_9_1h_lt_10
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_25
        | roc_9_1d_lt_200
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_50
      )
      # 15m & 1d down move, 1h & 4h still not low enough, 1h & 4h downtrend, 4h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_3_1d_gt_25
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (protection_mfi_14_1h < 40.0)
        | (protection_mfi_14_4h < 50.0)
        | cmf_20_1h_gt_neg_0
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_1h_lt_50
        | stochrsi_k_1h_lt_20
        | stochrsi_k_4h_lt_40
      )
      # 15m down move, 15m & 1h & 4h still high, 15m & 1h & 4h high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_70
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_20
      )
      # 15m down move, 15m & 1h & 4h still high, 15m & 1h downtrend, 4h high, 15m & 1h still high
      & (
        (rsi_3_15m_gt_25)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_020)
        | cmf_20_1h_gt_neg_010
        | aroonu_14_4h_lt_70
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_40
      )
      # 15m down move, 15m still high, 1h >& 4h high, 15m & 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_25
      )
      # 15m down move, 15m still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_80)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_80
        | stochrsi_k_15m_lt_50
        | roc_9_4h_lt_25
      )
      # 15m down move, 15m still high, 1h & 4h high, 1d downtrend, 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_75)
        | (protection_cmf_20_1d > -0.0)
        | aroonu_14_4h_lt_90
        | roc_9_4h_lt_50
      )
      # 15m down move, 15m & 1h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_25)
        | (aroonu_14_15m_lt_80)
        | aroonu_14_1h_lt_100
        | stochrsi_k_1h_lt_90
        | roc_9_1h_lt_10
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 4h downtrend, 1h & 4h still not low enough
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_15)
        | (rsi_14_15m_lt_10)
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_4h_gt_neg_030)
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_30
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enugh, 4h still high, 15m still high, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_15)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | (protection_aroonu_14_1h < 10.0)
        | aroonu_14_4h_lt_40
        | stochrsi_k_15m_lt_50
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_30
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | aroonu_14_15m_lt_30
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_30
        | roc_9_1h_gt_neg_15
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 15m & 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_035)
        | roc_9_1h_gt_neg_10
        | roc_9_4h_gt_neg_15
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 15m still high, 1h & 4h & 1d downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_30
        | (rsi_14_15m_lt_25)
        | (protection_rsi_14_1h < 25.0)
        | (protection_rsi_14_4h < 25.0)
        | aroonu_14_15m_lt_40
        | roc_9_1h_gt_neg_15
        | roc_9_4h_gt_neg_15
        | (roc_9_1d_gt_neg_15)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 4h downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_4h_lt_40
        | stochrsi_k_4h_lt_30
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h & 1d down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | cmf_20_15m_gt_neg_015
        | aroonu_14_4h_lt_70
        | (protection_cci_20_1h < -100.0)
        | (protection_cci_20_4h < 0.0)
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 15m & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 4h downtrend, 1d high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_4h_gt_neg_025)
        | (protection_aroonu_14_1d < 90.0)
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m still not low enough, 4h high & overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (aroonu_14_15m_lt_25)
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | stochrsi_k_15m_lt_30
        | roc_9_1d_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h downtrend, 15m & 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_030)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h stil high, 15m high, 4h downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | roc_9_4h_gt_neg_40
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_20
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 1h still not low enough, 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 1h & 4h downtrend, 15m & 1h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
      )
      # 15m & 1h down move, 15m still not low enough, 1h sitll high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h still high, 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15h & 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | stochrsi_k_15m_lt_50
      )
      # 15m & 1h & 4h down move, 15m high
      & ((rsi_3_15m_gt_30) | rsi_3_1h_gt_40 | rsi_3_4h_gt_40 | aroonu_14_15m_lt_70 | stochrsi_k_15m_lt_70)
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 1h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_100
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still low, 1h & 4h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h stil high, 15m & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h high, 1d downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_45
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_100
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h & 4h & 1d down move, 15m still not low enough, 1h & 4h still high, 4h downtrend, 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | roc_9_4h_gt_neg_20
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_70
        | stochrsi_k_15m_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h stil high, 15m & 4h still high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
        | roc_9_4h_lt_10
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (protection_cci_20_1h < 0.0)
        | (protection_cci_20_4h < 0.0)
        | roc_9_1d_lt_200
      )
      # 15m & 1h & 4h down move, 15m & 1h still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_80
        | roc_9_4h_lt_70
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 15m still high, 1h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_025)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_100
      )
      # 15m & 1h down move, 15m still not low enough, 1h stil high, 4h high, 1h downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | cmf_20_1h_gt_neg_010
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_100
        | roc_9_1d_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 1h high, 1h & 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_60
        | roc_9_1h_lt_20
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h & 1d down move, 15m & 4h downtrend, 15m & 1h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_3_1d_gt_55
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_15m_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_025)
        | aroonu_14_1h_lt_80
        | roc_9_4h_gt_neg_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_85
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_70
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 4h downtrend, 1h still high
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_1h_lt_40
        | stochrsi_k_1h_lt_50
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_50
        | roc_9_1d_lt_150
      )
      # 15m & 1h down move, 15m still high, 1h & 4h high & overbought
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_60)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_90
        | roc_9_1h_lt_50
        | roc_9_4h_lt_100
      )
      # 15m & 1h down move, 15m still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_80)
        | aroonu_14_4h_lt_90
        | roc_9_4h_lt_130
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m still high
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_4h_gt_5)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_30
      )
      # 15m & 4h down move, 15m & 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_4h_gt_15)
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_50
      )
      # 15m & 4h down move, 15m & 1h still high, 1h & 4h downtrend, 15m & 1h still high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_50
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_4h_gt_30
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
      )
      # 15m & 1h down move, 15m still high, 1h & 4h high & overbought
      & (
        (rsi_3_15m_gt_30)
        | (rsi_3_1h_gt_65)
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_75)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_40
        | roc_9_4h_lt_40
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (aroonu_14_15m_lt_80)
        | stochrsi_k_15m_lt_50
      )
      # 15m & 4h down move, 15m & 1h & 4h stil high, 14m & 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_4h_lt_90
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_80
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_4h_lt_30
        | roc_9_1d_lt_200
      )
      # 15m down move, 15m still not low enough, 1h & 4h high
      & (
        (rsi_3_15m_gt_30)
        | rsi_14_15m_lt_30
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_80
        | stochrsi_k_4h_lt_80
      )
      # 15m down move, 15m & 1h & 4h still high, 15m high, 15m & 1h still high, 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_30)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_70
        | roc_9_4h_lt_20
      )
      # 15m & 1h down move, 15m & 1h still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_20
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 4h still high, 1d downtrend
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_40
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_50)
      )
      # 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | (rsi_14_4h_lt_60)
        | roc_9_1d_lt_200
      )
      # 15m & 1h & 4h down move, 15m & 1h still high, 4h high, 15m & 4h high, 4h overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_20
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 15m high, 4h high & overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h down move, 15m & 1h high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_100
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_70
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still high, 15m & 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_70
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still highm 15m & 1h high, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_85
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_60
        | roc_9_4h_lt_10
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | aroonu_14_4h_lt_85
        | stochrsi_k_15m_lt_50
        | roc_9_1d_lt_40
      )
      # 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h downtrend, 1h still high, 4h high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_030)
        | (cmf_20_1h_gt_neg_030)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | (protection_stochk_14_3_3_1h < 60.0)
        | (protection_stochk_14_3_3_4h < 90.0)
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m high
      & ((rsi_3_15m_gt_35) | rsi_3_1h_gt_50 | rsi_3_4h_gt_50 | stochrsi_k_15m_lt_90)
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m high, 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_60
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_70
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h & 4h still high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_15m_lt_60
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h stil high, 1h & 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_80
        | roc_9_1h_lt_10
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m still high, 4h overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_50
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h high, 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_70
        | roc_9_1d_lt_75
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 1h high
      & (
        (rsi_3_15m_gt_35)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_90
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_70
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h downtrend, 15m high
      & (
        (rsi_3_15m_gt_35)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m still not low enough, 4h & 1h still high, 1d overbought
      & (
        (rsi_3_15m_gt_35)
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (aroonu_14_15m_lt_20)
        | aroonu_14_4h_lt_40
        | stochrsi_k_1h_lt_50
        | roc_9_1d_lt_150
      )
      # 15m & 1h down move, 15m & 1h & 4h high, 1h overbought
      & (
        (rsi_3_15m_gt_35)
        | (rsi_3_1h_gt_65)
        | (rsi_14_15m_lt_50)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_90
        | roc_9_1h_lt_20
      )
      # 15m & 4h down move, 15m & 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_35)
        | (rsi_3_4h_gt_10)
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_80
        | roc_9_4h_gt_neg_30
      )
      # 15m & 4h down move, 15m still high, 1h high, 15m & 1h high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_40
        | (rsi_14_1h_lt_70)
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_100
      )
      # 15m & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h downtrend, 15m & 1h still high
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_4h_gt_35
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_025)
        | (cmf_20_4h_gt_neg_025)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_50
        | stochrsi_k_15m_lt_50
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 1h high, 4h downtrend
      & (
        (rsi_3_15m_gt_35)
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_70
        | roc_9_4h_gt_neg_20
      )
      # 15m down move, 15m still high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_35)
        | (rsi_14_15m_lt_50)
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | stochrsi_k_1h_lt_60
        | stochrsi_k_4h_lt_60
        | roc_9_1h_lt_20
        | roc_9_4h_lt_20
      )
      # 15m down move, 15m & 1h still high, 4h high, 15m downtrend, 15m high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_35)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | cmf_20_15m_gt_neg_010
        | aroonu_14_15m_lt_70
        | roc_9_1h_lt_15
        | roc_9_4h_lt_80
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 4h high & overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_70
      )
      # 15m & 1h & 4h down move, 15m & 1h sitll not low enough, 4h still high, 15m high
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_40
        | stochrsi_k_15m_lt_70
      )
      # 15m & 1h & 4h & 1d down move, 1d downtrend, 4h still not low enough, 15m still high, 1h downtrend
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_45
        | rsi_3_1d_gt_45
        | (protection_cmf_20_1d > -0.40)
        | aroonu_14_4h_lt_30
        | stochrsi_k_15m_lt_50
        | roc_9_1h_gt_neg_25
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h downtrend, 4h high
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_45
        | cmf_20_15m_gt_neg_040
        | (cmf_20_1h_gt_neg_040)
        | (cmf_20_4h_gt_neg_040)
        | aroonu_14_4h_lt_75
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_50
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (protection_rsi_14_4h < 90.0)
        | aroonu_14_4h_lt_90
        | roc_9_4h_lt_80
      )
      # 15m & 1h down move, 15m still not low enough, 1h still high, 4h high, 15m still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_10)
        | rsi_3_1h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_40
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m high, 1h & 4h downtrend
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | stochrsi_k_15m_lt_60
        | roc_9_1h_gt_neg_30
        | roc_9_4h_gt_neg_40
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m & 1h high
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h high
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_55
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h & 1d down move, 15m & 1h & 4h still high, 15m & 1h high, 1d overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_60
        | rsi_3_1d_gt_60
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_85
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 4h downtrend, 4h overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | (cmf_20_4h_gt_neg_015)
        | aroonu_14_4h_lt_50
        | stochrsi_k_15m_lt_20
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_25
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_50
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h downtrend, 1h high, 4h overbought
      & (
        (rsi_3_15m_gt_40)
        | (rsi_3_1h_gt_65)
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_030)
        | (aroonu_14_15m_lt_20)
        | aroonu_14_1h_lt_70
        | roc_9_4h_lt_10
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 15m still high, 1h high, 1h overbought
      & (
        (rsi_3_15m_gt_40)
        | (rsi_3_1h_gt_65)
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_85
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_80
        | roc_9_1h_lt_20
      )
      # 15m &4h down move, 15m & 1h & 4h still high, 15m still high, 1h high, 15m & 1h overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_80
        | (roc_9_15m_lt_10)
        | roc_9_1h_lt_40
      )
      # 15m & 4h down move, 15m & 1h & 4h still high, 15m & 1h high, 1h overbought
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | stochrsi_k_1h_lt_70
        | roc_9_1h_lt_20
      )
      # 15m & 1d down move, 15m & 1h & 4h stil high, 4h high, 15m & 1h & 4h still high
      & (
        (rsi_3_15m_gt_40)
        | rsi_3_1d_gt_20
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
      )
      # 15m down move, 15m & 1h still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_40)
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | (protection_rsi_14_4h < 90.0)
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_100
      )
      # 15m down move, 15m still high, 1h & 4h high & overbought
      & (
        (rsi_3_15m_gt_40)
        | (rsi_14_15m_lt_50)
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_70
        | roc_9_4h_lt_80
      )
      # 15m down move, 15m & 1h & 4h still high, 15m & 1h & 4h high
      & (
        (rsi_3_15m_gt_40)
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_1h_lt_100
        | aroonu_14_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h still high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_40
        | roc_9_1d_lt_100
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 15m & 1h & 4h downtrend, 4h high
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_010
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_90
      )
      # 15m & 1h down move, 15m & 1h & 4h still high, 1h & 4h & 1d downtrend, 1h & 4h high
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | (protection_cmf_20_1d > -0.30)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_90
      )
      # 15m & 1h down move, 1h & 4h still high, 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_1h_gt_45
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_80
        | roc_9_1h_lt_30
        | roc_9_4h_lt_100
      )
      # 15m & 1h & 4h & 1d down move, 15m still not low enough, 1h & 4h still high, 15m still high, 1d overbought
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_3_1d_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | stochrsi_k_15m_lt_50
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h down move, 15m & 1h & 4h still not low enough, 15m still high, 4h high & overbought
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_40
      )
      # 15m & 1h down move, 15m & 1h still high, 4h high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_45)
        | (rsi_3_1h_gt_60)
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_90
        | roc_9_1h_lt_30
        | roc_9_4h_lt_80
      )
      # 15m & 1h down move, 15m still high, 1h high, 15m overbought
      & (
        (rsi_3_15m_gt_45)
        | (rsi_3_1h_gt_60)
        | aroonu_14_15m_lt_50
        | aroonu_14_1h_lt_100
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_80
        | (protection_roc_9_15m < 20.0)
      )
      # 15m & 4h down move, 15m & 1h & 4h still not low enough, 15m & 1h & 4h downtrend, 1h & 4h still high
      & (
        (rsi_3_15m_gt_45)
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | cmf_20_15m_gt_neg_015
        | (cmf_20_1h_gt_neg_025)
        | (cmf_20_4h_gt_neg_035)
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
      )
      # 15m down move, 15m & 1h & 4h high, 15m & 1h high, 4h & 1d overbought
      & (
        (rsi_3_15m_gt_45)
        | (rsi_14_15m_lt_50)
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_70)
        | aroonu_14_15m_lt_70
        | aroonu_14_1h_lt_100
        | roc_9_4h_lt_10
        | roc_9_1d_lt_40
      )
      # 15m down move, 15m & 1h & 4h high, 1h & 4h high, 1h & 4h overbought
      & (
        (rsi_3_15m_gt_45)
        | (rsi_14_15m_lt_50)
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_40
        | roc_9_4h_lt_100
      )
      # 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 15m downtrend, 15m & 4h high
      & (
        (protection_rsi_3_15m > 55.0)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | cmf_20_15m_gt_neg_010
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_85
        | stochrsi_k_15m_lt_70
      )
      # 15m & 1h down move, 15m & 1h & 4h high, 1h & 4h overbought
      & (
        (protection_rsi_3_15m > 55.0)
        | (rsi_3_1h_gt_65)
        | (rsi_14_15m_lt_50)
        | (rsi_14_1h_lt_60)
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
        | roc_9_1h_lt_30
        | roc_9_4h_lt_70
      )
      # 1h & 4h down move, 15m high
      & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | stochrsi_k_15m_lt_50)
      # 1h & 4h down move, 4h still not low enough
      & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | aroonu_14_4h_lt_20)
      # 1h & 4h down move, 15m still not low enough, 4h downtrend
      & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5) | rsi_14_15m_lt_30 | (cmf_20_4h_gt_neg_030))
      # 1h & 4h down move, 1h downtrend, 4h still high
      & ((rsi_3_1h_gt_3) | rsi_3_4h_gt_20 | (cmf_20_1h_gt_neg_030) | aroonu_14_4h_lt_50)
      # 1h & 4h down move, 1h still not low enough, 4h still high, 1d overbought
      & ((rsi_3_1h_gt_3) | rsi_3_4h_gt_35 | rsi_14_1h_lt_30 | rsi_14_4h_lt_50 | roc_9_1d_lt_80)
      # 1h & 4h & 1d down move, 1d still not low enough, 1d downtrend
      & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | rsi_3_1d_gt_10 | (protection_aroonu_14_1d < 25.0) | (roc_9_1d_gt_neg_30))
      # 1h & 4h down move, 1h & 4h downtrend
      & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | cmf_20_1h_gt_neg_05 | cmf_20_4h_gt_neg_05)
      # 1h & 4h down move, 15m & 1h & 4h downtrend, 1h & 4h still high
      & (
        (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_20
        | (cmf_20_15m_gt_neg_020)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_50
      )
      # 1h & 4h down move, 15m & 1hg downtrend, 4h downtrend
      & ((rsi_3_1h_gt_5) | rsi_3_4h_gt_20 | cmf_20_15m_gt_neg_040 | (cmf_20_1h_gt_neg_040) | roc_9_4h_gt_neg_20)
      # 1h & 4h down move, 1h still high, 4h high, 1d overbought
      & ((rsi_3_1h_gt_5) | rsi_3_4h_gt_30 | aroonu_14_1h_lt_50 | aroonu_14_4h_lt_85 | roc_9_1d_lt_50)
      # 1h & 4h down move, 1h & 4h still high, 4h high, 15m & 1h downtrend
      & (
        (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_40
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_40
        | stochrsi_k_4h_lt_70
        | (protection_roc_9_15m > -10.0)
        | roc_9_1h_gt_neg_20
      )
      # 1h & 4h down move, 15m & 1h still not low enough, 4h high, 1d overbought
      & (
        (rsi_3_1h_gt_5)
        | rsi_3_4h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_1d_lt_100
      )
      # 1h & 4h down move, 15m & 1h & 4h downtrend, 1h high
      & (
        (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_20
        | cmf_20_15m_gt_neg_0
        | (cmf_20_1h_gt_neg_030)
        | (cmf_20_4h_gt_neg_030)
        | aroonu_14_1h_lt_60
      )
      # 1h & 4h down move, 1h & 4h downtrend, 1h high
      & ((rsi_3_1h_gt_10) | rsi_3_4h_gt_20 | (cmf_20_1h_gt_neg_040) | (cmf_20_4h_gt_neg_040) | aroonu_14_1h_lt_60)
      # 1h & 4h & 1d down move, 1h & 4h still not low enough, 1h & 4h downtrend, 1h still not low enough
      & (
        (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_15)
        | rsi_3_1d_gt_15
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_020)
        | stochrsi_k_1h_lt_20
      )
      # 1h & 4h down move, 1h & 4h still not low enough, 15m high, 1h & 4h downtrend
      & (
        (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_15)
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_20
        | stochrsi_k_15m_lt_80
        | roc_9_1h_gt_neg_30
        | roc_9_4h_gt_neg_30
      )
      # 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h & 4h downtrend
      & (
        (rsi_3_1h_gt_15)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_30
        | stochrsi_k_1h_lt_40
        | roc_9_1h_gt_neg_10
      )
      # 1h & 4h down move, 1h still not low enough, 4h downtrend
      & (rsi_3_1h_gt_20 | (rsi_3_4h_gt_3) | stochrsi_k_1h_lt_30 | roc_9_4h_gt_neg_25)
      # 1h & 4h down move, 1h & 4h downtrend, 1h high, 4h downtrend
      & (
        rsi_3_1h_gt_20
        | rsi_3_4h_gt_30
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_025)
        | aroonu_14_1h_lt_80
        | roc_9_4h_gt_neg_30
      )
      # 1h & 4h & 1d down move, 1h & 4h still not low enough, 1d high & overbought
      & (
        rsi_3_1h_gt_20
        | rsi_3_4h_gt_40
        | rsi_3_1d_gt_60
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_40
        | (protection_aroonu_14_1d < 70.0)
        | roc_9_1d_lt_100
      )
      # 1h & 1d down move, 15m & 1h & 4h still not low enough, 15m & 1h downtrend, 1h still high
      & (
        rsi_3_1h_gt_20
        | rsi_3_1d_gt_30
        | (rsi_14_15m_lt_10)
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_30
        | (cmf_20_15m_gt_neg_030)
        | (cmf_20_1h_gt_neg_030)
        | stochrsi_k_1h_lt_40
      )
      # 1h & 4h & 1d down move, 1h still not low enough, 4h still high, 1d downtrend
      & (
        rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_30
        | stochrsi_k_1h_lt_30
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_30)
      )
      # 1h & 4h down move, 1h & 4h still not low enough, 4h still high, 1h & 4h downtrend, 1d overbought
      & (
        rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_40
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_20
        | roc_9_1d_lt_80
      )
      # 5m & 15m & 1h & 4h down move, 15m downtrend, 4h high, 1d overbought
      & (
        rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | cmf_20_15m_gt_neg_05
        | cmf_20_1h_gt_neg_03
        | cmf_20_4h_gt_neg_03
        | aroonu_14_1h_lt_50
      )
      # 1h & 4h down move, 1h & 4h high, 4h overbought
      & (
        rsi_3_1h_gt_25
        | rsi_3_4h_gt_60
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_4h_lt_80
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_80
      )
      # 1h & 4h & 1d down move, 15m & 1h & 4h still not low enough, 4h still high
      & (
        (rsi_3_1h_gt_30)
        | rsi_3_4h_gt_30
        | rsi_3_1d_gt_5
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_4h_lt_40
      )
      # 1h & 4h down move, 1h & 4h still high, 1h still not low enough, 4h still high, 1h downtrend, 4h & 1d overbought
      & (
        (rsi_3_1h_gt_30)
        | rsi_3_4h_gt_50
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_25
        | aroonu_14_4h_lt_50
        | roc_9_1h_gt_neg_10
        | roc_9_4h_lt_20
        | roc_9_1d_lt_100
      )
      # 1h & 4h down move, 1h & 4h still high, 4h high, 1h & 4h overbought
      & (
        (rsi_3_1h_gt_30)
        | rsi_3_4h_gt_60
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
        | roc_9_1h_lt_10
        | roc_9_4h_lt_25
      )
      # 1h down move, 1h still high, 4h overbought
      & (rsi_3_1h_gt_55 | rsi_14_1h_lt_40 | roc_9_4h_lt_300)
      # 1h & 1d down move, 1h & 4h & 1d still high, 1h & 4h high, 4h overbought
      & (
        (rsi_3_1h_gt_60)
        | rsi_3_1d_gt_25
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | (protection_mfi_14_1d < 50.0)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_90
        | roc_9_4h_lt_25
      )
      # 4h down move, 15m & 1h & 4h still not low enough
      & ((rsi_3_4h_gt_3) | rsi_14_15m_lt_20 | (rsi_14_1h_lt_20) | rsi_14_4h_lt_30)
      # 4h down move, 1h & 4h downtrend, 1h still not low enough
      & ((rsi_3_4h_gt_3) | (cmf_20_1h_gt_neg_020) | (cmf_20_4h_gt_neg_025) | aroonu_14_1h_lt_30)
      # 4h down move, 1h & 4h downtrend, 1h & 4h & 1d downtrend
      & (
        (rsi_3_4h_gt_3)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_035)
        | (protection_cci_20_change_pct_4h > 0.0)
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_25
        | (roc_9_1d_gt_neg_25)
      )
      # 4h down move, 15m downtrend, 15m still not low enough, 1h high
      & ((rsi_3_4h_gt_3) | (cmf_20_15m_gt_neg_020) | stochrsi_k_15m_lt_20 | stochrsi_k_1h_lt_70)
      # 4h down move, 1h & 4h downtrend, 15m high
      & ((rsi_3_4h_gt_3) | (cmf_20_1h_gt_neg_025) | (cmf_20_4h_gt_neg_030) | stochrsi_k_15m_lt_70)
      # 4h down move, 15m & 1h high
      & ((rsi_3_4h_gt_3) | aroonu_14_15m_lt_60 | aroonu_14_1h_lt_90)
      # 4h down move, 15m high, 4h still high
      & ((rsi_3_4h_gt_3) | aroonu_14_15m_lt_60 | aroonu_14_4h_lt_40 | stochrsi_k_15m_lt_50)
      # 4h down move, 15m & 1h high, 4h downtrend
      & ((rsi_3_4h_gt_3) | stochrsi_k_15m_lt_50 | stochrsi_k_1h_lt_50 | roc_9_4h_gt_neg_20)
      # 4h & 1d down move, 15m still not low enough, 4h downtrend
      & ((rsi_3_4h_gt_5) | rsi_3_1d_gt_5 | stochrsi_k_15m_lt_20 | roc_9_4h_gt_neg_40)
      # 4h down move, 15m & 1h & 4h still not low enough, 1h & 4h downtrend, 4h & 15m still not low enough
      & (
        (rsi_3_4h_gt_5)
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | aroonu_14_4h_lt_30
        | stochrsi_k_15m_lt_20
      )
      # 4h down move, 1h & 4h downtrend, 1h still not low enough, 4h high
      & ((rsi_3_4h_gt_5) | cmf_20_1h_gt_neg_010 | (cmf_20_4h_gt_neg_020) | stochrsi_k_1h_lt_20 | stochrsi_k_4h_lt_40)
      # 4h down mnove, 15m & 1h & 4h downtrend, 15m high, 4h downtrend
      & (
        (rsi_3_4h_gt_10)
        | (cmf_20_15m_gt_neg_025)
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_70
        | roc_9_4h_gt_neg_30
      )
      # 4h down move, 15m & 1h & 4h still high, 15m high
      & (
        (rsi_3_4h_gt_10)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_60
        | stochrsi_k_15m_lt_70
      )
      # 4h & 1d down move, 15m & 1h still not low enough, 4h still high, 4h downtrend, 1d overbought
      & (
        (rsi_3_4h_gt_15)
        | rsi_3_1d_gt_65
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | rsi_14_4h_lt_40
        | roc_9_4h_gt_neg_40
        | roc_9_1d_lt_200
      )
      # 4h & 1d down move, 1h still high, 4h high, 1d downtrend
      & (
        rsi_3_4h_gt_25
        | rsi_3_1d_gt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
        | (roc_9_1d_gt_neg_40)
      )
      # 4h down move, 1h & 4h still not low enough, 15m high, 4h downtrend
      & (
        rsi_3_4h_gt_25
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_50
        | stochrsi_k_15m_lt_50
        | roc_9_4h_gt_neg_50
      )
      # 4h & 1d down move, 15m & 1h & 4h still not low enough, 4h downtrend, 1h still high, 4h downtrend
      & (
        rsi_3_4h_gt_30
        | rsi_3_1d_gt_40
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | (rsi_14_4h_lt_20)
        | (cmf_20_4h_gt_neg_025)
        | stochrsi_k_1h_lt_50
        | roc_9_4h_gt_neg_60
      )
      # 4h down move, 15m & 1h & 4h still high, 15m high, 4h still not low enough, 1d overbought
      & (
        rsi_3_4h_gt_35
        | (rsi_14_15m_lt_50)
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | aroonu_14_4h_lt_30
        | stochrsi_k_15m_lt_50
        | stochrsi_k_4h_lt_30
        | roc_9_1d_lt_50
      )
      # 4h down move, 15m high, 15m & 1h & 4h high, 4h & 1d overbought
      & (
        rsi_3_4h_gt_55
        | (aroonu_14_15m_lt_80)
        | stochrsi_k_15m_lt_50
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_80
        | roc_9_4h_lt_20
        | roc_9_1d_lt_30
      )
      # 1d down move, 15m & 1h still not low enough, 4h & 1d downtrend
      & (
        rsi_3_1d_gt_3
        | rsi_14_15m_lt_20
        | (rsi_14_1h_lt_20)
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_30
        | roc_9_4h_gt_neg_30
        | (roc_9_1d_gt_neg_50)
      )
      # 1d down move, 1h & 4h still not low enough, 1h still high & overbought, 1d downtrend
      & (
        rsi_3_1d_gt_3
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_1h_lt_50
        | stochrsi_k_1h_lt_50
        | roc_9_1h_lt_10
        | (roc_9_1d_gt_neg_30)
      )
      # 1d down move, 15m & 1h & 4h still not low enough, 15m still not low enough, 1h high
      & (
        rsi_3_1d_gt_5
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_85
        | stochrsi_k_1h_lt_80
      )
      # 1d down move, 15m still not low enough, 1h high, 1d downtrend
      & (rsi_3_1d_gt_5 | rsi_14_15m_lt_30 | stochrsi_k_1h_lt_80 | (protection_roc_2_1d > -40.0))
      # 1d down move, 15m high, 1h & 4h downtrend
      & (rsi_3_1d_gt_5 | stochrsi_k_15m_lt_70 | roc_9_1h_gt_neg_60 | roc_9_4h_gt_neg_60)
      # 1d down move, 1h still high, 4h high
      & (rsi_3_1d_gt_5 | aroonu_14_1h_lt_40 | aroonu_14_4h_lt_70)
      # 1d down move, 4h high, 1h & 4h downtrend
      & (rsi_3_1d_gt_5 | stochrsi_k_4h_lt_70 | roc_9_1h_gt_neg_10 | roc_9_4h_gt_neg_10)
      # 1d down move, 1h high & overbought, 4h & 1d downtrend
      & (rsi_3_1d_gt_10 | stochrsi_k_1h_lt_80 | roc_9_1h_lt_10 | roc_9_4h_gt_neg_40 | (roc_9_1d_gt_neg_40))
      # 1d down move, 1h & 4h still high, 1h & 4h downtrend, 1h & 4h high, 1d downtrend
      & (
        rsi_3_1d_gt_10
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | (cmf_20_1h_gt_neg_040)
        | (cmf_20_4h_gt_neg_010)
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_85
        | (roc_9_1d_gt_neg_40)
      )
      # 15m & 1h & 4h still high, 4h downtrend, 4h overbought
      & ((rsi_14_15m_lt_50) | rsi_14_1h_lt_50 | (rsi_14_4h_lt_60) | cmf_20_4h_gt_neg_02 | roc_9_4h_lt_250)
      # 4h red, 15m & 1h & 4h down move, 1h & 4h still high, 4h high
      & (
        (protection_change_pct_4h > -30.0)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_70
      )
      # 4h P&D, 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high, 1h & 4h high
      & (
        (protection_change_pct_4h > -5.0)
        | (protection_change_pct_4h_shift_48 < 5.0)
        | (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
      )
      # 4h green with top wick, 15m & 1h down move, 15m still not low enough, 1h & 4h high
      & (
        (protection_change_pct_4h < 10.0)
        | (top_wick_pct_4h_lt_10)
        | (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_60
        | aroonu_14_4h_lt_90
      )
      # 4h green with top wick, 1h down move, 1h still high, 4h high, 1d overbought
      & (
        (protection_change_pct_4h < 10.0)
        | (top_wick_pct_4h_lt_10)
        | rsi_3_1h_gt_45
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_90
        | roc_9_1d_lt_20
      )
      # 4h green with top wick, 15m & 1h down move, 1h still high, 4h high
      & (
        (protection_change_pct_4h < 15.0)
        | (protection_top_wick_pct_4h < 15.0)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_35
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_100
      )
      # 4h green with top wick, 15m & 1h down move, 1h & 4h high
      & (
        (protection_change_pct_4h < 15.0)
        | (top_wick_pct_4h_lt_10)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_40
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_100
      )
      # 4h green, 15m & 1h down move, 15m still not low enough, 1h & 4h high
      & (
        (protection_change_pct_4h < 15.0)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_70)
        | aroonu_14_1h_lt_70
        | aroonu_14_4h_lt_100
      )
      # 1d red, 1h & 4h down move, 1h still high, 4d downtrend
      & (
        (protection_change_pct_1d > -40.0)
        | rsi_3_1h_gt_55
        | (rsi_3_4h_gt_10)
        | stochrsi_k_1h_lt_50
        | roc_9_4h_gt_neg_35
      )
      # 1d P&D, 15m & 4h down move, 15m & 4h still high
      & (
        (change_pct_1d_gt_neg_20)
        | (protection_change_pct_1d_shift_288 < 20.0)
        | rsi_3_15m_gt_20
        | rsi_3_4h_gt_25
        | stochrsi_k_15m_lt_40
        | stochrsi_k_4h_lt_50
      )
      # 1d red, 15m & 1h & 4h down move, 1h still not low enough, 4h & 1d still high
      & (
        (change_pct_1d_gt_neg_20)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_50
        | (rsi_14_1h_lt_35)
        | rsi_14_4h_lt_40
        | stochrsi_k_4h_lt_40
        | (protection_stochrsik_14_14_3_3_1d < 50.0)
      )
      # 1d red, 1h & 4h & 1d down move, 1h still not low enough, 4h & 1d still high, 1d downtrend
      & (
        (change_pct_1d_gt_neg_20)
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_50
        | rsi_3_1d_gt_50
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (protection_rsi_14_1d < 40.0)
        | stochrsi_k_4h_lt_40
        | (protection_roc_9_1d > -20.0)
      )
      # 1d red, 15m & 1h & 4h down move, 1d high, 15m & 1h still high
      & (
        (change_pct_1d_gt_neg_20)
        | rsi_3_15m_gt_30
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | (protection_aroonu_14_1d < 85.0)
        | stochrsi_k_15m_lt_40
        | stochrsi_k_1h_lt_50
      )
      # 1d P&D, 15m & 1h & 4h down move, 15m & 1h & 4h still high, 15m & 4h still high
      & (
        (protection_change_pct_1d > -15.0)
        | (protection_change_pct_1d_shift_288 < 15.0)
        | (protection_rsi_3_15m > 50.0)
        | rsi_3_1h_gt_50
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_50
        | aroonu_14_4h_lt_50
      )
      # 1d P&D, 15m & 1h & 4h & 1d down move, 4h still not low enough
      & (
        (change_pct_1d_gt_neg_10)
        | (protection_change_pct_1d_shift_288 < 10.0)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_25
        | (rsi_3_4h_gt_10)
        | rsi_3_1d_gt_40
        | rsi_14_4h_lt_30
      )
      # 1d P&D, 15m & 1h down move, 1h still not low enough, 4h still high, 15m downtrend, 1h still high
      & (
        (change_pct_1d_gt_neg_10)
        | (protection_change_pct_1d_shift_288 < 10.0)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (cmf_20_15m_gt_neg_030)
        | aroonu_14_1h_lt_50
      )
      # 1d P&D, 15m down move, 1h high
      & (
        (change_pct_1d_gt_neg_10)
        | (protection_change_pct_1d_shift_288 < 20.0)
        | (protection_top_wick_pct_1d_shift_288 < 20.0)
        | (rsi_3_15m_gt_35)
        | aroonu_14_1h_lt_70
      )
      # 1d P&D, 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1d overbought
      & (
        (change_pct_1d_gt_neg_10)
        | (protection_change_pct_1d_shift_288 < 20.0)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | roc_9_1d_lt_25
      )
      # 1d P&D, 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h & 4h downtrend, 1d overbought
      & (
        (change_pct_1d_gt_neg_10)
        | (protection_change_pct_1d_shift_288 < 50.0)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | roc_9_1h_gt_neg_10
        | roc_9_4h_gt_neg_10
        | roc_9_1d_lt_100
      )
      # 1d red with top wick, 15m & 1h down move, 1h downtrend, 1h high
      & (
        (change_pct_1d_gt_neg_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_25
        | cmf_20_1h_gt_neg_02
        | aroonu_14_1h_lt_70
        | stochrsi_k_1h_lt_40
      )
      # 1d P&D, 15m & 1h down move, 15m still not low enough, 1h & 4h still high, 1d overbought
      & (
        (protection_change_pct_1d > -5.0)
        | (protection_change_pct_1d_shift_288 < 10.0)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | roc_9_1d_lt_100
      )
      # 1d P&D, 15m & 1h & 4h down move, 1h & 4h still not low enough, 1h & 4h downtrend, 1d overbought
      & (
        (protection_change_pct_1d > -5.0)
        | (protection_change_pct_1d_shift_288 < 10.0)
        | rsi_3_15m_gt_25
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_30
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_30
        | roc_9_1h_gt_neg_25
        | roc_9_4h_gt_neg_25
        | roc_9_1d_lt_50
      )
      # 1d red, 15m & 1h & 4h down move, 1h & 4h still not low enough, 1d high, 4h downtrend, 1d overbought
      & (
        (protection_change_pct_1d > -5.0)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | (protection_aroonu_14_1d < 85.0)
        | roc_9_4h_gt_neg_30
        | roc_9_1d_lt_20
      )
      # 1d green with top wick, 15m & 1h & 1d down move, 1h still not low enough, 4h still high, 1d overbought
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_30
        | rsi_3_1d_gt_65
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | stochrsi_k_4h_lt_50
        | roc_9_1d_lt_20
      )
      # 1d green with top wick, 15m & 1h & 4h down move, 1h & 4h still high
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_65
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_1h_lt_30
        | aroonu_14_4h_lt_60
      )
      # 1d green with top wick, 15m down move, 1h & 4h high, 1d overbought
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_10
        | (rsi_14_1h_lt_70)
        | (rsi_14_4h_lt_80)
        | stochrsi_k_4h_lt_90
        | roc_9_1d_lt_40
      )
      # 1d green with top wick, 15m down move, 15m & 1h still high, 4h & 1d high, 4h overbought
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_10
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_75)
        | aroonu_14_4h_lt_80
        | (protection_aroonu_14_1d < 90.0)
        | roc_9_4h_lt_25
      )
      # 1d green with top wick, 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_60
      )
      # 1d green with top wick, 15m down move, 15m & 1h still high, 4h high & overbought
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_15
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_80
      )
      # 1d green with top wick, 1h & 4h down move, 1h & 4h still high
      & (
        (change_pct_1d_lt_10)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_1h_gt_55
        | rsi_3_4h_gt_55
        | aroonu_14_1h_lt_50
        | aroonu_14_4h_lt_50
      )
      # 1d green with top wick, 15m & 1h down move, 15m & 1h & 4h still high, 4h high & overbought
      & (
        (protection_change_pct_1d < 20.0)
        | (top_wick_pct_1d_lt_20)
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_45
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_20
      )
      # 1d green with top wick, 1h & 4h down move, 1h still not low enough, 4h still high, 4h & 1d overbought
      & (
        (protection_change_pct_1d < 20.0)
        | (top_wick_pct_1d_lt_20)
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_50
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_10
        | roc_9_1d_lt_50
      )
      # 1d green with top wick, 15m down move, 15m & 1h & 4h still high, 4h & 1d overbought
      & (
        (protection_change_pct_1d < 25.0)
        | (top_wick_pct_1d_lt_25)
        | (rsi_3_15m_gt_40)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | stochrsi_k_15m_lt_30
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_20
        | roc_9_1d_lt_50
      )
      # 1d green with top wick, 15m & 1h & 4h down move, 15m still not low enough, 4h high, 1d overbought
      & (
        (change_pct_1d_lt_30)
        | (top_wick_pct_1d_lt_10)
        | rsi_3_15m_gt_30
        | rsi_3_1h_gt_30
        | (protection_rsi_3_4h > 70.0)
        | (rsi_14_4h_lt_60)
        | (aroonu_14_15m_lt_25)
        | aroonu_14_4h_lt_70
        | roc_9_1d_lt_40
      )
      # 1d green with top wick, 15m & 1h & 4h down move, 1h still not low enough, 4h still high, 1d overbought
      & (
        (change_pct_1d_lt_30)
        | (top_wick_pct_1d_lt_20)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_40
        | aroonu_14_1h_lt_20
        | aroonu_14_4h_lt_50
        | roc_9_1d_lt_100
      )
      # 1d green with top wick, 15m down move, 15m & 1h still high, 4h high & overbought
      & (
        (change_pct_1d_lt_30)
        | (top_wick_pct_1d_lt_20)
        | (rsi_3_15m_gt_35)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_50
      )
      # 1d green with top wick, 1h down move, 1h still high, 4h high & overbought, 1d overbought
      & (
        (change_pct_1d_lt_30)
        | (top_wick_pct_1d_lt_20)
        | rsi_3_1h_gt_50
        | rsi_14_1h_lt_40
        | (rsi_14_4h_lt_60)
        | aroonu_14_4h_lt_70
        | roc_9_4h_lt_40
        | roc_9_1d_lt_50
      )
      # 1d green with top wick, 15m & 1h down move, 1h & 4h still high, 4h overbought
      & (
        (change_pct_1d_lt_30)
        | (protection_top_wick_pct_1d < 30.0)
        | rsi_3_15m_gt_25
        | rsi_3_1h_gt_25
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_30
      )
      # 1d green with top wick, 15m & 4h down move, 15m & 1h still high, 1d overbought
      & (
        (change_pct_1d_lt_30)
        | (protection_top_wick_pct_1d < 30.0)
        | (protection_rsi_3_15m > 50.0)
        | rsi_3_4h_gt_60
        | aroonu_14_15m_lt_50
        | stochrsi_k_1h_lt_50
        | roc_9_1d_lt_100
      )
      # 1d green, 15m & 4h down move, 4h still high, 4h & 1d overbought
      & ((change_pct_1d_lt_50) | rsi_3_15m_gt_15 | rsi_3_4h_gt_25 | rsi_14_4h_lt_50 | roc_9_4h_lt_40 | roc_9_1d_lt_100)
      # 1d green with top wick, 15m & 1h & 4h down move, 1h & 4h still high, 4h high
      & (
        (change_pct_1d_lt_50)
        | (top_wick_pct_1d_lt_50)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_70
      )
      # 1d green with top wick, 1d down move, 4h still high & overbought
      & (
        (change_pct_1d_lt_50)
        | (top_wick_pct_1d_lt_50)
        | rsi_3_1h_gt_45
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_50
        | roc_9_4h_lt_50
      )
      # 1d green with top wick, 4h down move, 4h still high, 1d overbought
      & ((change_pct_1d_lt_50) | (top_wick_pct_1d_lt_50) | rsi_3_4h_gt_40 | rsi_14_4h_lt_40 | roc_9_1d_lt_200)
      # 1d green, 15m & 4h down move, 15m & 1h & 4h still high, 15m high, 4h & 1d overbought
      & (
        (change_pct_1d_lt_50)
        | (protection_rsi_3_15m > 50.0)
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_15m_lt_60
        | roc_9_4h_lt_30
        | roc_9_1d_lt_200
      )
      # 4h top wick, 15m down move, 15m still not low enough, 1h & 4h still high, 4h overbought
      & (
        (protection_top_wick_pct_4h < 20.0)
        | rsi_3_15m_gt_25
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | stochrsi_k_1h_lt_50
        | stochrsi_k_4h_lt_50
        | roc_9_4h_lt_50
      )
      # 4h top wick, 15m & 1h down move, 15m & 1h still high, 1h & 4h high
      & (
        (protection_top_wick_pct_4h < 20.0)
        | (rsi_3_15m_gt_40)
        | rsi_3_1h_gt_55
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_60)
        | aroonu_14_15m_lt_40
        | aroonu_14_1h_lt_85
        | aroonu_14_4h_lt_100
      )
      # 1d top wick, 1h & 4h down move, 15m downtrend, 4h still high, 1d overbought
      & (
        (top_wick_pct_1d_lt_20)
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_45
        | cmf_20_15m_gt_neg_02
        | aroonu_14_4h_lt_50
        | roc_9_1d_lt_80
      )
      # 1d top wick, 4h down move, 4h still high, 1d overbought
      & ((top_wick_pct_1d_lt_25) | rsi_3_4h_gt_25 | (rsi_14_4h_lt_45) | aroonu_14_4h_lt_40 | roc_9_1d_lt_200)
      # 1d top wick, 15m & 1h & 4h down move, 15m & 1h downtrend, 4h still high
      & (
        (top_wick_pct_1d_lt_25)
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_50
        | (cmf_20_15m_gt_neg_025)
        | (cmf_20_1h_gt_neg_025)
        | aroonu_14_4h_lt_50
      )
      # 1d top wick, 15m & 1h & 4h down move, 15m still not low enough, 1h & 4h still high
      & (
        (top_wick_pct_1d_lt_25)
        | rsi_3_15m_gt_30
        | (rsi_3_1h_gt_60)
        | rsi_3_4h_gt_60
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_15m_lt_30
        | aroonu_14_4h_lt_50
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_20
      )
      # 1d top wick, 15m down move, 15m stil high, 1h & 4h high, 4h overbought
      & (
        (top_wick_pct_1d_lt_25)
        | (rsi_3_15m_gt_35)
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_50
        | (rsi_14_4h_lt_80)
        | aroonu_14_1h_lt_80
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_50
      )
      # 1d top wick, 15m & 1h & 4h down move, 15m & 1h & 4h still high
      & (
        (protection_top_wick_pct_1d < 80.0)
        | (rsi_3_15m_gt_40)
        | (rsi_3_1h_gt_65)
        | rsi_3_4h_gt_65
        | rsi_14_15m_lt_40
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_40
        | aroonu_14_4h_lt_50
      )
      # pump, drop but not yet near the previous lows, 15m & 1h & 4h & 1d down move, 1d overbought
      & (
        (((protection_high_max_6_1d - protection_low_min_6_1d) / protection_low_min_6_1d) < 1.5)
        | (protection_close > (protection_high_max_6_4h * 0.70))
        | (protection_close < (protection_low_min_6_1d * 1.25))
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_45
        | roc_9_1d_lt_20
      )
      # pump, drop in lays days, 1h & 4h down move, 1h & 4h still not low enough, 1d overbought
      & (
        (((protection_high_max_12_1d - protection_low_min_12_1d) / protection_low_min_12_1d) < 3.0)
        | (protection_close > (protection_high_max_24_4h * 0.70))
        | (rsi_3_1h_gt_15)
        | rsi_3_1d_gt_50
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | roc_9_1d_lt_20
      )
      # pump, 15m & 1h & 4h down move, 15m & 1h still not low enough, 4h still high, 1h downtrend, 1h high
      & (
        (((protection_high_max_12_1d - protection_low_min_12_1d) / protection_low_min_12_1d) < 3.0)
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_30
        | rsi_3_4h_gt_40
        | rsi_14_15m_lt_20
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_40
        | cmf_20_1h_gt_neg_010
        | aroonu_14_1h_lt_70
      )
      # pump, drop in last 6 days, 1h & 4h down move, 1h & 4h still not low enough, 4h downtrend, 4h & 1d downtrend
      & (
        (((protection_high_max_30_1d - protection_low_min_30_1d) / protection_low_min_30_1d) < 10.0)
        | (protection_close > (protection_high_max_6_1d * 0.50))
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | (cmf_20_4h_gt_neg_010)
        | roc_9_4h_gt_neg_15
        | (roc_9_1d_gt_neg_25)
      )
      # drop in the last 4 hours, 1h & 4h high
      & ((protection_close > (protection_close_max_48 * 0.30)) | aroonu_14_1h_lt_85 | aroonu_14_4h_lt_85)
      # drop in last 12 hours, 14m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h high & overbought
      & (
        (protection_close > (protection_high_max_12_1h * 0.50))
        | rsi_3_15m_gt_20
        | rsi_3_1h_gt_35
        | rsi_3_4h_gt_55
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | rsi_14_4h_lt_50
        | aroonu_14_4h_lt_80
        | roc_9_4h_lt_25
      )
      # drop in last 12 hours, 1h & 4h down move, 1h & 4h downtrend
      & (
        (protection_close > (protection_high_max_12_1h * 0.35))
        | (rsi_3_1h_gt_15)
        | (rsi_3_4h_gt_5)
        | roc_9_1h_gt_neg_50
        | roc_9_4h_gt_neg_50
      )
      # drop in last 4 days, 15m & 1h & 4h down move, 15m still not low enough, 1h still high, 4h overbought
      & (
        (protection_close > (protection_high_max_24_4h * 0.40))
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_50
        | rsi_14_15m_lt_30
        | rsi_14_1h_lt_40
        | roc_9_4h_lt_20
      )
      # drop in last 4 days, 15m & 1h & 4h & 1d down move, 4h high
      & (
        (protection_close > (protection_high_max_24_4h * 0.40))
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_40
        | rsi_3_4h_gt_60
        | rsi_3_1d_gt_10
        | stochrsi_k_4h_lt_80
      )
      # drop in last 6 days, 15m & 1h & 4h & 1d down move, 1d high, 4h downtrend
      & (
        (protection_close > (protection_high_max_24_4h * 0.35))
        | (rsi_3_15m_gt_5)
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_30
        | (protection_aroonu_14_1d < 80.0)
        | roc_9_4h_gt_neg_40
      )
      # drop in last 4 days, 15m & 1d down move, 15m still not low enough, 1h still high, 1d high, 4h downtrend
      & (
        (protection_close > (protection_high_max_24_4h * 0.35))
        | rsi_3_15m_gt_15
        | rsi_3_1d_gt_30
        | (aroonu_14_15m_lt_25)
        | aroonu_14_1h_lt_40
        | (protection_aroonu_14_1d < 80.0)
        | roc_9_4h_gt_neg_50
      )
      # drop in last 4 days, 1h & 5h & 1d down move, 1h still high, 1h & 4h downtrend
      & (
        (protection_close > (protection_high_max_24_4h * 0.25))
        | rsi_3_1h_gt_20
        | rsi_3_4h_gt_25
        | rsi_3_1d_gt_25
        | aroonu_14_1h_lt_50
        | roc_9_1h_gt_neg_20
        | roc_9_4h_gt_neg_35
      )
      # drop in last 4 days, 1d down move, 1h & 4h downtrend, 15m & 4h downtrend
      & (
        (protection_close > (protection_high_max_24_4h * 0.25))
        | rsi_3_1d_gt_15
        | (cmf_20_1h_gt_neg_020)
        | (cmf_20_4h_gt_neg_020)
        | (protection_roc_9_15m > -15.0)
        | roc_9_4h_gt_neg_20
      )
      # drop in last 6 days, 15m & 1d down move, 1h still high, 4h high, 4h downtrend
      & (
        (protection_close > (protection_high_max_6_1d * 0.25))
        | rsi_3_15m_gt_15
        | rsi_3_1d_gt_15
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_60
        | roc_9_4h_gt_neg_25
      )
      # drop in last 6 days, 15m & 1h down move, 15m & 1h still not low enough, 15m & 1h & 4h & 1d downtrend
      & (
        (protection_close > (protection_high_max_6_1d * 0.25))
        | rsi_3_15m_gt_25
        | rsi_3_1h_gt_30
        | rsi_14_15m_lt_30
        | cmf_20_15m_gt_neg_010
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_040)
        | (protection_cmf_20_1d > -0.50)
        | aroonu_14_1h_lt_30
      )
      # drop in last 4 days, 4h & 1d down move, 1h high
      & (
        (protection_close > (protection_high_max_24_4h * 0.15)) | rsi_3_4h_gt_25 | rsi_3_1d_gt_25 | stochrsi_k_1h_lt_70
      )
      # drop in last 4 days, 1d down move, 1d downtrendm 1h still high, 1d downtrend
      & (
        (protection_close > (protection_high_max_24_4h * 0.15))
        | rsi_3_1d_gt_20
        | (protection_cmf_20_1d > -0.30)
        | aroonu_14_1h_lt_50
        | (protection_roc_2_1d > -40.0)
      )
      # drop in last 6 days, 1d down move, 1h & 4h & 1d downtrend, 1d still high, 4h downtrend
      & (
        (protection_close > (protection_high_max_6_1d * 0.15))
        | rsi_3_1d_gt_20
        | cmf_20_1h_gt_neg_010
        | (cmf_20_4h_gt_neg_040)
        | (protection_cmf_20_1d > -0.50)
        | (protection_aroonu_14_1d < 50.0)
        | roc_9_4h_gt_neg_30
      )
      # drop in last 12 days. 15m & 1h & 4h & 1d down move, 4h still high, 1d downtrend
      & (
        (protection_close > (protection_high_max_12_1d * 0.25))
        | rsi_3_15m_gt_10
        | (rsi_3_1h_gt_10)
        | rsi_3_4h_gt_35
        | rsi_3_1d_gt_35
        | stochrsi_k_4h_lt_50
        | (roc_9_1d_gt_neg_40)
      )
      # drop in last 12 days, 15m & 1h down move, 1h still not low enough, 4h high
      & (
        (protection_close > (protection_high_max_12_1d * 0.25))
        | rsi_3_15m_gt_15
        | rsi_3_1h_gt_30
        | rsi_14_1h_lt_30
        | rsi_14_4h_lt_30
        | stochrsi_k_1h_lt_40
        | stochrsi_k_4h_lt_70
      )
      # drop in last 20 days, 15m & 1h & 1d down move, 15m still not low enough, 1h high
      & (
        (protection_close > (protection_high_max_20_1d * 0.05))
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_25
        | rsi_3_1d_gt_25
        | aroonu_14_15m_lt_30
        | aroonu_14_1h_lt_80
      )
      # drop in last 20 days, 1h & 4h & 1d down move, 1h & 4h still not low enough, 1h & 4h & 1d downtrend
      & (
        (protection_close > (protection_high_max_20_1d * 0.01))
        | rsi_3_1h_gt_45
        | rsi_3_4h_gt_60
        | rsi_3_1d_gt_15
        | (protection_rsi_14_1h < 15.0)
        | (rsi_14_4h_lt_20)
        | cmf_20_1h_gt_neg_0
        | (cmf_20_4h_gt_neg_010)
        | (protection_cmf_20_1d > -0.40)
        | (protection_cci_20_1h < -150.0)
        | (cci_20_4h_lt_neg_200)
        | (protection_roc_2_1d > -25.0)
        | (protection_roc_9_1d > -60.0)
      )
      # drop in last 30 days, 15m & 1h down move, 1h still high, 4h high & overbought
      & (
        (protection_close > (protection_high_max_30_1d * 0.10))
        | rsi_3_15m_gt_10
        | rsi_3_1h_gt_55
        | aroonu_14_1h_lt_40
        | aroonu_14_4h_lt_85
        | roc_9_4h_lt_80
      )
      # drop in last 30 days, 15m down move, 15m & 1h high
      & (
        (protection_close > (protection_high_max_30_1d * 0.05))
        | rsi_3_15m_gt_15
        | rsi_3_4h_gt_50
        | (aroonu_14_15m_lt_80)
        | stochrsi_k_1h_lt_85
      )
      # drop in last 30 days, 15m & 1h & 4h down move, 15m still not low enough, 1h high
      & (
        (protection_close > (protection_high_max_30_1d * 0.05))
        | rsi_3_15m_gt_25
        | rsi_3_1h_gt_25
        | rsi_3_4h_gt_40
        | stochrsi_k_15m_lt_20
        | stochrsi_k_1h_lt_40
      )
    )
    df["global_protections_long_pump"] = True

    df["global_protections_long_dump"] = True

    df["protections_long_rebuy"] = True

    # Global protections Short
    df["protections_short_global"] = (
      # 5m & 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h still low, 1h uptrend
      (
        (protection_rsi_3 < 90.0)
        | rsi_3_15m_lt_75
        | rsi_3_1h_lt_75
        | (protection_rsi_3_4h < 75.0)
        | rsi_14_15m_gt_90
        | rsi_14_1h_gt_85
        | rsi_14_4h_gt_70
        | (stochrsik_14_14_3_3_4h_gt_60)
        | roc_9_1h_lt_15
      )
      # 5m & 15m up move, 15m & 1h & 4h still low, 15m & 1h low, 4h still low
      & (
        (protection_rsi_3 < 90.0)
        | rsi_3_15m_lt_75
        | (protection_rsi_14_15m > 60.0)
        | (protection_rsi_14_1h > 50.0)
        | (protection_rsi_14_4h > 40.0)
        | (protection_aroonu_14_15m > 20.0)
        | (protection_aroonu_14_1h > 20.0)
        | (protection_aroonu_14_4h > 40.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 1h & 4h still low, 4h low
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_60
        | (rsi_3_4h_lt_60)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_70
        | rsi_14_4h_gt_70
        | (protection_aroonu_14_1h > 60.0)
        | (protection_aroonu_14_4h > 60.0)
        | (protection_stochrsik_14_14_3_3_4h > 40.0)
      )
      # 15m & 1h & 4h up move, 15m still not high enough, 1h & 4h still low, 1h low
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_60
        | (protection_rsi_3_4h < 35.0)
        | rsi_14_15m_gt_80
        | (protection_rsi_14_1h > 60.0)
        | rsi_14_4h_gt_60
        | (protection_aroonu_14_1h > 40.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h uptrend
      & (
        (rsi_3_15m_lt_95)
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (protection_cci_20_1h > 200.0)
        | (protection_cci_20_4h > 150.0)
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h up move, 1h & 4h still now high enough, 15m uptrend, 1h still not high enough
      & (
        (rsi_3_15m_lt_95)
        | (protection_rsi_3_1h < 50.0)
        | (protection_rsi_3_4h < 50.0)
        | rsi_14_1h_gt_70
        | rsi_14_4h_gt_70
        | (protection_cmf_20_15m < 0.20)
        | (stochrsik_14_14_3_3_1h_gt_70)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 1h & 4h & 1d uptrend
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_90
        | (rsi_3_4h_lt_80)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | roc_9_1h_lt_10
        | roc_9_4h_lt_20
        | roc_9_1d_lt_80
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 1h & 4h uptrend
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (cci_20_1h_gt_250)
        | (cci_20_4h_gt_200)
        | roc_9_1h_lt_10
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 15m uptrend, 4h still low
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_70
        | (protection_cmf_20_15m < 0.25)
        | (stochrsik_14_14_3_3_4h_gt_60)
      )
      # 15m & 1h & 4h up move, 15m still not high enough, 1h & 4h still low, 4h still low
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_60
        | (rsi_3_4h_lt_60)
        | rsi_14_15m_gt_80
        | (protection_rsi_14_1h > 60.0)
        | rsi_14_4h_gt_60
        | (protection_aroonu_14_4h > 50.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h still not high enough, 1h & 4h uptrend
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_85
        | (protection_rsi_3_4h < 85.0)
        | (protection_aroonu_14_15m > 70.0)
        | (protection_stochrsik_14_14_3_3_15m > 80.0)
        | (protection_stochrsik_14_14_3_3_1h > 80.0)
        | roc_9_1h_lt_10
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 15m & 1h & 4h uptrend
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_85
        | (rsi_3_4h_lt_80)
        | rsi_14_15m_gt_85
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (protection_cmf_20_15m < 0.20)
        | (protection_cmf_20_1h < 0.10)
        | (protection_cmf_20_4h < 0.10)
      )
      # 15m & 1h & 4h up move, 1h still low, 4h & 1d uptrend
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_85
        | (rsi_3_4h_lt_70)
        | (protection_stochrsik_14_14_3_3_1h > 50.0)
        | roc_9_4h_lt_80
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h up move, 1h & 4h still not high enough, 4h overbought
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | (protection_aroonu_14_4h > 70.0)
        | (protection_stochrsik_14_14_3_3_1h > 80.0)
        | (stochrsik_14_14_3_3_4h_gt_80)
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h up move, 1h still nt high enough, 1h & 4h uptrend
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_70
        | (rsi_3_4h_lt_70)
        | (protection_aroonu_14_1h > 70.0)
        | (stochrsik_14_14_3_3_1h_gt_70)
        | (protection_roc_9_1h < 45.0)
        | (protection_roc_9_4h < 45.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 1h still low, 1h & 4h uptrend
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_70
        | (rsi_3_4h_lt_70)
        | rsi_14_15m_gt_70
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (protection_stochrsik_14_14_3_3_1h > 60.0)
        | roc_9_1h_lt_20
        | roc_9_4h_lt_40
      )
      # 15m & 1h & 4h up move, 4h still not high enough, 15m & 1h & 4h uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | (protection_stochrsik_14_14_3_3_4h > 75.0)
        | (roc_9_15m_lt_10)
        | roc_9_1h_lt_10
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h low, 1h & 4h uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_60)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_60
        | (protection_stochrsik_14_14_3_3_4h > 40.0)
        | roc_9_1h_lt_20
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h still low, 15m & 1h & 4h uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_80
        | (protection_rsi_3_4h < 55.0)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_70
        | (protection_aroonu_14_4h > 70.0)
        | (roc_9_15m_lt_10)
        | roc_9_1h_lt_10
        | roc_9_4h_lt_20
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 15m uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_70
        | (rsi_3_4h_lt_70)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_70
        | rsi_14_4h_gt_70
        | (protection_aroonu_14_4h > 70.0)
        | (protection_stochrsik_14_14_3_3_15m > 90.0)
        | (roc_9_15m_lt_10)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 1h low, 4h overbought
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_70
        | (rsi_3_4h_lt_70)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (protection_stochrsik_14_14_3_3_1h > 40.0)
        | roc_9_4h_lt_30
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h low
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_70
        | (protection_rsi_3_4h < 35.0)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_70
        | rsi_14_4h_gt_60
        | (protection_stochrsik_14_14_3_3_4h > 30.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h low, 4h overbought
      & (
        rsi_3_15m_lt_75
        | rsi_3_1h_lt_75
        | (rsi_3_4h_lt_70)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_70
        | (protection_aroonu_14_4h > 30.0)
        | roc_9_4h_lt_10
      )
      # 15m & 1h & 4h up move, 15m low, 1h uptrend
      & (
        rsi_3_15m_lt_70
        | (protection_rsi_3_1h < 95.0)
        | (protection_rsi_3_4h < 85.0)
        | (protection_stochrsik_14_14_3_3_15m > 30.0)
        | (protection_roc_9_1h < 25.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h uptrend, 15m still low, 1h uptrend
      & (
        rsi_3_15m_lt_70
        | rsi_3_1h_lt_70
        | (rsi_3_4h_lt_70)
        | (protection_cmf_20_15m < 0.20)
        | (protection_cmf_20_1h < 0.20)
        | (protection_cmf_20_4h < 0.20)
        | (protection_stochrsik_14_14_3_3_15m > 50.0)
        | roc_9_1h_lt_50
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 4h uptrend
      & (
        rsi_3_15m_lt_70
        | rsi_3_1h_lt_60
        | (rsi_3_4h_lt_60)
        | rsi_14_15m_gt_70
        | rsi_14_1h_gt_70
        | rsi_14_4h_gt_70
        | (stochrsik_14_14_3_3_1h_gt_70)
        | roc_9_4h_lt_50
      )
      # 1h & 4h up move, 1d still low, 15m & 4h still not high enough
      & (
        (protection_rsi_3_1h < 95.0)
        | (rsi_3_4h_lt_80)
        | (rsi_14_1d_gt_50)
        | (protection_stochrsik_14_14_3_3_15m > 70.0)
        | (protection_stochrsik_14_14_3_3_4h > 70.0)
      )
      # 1h & 4h up move, 1d still low, 1h & 4h & 1d uptrend
      & (rsi_3_1h_lt_90 | (rsi_3_4h_lt_90) | (rsi_14_1d_gt_50) | roc_9_1h_lt_20 | roc_9_4h_lt_20 | roc_9_1d_lt_20)
      # 4h up move, 15m & 1h & 4h still not high enough, 1d still low, 4h still not high enough, 1d still low
      & (
        (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (rsi_14_1d_gt_50)
        | (stochrsik_14_14_3_3_4h_gt_80)
        | (protection_stochrsik_14_14_3_3_1d > 50.0)
      )
      # 4h up move, 15m & 1h & 4h still not high enough, 15m low, 15m & 1h & 4h uptrend
      & (
        (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_80
        | (protection_stochrsik_14_14_3_3_15m > 40.0)
        | (protection_roc_9_15m < 20.0)
        | roc_9_1h_lt_15
        | roc_9_4h_lt_15
      )
      # 4h up move, 15m & 1h & 4h still not high enough, 1h still low, 1h & 4h overbought
      & (
        (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_80
        | rsi_14_1h_gt_80
        | rsi_14_4h_gt_90
        | (protection_stochrsik_14_14_3_3_1h > 60.0)
        | roc_9_1h_lt_20
        | roc_9_4h_lt_60
      )
    )

    df["global_protections_short_pump"] = (
      # 15m & 1h & 4h & 1d up move, 15m & 1h & 4h still not high enough, 1d still not high enough & uptrend
      (
        (protection_rsi_3_15m < 40.0)
        | (protection_rsi_3_1h < 40.0)
        | (protection_rsi_3_4h < 85.0)
        | (protection_rsi_3_1d < 85.0)
        | rsi_14_15m_gt_70
        | (protection_cci_20_15m > 350.0)
        | rsi_14_1h_gt_75
        | (cci_20_1h_gt_250)
        | (protection_stochrsik_14_14_3_3_1h > 50.0)
        | rsi_14_4h_gt_95
        | (aroond_14_4h_lt_50)
        | (protection_cci_20_4h > 250.0)
        | (protection_rsi_14_1d > 60.0)
        | (protection_aroond_14_1d < 75.0)
        | (protection_stochrsik_14_14_3_3_1d > 70.0)
        | roc_9_1d_lt_40
      )
      # 15m & 1h & 4h & 1d up move, 15m & 1h & 4h still not high enough, 1d still not high enough & uptrend
      & (
        (protection_rsi_3_15m < 60.0)
        | rsi_3_1h_lt_60
        | (rsi_3_4h_lt_80)
        | (protection_rsi_3_1d < 90.0)
        | rsi_14_15m_gt_90
        | (protection_cci_20_15m > 350.0)
        | rsi_14_1h_gt_90
        | (protection_cci_20_1h > 300.0)
        | rsi_14_4h_gt_80
        | (cci_20_4h_gt_200)
        | (protection_rsi_14_1d > 95.0)
        | roc_9_1d_lt_80
      )
      # 1d green, 15m & 1h & 4h & 1d up move, 4h & 1d still not high enough & uptrend
      & (
        (protection_rsi_3_15m < 60.0)
        | rsi_3_1h_lt_70
        | (rsi_3_4h_lt_70)
        | (protection_rsi_3_1d < 80.0)
        | rsi_14_4h_gt_70
        | (willr_14_4h_gt_neg_10)
        | (stochrsik_14_14_3_3_4h_gt_80)
        | roc_9_4h_lt_40
        | (protection_rsi_14_1d > 80.0)
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 1d up move, 15m & 1h & 4h still not high enough, 1d still not high enough & uptrend
      & (
        (protection_rsi_3_15m < 65.0)
        | rsi_3_1h_lt_70
        | (protection_rsi_3_1d < 60.0)
        | rsi_14_15m_gt_90
        | (protection_cmf_20_15m > 0.40)
        | (protection_willr_14_15m > -10.0)
        | (protection_cci_20_15m > 450.0)
        | (protection_stochk_14_3_3_15m > 90.0)
        | rsi_14_1h_gt_90
        | (protection_cmf_20_1h > 0.20)
        | (protection_willr_14_1h > -5.0)
        | (cci_20_1h_gt_250)
        | rsi_14_4h_gt_90
        | (protection_cmf_20_4h > 0.10)
        | (protection_cci_20_4h > 250.0)
        | (protection_rsi_14_1d > 90.0)
        | roc_9_1d_lt_25
      )
      # 15m & 1h & 4h & 1d up move, 15m & 1h & 4h & 1d still not high enough, 1d uptrend
      & (
        rsi_3_15m_lt_70
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | (protection_rsi_3_1d < 80.0)
        | (protection_mfi_14_15m > 90.0)
        | (protection_stochrsik_14_14_3_3_15m > 90.0)
        | (protection_mfi_14_1h > 90.0)
        | (protection_mfi_14_4h > 80.0)
        | (protection_willr_14_4h > -5.0)
        | (aroond_14_4h_lt_50)
        | roc_9_1d_lt_40
      )
      # 15m & 1h up move, 15m & 1h & 4h still not high enough, 1d still not high enough & uptrend
      & (
        rsi_3_15m_lt_70
        | rsi_3_1h_lt_85
        | (protection_mfi_14_15m > 90.0)
        | (protection_stochrsik_14_14_3_3_15m > 80.0)
        | rsi_14_1h_gt_80
        | (protection_mfi_14_1h > 80.0)
        | (stochrsik_14_14_3_3_1h_gt_70)
        | rsi_14_4h_gt_80
        | (protection_rsi_14_1d > 80.0)
        | roc_9_1d_lt_40
      )
      # 15m & 1h & 4h & 1d up move, 15m & 1h still not high enough, 4h & 1d stil not high enough & uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | (protection_rsi_3_1d < 95.0)
        | rsi_14_15m_gt_85
        | (cci_20_15m_gt_250)
        | rsi_14_1h_gt_85
        | (cci_20_1h_gt_250)
        | (protection_cci_20_change_pct_1h < -0.0)
        | (protection_stochrsik_14_14_3_3_1h > 90.0)
        | (protection_rsi_14_4h > 85.0)
        | (protection_cci_20_4h > 250.0)
        | (protection_cci_20_change_pct_4h < -0.0)
        | (protection_stochrsik_14_14_3_3_4h > 90.0)
        | roc_9_4h_lt_30
        | (protection_rsi_14_1d > 90.0)
        | (protection_willr_14_1d > -10.0)
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h up move, 15m & 1h still not high enough, 4h still not high enough & uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_90
        | (protection_cci_20_15m > 400.0)
        | rsi_14_1h_gt_90
        | (protection_cci_20_1h > 400.0)
        | (protection_cci_20_4h > 400.0)
        | (protection_roc_9_4h < 200.0)
      )
      # 15m & 1h up move, 15m & 1h & 4h still not high enough, 1d still not high enough & uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_90
        | rsi_14_15m_gt_85
        | (cci_20_15m_gt_250)
        | rsi_14_1h_gt_75
        | (protection_aroond_14_1h < 50.0)
        | (protection_cci_20_1h > 350.0)
        | (protection_cci_20_change_pct_1h < -0.0)
        | (protection_rsi_14_4h > 85.0)
        | (protection_cci_20_4h > 150.0)
        | (protection_cci_20_change_pct_4h < -0.0)
        | (protection_stochrsik_14_14_3_3_4h > 70.0)
        | (protection_rsi_14_1d > 85.0)
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h & 1d up move, 15m & 1h & 4h & 1d still not high enough
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_90
        | (rsi_3_4h_lt_70)
        | (protection_rsi_3_1d < 70.0)
        | rsi_14_15m_gt_85
        | rsi_14_1h_gt_85
        | (cci_20_1h_gt_250)
        | (protection_cci_20_change_pct_1h < -0.0)
        | rsi_14_4h_gt_70
        | (protection_aroond_14_4h < 75.0)
        | (cci_20_4h_gt_200)
        | (protection_cci_20_change_pct_4h < -0.0)
        | (protection_stochk_14_3_3_4h > 70.0)
        | (protection_rsi_14_1d > 70.0)
      )
      # 15m & 1h & 4h & 1d up move, 1h still not high enough, 1d still low, 4h & 1d uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_85
        | (rsi_3_4h_lt_90)
        | (protection_rsi_3_1d < 95.0)
        | (protection_stochrsik_14_14_3_3_1h > 60.0)
        | (protection_aroond_14_1d < 50.0)
        | roc_9_4h_lt_100
        | roc_9_1d_lt_100
      )
      # 15m & 1h & 4h & 1d up move, 15m & 1h still not high enough, 4h & 1d still not high enough & uptrend
      & (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_90)
        | (protection_rsi_3_1d < 95.0)
        | rsi_14_15m_gt_85
        | (protection_stochk_14_3_3_15m > 90.0)
        | rsi_14_1h_gt_90
        | (protection_stochk_14_3_3_1h > 90.0)
        | rsi_14_4h_gt_95
        | (protection_stochk_14_3_3_4h > 90.0)
        | roc_9_4h_lt_50
        | (protection_rsi_14_1d > 95.0)
        | (protection_stochk_14_3_3_1d > 70.0)
        | (protection_aroond_14_1d < 50.0)
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h up move, 1h & 4h still not high enough, 1d uptrend
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_60)
        | (protection_willr_14_1h > -5.0)
        | (protection_aroond_14_1h < 25.0)
        | (willr_14_4h_gt_neg_10)
        | (aroond_14_4h_lt_50)
        | (stochrsik_14_14_3_3_4h_gt_60)
        | roc_9_1d_lt_50
      )
      # 15m & 1h & 4h up move, 15m still not high enough, 1h & 4h still not high enough & uptrend, 1d still not high enough
      & (
        rsi_3_15m_lt_85
        | rsi_3_1h_lt_85
        | (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_95
        | (protection_cmf_20_15m > 0.50)
        | (protection_uo_7_14_28_15m > 80.0)
        | (protection_uo_7_14_28_change_pct_15m < -0.0)
        | (cci_20_15m_gt_250)
        | (protection_stochk_14_3_3_15m > 90.0)
        | rsi_14_1h_gt_95
        | (protection_cmf_20_1h > 0.50)
        | (protection_uo_7_14_28_1h > 80.0)
        | (protection_cci_20_1h > 350.0)
        | roc_9_1h_lt_10
        | rsi_14_4h_gt_90
        | (protection_cmf_20_4h > 0.35)
        | (protection_uo_7_14_28_4h > 75.0)
        | (protection_cci_20_4h > 500.0)
        | (protection_roc_2_4h < 10.0)
        | roc_9_4h_lt_10
        | (protection_rsi_14_1d > 70.0)
      )
      # 15m & 1h & 4h up move, 15m & 1h & 4h still not high enough, 1d still not high enough & overbought
      & (
        rsi_3_15m_lt_90
        | rsi_3_1h_lt_60
        | (rsi_3_4h_lt_60)
        | rsi_14_15m_gt_85
        | (cci_20_15m_gt_250)
        | rsi_14_1h_gt_70
        | (protection_cci_20_1h > 200.0)
        | (protection_stochk_14_3_3_1h > 90.0)
        | (protection_rsi_14_4h > 65.0)
        | (cci_20_4h_gt_200)
        | (protection_stochk_14_3_3_4h > 90.0)
        | (protection_rsi_14_1d > 65.0)
        | (protection_stochk_14_3_3_1d > 70.0)
        | roc_9_1d_lt_30
      )
      # 15m & 1h & 4h & 1d up move, 15m & 1h & 4h still not high enough. 1d still not high enough & uptrend
      & (
        (rsi_3_15m_lt_95)
        | rsi_3_1h_lt_80
        | (rsi_3_4h_lt_80)
        | (protection_rsi_3_1d < 80.0)
        | rsi_14_15m_gt_90
        | rsi_14_1h_gt_90
        | (stochrsik_14_14_3_3_1h_gt_70)
        | rsi_14_4h_gt_90
        | (protection_willr_14_4h > -5.0)
        | (protection_rsi_14_1d > 80.0)
        | (protection_stochrsik_14_14_3_3_1d > 80.0)
        | roc_9_1d_lt_40
      )
      # 15m & 1h & 4h up move, 15m & 1h still not high enough, 4h still not high enough & uptrend
      & (
        (rsi_3_15m_lt_95)
        | rsi_3_1h_lt_90
        | (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_90
        | (cci_20_15m_gt_250)
        | rsi_14_1h_gt_90
        | (protection_aroond_14_1h < 25.0)
        | (protection_cci_20_1h > 300.0)
        | (protection_stochk_14_3_3_1h > 90.0)
        | rsi_14_4h_gt_95
        | (protection_cci_20_4h > 300.0)
        | roc_9_4h_lt_20
      )
      # 1h & 4h & 1d up move, 15m still not high enough, 1h & 4h & 1d still not high enough, 1d uptrend
      & (
        rsi_3_1h_lt_80
        | (rsi_3_4h_lt_60)
        | (protection_rsi_3_1d < 90.0)
        | (protection_stochrsik_14_14_3_3_15m > 80.0)
        | (protection_willr_14_1h > -20.0)
        | (protection_willr_14_4h > -25.0)
        | (protection_stochrsik_14_14_3_3_4h > 20.0)
        | (protection_aroond_14_1d < 50.0)
        | roc_9_1d_lt_20
      )
    )

    df["global_protections_short_dump"] = (
      # 15m & 1h up move, 15m & 1h still not high enough, 4h still low, 1d still low & downtrend
      (
        rsi_3_15m_lt_80
        | rsi_3_1h_lt_70
        | rsi_14_15m_gt_80
        | (protection_cci_20_15m > 400.0)
        | rsi_14_1h_gt_75
        | (cci_20_1h_gt_250)
        | rsi_14_4h_gt_60
        | (aroond_14_4h_lt_50)
        | (cci_20_4h_gt_200)
        | (rsi_14_1d_gt_50)
        | (protection_aroond_14_1d < 75.0)
        | (roc_9_1d_gt_neg_30)
      )
      # 15m up move, 15m still low, 1h & 4h & 1d still not high
      & (
        rsi_3_15m_lt_85
        | (protection_aroond_14_15m < 50.0)
        | rsi_14_1h_gt_70
        | (protection_willr_14_1h > -50.0)
        | (protection_stochrsik_14_14_3_3_1h > 80.0)
        | (protection_aroond_14_1h < 75.0)
        | rsi_14_4h_gt_70
        | (protection_willr_14_4h > -50.0)
        | (protection_aroond_14_4h < 25.0)
        | (protection_stochrsik_14_14_3_3_4h > 30.0)
        | (protection_rsi_14_1d > 70.0)
      )
      # 1h & 4h up move, 15m & 1h & 4h still not high enough, 1d still low & downtrend
      & (
        rsi_3_1h_lt_70
        | (rsi_3_4h_lt_90)
        | rsi_14_15m_gt_95
        | (protection_cci_20_15m > 600.0)
        | rsi_14_1h_gt_95
        | (protection_cci_20_1h > 600.0)
        | rsi_14_4h_gt_95
        | (willr_14_4h_gt_neg_10)
        | (protection_cci_20_4h > 600.0)
        | (protection_rsi_14_1d > 40.0)
        | (protection_roc_9_1d > -20.0)
      )
    )
    df["protections_short_rebuy"] = True

    if debug_time:
      tok_after_protections = time.perf_counter()
      tok_total = time.perf_counter()
      log.debug(
        f"[{metadata_pair}] "
        f"populate_indicators pre-protections: "
        f"{tok_before_protections - tik:0.4f}s | "
        f"protections: "
        f"{tok_after_protections - tok_before_protections:0.4f}s | "
        f"total: "
        f"{tok_total - tik:0.4f}s"
      )

    return df

  # Confirm Trade Entry
  # ---------------------------------------------------------------------------------------------
  def confirm_trade_entry(
    self,
    pair: str,
    order_type: str,
    amount: float,
    rate: float,
    time_in_force: str,
    current_time: datetime,
    entry_tag: Optional[str],
    side: str,
    **kwargs,
  ) -> bool:
    # Force Entry
    if entry_tag == "force_entry":
      return True

    # Mode Validation
    entry_tags = entry_tag.split()
    is_long_side = side == "long"
    is_short_side = side == "short"
    long_grind_mode_tags = self.long_grind_mode_tags
    long_top_coins_mode_tags = self.long_top_coins_mode_tags
    long_scalp_mode_tags = self.long_scalp_mode_tags
    if all(c in long_grind_mode_tags for c in entry_tags):
      return self._handle_grind_mode(pair, current_time)
    if all(c in long_top_coins_mode_tags for c in entry_tags):
      return self._handle_top_coins_mode(pair, current_time)
    if all(c in long_scalp_mode_tags for c in entry_tags):
      return self._handle_scalp_mode(pair, current_time)

    # Long/Short Slot Validation (only in futures mode)
    if self.is_futures_mode:
      max_side_trades = 0
      if is_long_side:
        max_side_trades = self.futures_max_open_trades_long
      elif is_short_side:
        max_side_trades = self.futures_max_open_trades_short

      if max_side_trades != 0:
        open_trades = Trade.get_trades_proxy(is_open=True)
        side_trades = sum(1 for t in open_trades if t.trade_direction == side)
        if side_trades >= max_side_trades:
          log.info(
            f"[{current_time}] Cancelling entry for {pair} due to {side} trades reaching the max limit of {max_side_trades}."
          )
          return False

    max_slippage = self.max_slippage

    # Slippage Validation
    df, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe)
    if len(df) >= 1:
      last_candle = df.iloc[-1]
      last_close = last_candle["close"]
      if (is_long_side and rate > last_close) or (is_short_side and rate < last_close):
        slippage = (rate / last_close) - 1.0
        if (is_long_side and slippage < max_slippage) or (is_short_side and slippage > -max_slippage):
          return True
        else:
          log.warning(f"[{current_time}] Cancelling entry for {pair} due to slippage {(slippage * 100.0):.2f}%")
          return False

    return True

  def _handle_grind_mode(self, pair: str, current_time: datetime) -> bool:
    grind_mode_coins = self.grind_mode_coins
    grind_mode_max_slots = self.grind_mode_max_slots
    long_grind_mode_tags = self.long_grind_mode_tags

    is_pair_grind_mode = pair.partition("/")[0] in grind_mode_coins
    if not is_pair_grind_mode:
      log.info(f"[{current_time}] Cancelling entry for {pair} due to not being in grind mode coins list.")
      return False

    open_trades = Trade.get_trades_proxy(is_open=True)
    num_open_grind_mode = sum(1 for t in open_trades if all(c in long_grind_mode_tags for c in t.enter_tag.split()))
    if num_open_grind_mode >= grind_mode_max_slots:
      log.info(f"[{current_time}] Cancelling entry for {pair} due to grind mode slots limit reached.")
      return False

    return True

  def _handle_top_coins_mode(self, pair: str, current_time: datetime) -> bool:
    is_pair_top_coins_mode = pair.partition("/")[0] in self.top_coins_mode_coins
    if not is_pair_top_coins_mode:
      log.info(f"[{current_time}] Cancelling entry for {pair} due to not being in top coins list.")
      return False
    return True

  def _handle_scalp_mode(self, pair: str, current_time: datetime) -> bool:
    current_free_slots = self.config["max_open_trades"] - Trade.get_open_trade_count()
    if current_free_slots < self.min_free_slots_scalp_mode:
      log.info(f"[{current_time}] Cancelling entry for {pair} due to insufficient free slots.")
      return False
    return True

  # Confirm Trade Exit
  # ---------------------------------------------------------------------------------------------
  def confirm_trade_exit(
    self,
    pair: str,
    trade: Trade,
    order_type: str,
    amount: float,
    rate: float,
    time_in_force: str,
    exit_reason: str,
    current_time: datetime,
    **kwargs,
  ) -> bool:
    trade_realized_profit = trade.realized_profit
    trade_stake_amount = trade.stake_amount
    trade_is_short = trade.is_short
    trade_liquidation_price = trade.liquidation_price
    trade_open_rate = trade.open_rate

    is_backtest = self.is_backtest_mode()
    # Allow force exits
    if exit_reason != "force_exit":
      if self._should_hold_trade(trade, rate, exit_reason):
        return False
      if exit_reason in ["stop_loss", "trailing_stop_loss"]:
        # log.info(f"[{current_time}] Cancelling {exit_reason} exit for {pair}")
        is_liquidation = False
        if self.is_futures_mode and is_backtest:
          if (trade_is_short and rate > trade_liquidation_price) or (
            not trade_is_short and rate < trade_liquidation_price
          ):
            is_liquidation = True
        if not is_liquidation:
          return False
      if self.exit_profit_only:
        profit = 0.0
        if trade_realized_profit != 0.0:
          profit = ((rate - trade_open_rate) / trade_open_rate) * trade_stake_amount * (1 - trade.fee_close)
          profit = profit + trade_realized_profit
          profit = profit / trade_stake_amount
        else:
          profit = trade.calc_profit_ratio(rate)
        if profit < self.exit_profit_offset:
          return False

    self._remove_profit_target(pair)
    return True

  # Check Entry Timeout
  # ---------------------------------------------------------------------------------------------
  def check_entry_timeout(self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs) -> bool:
    ob = self.dp.orderbook(pair, 1)
    bids = ob["bids"][0][0]
    asks = ob["asks"][0][0]
    # Cancel order if price is more than 3% difference.
    if trade.is_short:
      if asks < order.price * 0.97:
        return True
    else:
      if bids > order.price * 1.03:
        return True
    return False

  # Check Exit Timeout
  # ---------------------------------------------------------------------------------------------
  def check_exit_timeout(self, pair: str, trade: Trade, order: Order, current_time: datetime, **kwargs) -> bool:
    # If force exit skip the check
    if order.ft_order_tag is not None and order.ft_order_tag == "force_exit":
      return False
    ob = self.dp.orderbook(pair, 1)
    bids = ob["bids"][0][0]
    asks = ob["asks"][0][0]
    # Cancel order if price is more than 3% difference.
    if trade.is_short:
      if bids > order.price * 1.03:
        return True
    else:
      if asks < order.price * 0.97:
        return True
    return False

  # Bot Loop Start
  # ---------------------------------------------------------------------------------------------
  def bot_loop_start(self, current_time: datetime, **kwargs) -> None:
    if self.config["runmode"].value not in ("live", "dry_run"):
      return super().bot_loop_start(datetime, **kwargs)

    if self.hold_support_enabled:
      self.load_hold_trades_config()

    return super().bot_loop_start(current_time, **kwargs)

  # Leverage
  # ---------------------------------------------------------------------------------------------
  def leverage(
    self,
    pair: str,
    current_time: datetime,
    current_rate: float,
    proposed_leverage: float,
    max_leverage: float,
    entry_tag: Optional[str],
    side: str,
    **kwargs,
  ) -> float:
    enter_tags = entry_tag.split()
    long_rebuy_mode_tags = self.long_rebuy_mode_tags
    long_grind_mode_tags = self.long_grind_mode_tags
    if all(c in long_rebuy_mode_tags for c in enter_tags):
      return self.futures_mode_leverage_rebuy_mode
    elif all(c in long_grind_mode_tags for c in enter_tags):
      return self.futures_mode_leverage_grind_mode
    return self.futures_mode_leverage

  # Correct Min Stake
  # ---------------------------------------------------------------------------------------------
  def correct_min_stake(self, min_stake: Optional[float], trade_leverage: Optional[float] = None) -> Optional[float]:
    if self.is_futures_mode and self.config["exchange"]["name"] in ("binance", "bybit", "krakenfutures"):
      min_futures_stake = 5.0 / (trade_leverage if trade_leverage is not None else self.futures_mode_leverage)
      if (min_stake is None) or (min_stake < min_futures_stake):
        min_stake = min_futures_stake
    return min_stake

  def is_backtest_mode(self) -> bool:
    """Check if the current run mode is backtest or hyperopt"""
    return self.dp.runmode.value in ["backtest", "hyperopt"]

  def is_system_v3(self, trade: Trade) -> bool:
    """Check if the current system is v3"""
    return trade.get_custom_data(key="system_version") == self.system_v3_name

  def is_system_v3_1(self, trade: Trade) -> bool:
    """Check if the current system is v3_1"""
    return trade.get_custom_data(key="system_version") == self.system_v3_1_name

  def is_system_v3_2(self, trade: Trade) -> bool:
    """Check if the current system is v3_2"""
    return trade.get_custom_data(key="system_version") == self.system_v3_2_name

  def get_system_version_flags(self, trade: Trade) -> tuple[bool, bool, bool]:
    """Check the current system version flags with one custom-data lookup."""
    system_version = trade.get_custom_data(key="system_version")
    return (
      system_version == self.system_v3_name,
      system_version == self.system_v3_1_name,
      system_version == self.system_v3_2_name,
    )

  def has_valid_entry_conditions(
    self, trade: Trade, exit_rate: float, last_candle, previous_candle, filled_orders=None
  ) -> bool:
    """Check if there are valid entry conditions"""
    if filled_orders is None:
      filled_orders = trade.select_filled_orders()
    if not filled_orders:
      return False
    last_filled_price = filled_orders[-1].safe_price
    slice_profit = (exit_rate - last_filled_price) / last_filled_price
    if not trade.is_short:
      return last_candle["enter_long"] or self.long_grind_entry(last_candle, previous_candle, slice_profit, False)
    else:
      return last_candle["enter_short"] or self.short_grind_entry(last_candle, previous_candle, slice_profit, False)
    return False

  # Update signals (enable/disable) from config
  # ---------------------------------------------------------------------------------------------
  def update_signals_from_config(self, config):
    # Update long entry signal parameters (if they exist in the config)
    if hasattr(self, "long_entry_signal_params") and "long_entry_signal_params" in config:
      long_entry_signal_params = self.long_entry_signal_params
      config_long_entry_signal_params = config["long_entry_signal_params"]
      for condition_key in long_entry_signal_params:
        if condition_key in config_long_entry_signal_params:
          long_entry_signal_params[condition_key] = config_long_entry_signal_params[condition_key]

    # Update short entry signal parameters (if they exist in the config)
    if hasattr(self, "short_entry_signal_params") and "short_entry_signal_params" in config:
      short_entry_signal_params = self.short_entry_signal_params
      config_short_entry_signal_params = config["short_entry_signal_params"]
      for condition_key in short_entry_signal_params:
        if condition_key in config_short_entry_signal_params:
          short_entry_signal_params[condition_key] = config_short_entry_signal_params[condition_key]

  # Set Profit Target
  # ---------------------------------------------------------------------------------------------
  def _set_profit_target(
    self, pair: str, sell_reason: str, rate: float, current_profit: float, current_time: datetime
  ):
    self.target_profit_cache.data[pair] = {
      "rate": rate,
      "profit": current_profit,
      "sell_reason": sell_reason,
      "time_profit_reached": current_time.isoformat(),
    }
    self.target_profit_cache.save()

  # Remove Profit Target
  # ---------------------------------------------------------------------------------------------
  def _remove_profit_target(self, pair: str):
    target_profit_cache = self.target_profit_cache

    if target_profit_cache is not None:
      target_profit_cache.data.pop(pair, None)
      target_profit_cache.save()

  # Get Hold Trades Config File
  # ---------------------------------------------------------------------------------------------
  def get_hold_trades_config_file(self):
    proper_holds_file_path = self.config["user_data_dir"].resolve() / "nfi-hold-trades.json"
    if proper_holds_file_path.is_file():
      return proper_holds_file_path

    strat_file_path = pathlib.Path(__file__)
    hold_trades_config_file_resolve = strat_file_path.resolve().parent / "hold-trades.json"
    if hold_trades_config_file_resolve.is_file():
      log.warning(
        "Please move %s to %s which is now the expected path for the holds file",
        hold_trades_config_file_resolve,
        proper_holds_file_path,
      )
      return hold_trades_config_file_resolve

    # The resolved path does not exist, is it a symlink?
    hold_trades_config_file_absolute = strat_file_path.absolute().parent / "hold-trades.json"
    if hold_trades_config_file_absolute.is_file():
      log.warning(
        "Please move %s to %s which is now the expected path for the holds file",
        hold_trades_config_file_absolute,
        proper_holds_file_path,
      )
      return hold_trades_config_file_absolute

  # Load Hold Trades Config
  # ---------------------------------------------------------------------------------------------
  def load_hold_trades_config(self):
    hold_trades_cache = self.hold_trades_cache
    if hold_trades_cache is None:
      hold_trades_config_file = self.get_hold_trades_config_file()
      if hold_trades_config_file:
        log.warning("Loading hold support data from %s", hold_trades_config_file)
        hold_trades_cache = HoldsCache(hold_trades_config_file)
        self.hold_trades_cache = hold_trades_cache

    if hold_trades_cache:
      hold_trades_cache.load()

  # Should Hold Trade
  # ---------------------------------------------------------------------------------------------
  def _should_hold_trade(self, trade: "Trade", rate: float, sell_reason: str) -> bool:
    calc_total_profit = self.calc_total_profit
    trade_id = trade.id
    trade_pair = trade.pair

    if self.config["runmode"].value not in ("live", "dry_run"):
      return False

    if not self.hold_support_enabled:
      return False

    # Just to be sure our hold data is loaded, should be a no-op call after the first bot loop
    self.load_hold_trades_config()

    hold_trades_cache = self.hold_trades_cache
    if not hold_trades_cache:
      # Cache hasn't been setup, likely because the corresponding file does not exist, sell
      return False

    hold_trades_data = hold_trades_cache.data
    if not hold_trades_data:
      # We have no pairs we want to hold until profit, sell
      return False

    # By default, no hold should be done
    hold_trade = False
    profit_values = None

    def get_profit_values():
      nonlocal profit_values
      if profit_values is None:
        filled_entries = trade.select_filled_orders(trade.entry_side)
        filled_exits = trade.select_filled_orders(trade.exit_side)
        profit_values = calc_total_profit(trade, filled_entries, filled_exits, rate)

      return profit_values

    for hold_key_name, hold_key in (("trade_ids", trade_id), ("trade_pairs", trade_pair)):
      hold_targets: dict = hold_trades_data.get(hold_key_name)
      if not hold_targets or hold_key not in hold_targets:
        continue

      trade_profit_ratio = hold_targets[hold_key]
      current_profit_ratio = get_profit_values()[3]
      if sell_reason == "force_sell":
        formatted_profit_ratio = f"{trade_profit_ratio * 100}%"
        formatted_current_profit_ratio = f"{current_profit_ratio * 100}%"
        log.warning(
          "Force selling %s even though the current profit of %s < %s",
          trade,
          formatted_current_profit_ratio,
          formatted_profit_ratio,
        )
        return False
      elif current_profit_ratio >= trade_profit_ratio:
        # This trade is on the list to hold, and we reached minimum profit, sell
        formatted_profit_ratio = f"{trade_profit_ratio * 100}%"
        formatted_current_profit_ratio = f"{current_profit_ratio * 100}%"
        log.warning(
          "Selling %s because the current profit of %s >= %s",
          trade,
          formatted_current_profit_ratio,
          formatted_profit_ratio,
        )
        return False

      # This trade is on the list to hold, and we haven't reached minimum profit, hold
      hold_trade = True

    return hold_trade

  # Populate Exit Trend
  # ---------------------------------------------------------------------------------------------
  def populate_exit_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
    df.loc[:, "exit_long"] = 0
    df.loc[:, "exit_short"] = 0

    return df

  #
  # $$$$$$$$\ $$\   $$\ $$$$$$$$\ $$$$$$$\ $$\     $$\
  # $$  _____|$$$\  $$ |\__$$  __|$$  __$$\\$$\   $$  |
  # $$ |      $$$$\ $$ |   $$ |   $$ |  $$ |\$$\ $$  /
  # $$$$$\    $$ $$\$$ |   $$ |   $$$$$$$  | \$$$$  /
  # $$  __|   $$ \$$$$ |   $$ |   $$  __$$<   \$$  /
  # $$ |      $$ |\$$$ |   $$ |   $$ |  $$ |   $$ |
  # $$$$$$$$\ $$ | \$$ |   $$ |   $$ |  $$ |   $$ |
  # \________|\__|  \__|   \__|   \__|  \__|   \__|
  #

  #
  #  $$$$$$\   $$$$$$\  $$\   $$\ $$$$$$$\  $$$$$$\ $$$$$$$$\ $$$$$$\  $$$$$$\  $$\   $$\  $$$$$$\
  # $$  __$$\ $$  __$$\ $$$\  $$ |$$  __$$\ \_$$  _|\__$$  __|\_$$  _|$$  __$$\ $$$\  $$ |$$  __$$\
  # $$ /  \__|$$ /  $$ |$$$$\ $$ |$$ |  $$ |  $$ |     $$ |     $$ |  $$ /  $$ |$$$$\ $$ |$$ /  \__|
  # $$ |      $$ |  $$ |$$ $$\$$ |$$ |  $$ |  $$ |     $$ |     $$ |  $$ |  $$ |$$ $$\$$ |\$$$$$$\
  # $$ |      $$ |  $$ |$$ \$$$$ |$$ |  $$ |  $$ |     $$ |     $$ |  $$ |  $$ |$$ \$$$$ | \____$$\
  # $$ |  $$\ $$ |  $$ |$$ |\$$$ |$$ |  $$ |  $$ |     $$ |     $$ |  $$ |  $$ |$$ |\$$$ |$$\   $$ |
  # \$$$$$$  | $$$$$$  |$$ | \$$ |$$$$$$$  |$$$$$$\    $$ |   $$$$$$\  $$$$$$  |$$ | \$$ |\$$$$$$  |
  #  \______/  \______/ \__|  \__|\_______/ \______|   \__|   \______| \______/ \__|  \__| \______/
  #

  # Populate Entry Trend
  # ---------------------------------------------------------------------------------------------
  def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame:
    debug = False
    if debug:
      tik = time.perf_counter()
    config = self.config
    long_entry_signal_params = self.long_entry_signal_params
    short_entry_signal_params = self.short_entry_signal_params
    top_coins_mode_coins = self.top_coins_mode_coins

    long_entry_conditions = []
    short_entry_conditions = []

    entry_tags = np.full(len(df), "", dtype=object)
    df.loc[:, "enter_long"] = 0
    df.loc[:, "enter_short"] = 0
    np_view = lambda c: df[c].to_numpy(copy=False)
    np_shift = self.np_shift
    rsi_3_1h = np_view("RSI_3_1h")
    rsi_3_15m = np_view("RSI_3_15m")
    rsi_3_4h = np_view("RSI_3_4h")
    roc_9_1d = np_view("ROC_9_1d")
    aroonu_14_4h = np_view("AROONU_14_4h")
    aroonu_14_4h_shift_48 = np_shift(aroonu_14_4h, 48)
    roc_9_4h = np_view("ROC_9_4h")
    roc_9_4h_shift_48 = np_shift(roc_9_4h, 48)
    aroonu_14_1h = np_view("AROONU_14_1h")
    stochrsi_k_4h = np_view("STOCHRSIk_14_14_3_3_4h")
    stochrsi_k_1h = np_view("STOCHRSIk_14_14_3_3_1h")
    aroonu_14_1d = np_view("AROONU_14_1d")
    rsi_3_1d = np_view("RSI_3_1d")
    aroonu_14_15m = np_view("AROONU_14_15m")
    roc_9_1h = np_view("ROC_9_1h")
    stochrsi_k_15m = np_view("STOCHRSIk_14_14_3_3_15m")
    stochrsi_k_1d = np_view("STOCHRSIk_14_14_3_3_1d")
    rsi_3 = np_view("RSI_3")
    close = np_view("close")
    high_px = np_view("high")
    low_px = np_view("low")
    orange_h = np_view("ORANGE_H")
    orange_l = np_view("ORANGE_L")
    willr_14_4h = np_view("WILLR_14_4h")
    stoch_k_4h = np_view("STOCHk_14_3_3_4h")

    sqz_on = np_view("SQZ_ON")
    sqz_cnt_24 = np_view("SQZ_CNT_24")
    stoch_9_3 = np_view("STOCH_9_3")
    stoch_14_3 = np_view("STOCH_14_3")
    stoch_4_4 = np_view("STOCH_4_4")
    stoch_60_10 = np_view("STOCH_60_10")
    quad_low_min_12 = np_view("QUAD_LOW_MIN_12")
    quad_high_max_12 = np_view("QUAD_HIGH_MAX_12")
    quad_s93_min_12 = np_view("QUAD_S93_MIN_12")
    quad_s93_max_12 = np_view("QUAD_S93_MAX_12")
    bbp_20_2_0_4h = np_view("BBP_20_2.0_4h")
    obv_change_pct = np_view("OBV_change_pct")
    open_rate = np_view("open")
    roc_9_15m = np_view("ROC_9_15m")
    rsi_14_4h = np_view("RSI_14_4h")
    rsi_14_4h_shift_48 = np_shift(rsi_14_4h, 48)
    roc_2_1d = np_view("ROC_2_1d")
    uo_7_14_28_4h = np_view("UO_7_14_28_4h")
    willr_84_1h = np_view("WILLR_84_1h")
    mfi_14 = np_view("MFI_14")
    volume = np_view("volume")
    large_bubble_thr = np_view("LARGE_BUBBLE_THR")
    cvd_buy_vol = np_view("CVD_BUY_VOL")
    cvd_sell_vol = np_view("CVD_SELL_VOL")

    # Reused entry Series and comparison masks
    aroond_14 = np_view("AROOND_14")
    aroond_14_15m = np_view("AROOND_14_15m")
    aroond_14_1h = np_view("AROOND_14_1h")
    aroond_14_4h = np_view("AROOND_14_4h")
    aroonu_14 = np_view("AROONU_14")
    bbb_20_2_0 = np_view("BBB_20_2.0")
    bbb_20_2_0_1h = np_view("BBB_20_2.0_1h")
    bbl_20_2_0 = np_view("BBL_20_2.0")
    bbu_20_2_0 = np_view("BBU_20_2.0")
    _bb_rng = bbu_20_2_0 - bbl_20_2_0
    bbp_20_2_0 = np.divide(close - bbl_20_2_0, _bb_rng, out=np.full_like(_bb_rng, np.nan), where=_bb_rng != 0)
    # 1h band position for confluence signals (67/70/71 family)
    bbl_20_2_0_1h = np_view("BBL_20_2.0_1h")
    bbu_20_2_0_1h = np_view("BBU_20_2.0_1h")
    _bb_rng_1h = bbu_20_2_0_1h - bbl_20_2_0_1h
    bbp_20_2_0_1h = np.divide(
      close - bbl_20_2_0_1h, _bb_rng_1h, out=np.full_like(_bb_rng_1h, np.nan), where=_bb_rng_1h != 0
    )
    cci_20_change_pct_1h = np_view("CCI_20_change_pct_1h")
    cci_20_1h = np_view("CCI_20_1h")
    cci_20_4h = np_view("CCI_20_4h")
    cci_20_change_pct_4h = np_view("CCI_20_change_pct_4h")
    change_pct_1d = np_view("change_pct_1d")
    change_pct_1d_shift_288 = np_shift(change_pct_1d, 288)
    change_pct_1h = np_view("change_pct_1h")
    change_pct_1h_shift_12 = np_shift(change_pct_1h, 12)
    change_pct_4h = np_view("change_pct_4h")
    change_pct_4h_shift_48 = np_shift(change_pct_4h, 48)
    close_max_12 = np_view("close_max_12")
    close_max_48 = np_view("close_max_48")
    cmf_20 = np_view("CMF_20")
    cmf_20_15m = np_view("CMF_20_15m")
    cmf_20_1d = np_view("CMF_20_1d")
    cmf_20_1h = np_view("CMF_20_1h")
    cmf_20_4h = np_view("CMF_20_4h")
    ema_12 = np_view("EMA_12")
    ema_12_shift_1 = np_shift(ema_12, 1)
    ema_12_15m = np_view("EMA_12_15m")
    ema_12_15m_shift_1 = np_shift(ema_12_15m, 1)
    ema_12_4h = np_view("EMA_12_4h")
    ema_20 = np_view("EMA_20")
    ema_26 = np_view("EMA_26")
    ema_26_shift_1 = np_shift(ema_26, 1)
    ema_26_15m = np_view("EMA_26_15m")
    ema_26_15m_shift_1 = np_shift(ema_26_15m, 1)
    ema_50_15m = np_view("EMA_50_15m")
    ema_200_15m = np_view("EMA_200_15m")
    ema_200 = np_view("EMA_200")
    ema_200_1h = np_view("EMA_200_1h")
    ema_200_4h = np_view("EMA_200_4h")
    ema_9 = np_view("EMA_9")
    high_max_12_1d = np_view("high_max_12_1d")
    high_max_12_4h = np_view("high_max_12_4h")
    high_max_20_1d = np_view("high_max_20_1d")
    high_max_24_4h = np_view("high_max_24_4h")
    high_max_30_1d = np_view("high_max_30_1d")
    high_max_6_1d = np_view("high_max_6_1d")
    high_max_6_4h = np_view("high_max_6_4h")
    low_min_12_1d = np_view("low_min_12_1d")
    low_min_24_4h = np_view("low_min_24_4h")
    mfi_14_15m = np_view("MFI_14_15m")
    mfi_14_1h = np_view("MFI_14_1h")
    num_empty_288 = np_view("num_empty_288")
    protections_long_global = np_view("protections_long_global")
    protections_short_global = np_view("protections_short_global")
    global_protections_long_pump = np_view("global_protections_long_pump")
    global_protections_long_dump = np_view("global_protections_long_dump")

    engulf_bull = np_view("ENGULF_BULL")
    engulf_bear = np_view("ENGULF_BEAR")

    sfp_bull = np_view("SFP_BULL")
    sfp_bear = np_view("SFP_BEAR")
    ib_ready = np_view("IB_READY")
    ib_mother_h = np_view("IB_MOTHER_H")
    ib_mother_l = np_view("IB_MOTHER_L")
    roc_288 = np_view("ROC_288")
    vol_rel = np_view("VOL_REL")
    ph_cross_cnt_12 = np_view("PH_CROSS_CNT_12")
    ph_base_pos = np_view("PH_BASE_POS")
    ph_pre_tight = np_view("PH_PRE_TIGHT")
    mrb_bull = np_view("MRB_BULL")
    mrb_bear = np_view("MRB_BEAR")
    dh_prev_min = np_view("DH_PREV_MIN")
    pb_hammer = np_view("PB_HAMMER")
    pb_star = np_view("PB_STAR")
    adx_14_4h = np_view("ADX_14_4h")
    plus_di_14_4h = np_view("PLUS_DI_14_4h")
    minus_di_14_4h = np_view("MINUS_DI_14_4h")
    dc_high_7d = np_view("DC_HIGH_7D")
    dc_low_7d = np_view("DC_LOW_7D")
    global_protections_short_pump = np_view("global_protections_short_pump")
    global_protections_short_dump = np_view("global_protections_short_dump")
    roc_2 = np_view("ROC_2")
    roc_9 = np_view("ROC_9")
    rsi_14 = np_view("RSI_14")
    rsi_14_15m = np_view("RSI_14_15m")
    rsi_14_1d = np_view("RSI_14_1d")
    rsi_14_1h = np_view("RSI_14_1h")
    rsi_14_1h_shift_12 = np_shift(rsi_14_1h, 12)
    rsi_20 = np_view("RSI_20")
    rsi_20_shift_1 = np_shift(rsi_20, 1)
    rsi_3_change_pct_1h = np_view("RSI_3_change_pct_1h")
    rsi_3_change_pct_4h = np_view("RSI_3_change_pct_4h")
    rsi_4 = np_view("RSI_4")
    sma_16 = np_view("SMA_16")
    sma_21 = np_view("SMA_21")
    sma_21_shift_1 = np_shift(sma_21, 1)
    sma_200 = np_view("SMA_200")
    sma_200_shift_1 = np_shift(sma_200, 1)
    stochrsi_k = np_view("STOCHRSIk_14_14_3_3")
    top_wick_pct_1d = np_view("top_wick_pct_1d")
    top_wick_pct_1d_shift_288 = np_shift(top_wick_pct_1d, 288)
    willr_14 = np_view("WILLR_14")
    willr_14_1h = np_view("WILLR_14_1h")
    obv_change_pct_15m = np_view("OBV_change_pct_15m")
    high_max_6_1h = np_view("high_max_6_1h")
    high_max_12_1h = np_view("high_max_12_1h")
    high_max_24_1h = np_view("high_max_24_1h")
    sma_16_1h = np_view("SMA_16_1h")
    ema_16 = np_view("EMA_16")
    ema_20_15m = np_view("EMA_20_15m")
    ema_50 = np_view("EMA_50")
    open_15m = np_view("open_15m")
    top_wick_pct_4h = np_view("top_wick_pct_4h")
    low_min_6_1d = np_view("low_min_6_1d")
    willr_14_15m = np_view("WILLR_14_15m")
    close_15m = np_view("close_15m")
    change_pct = np_view("change_pct")
    low_min_20_1d = np_view("low_min_20_1d")
    low_min_24_1h = np_view("low_min_24_1h")
    low_min_6_1h = np_view("low_min_6_1h")
    sma_9 = np_view("SMA_9")
    mfi_14_4h = np_view("MFI_14_4h")
    cci_20_change_pct_15m = np_view("CCI_20_change_pct_15m")
    close_min_6 = np_view("close_min_6")
    close_min_12 = np_view("close_min_12")
    close_min_48 = np_view("close_min_48")
    uo_7_14_28_1h = np_view("UO_7_14_28_1h")
    rsi_14_change_pct = np_view("RSI_14_change_pct")
    mfi_14_1d = np_view("MFI_14_1d")
    rsi_14_change_pct_15m = np_view("RSI_14_change_pct_15m")
    rsi_3_change_pct_1d = np_view("RSI_3_change_pct_1d")
    rsi_14_change_pct_1h = np_view("RSI_14_change_pct_1h")
    roc_2_1h = np_view("ROC_2_1h")
    roc_2_4h = np_view("ROC_2_4h")
    change_pct_15m = np_view("change_pct_15m")
    cci_20_15m = np_view("CCI_20_15m")
    aroond_14_1d = np_view("AROOND_14_1d")
    bot_wick_pct_1d = np_view("bot_wick_pct_1d")
    low_min_12_1h = np_view("low_min_12_1h")
    low_min_30_1d = np_view("low_min_30_1d")
    rsi_14_change_pct_4h = np_view("RSI_14_change_pct_4h")
    stochk_14_3_3_15m = np_view("STOCHk_14_3_3_15m")
    stochk_14_3_3_1h = np_view("STOCHk_14_3_3_1h")
    uo_7_14_28_15m = np_view("UO_7_14_28_15m")
    stochk_14_3_3_4h = np_view("STOCHk_14_3_3_4h")
    stochk_14_3_3_1d = np_view("STOCHk_14_3_3_1d")
    willr_14_1d = np_view("WILLR_14_1d")
    uo_7_14_28_change_pct_15m = np_view("UO_7_14_28_change_pct_15m")
    stochrsi_k_change_pct_4h = np_view("STOCHRSIk_14_14_3_3_change_pct_4h")
    willr_480 = np_view("WILLR_480")
    rsi_3_change_pct_15m = np_view("RSI_3_change_pct_15m")
    close_max_6 = np_view("close_max_6")
    bbd_40_2_0 = np_view("BBD_40_2.0")
    bbt_40_2_0 = np_view("BBT_40_2.0")
    bbl_40_2_0 = np_view("BBL_40_2.0")
    close_shift_1 = np_shift(close, 1)
    bbl_40_2_0_shift_1 = np_shift(bbl_40_2_0, 1)
    close_delta = np_view("close_delta")

    rsi_3_gt_3 = rsi_3 > 3.0
    rsi_3_gt_5 = rsi_3 > 5.0
    rsi_3_gt_10 = rsi_3 > 10.0
    rsi_3_gt_15 = rsi_3 > 15.0
    rsi_3_15m_gt_3 = rsi_3_15m > 3.0
    rsi_3_15m_gt_5 = rsi_3_15m > 5.0
    rsi_3_15m_gt_10 = rsi_3_15m > 10.0
    rsi_3_15m_gt_15 = rsi_3_15m > 15.0
    rsi_3_15m_gt_20 = rsi_3_15m > 20.0
    rsi_3_15m_gt_25 = rsi_3_15m > 25.0
    rsi_3_15m_gt_30 = rsi_3_15m > 30.0
    rsi_3_15m_gt_35 = rsi_3_15m > 35.0
    rsi_3_15m_gt_40 = rsi_3_15m > 40.0
    rsi_3_15m_gt_45 = rsi_3_15m > 45.0
    rsi_3_15m_gt_50 = rsi_3_15m > 50.0
    rsi_3_15m_gt_55 = rsi_3_15m > 55.0
    rsi_3_1h_gt_3 = rsi_3_1h > 3.0
    rsi_3_1h_gt_5 = rsi_3_1h > 5.0
    rsi_3_1h_gt_10 = rsi_3_1h > 10.0
    rsi_3_1h_gt_15 = rsi_3_1h > 15.0
    rsi_3_1h_gt_20 = rsi_3_1h > 20.0
    rsi_3_1h_gt_25 = rsi_3_1h > 25.0
    rsi_3_1h_gt_30 = rsi_3_1h > 30.0
    rsi_3_1h_gt_35 = rsi_3_1h > 35.0
    rsi_3_1h_gt_40 = rsi_3_1h > 40.0
    rsi_3_1h_gt_45 = rsi_3_1h > 45.0
    rsi_3_1h_gt_50 = rsi_3_1h > 50.0
    rsi_3_1h_gt_55 = rsi_3_1h > 55.0
    rsi_3_1h_gt_60 = rsi_3_1h > 60.0
    rsi_3_1h_gt_65 = rsi_3_1h > 65.0
    rsi_3_4h_gt_3 = rsi_3_4h > 3.0
    rsi_3_4h_gt_5 = rsi_3_4h > 5.0
    rsi_3_4h_gt_10 = rsi_3_4h > 10.0
    rsi_3_4h_gt_15 = rsi_3_4h > 15.0
    rsi_3_4h_gt_20 = rsi_3_4h > 20.0
    rsi_3_4h_gt_25 = rsi_3_4h > 25.0
    rsi_3_4h_gt_30 = rsi_3_4h > 30.0
    rsi_3_4h_gt_35 = rsi_3_4h > 35.0
    rsi_3_4h_gt_40 = rsi_3_4h > 40.0
    rsi_3_4h_gt_45 = rsi_3_4h > 45.0
    rsi_3_4h_gt_50 = rsi_3_4h > 50.0
    rsi_3_4h_gt_55 = rsi_3_4h > 55.0
    rsi_3_4h_gt_60 = rsi_3_4h > 60.0
    rsi_3_4h_gt_65 = rsi_3_4h > 65.0
    rsi_3_1d_gt_3 = rsi_3_1d > 3.0
    rsi_3_1d_gt_5 = rsi_3_1d > 5.0
    rsi_3_1d_gt_10 = rsi_3_1d > 10.0
    rsi_3_1d_gt_15 = rsi_3_1d > 15.0
    rsi_3_1d_gt_20 = rsi_3_1d > 20.0
    rsi_3_1d_gt_25 = rsi_3_1d > 25.0
    rsi_3_1d_gt_30 = rsi_3_1d > 30.0
    rsi_3_1d_gt_35 = rsi_3_1d > 35.0
    rsi_3_1d_gt_40 = rsi_3_1d > 40.0
    rsi_3_1d_gt_45 = rsi_3_1d > 45.0
    rsi_3_1d_gt_50 = rsi_3_1d > 50.0
    rsi_3_1d_gt_55 = rsi_3_1d > 55.0
    rsi_3_1d_gt_60 = rsi_3_1d > 60.0
    rsi_3_1d_gt_65 = rsi_3_1d > 65.0
    rsi_3_lt_40 = rsi_3 < 40.0
    rsi_3_lt_46 = rsi_3 < 46.0
    rsi_3_lt_50 = rsi_3 < 50.0
    rsi_3_lt_90 = rsi_3 < 90.0
    rsi_3_lt_95 = rsi_3 < 95.0
    rsi_3_lt_97 = rsi_3 < 97.0
    rsi_3_lt_98 = rsi_3 < 98.0
    rsi_3_15m_lt_50 = rsi_3_15m < 50.0
    rsi_3_15m_lt_55 = rsi_3_15m < 55.0
    rsi_3_15m_lt_60 = rsi_3_15m < 60.0
    rsi_3_15m_lt_70 = rsi_3_15m < 70.0
    rsi_3_15m_lt_75 = rsi_3_15m < 75.0
    rsi_3_15m_lt_80 = rsi_3_15m < 80.0
    rsi_3_15m_lt_85 = rsi_3_15m < 85.0
    rsi_3_15m_lt_90 = rsi_3_15m < 90.0
    rsi_3_15m_lt_95 = rsi_3_15m < 95.0
    rsi_3_15m_lt_97 = rsi_3_15m < 97.0
    rsi_3_1h_lt_40 = rsi_3_1h < 40.0
    rsi_3_1h_lt_50 = rsi_3_1h < 50.0
    rsi_3_1h_lt_55 = rsi_3_1h < 55.0
    rsi_3_1h_lt_60 = rsi_3_1h < 60.0
    rsi_3_1h_lt_65 = rsi_3_1h < 65.0
    rsi_3_1h_lt_70 = rsi_3_1h < 70.0
    rsi_3_1h_lt_75 = rsi_3_1h < 75.0
    rsi_3_1h_lt_80 = rsi_3_1h < 80.0
    rsi_3_1h_lt_85 = rsi_3_1h < 85.0
    rsi_3_1h_lt_90 = rsi_3_1h < 90.0
    rsi_3_1h_lt_95 = rsi_3_1h < 95.0
    rsi_3_4h_lt_40 = rsi_3_4h < 40.0
    rsi_3_4h_lt_50 = rsi_3_4h < 50.0
    rsi_3_4h_lt_60 = rsi_3_4h < 60.0
    rsi_3_4h_lt_70 = rsi_3_4h < 70.0
    rsi_3_4h_lt_75 = rsi_3_4h < 75.0
    rsi_3_4h_lt_80 = rsi_3_4h < 80.0
    rsi_3_4h_lt_85 = rsi_3_4h < 85.0
    rsi_3_4h_lt_90 = rsi_3_4h < 90.0
    rsi_3_4h_lt_95 = rsi_3_4h < 95.0
    rsi_3_1d_lt_35 = rsi_3_1d < 35.0
    rsi_3_1d_lt_80 = rsi_3_1d < 80.0
    rsi_3_1d_lt_90 = rsi_3_1d < 90.0
    rsi_3_1d_lt_95 = rsi_3_1d < 95.0
    rsi_14_15m_lt_30 = rsi_14_15m < 30.0
    rsi_14_15m_lt_35 = rsi_14_15m < 35.0
    rsi_14_15m_lt_40 = rsi_14_15m < 40.0
    rsi_14_15m_lt_50 = rsi_14_15m < 50.0
    rsi_14_1h_gt_20 = rsi_14_1h > 20.0
    rsi_14_1h_gt_65 = rsi_14_1h > 65.0
    rsi_14_1h_lt_30 = rsi_14_1h < 30.0
    rsi_14_1h_lt_40 = rsi_14_1h < 40.0
    rsi_14_1h_lt_50 = rsi_14_1h < 50.0
    rsi_14_1h_lt_80 = rsi_14_1h < 80.0
    rsi_14_4h_gt_20 = rsi_14_4h > 20.0
    rsi_14_4h_gt_30 = rsi_14_4h > 30.0
    rsi_14_4h_gt_40 = rsi_14_4h > 40.0
    rsi_14_4h_gt_50 = rsi_14_4h > 50.0
    rsi_14_4h_gt_60 = rsi_14_4h > 60.0
    rsi_14_4h_gt_80 = rsi_14_4h > 80.0
    rsi_14_4h_lt_30 = rsi_14_4h < 30.0
    rsi_14_4h_lt_40 = rsi_14_4h < 40.0
    rsi_14_4h_lt_50 = rsi_14_4h < 50.0
    rsi_14_4h_lt_68 = rsi_14_4h < 68.0
    rsi_14_4h_lt_70 = rsi_14_4h < 70.0
    rsi_14_4h_lt_75 = rsi_14_4h < 75.0
    rsi_14_4h_lt_80 = rsi_14_4h < 80.0
    rsi_14_1d_gt_10 = rsi_14_1d > 10.0
    rsi_14_1d_gt_40 = rsi_14_1d > 40.0
    rsi_14_1d_gt_45 = rsi_14_1d > 45.0
    rsi_14_1d_gt_50 = rsi_14_1d > 50.0
    rsi_14_1d_gt_60 = rsi_14_1d > 60.0
    rsi_14_1d_lt_40 = rsi_14_1d < 40.0
    rsi_14_1d_lt_50 = rsi_14_1d < 50.0
    rsi_14_1d_lt_60 = rsi_14_1d < 60.0
    rsi_14_1d_lt_70 = rsi_14_1d < 70.0
    rsi_14_1d_lt_75 = rsi_14_1d < 75.0
    rsi_14_1d_lt_80 = rsi_14_1d < 80.0

    aroond_14_lt_25 = aroond_14 < 25.0
    aroond_14_gt_75 = aroond_14 > 75.0
    aroond_14_15m_lt_25 = aroond_14_15m < 25.0
    aroond_14_15m_lt_50 = aroond_14_15m < 50.0
    aroond_14_15m_lt_70 = aroond_14_15m < 70.0
    aroond_14_15m_lt_80 = aroond_14_15m < 80.0
    aroond_14_1h_lt_25 = aroond_14_1h < 25.0
    aroond_14_1h_lt_50 = aroond_14_1h < 50.0
    aroond_14_1h_lt_70 = aroond_14_1h < 70.0
    aroond_14_4h_lt_25 = aroond_14_4h < 25.0
    aroond_14_4h_lt_40 = aroond_14_4h < 40.0
    aroond_14_4h_lt_50 = aroond_14_4h < 50.0
    aroond_14_4h_lt_70 = aroond_14_4h < 70.0
    aroond_14_4h_lt_80 = aroond_14_4h < 80.0
    aroond_14_4h_lt_85 = aroond_14_4h < 85.0
    aroonu_14_gt_75 = aroonu_14 > 75.0
    aroonu_14_15m_gt_0 = aroonu_14_15m > 0.0
    aroonu_14_15m_gt_10 = aroonu_14_15m > 10.0
    aroonu_14_15m_gt_20 = aroonu_14_15m > 20.0
    aroonu_14_15m_gt_30 = aroonu_14_15m > 30.0
    aroonu_14_15m_gt_40 = aroonu_14_15m > 40.0
    aroonu_14_15m_gt_50 = aroonu_14_15m > 50.0
    aroonu_14_15m_gt_60 = aroonu_14_15m > 60.0
    aroonu_14_1h_gt_0 = aroonu_14_1h > 0.0
    aroonu_14_1h_gt_10 = aroonu_14_1h > 10.0
    aroonu_14_1h_gt_20 = aroonu_14_1h > 20.0
    aroonu_14_1h_gt_30 = aroonu_14_1h > 30.0
    aroonu_14_1h_gt_40 = aroonu_14_1h > 40.0
    aroonu_14_1h_gt_60 = aroonu_14_1h > 60.0
    aroonu_14_4h_gt_0 = aroonu_14_4h > 0.0
    aroonu_14_4h_gt_10 = aroonu_14_4h > 10.0
    aroonu_14_4h_gt_20 = aroonu_14_4h > 20.0
    aroonu_14_4h_gt_30 = aroonu_14_4h > 30.0
    aroonu_14_4h_gt_50 = aroonu_14_4h > 50.0
    aroonu_14_4h_gt_70 = aroonu_14_4h > 70.0
    aroonu_14_4h_gt_80 = aroonu_14_4h > 80.0
    aroonu_14_1d_gt_0 = aroonu_14_1d > 0.0
    aroonu_14_1d_gt_10 = aroonu_14_1d > 10.0
    aroonu_14_1d_gt_20 = aroonu_14_1d > 20.0
    aroonu_14_1d_gt_30 = aroonu_14_1d > 30.0
    aroonu_14_1d_gt_50 = aroonu_14_1d > 50.0
    aroonu_14_lt_25 = aroonu_14 < 25.0
    aroonu_14_lt_30 = aroonu_14 < 30.0
    aroonu_14_15m_lt_20 = aroonu_14_15m < 20.0
    aroonu_14_15m_lt_25 = aroonu_14_15m < 25.0
    aroonu_14_15m_lt_30 = aroonu_14_15m < 30.0
    aroonu_14_15m_lt_40 = aroonu_14_15m < 40.0
    aroonu_14_15m_lt_50 = aroonu_14_15m < 50.0
    aroonu_14_15m_lt_60 = aroonu_14_15m < 60.0
    aroonu_14_15m_lt_70 = aroonu_14_15m < 70.0
    aroonu_14_15m_lt_75 = aroonu_14_15m < 75.0
    aroonu_14_15m_lt_80 = aroonu_14_15m < 80.0
    aroonu_14_15m_lt_85 = aroonu_14_15m < 85.0
    aroonu_14_15m_lt_90 = aroonu_14_15m < 90.0
    aroonu_14_15m_lt_100 = aroonu_14_15m < 100.0
    aroonu_14_1h_lt_20 = aroonu_14_1h < 20.0
    aroonu_14_1h_lt_25 = aroonu_14_1h < 25.0
    aroonu_14_1h_lt_30 = aroonu_14_1h < 30.0
    aroonu_14_1h_lt_40 = aroonu_14_1h < 40.0
    aroonu_14_1h_lt_50 = aroonu_14_1h < 50.0
    aroonu_14_1h_lt_60 = aroonu_14_1h < 60.0
    aroonu_14_1h_lt_70 = aroonu_14_1h < 70.0
    aroonu_14_1h_lt_75 = aroonu_14_1h < 75.0
    aroonu_14_1h_lt_80 = aroonu_14_1h < 80.0
    aroonu_14_1h_lt_85 = aroonu_14_1h < 85.0
    aroonu_14_1h_lt_90 = aroonu_14_1h < 90.0
    aroonu_14_1h_lt_100 = aroonu_14_1h < 100.0
    aroonu_14_4h_lt_20 = aroonu_14_4h < 20.0
    aroonu_14_4h_lt_30 = aroonu_14_4h < 30.0
    aroonu_14_4h_lt_40 = aroonu_14_4h < 40.0
    aroonu_14_4h_lt_50 = aroonu_14_4h < 50.0
    aroonu_14_4h_lt_60 = aroonu_14_4h < 60.0
    aroonu_14_4h_lt_70 = aroonu_14_4h < 70.0
    aroonu_14_4h_lt_75 = aroonu_14_4h < 75.0
    aroonu_14_4h_lt_80 = aroonu_14_4h < 80.0
    aroonu_14_4h_lt_85 = aroonu_14_4h < 85.0
    aroonu_14_4h_lt_90 = aroonu_14_4h < 90.0
    aroonu_14_4h_lt_100 = aroonu_14_4h < 100.0
    aroonu_14_1d_lt_30 = aroonu_14_1d < 30.0
    aroonu_14_1d_lt_40 = aroonu_14_1d < 40.0
    aroonu_14_1d_lt_50 = aroonu_14_1d < 50.0
    aroonu_14_1d_lt_60 = aroonu_14_1d < 60.0
    aroonu_14_1d_lt_70 = aroonu_14_1d < 70.0
    aroonu_14_1d_lt_75 = aroonu_14_1d < 75.0
    aroonu_14_1d_lt_80 = aroonu_14_1d < 80.0
    aroonu_14_1d_lt_85 = aroonu_14_1d < 85.0
    aroonu_14_1d_lt_90 = aroonu_14_1d < 90.0
    aroonu_14_1d_lt_100 = aroonu_14_1d < 100.0

    cmf_20_15m_gt_neg_0_10 = cmf_20_15m > -0.10
    cmf_20_15m_gt_neg_0_20 = cmf_20_15m > -0.20
    cmf_20_15m_gt_neg_0_30 = cmf_20_15m > -0.30
    cmf_20_15m_gt_neg_0_35 = cmf_20_15m > -0.35
    cmf_20_15m_gt_neg_0_40 = cmf_20_15m > -0.40
    cmf_20_15m_gt_neg_0_50 = cmf_20_15m > -0.50
    cmf_20_15m_lt_0_10 = cmf_20_15m < 0.10
    cmf_20_15m_lt_0_20 = cmf_20_15m < 0.20
    cmf_20_15m_lt_0_30 = cmf_20_15m < 0.30
    cmf_20_1h_gt_neg_0_10 = cmf_20_1h > -0.10
    cmf_20_1h_gt_neg_0_20 = cmf_20_1h > -0.20
    cmf_20_1h_gt_neg_0_25 = cmf_20_1h > -0.25
    cmf_20_1h_gt_neg_0_30 = cmf_20_1h > -0.30
    cmf_20_1h_gt_neg_0_40 = cmf_20_1h > -0.40
    cmf_20_1h_lt_0_10 = cmf_20_1h < 0.10
    cmf_20_1h_lt_0_20 = cmf_20_1h < 0.20
    cmf_20_1h_lt_0_30 = cmf_20_1h < 0.30
    cmf_20_4h_gt_neg_0_0 = cmf_20_4h > -0.0
    cmf_20_4h_gt_neg_0_10 = cmf_20_4h > -0.10
    cmf_20_4h_gt_neg_0_20 = cmf_20_4h > -0.20
    cmf_20_4h_gt_neg_0_25 = cmf_20_4h > -0.25
    cmf_20_4h_gt_neg_0_30 = cmf_20_4h > -0.30
    cmf_20_4h_gt_neg_0_35 = cmf_20_4h > -0.35
    cmf_20_4h_gt_neg_0_40 = cmf_20_4h > -0.40
    cmf_20_4h_gt_neg_0_50 = cmf_20_4h > -0.50
    cmf_20_4h_lt_0_15 = cmf_20_4h < 0.15
    cmf_20_1d_gt_neg_0_0 = cmf_20_1d > -0.0
    cmf_20_1d_gt_neg_0_10 = cmf_20_1d > -0.10
    cmf_20_1d_gt_neg_0_20 = cmf_20_1d > -0.20
    cmf_20_1d_gt_neg_0_25 = cmf_20_1d > -0.25
    cmf_20_1d_gt_neg_0_30 = cmf_20_1d > -0.30
    cmf_20_1d_gt_neg_0_40 = cmf_20_1d > -0.40
    cmf_20_1d_gt_neg_0_50 = cmf_20_1d > -0.50
    cmf_20_1d_lt_0_10 = cmf_20_1d < 0.10

    stochrsi_k_lt_20 = stochrsi_k < 20.0
    stochrsi_k_lt_30 = stochrsi_k < 30.0
    stochrsi_k_gt_80 = stochrsi_k > 80.0
    stochrsi_k_15m_gt_10 = stochrsi_k_15m > 10.0
    stochrsi_k_15m_gt_20 = stochrsi_k_15m > 20.0
    stochrsi_k_15m_gt_30 = stochrsi_k_15m > 30.0
    stochrsi_k_15m_gt_40 = stochrsi_k_15m > 40.0
    stochrsi_k_15m_gt_50 = stochrsi_k_15m > 50.0
    stochrsi_k_15m_gt_60 = stochrsi_k_15m > 60.0
    stochrsi_k_15m_gt_70 = stochrsi_k_15m > 70.0
    stochrsi_k_15m_gt_80 = stochrsi_k_15m > 80.0
    stochrsi_k_15m_gt_90 = stochrsi_k_15m > 90.0
    stochrsi_k_4h_gt_10 = stochrsi_k_4h > 10.0
    stochrsi_k_4h_gt_20 = stochrsi_k_4h > 20.0
    stochrsi_k_4h_gt_30 = stochrsi_k_4h > 30.0
    stochrsi_k_4h_gt_40 = stochrsi_k_4h > 40.0
    stochrsi_k_4h_gt_50 = stochrsi_k_4h > 50.0
    stochrsi_k_4h_gt_60 = stochrsi_k_4h > 60.0
    stochrsi_k_4h_gt_70 = stochrsi_k_4h > 70.0
    stochrsi_k_4h_gt_75 = stochrsi_k_4h > 75.0
    stochrsi_k_4h_gt_80 = stochrsi_k_4h > 80.0
    stochrsi_k_4h_gt_90 = stochrsi_k_4h > 90.0
    stochrsi_k_15m_lt_20 = stochrsi_k_15m < 20.0
    stochrsi_k_15m_lt_30 = stochrsi_k_15m < 30.0
    stochrsi_k_15m_lt_40 = stochrsi_k_15m < 40.0
    stochrsi_k_15m_lt_50 = stochrsi_k_15m < 50.0
    stochrsi_k_15m_lt_60 = stochrsi_k_15m < 60.0
    stochrsi_k_15m_lt_70 = stochrsi_k_15m < 70.0
    stochrsi_k_15m_lt_80 = stochrsi_k_15m < 80.0
    stochrsi_k_1h_gt_10 = stochrsi_k_1h > 10.0
    stochrsi_k_1h_gt_20 = stochrsi_k_1h > 20.0
    stochrsi_k_1h_gt_30 = stochrsi_k_1h > 30.0
    stochrsi_k_1h_gt_40 = stochrsi_k_1h > 40.0
    stochrsi_k_1h_gt_50 = stochrsi_k_1h > 50.0
    stochrsi_k_1h_gt_60 = stochrsi_k_1h > 60.0
    stochrsi_k_1h_gt_70 = stochrsi_k_1h > 70.0
    stochrsi_k_1h_gt_75 = stochrsi_k_1h > 75.0
    stochrsi_k_1h_gt_80 = stochrsi_k_1h > 80.0
    stochrsi_k_1h_gt_90 = stochrsi_k_1h > 90.0
    stochrsi_k_1h_lt_20 = stochrsi_k_1h < 20.0
    stochrsi_k_1h_lt_30 = stochrsi_k_1h < 30.0
    stochrsi_k_1h_lt_40 = stochrsi_k_1h < 40.0
    stochrsi_k_1h_lt_50 = stochrsi_k_1h < 50.0
    stochrsi_k_1h_lt_60 = stochrsi_k_1h < 60.0
    stochrsi_k_1h_lt_70 = stochrsi_k_1h < 70.0
    stochrsi_k_1h_lt_80 = stochrsi_k_1h < 80.0
    stochrsi_k_1h_lt_90 = stochrsi_k_1h < 90.0
    stochrsi_k_4h_lt_10 = stochrsi_k_4h < 10.0
    stochrsi_k_4h_lt_20 = stochrsi_k_4h < 20.0
    stochrsi_k_4h_lt_30 = stochrsi_k_4h < 30.0
    stochrsi_k_4h_lt_40 = stochrsi_k_4h < 40.0
    stochrsi_k_4h_lt_50 = stochrsi_k_4h < 50.0
    stochrsi_k_4h_lt_60 = stochrsi_k_4h < 60.0
    stochrsi_k_4h_lt_70 = stochrsi_k_4h < 70.0
    stochrsi_k_4h_lt_80 = stochrsi_k_4h < 80.0
    stochrsi_k_4h_lt_90 = stochrsi_k_4h < 90.0
    stochrsi_k_1d_gt_10 = stochrsi_k_1d > 10.0
    stochrsi_k_1d_gt_20 = stochrsi_k_1d > 20.0
    stochrsi_k_1d_gt_30 = stochrsi_k_1d > 30.0
    stochrsi_k_1d_gt_40 = stochrsi_k_1d > 40.0
    stochrsi_k_1d_gt_50 = stochrsi_k_1d > 50.0
    stochrsi_k_1d_gt_60 = stochrsi_k_1d > 60.0
    stochrsi_k_1d_gt_70 = stochrsi_k_1d > 70.0
    stochrsi_k_1d_lt_20 = stochrsi_k_1d < 20.0
    stochrsi_k_1d_lt_30 = stochrsi_k_1d < 30.0
    stochrsi_k_1d_lt_40 = stochrsi_k_1d < 40.0
    stochrsi_k_1d_lt_50 = stochrsi_k_1d < 50.0
    stochrsi_k_1d_lt_60 = stochrsi_k_1d < 60.0
    stochrsi_k_1d_lt_70 = stochrsi_k_1d < 70.0
    stochrsi_k_1d_lt_80 = stochrsi_k_1d < 80.0
    stochrsi_k_1d_lt_90 = stochrsi_k_1d < 90.0

    roc_9_1h_lt_10 = roc_9_1h < 10.0
    roc_9_1h_gt_neg_50 = roc_9_1h > -50.0
    roc_9_1h_gt_neg_40 = roc_9_1h > -40.0
    roc_9_1h_gt_neg_30 = roc_9_1h > -30.0
    roc_9_1h_gt_neg_25 = roc_9_1h > -25.0
    roc_9_1h_gt_neg_20 = roc_9_1h > -20.0
    roc_9_1h_gt_neg_15 = roc_9_1h > -15.0
    roc_9_1h_gt_neg_10 = roc_9_1h > -10.0
    roc_9_1h_lt_15 = roc_9_1h < 15.0
    roc_9_1h_lt_20 = roc_9_1h < 20.0
    roc_9_1h_lt_25 = roc_9_1h < 25.0
    roc_9_1h_lt_30 = roc_9_1h < 30.0
    roc_9_1h_lt_40 = roc_9_1h < 40.0
    roc_9_1h_lt_50 = roc_9_1h < 50.0
    roc_9_1h_lt_60 = roc_9_1h < 60.0
    roc_9_1h_lt_80 = roc_9_1h < 80.0
    roc_9_1h_lt_100 = roc_9_1h < 100.0
    roc_9_4h_gt_neg_30 = roc_9_4h > -30.0
    roc_9_4h_gt_neg_70 = roc_9_4h > -70.0
    roc_9_4h_gt_neg_50 = roc_9_4h > -50.0
    roc_9_4h_gt_neg_40 = roc_9_4h > -40.0
    roc_9_4h_gt_neg_35 = roc_9_4h > -35.0
    roc_9_4h_gt_neg_25 = roc_9_4h > -25.0
    roc_9_4h_gt_neg_15 = roc_9_4h > -15.0
    roc_9_4h_gt_neg_10 = roc_9_4h > -10.0
    roc_9_4h_gt_neg_20 = roc_9_4h > -20.0
    roc_9_4h_lt_5 = roc_9_4h < 5.0
    roc_9_4h_lt_10 = roc_9_4h < 10.0
    roc_9_4h_lt_15 = roc_9_4h < 15.0
    roc_9_4h_lt_20 = roc_9_4h < 20.0
    roc_9_4h_lt_25 = roc_9_4h < 25.0
    roc_9_4h_lt_30 = roc_9_4h < 30.0
    roc_9_4h_lt_40 = roc_9_4h < 40.0
    roc_9_4h_lt_50 = roc_9_4h < 50.0
    roc_9_4h_lt_60 = roc_9_4h < 60.0
    roc_9_4h_lt_70 = roc_9_4h < 70.0
    roc_9_4h_lt_80 = roc_9_4h < 80.0
    roc_9_4h_lt_100 = roc_9_4h < 100.0
    roc_9_1d_gt_neg_50 = roc_9_1d > -50.0
    roc_9_1d_gt_neg_100 = roc_9_1d > -100.0
    roc_9_1d_gt_neg_80 = roc_9_1d > -80.0
    roc_9_1d_gt_neg_70 = roc_9_1d > -70.0
    roc_9_1d_gt_neg_60 = roc_9_1d > -60.0
    roc_9_1d_gt_neg_25 = roc_9_1d > -25.0
    roc_9_1d_gt_neg_15 = roc_9_1d > -15.0
    roc_9_1d_gt_neg_10 = roc_9_1d > -10.0
    roc_9_1d_gt_neg_40 = roc_9_1d > -40.0
    roc_9_1d_gt_neg_30 = roc_9_1d > -30.0
    roc_9_1d_gt_neg_20 = roc_9_1d > -20.0
    roc_9_1d_gt_0 = roc_9_1d > 0.0
    roc_9_1d_gt_25 = roc_9_1d > 25.0
    roc_9_1d_gt_30 = roc_9_1d > 30.0
    roc_9_1d_lt_0 = roc_9_1d < 0.0
    roc_9_1d_lt_10 = roc_9_1d < 10.0
    roc_9_1d_lt_15 = roc_9_1d < 15.0
    roc_9_1d_lt_20 = roc_9_1d < 20.0
    roc_9_1d_lt_25 = roc_9_1d < 25.0
    roc_9_1d_lt_30 = roc_9_1d < 30.0
    roc_9_1d_lt_35 = roc_9_1d < 35.0
    roc_9_1d_lt_40 = roc_9_1d < 40.0
    roc_9_1d_lt_50 = roc_9_1d < 50.0
    roc_9_1d_lt_60 = roc_9_1d < 60.0
    roc_9_1d_lt_70 = roc_9_1d < 70.0
    roc_9_1d_lt_80 = roc_9_1d < 80.0
    roc_9_1d_lt_100 = roc_9_1d < 100.0
    roc_9_1d_lt_150 = roc_9_1d < 150.0
    roc_9_1d_lt_200 = roc_9_1d < 200.0
    cci_20_change_pct_1h_gt_neg_0 = cci_20_change_pct_1h > -0.0
    cci_20_change_pct_1h_lt_neg_0 = cci_20_change_pct_1h < -0.0
    cci_20_change_pct_1h_lt_0 = cci_20_change_pct_1h < 0.0
    cci_20_change_pct_4h_lt_neg_0 = cci_20_change_pct_4h < -0.0
    cci_20_change_pct_4h_lt_0 = cci_20_change_pct_4h < 0.0
    change_pct_1d_gt_neg_50 = change_pct_1d > -50.0
    change_pct_1d_gt_neg_30 = change_pct_1d > -30.0
    change_pct_1d_gt_neg_20 = change_pct_1d > -20.0
    change_pct_1d_gt_neg_15 = change_pct_1d > -15.0
    change_pct_1d_gt_neg_10 = change_pct_1d > -10.0
    change_pct_1d_gt_neg_5 = change_pct_1d > -5.0
    change_pct_1d_lt_10 = change_pct_1d < 10.0
    change_pct_1d_lt_15 = change_pct_1d < 15.0
    change_pct_1d_lt_25 = change_pct_1d < 25.0
    change_pct_1d_lt_30 = change_pct_1d < 30.0
    change_pct_1d_lt_40 = change_pct_1d < 40.0
    change_pct_1d_lt_50 = change_pct_1d < 50.0
    top_wick_pct_1d_lt_8 = top_wick_pct_1d < 8.0
    top_wick_pct_1d_lt_10 = top_wick_pct_1d < 10.0
    top_wick_pct_1d_lt_15 = top_wick_pct_1d < 15.0
    top_wick_pct_1d_lt_20 = top_wick_pct_1d < 20.0
    top_wick_pct_1d_lt_25 = top_wick_pct_1d < 25.0
    top_wick_pct_1d_lt_30 = top_wick_pct_1d < 30.0
    top_wick_pct_1d_lt_50 = top_wick_pct_1d < 50.0
    # comparison masks used only by the breakout family (65)
    bbb_20_2_0_1h_gt_20 = bbb_20_2_0_1h > 20.0
    obv_change_pct_15m_lt_50 = obv_change_pct_15m < 50.0
    roc_9_15m_lt_20 = roc_9_15m < 20.0
    rsi_14_change_pct_gt_0 = rsi_14_change_pct > 0.0
    rsi_3_change_pct_1d_gt_neg_20 = rsi_3_change_pct_1d > -20.0

    is_backtest = self.dp.runmode.value in ["backtest", "hyperopt", "plot", "webserver"]
    # the number of free slots
    current_free_slots = config["max_open_trades"]
    if not is_backtest:
      current_free_slots = config["max_open_trades"] - Trade.get_open_trade_count()
    # Grind mode
    pair_coin = metadata["pair"].partition("/")[0]
    num_open_long_grind_mode = 0
    is_pair_long_grind_mode = pair_coin in self.grind_mode_coins
    if not is_backtest:
      open_trades = Trade.get_trades_proxy(is_open=True)
      for open_trade in open_trades:
        enter_tag = open_trade.enter_tag
        if enter_tag is not None:
          enter_tags = enter_tag.split()
          if all(c in self.long_grind_mode_tags for c in enter_tags):
            num_open_long_grind_mode += 1
    # Top Coins mode
    is_pair_long_top_coins_mode = pair_coin in top_coins_mode_coins
    is_pair_short_top_coins_mode = pair_coin in top_coins_mode_coins
    # if BTC/ETH stake
    is_btc_stake = config["stake_currency"] in self.btc_stakes
    allowed_empty_candles_288 = 144 if is_btc_stake else 60

    ###############################################################################################

    # LONG ENTRY CONDITIONS STARTS HERE

    ###############################################################################################

    #
    #  /$$       /$$$$$$ /$$   /$$ /$$$$$$        /$$$$$$$$/$$   /$$/$$$$$$$$/$$$$$$$$/$$$$$$$
    # | $$      /$$__  $| $$$ | $$/$$__  $$      | $$_____| $$$ | $|__  $$__| $$_____| $$__  $$
    # | $$     | $$  \ $| $$$$| $| $$  \__/      | $$     | $$$$| $$  | $$  | $$     | $$  \ $$
    # | $$     | $$  | $| $$ $$ $| $$ /$$$$      | $$$$$  | $$ $$ $$  | $$  | $$$$$  | $$$$$$$/
    # | $$     | $$  | $| $$  $$$| $$|_  $$      | $$__/  | $$  $$$$  | $$  | $$__/  | $$__  $$
    # | $$     | $$  | $| $$\  $$| $$  \ $$      | $$     | $$\  $$$  | $$  | $$     | $$  \ $$
    # | $$$$$$$|  $$$$$$| $$ \  $|  $$$$$$/      | $$$$$$$| $$ \  $$  | $$  | $$$$$$$| $$  | $$
    # |________/\______/|__/  \__/\______/       |________|__/  \__/  |__/  |________|__/  |__/
    #

    for enabled_long_entry_signal in long_entry_signal_params:
      long_entry_condition_index = int(enabled_long_entry_signal.rsplit("_", 2)[1])
      if long_entry_signal_params[enabled_long_entry_signal]:
        # Long Entry Conditions Starts Here
        # -----------------------------------------------------------------------------------------
        long_entry_logic = []
        long_entry_logic.append(True)

        # Condition #1 - Normal mode (Long).
        if long_entry_condition_index == 1:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 15m & 1h down move
            ((rsi_3_gt_3) | (rsi_3_15m_gt_3) | (rsi_3_change_pct_1h > -50.0))
            # 5m & 15m & 1h down move, 1d high & overbought
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 5m & 15m down move, 5h high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_5) | (rsi_14_4h < 60.0))
            # 5m & 15m down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_10) | aroonu_14_4h_lt_100)
            # 5m & 1h down move
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_5))
            # 5m & 1h down move, 15m still not low enough
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_15m_lt_30))
            # 5m & 1h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1d still high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_3) | (stochrsi_k_1d_lt_50))
            # 5m & 1h down move, 15m still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_15m_lt_30))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_25) | aroonu_14_4h_lt_70)
            # 5m down move, 15m high
            & ((rsi_3_gt_3) | (aroonu_14_15m_lt_80))
            # 5m down move, 1h high, 4h overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 5m & 1h & 4h down move, 4h high
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_80))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h downtrend, 1h high
            & ((rsi_3_15m > 1.0) | (cmf_20_1h_gt_neg_0_10) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h down move 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_15))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 1h & 4h & 1d down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15))
            # 15m & 1h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_50))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_70))
            # 15m & 1h & 1d down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_30) | (roc_9_1d_gt_neg_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m downtrend
            & ((rsi_3_15m_gt_3) | (cmf_20_15m_gt_neg_0_40) | (roc_9_15m > -20.0))
            # 15m down move, 15m still high, 15m downtrend
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_40) | (roc_9_15m > -20.0))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_90))
            # 15m down move, 4h high, 15m downtrend
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_70) | (roc_9_15m > -20.0))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_85) | (roc_9_1d_lt_100))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1h_lt_90) | (roc_9_4h_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 15m down move, drop in last half hour, 15m downtrend
            & ((rsi_3_15m_gt_3) | (close > (close_max_6 * 0.75)) | (roc_9_15m > -20.0))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h & 1d down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_70))
            # 5m & 1h down move, 1h overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_60) | (roc_9_1h_lt_40))
            # 15m & 4h down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_1d_lt_40))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_60))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_50))
            # 15m & 1d down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m still high, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 15m & 4h still high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_60))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_80))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_80))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_70))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (roc_9_1d_gt_neg_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_14_4h_lt_80))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (roc_9_4h_lt_80))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_55) | (rsi_3_4h_gt_55) | (stochrsi_k_1h_lt_90))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1h_lt_75))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_30))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_85))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_50) | (stochrsi_k_1d_lt_80))
            # 15m & 1d down move, 1h & 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_100))
            # 15m down move & downtrend, 4h high
            & ((rsi_3_15m_gt_10) | (cmf_20_15m_gt_neg_0_30) | (aroonu_14_4h_lt_100))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_20))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_40))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_80))
            # 15m down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_25))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_70) | roc_9_1d_gt_neg_50)
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_20))
            # 15m down move, 1h & 1d overbought
            & ((rsi_3_15m_gt_10) | (roc_9_1h_lt_10) | (roc_9_1d_lt_80))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_10) | (roc_9_4h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_80))
            # 15m down move, 15m still high, 4h overbought
            & ((rsi_3_15m_gt_15) | (rsi_14_15m_lt_50) | (roc_9_4h_lt_50))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_90))
            # 15m & 1h & 4h & 1d down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_65) | (aroonu_14_4h_lt_80))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_15m_lt_40))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 1d overbought
            & ((rsi_3_15m_gt_30) | (roc_9_1d_lt_80))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_10))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_100))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (cmf_20_1h_gt_neg_0_30))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_50) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_5) | rsi_3_4h_gt_20 | (roc_9_1d_lt_40))
            # 1h & 1d down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_5) | (roc_9_1d_gt_neg_30))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_15m_lt_30))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50))
            # 1h & 4h & 1d down move, 4h downtrend, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (rsi_14_4h_gt_30) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 1h & 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_4h_lt_80))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_14_4h_lt_75))
            # 1h down move, 15m downtrend, 1d high
            & ((rsi_3_1h_gt_10) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 4h overbought
            & ((rsi_3_1h_gt_10) | (roc_9_4h_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_50))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 1h & 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70) | roc_9_1d_lt_50)
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_80))
            # 1h down mve, 4h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 1h down move, 1h & 4h downtrend
            & ((rsi_3_1h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 4h overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (roc_9_4h_lt_80))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_200))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_60))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_50))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 1h still high, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_55) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_40))
            # 1h down move, 1h high, 15n downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (roc_9_15m > -20.0))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_4h_lt_80) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_80))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_35) | (roc_9_4h_lt_40) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_50))
            # 1h down move, 1h downtrend, 1h high
            & ((rsi_3_1h_gt_40) | (cmf_20_1h_gt_neg_0_25) | (aroonu_14_1h_lt_90))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 15m downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_15m > -15.0))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_100))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_20))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_50) | (rsi_14_4h < 90.0))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_40))
            # 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_4h_lt_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_100))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_20) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d high & overbought
            & (rsi_3_4h_gt_20 | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_50))
            # 4h down move, 1d overbought
            & ((rsi_3_4h_gt_45) | (roc_9_1d_lt_80))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_60))
            # 1d down move, 1h high, 4h & 1d downtrend
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_50))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h still high, 4h high
            & ((rsi_3_1d_gt_20) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_25) | aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90))
            # 1d down move, 1d high
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80))
            # 1d down move, 4h still high, 1d overbought
            & ((rsi_3_1d_gt_50) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_200))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_60) | (aroonu_14_1d_lt_80) | roc_9_1d_lt_50)
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_change_pct_1h > -75.0) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h downtrend
            & ((cmf_20_15m_gt_neg_0_30) | (cmf_20_1h_gt_neg_0_30) | (cmf_20_4h_gt_neg_0_30))
            # 15m high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (roc_9_1d_lt_80))
            # 1h still high, 1h & 4h downtrend
            & ((aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_30))
            # 1h & 4h high & overbought
            & ((aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_20))
            # 1h high, 1h & 4h overbought
            & ((aroonu_14_1h_lt_85) | (roc_9_1h_lt_10) | (roc_9_1d_lt_30))
            # 1h high, 1h overbought, 1d downtrend
            & ((aroonu_14_1h_lt_85) | (roc_9_1h_lt_20) | (roc_9_1d_gt_neg_40))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 4h high, 1h downtrend
            & ((aroonu_14_4h_lt_80) | (roc_9_1h_gt_neg_15))
            # 4h high & 1h & 4h overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_1h_lt_40) | (roc_9_4h_lt_80))
            # 4h high, 1d downtrend
            & ((aroonu_14_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1d high, 4h downtrend, 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_25) | (roc_9_1d_lt_50))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_90) | (roc_9_1h_gt_neg_10) | (roc_9_4h_gt_neg_20))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_lt_40) | (roc_9_1d_lt_80))
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h high, 1h downtrend
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_gt_neg_15))
            # 4h high, 1d downtrend
            & ((stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_40))
            # 4h high & 1h & 4h overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_40) | (roc_9_4h_lt_80))
            # 5m down move, 15m still not low enough, 1h high
            & ((roc_2 > -10.0) | (aroonu_14_15m_lt_30) | aroonu_14_1h_lt_80)
            # 5m down move, 15m still high
            & ((roc_2 > -10.0) | (aroonu_14_15m_lt_50))
            # 5m down move, 15m & 1h down move, 15m still high
            & ((roc_9 > -15.0) | (rsi_3_15m_gt_5) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_50))
            # 5m down move, 4h down move, 15m downtrend, 1h high
            & ((roc_9 > -15.0) | (rsi_3_4h_gt_45) | (cmf_20_15m_gt_neg_0_30) | (aroonu_14_1h_lt_60))
            # 1h downtrend, 4h high & overbought
            & ((roc_9_1h_gt_neg_25) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_80))
            # 1h & 4h overbought, 1d downtrend
            & ((roc_9_1h_lt_20) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_40))
            # 1d P&D, 1d downtrend
            & ((change_pct_1d_gt_neg_5) | (change_pct_1d_shift_288 < 30.0) | (cmf_20_1d_gt_neg_0_0))
            # 1d green with top wick, 1h down move
            & ((change_pct_1d < 20.0) | (top_wick_pct_1d_lt_15) | rsi_3_1h_gt_20)
            # 1d green with top wick, 4h high
            & ((change_pct_1d_lt_25) | (top_wick_pct_1d_lt_25) | aroonu_14_4h_lt_80)
            # 1d green, 1h down move, 1d downtrend
            & ((change_pct_1d_lt_40) | (rsi_3_1h_gt_25) | (cmf_20_1d_gt_neg_0_20))
            # 1d green with top wick, 4h overbought
            & ((change_pct_1d_lt_50) | (top_wick_pct_1d_lt_30) | (roc_9_4h_lt_80))
            # 1d top wick, 1h & 4h down move, 1d high
            & ((top_wick_pct_1d_lt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100))
            # big drop in the last hour, 15m downtrend
            & ((close > (close_max_12 * 0.65)) | (cmf_20_15m_gt_neg_0_50))
            # big drop in the last 6 hours, 1h down move, 1h high
            & ((close > (high_max_6_1h * 0.60)) | rsi_3_1h_gt_20 | (aroonu_14_1h_lt_60))
            # big drop in the last 24 hours,  1h still high
            & ((close > (high_max_24_1h * 0.40)) | (stochrsi_k_1h < 45.0))
            # big drop in the last 4 days, 1h high
            & ((close > (high_max_24_4h * 0.20)) | aroonu_14_1h_lt_70)
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # the daily low is not fresh at all, the hour has stopped falling, the 15m oscillator
            # is up and the hourly one is below mid-band: a market turning, not breaking
            & ((aroond_14_1d > 0.0) | (roc_2_1h > -2.5) | (uo_7_14_28_15m > 42.0) | (uo_7_14_28_1h < 46.0))
            # the daily low is recent, 4h money flow clearly negative, the base money flow already
            # at zero and a squeeze behind it: the sell-off is finished and coiling
            & ((aroond_14_1d > 50.0) | (cmf_20_4h < -0.1) | (mfi_14 > 5.0) | (sqz_cnt_24 > 4.0))
            # daily money flow rich, the base RSI already low, the daily RSI_3 snapping up and the
            # hourly stochastic off its floor: nothing left underneath on any timeframe
            & ((mfi_14_1d < 60.0) | (rsi_14 < 28.0) | (rsi_3_change_pct_1d < 50.0) | (stochk_14_3_3_1h > 15.0))
            # daily money flow negative while the base RSI is dropping, the 15m is not selling and
            # the hour is red: the day is already priced in (4 losses, free in all three years)
            & (
              (cmf_20_1d < -0.05)
              | (rsi_14_change_pct < -10.0)
              | (rsi_3_change_pct_15m > -70.0)
              | (change_pct_1h < -1.0)
            )
            # the daily RSI is not strong, the 15m RSI_3 is not washed, the hourly oscillator is
            # below mid-band and the hour is flat: a quiet market with no leg to sell (3 losses)
            & ((rsi_14_1d < 55.0) | (rsi_3_15m > 15.0) | (uo_7_14_28_1h < 46.0) | (change_pct_1h > -2.0))
            # daily money flow rich, the hour barely down, the 4h nowhere near its low and the day
            # up more than 2%: shorting strength on every timeframe at once (3 losses)
            & ((mfi_14_1d < 60.0) | (roc_9_1h > -2.0) | (willr_14_4h < -40.0) | (change_pct_1d > 2.0))
            # no daily high behind it, base money flow drained, a loose pre-break base and the 15m
            # no longer falling: a tired market, not a breaking one (4 losses, all in 2022)
            & ((aroonu_14_1d > 0.0) | (mfi_14 > 15.0) | (ph_pre_tight > 1.0) | (roc_9_15m > -1.0))
            # no daily high, the daily RSI_3 is washed, hourly RSI_3 snapping up and the 15m
            # oscillator off its floor: the daily leg is finished (4 losses)
            & ((aroonu_14_1d > 0.0) | (rsi_3_1d > 40.0) | (rsi_3_change_pct_1h < -20.0) | (stochrsi_k_15m > 10.0))
          )

          # Logic
          long_entry_logic.append(
            (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.034))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
            & (close < (bbl_20_2_0 * 0.999))
          )

        # Condition #2 - Normal mode (Long).
        if long_entry_condition_index == 2:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1h down move, 1h still not low enough
            ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100))
            # 5m & 1h down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_35) | (aroonu_14_1d_lt_100))
            # 5m & 4h down move, 15m still not low enough
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_30))
            # 5m & 4h down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_30))
            # 5m & 4h & 1d down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50))
            # 5m & 1d down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_10) | (aroonu_14_1h_lt_40))
            # 5m & 1d down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_50))
            # 5m & 1d down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_15) | (cmf_20_1d_gt_neg_0_25))
            # 5m & 1d down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_40))
            # 5m down move, 1h high
            & ((rsi_3_gt_3) | (aroonu_14_1h_lt_80))
            # 5m down move, 4h high, 1d overbought
            & ((rsi_3_gt_3) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 5m down move, 4h high & overbought
            & ((rsi_3_gt_3) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 5m down move, 4h & 1d overbought
            & ((rsi_3_gt_3) | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 5m down move, 1d downtrend
            & ((rsi_3_gt_3) | (roc_9_1d_gt_neg_40))
            # 5m & 15m down move, 15m still high
            & ((rsi_3_gt_5) | (rsi_3_15m_gt_10) | (stochrsi_k_15m_lt_40))
            # 5m & 15m down move, 1h high
            & ((rsi_3_gt_5) | (rsi_3_15m_gt_30) | (stochrsi_k_1h_lt_80))
            # 5m & 4h down move, 1d downtrend
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 5m & 4h down move, 4h still not low enough
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_4h < 20.0))
            # 5m down move, 4h high, 1h overbought
            & ((rsi_3_gt_10) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_30))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m > 1.0) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_15))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (aroonu_14_4h_lt_50))
            # 15m & 1h down move, 15m downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (cmf_20_15m_gt_neg_0_30))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (aroonu_14_15m_lt_30))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (aroonu_14_1h_lt_25))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_10))
            # 15m & 1h & 4h down move, 4h still not low enough, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_20) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_30))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (stochrsi_k_1d_lt_60))
            # 15m & 1h down move, 15m downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_5) | (rsi_14_4h_lt_30))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_5) | (cmf_20_4h_gt_neg_0_35))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_70))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_30) | (stochrsi_k_4h < 40.0))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_20) | (stochrsi_k_1h_lt_60))
            # 15m down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 15m down move, 4h still high, 15m downtrend
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_40) | (cmf_20_15m_gt_neg_0_35))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_30))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_3) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_50))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_10))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_60))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_60))
            # 15m & 1h & 4h & 1d down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_1d_lt_40))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_70))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_40))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_50))
            # 15m & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_50))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_10))
            # 15m & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_4h_lt_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_40))
            # 15m & 1d down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_10) | (aroonu_14_15m_lt_30))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_90))
            # 15m down move, 15m downtrend, 4h still not low enough
            & ((rsi_3_15m_gt_5) | (cmf_20_15m_gt_neg_0_30) | (stochrsi_k_4h < 30.0))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_20) | (stochrsi_k_4h_lt_70))
            # 15m down move, 15m stil high, 1h still high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 15m down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_5) | (stochrsi_k_15m_lt_20) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1h still high, 4h overbought
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_50) | (roc_9_4h_lt_30))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_15m_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_60))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_70))
            # 15m & 1h & 4h & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_70))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_75))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_50))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (rsi_14_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80))
            # 15m & 1h & 1d down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80))
            # 16m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_55) | (stochrsi_k_4h_lt_90))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_70))
            # 15m & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_50))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_60) | (roc_9_1d_lt_10))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_90))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_55) | (roc_9_4h_lt_50))
            # 15m & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (rsi_14_1d_lt_40))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_90))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_70))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_70))
            # 15m down move, 15m downtrend, 1h high
            & ((rsi_3_15m_gt_10) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1h_lt_80))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | aroonu_14_1d_lt_100)
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_15m_lt_20) | (aroonu_14_4h_lt_70))
            # 15m down move, 15m sill high, 4h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_15m_lt_40) | (aroonu_14_4h_lt_60))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 15m & 1h & 4h down move, 4h still high, 1d still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (stochrsi_k_1d_lt_50))
            # 15m & 1h down move, 4h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (roc_9_4h_gt_neg_20))
            # 15m & 1h & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_30))
            # 15m & 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 1h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (cmf_20_1h_gt_neg_0_30))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_60))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1d_lt_90))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (stochrsi_k_4h_lt_70))
            # 15m & 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_55) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_30))
            # 15m & 1h down move, 1h high, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_90) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_70))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_40))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_25) | (aroonu_14_4h_lt_60))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_30) | (aroonu_14_1h_lt_70))
            # 15m down move, 15m & 4h still high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_40))
            # 15m down move, 1h still high, 4h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_4h_lt_60))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_75) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_15m_lt_50) | (roc_9_1d_lt_100))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m down move, 4h still high, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_30))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_90))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 15m & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_20))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_30))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_100))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_70))
            # 15m & 1h & 4h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_55) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (roc_9_1d_lt_80))
            # 15m & 4h down move, 1h overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_35) | (roc_9_1h_lt_100))
            # 15m & 1d down move, 4h & 1d still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_40) | (stochrsi_k_1d_lt_40))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_20) | (stochrsi_k_1h_lt_90))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_50))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_50))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_80) | (roc_9_1h_lt_50))
            # 15m & 1h & 4h down move, 1d high, 4h still not low enough
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (stochrsi_k_4h_lt_30))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_50))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_80))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_50))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_35) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_80))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_40))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h > 1.0) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_10))
            # 1h down move, 15m downtrend, 1h still high
            & ((rsi_3_1h_gt_3) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (roc_9_15m > -30.0))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 1h & 1d down move, 15m still high
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_10) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_4h < 40.0))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1d_gt_neg_30))
            # 1h % 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (cmf_20_4h_gt_neg_0_30))
            # 1h & 4h & 1d down move, 1d still high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50) | (roc_9_1h_gt_neg_20))
            # 1h & 4h & 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70) | (roc_9_1h_gt_neg_10))
            # 1h & 4h & 1d down move, 1d still high, 1d overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_50) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_50))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h & 1d down move, 4h downtrend, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (rsi_14_4h_gt_30) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_50))
            # 1h & 1d down move, 15m still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40))
            # 1h down move, 1h still not low enough 1d overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_14_1d_lt_60))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_20))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | rsi_3_4h_gt_20 | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (stochrsi_k_4h < 30.0))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_50))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (roc_9_1d_lt_10))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high, 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_60) | roc_9_1d_lt_50)
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h < 60.0) | (roc_9_4h_lt_10))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_15) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d down move, 1h stil high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_85))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_50))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1h still not low enough
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_80) | (stochrsi_k_1h_lt_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h & 1d down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_85))
            # 1h down move, 4h high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_70) | (cmf_20_4h_gt_neg_0_50))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_4h_lt_30) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_200))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (roc_9_4h_gt_neg_25) | (roc_9_1d_gt_neg_60))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_1h_lt_40))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_50) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h high, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_25))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_85) | (roc_9_4h_lt_100))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_85) | (roc_9_1d_lt_100))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_40))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_200))
            # 1h & 4h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_60) | (roc_9_1d_lt_40))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_10))
            # 1h down move, 4h still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_100))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (roc_9_1d_lt_200))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_40))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_60))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_85) | (roc_9_1h_lt_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h < 60.0) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_50) | (roc_9_1h_lt_10) | (roc_9_4h_lt_100))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_4h_lt_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_40))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_40))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_15) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_5) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 4h down move, 15m still high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_50))
            # 4h & 1d down move, 1h still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_1d_lt_40))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (roc_9_1d_gt_neg_25))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_100))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_45) | (stochrsi_k_1d_lt_80))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_40))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h < 40.0) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h < 40.0))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_80))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_10))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 4h & 1d down move, 1h high & overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 4h & 1d down move, 1h high & overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_70) | (roc_9_1h_lt_10))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_30))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_100))
            # 4h down move, 4h still high. 4h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (cmf_20_4h_gt_neg_0_40))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h high, 4h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_60) | (roc_9_1d_lt_60))
            # 4h down move, 1d downtrend
            & ((rsi_3_4h_gt_30) | (roc_9_1d_gt_neg_50))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_35) | (roc_9_4h_lt_30) | (roc_9_1d_lt_200))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_40))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_40) | (stochrsi_k_4h < 40.0) | roc_9_1d_lt_50)
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_60))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_100))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_80))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_55) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_10))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_60))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_5) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h & 4h still not low enough
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_20) | (stochrsi_k_4h < 20.0))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_10) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_10) | (aroonu_14_1h_lt_70))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h overbought, 1d downtrend
            & ((rsi_3_1d_gt_15) | (roc_9_1h_lt_20) | (roc_9_1d_gt_neg_50))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_90) | (roc_9_1d_gt_neg_10))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_25) | aroonu_14_1h_lt_70 | (roc_9_1d_lt_25))
            # 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_80))
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_45) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_60))
            # 1d down move, 1d still high, 4h still high
            & ((rsi_3_1d_gt_50) | (rsi_14_1d_lt_50) | (stochrsi_k_4h_lt_50))
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_40) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_20))
            # 1h high, 4h & 1d overbought
            & (aroonu_14_1h_lt_70 | (roc_9_4h_lt_50) | (roc_9_1d_lt_200))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_50))
            # 1h & 4h high, 1d downtrend
            & (aroonu_14_1h_lt_70 | (aroonu_14_4h_lt_100) | (roc_9_1d_gt_neg_40))
            # 1h high, 4h & 1d downtrend
            & (aroonu_14_1h_lt_70 | (roc_9_4h_gt_neg_30) | roc_9_1d_gt_neg_50)
            # 1h & 4h high, 1h overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_30))
            # 1h & 4high, 1d downtrend
            & (aroonu_14_1h_lt_80 | aroonu_14_4h_lt_100 | (roc_9_1d_gt_neg_20))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_4h_lt_100 | (roc_9_1d_lt_80))
            # 1h & 1d high, 1d overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_30))
            # 1h high, 1d downtrend
            & (aroonu_14_1h_lt_80 | (roc_9_1d_gt_neg_40))
            # 1h & 4h high, 1d overbought
            & ((aroonu_14_1h_lt_90) | aroonu_14_4h_lt_100 | (roc_9_1d_lt_30))
            # 1h high, 4h & 1d overbought
            & ((aroonu_14_1h_lt_90) | (roc_9_4h_lt_40) | (roc_9_1d_lt_40))
            # 4h still high, 5m downtrend
            & ((aroonu_14_4h_lt_40) | (roc_9 > -40.0))
            # 4h high & overbought
            & ((aroonu_14_4h_lt_70) | (roc_9_4h_lt_80))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 4h high, 1h & 4h overbought
            & ((aroonu_14_4h_lt_100) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 1d high, 1d downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_lt_60) | (roc_9_1d_lt_60))
            # 1d high, 1h & 4h down move
            & ((aroonu_14_1d_lt_100) | (roc_9_1h_lt_25) | (roc_9_4h_lt_60))
            # 15m high, 1d overbought
            & ((stochrsi_k_15m_lt_70) | (roc_9_1d_lt_60))
            # 1h high, 1d downtrend
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_50))
            # 1h high, 1d overbought
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_lt_40))
            # 1h high, 4h downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h < 80.0) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 1d high, 1h & 1d overbought
            & ((stochrsi_k_1d_lt_80) | (roc_9_1h_lt_10) | (roc_9_1d_lt_80))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_80) | (roc_9_4h_lt_60) | (roc_9_1d_lt_60))
            # 1d top wick, 1h & 4h down move, 1d high
            & ((top_wick_pct_1d_lt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # drop in last 20 days, 1h high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_70))
            # drop in last 20 days. 4h high
            & ((close > (high_max_20_1d * 0.10)) | (stochrsi_k_4h_lt_90))
          )

          # Logic
          long_entry_logic.append(
            # (df["RSI_3"] > 5.0)
            (aroonu_14_lt_30)
            & (stochrsi_k_lt_30)
            # & (rsi_3_15m > 5.0)
            & (aroonu_14_15m_lt_50)
            & (close < (ema_20 * 0.948))
          )

        # Condition #3 - Normal mode (Long).
        if long_entry_condition_index == 3:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 4h down move, 1h still high
            ((rsi_3_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_50))
            # 5m down move, 15m high, 1d overbought
            & ((rsi_3_gt_5) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_40))
            # 5m down move, 15m still high, 1d downtrend
            & ((rsi_3_gt_5) | (stochrsi_k_15m_lt_50) | (roc_9_1d_gt_neg_20))
            # 5m down move, 1h still high, 4h downtrend
            & ((rsi_3_gt_5) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_10))
            # 5m down move, 1h high. 1d downtrend
            & ((rsi_3_gt_5) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_30))
            # 5m down move, 15m & 1h high
            & ((rsi_3_gt_10) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 5m down move, 15m & 1d high
            & ((rsi_3_gt_10) | (aroonu_14_15m_lt_70) | aroonu_14_1d_lt_100)
            # 5m down move, 1h & 1d high
            & ((rsi_3_gt_15) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_90))
            # 15m & 1h dowbn move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (stochrsi_k_1d_lt_90))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_60))
            # 15m & 1h & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_50))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_90))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_100))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_60) | roc_9_1d_lt_50)
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_75))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | aroonu_14_4h_lt_70)
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1d > -30.0))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | rsi_3_4h_gt_20 | aroonu_14_1d_lt_100)
            # 15m & 1d down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_15m_lt_70))
            # 15m down move, 4h downtrend. 15m high
            & ((rsi_3_15m_gt_15) | (cmf_20_4h_gt_neg_0_30) | (aroonu_14_15m_lt_60))
            # 15m down move, 15m still high, 1h still high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_50))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 15m high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_60) | (roc_9_1d_gt_neg_70))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_60) | (roc_9_1d_lt_100))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | aroonu_14_1h_lt_70)
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | aroonu_14_4h_lt_70)
            # 15m down move, 15m & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | aroonu_14_1d_lt_100)
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | roc_9_1d_lt_50)
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (roc_9_4h_lt_25) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | aroonu_14_4h_lt_80)
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | aroonu_14_1d_lt_100)
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_20) | rsi_3_4h_gt_20 | (aroonu_14_15m_lt_60))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_75))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_10))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_15m_lt_50))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_50))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_90))
            # 15m &1d down move, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_50) | (roc_9_1d_lt_20))
            # 15m & 1d down move, 4h high, 4h & 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_60) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_30))
            # 15m down move, 15m still not low enough, 4h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_30) | (roc_9_4h_lt_60))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_50) | aroonu_14_4h_lt_70)
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_50) | roc_9_1d_lt_50)
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_60) | (roc_9_4h_gt_neg_40))
            # 15m down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_60) | (roc_9_4h_lt_10))
            # 15m down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_10))
            # 15m down move, 15m high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_1d_gt_neg_20))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | roc_9_1d_lt_50)
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_20) | aroonu_14_1h_lt_80 | (roc_9_4h_lt_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | aroonu_14_4h_lt_70 | (roc_9_4h_lt_50))
            # 15m down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_30))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_90))
            # 15m down move, 4h still high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_20) | (roc_9_4h_lt_25) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_lt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_60))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_70))
            # 15m & 1h & 4h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_80))
            # 15m & 4h & 1d down move, 15m & 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_75))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_50) | (aroonu_14_1h_lt_100))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_100))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_75))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_90))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_20))
            # 15m down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_60))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_20))
            # 15m down move, 4h high, 1d high
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_60) | (stochrsi_k_1d_lt_90))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 15m still high, 1h still high
            & ((rsi_3_15m_gt_25) | (stochrsi_k_15m_lt_50) | (aroonu_14_1h_lt_50))
            # 15m down move, 1h high, 4h high
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_25) | (roc_9_4h_lt_50) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 15m & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h down move, 15m high, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_55) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 15m high, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_55) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 15m & 1h down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_55) | (stochrsi_k_15m_lt_40) | (roc_9_1d_lt_30))
            # 15m & 4h & 1d down move, 15m high, 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_1d_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70))
            # 15m & 1d down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_90))
            # 15m down move, 1d high, 15m high
            & ((rsi_3_15m_gt_30) | (rsi_14_1d_lt_70) | (aroonu_14_15m_lt_70))
            # 15m down move, 15m high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_60) | (roc_9_1d_gt_neg_40))
            # 15m down move, 15m high, 15m downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (cmf_20_15m_gt_neg_0_30))
            # 15m down move, 15m high, 4h & 1d downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_10))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_70))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_30))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_60))
            # 15m down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_30) | (stochrsi_k_15m_lt_70) | (roc_9_4h_lt_70))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_30) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 15m & 4h & 1d down move, 4h still high, 15m high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_60) | (rsi_14_4h_lt_50) | (aroonu_14_15m_lt_70))
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_60) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (roc_9_4h_lt_80))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_1h_lt_90) | (roc_9_4h_lt_100))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_200))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_35) | (stochrsi_k_1h_lt_90) | roc_9_1d_gt_neg_50)
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_35) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_55) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m high, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_60) | (roc_9_1d_gt_neg_20))
            # 15m down move, 15m high, 1d high & overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_85) | (rsi_3_1d_gt_35))
            # 15m down move, 15m high, 1h downtrend
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_70) | (roc_9_1h_gt_neg_20))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_75) | (aroonu_14_4h_lt_75))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 1h down move, 4h still high, 4h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_10) | aroonu_14_4h_lt_70 | (roc_9_4h_lt_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_14_1d_lt_60))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_70))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | rsi_3_4h_gt_20 | (roc_9_1d_gt_neg_30))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (roc_9_1d_lt_10))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_60) | (roc_9_1d_lt_40))
            # 1h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_30) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 1h stil high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_30))
            # 1h & 4h & 1d down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_80))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_50))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_4h_gt_neg_40) | roc_9_1d_lt_50)
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 15m & 1h still high
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_50))
            # 1h down move, 1h still high, 1 & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h still high 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_200))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_60) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_60) | (roc_9_4h_lt_20))
            # 1h down move, 4h & 1h overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_75))
            # 1h down move, 15m still high, 4h  high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_40) | aroonu_14_4h_lt_80)
            # 1h down move, 15m still high, 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_70))
            # 1h down move, 15m still high, 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_50) | aroonu_14_4h_lt_70)
            # 1h down move, 15m & 1d high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_60) | (aroonu_14_1d_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | aroonu_14_1h_lt_70 | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_35) | aroonu_14_1h_lt_80 | (aroonu_14_1d_lt_90))
            # 1h down move, 1h downtrend, 4h overbought
            & ((rsi_3_1h_gt_35) | (cmf_20_1h_gt_neg_0_30) | (roc_9_4h_lt_20))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | aroonu_14_1h_lt_70 | (roc_9_1d_gt_neg_80))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_35) | aroonu_14_1h_lt_80 | roc_9_1d_lt_50)
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_80) | roc_9_1d_gt_neg_50)
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_60))
            # 1h down move, 15m still high, 4h downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_15m_lt_40) | (roc_9_4h_gt_neg_15))
            # 1h down move, 15m still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_50) | roc_9_1d_lt_50)
            # 1h down move, 15m & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_70) | aroonu_14_4h_lt_70)
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (stochrsi_k_4h_lt_80))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_20))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_85) | (roc_9_1d_gt_neg_60))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (cmf_20_1d_gt_neg_0_20))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_40) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1h down move, 15m high, 4h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_15m_lt_70) | (roc_9_4h_lt_30))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_40) | (roc_9_1d_lt_200))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 1h & 4h & 1d down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_60))
            # 1h down move, 15m & 1h high
            & ((rsi_3_1h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 4h still high, 1d overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_200))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_50))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 15m & 4h high
            & ((rsi_3_1h_gt_55) | (rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_60) | (stochrsi_k_4h_lt_70))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_100))
            # 1h down move, 15m & 1h high
            & ((rsi_3_1h_gt_65) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_65) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1h still high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_30))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 15m high, 1h still high
            & ((rsi_3_4h_gt_5) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_50))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_70))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_50))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_50))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_35) | (stochrsi_k_1d_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80))
            # 4h down move, 15m still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_30) | (roc_9_1d_gt_neg_40))
            # 4h down move, 15m high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_60) | (roc_9_4h_gt_neg_50))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 15m high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_70))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_15) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_60))
            # 4h down move, 15m & 1d high
            & ((rsi_3_4h_gt_15) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_80))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_80))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_80))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_40))
            # 4h & 1d down move, 15m high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_55) | (roc_9_1d_lt_50))
            # 4h down move, 15m & 4h still high
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_50))
            # 4h down move, 15m high, 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_70) | (stochrsi_k_1d_lt_70))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 4h down move, 15m high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_80) | (roc_9_4h_gt_neg_50))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_60))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_90))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 4h & 1d down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_10))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 4h down move, 15m & 4h still high
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_50))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_100))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_50))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60) | (roc_9_1d_gt_neg_70))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 4h down move, 15m still high, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h still high, 1d overbought
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_100))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_80) | roc_9_1d_gt_neg_50)
            # 4h down move, 1h high, 1h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1h_gt_neg_10))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_30) | (rsi_3_1d > 50.0) | (roc_9_1d_lt_100))
            # 4h down move, 1d downtrend, 1d overbought
            & ((rsi_3_4h_gt_30) | (cmf_20_1d_gt_neg_0_30) | (roc_9_1d_lt_40))
            # 4h down move, 15m high, 4h high
            & ((rsi_3_4h_gt_30) | (aroonu_14_15m_lt_60) | (aroonu_14_4h_lt_90))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_50))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_90))
            # 4h down move, 15m still high, 4h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 4h down move, 15m high, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_70))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_60) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 15m & 1h high
            & ((rsi_3_4h_gt_40) | (rsi_3_1d_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90))
            # 4h down move, 15m still high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_50))
            # 4h down move, 15m high, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_200))
            # 4h down move, 1h & 4h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_80))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 4h down move, 15m high, 1h high
            & ((rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_60))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | (roc_9_1d_lt_30))
            # 4h down move, 15m still high, 4h high
            & ((rsi_3_4h_gt_45) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_90))
            # 45 down move, 15m high, 1h high
            & ((rsi_3_4h_gt_45) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_70))
            # 4h down move, 15m high, 4h high
            & ((rsi_3_4h_gt_45) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_70))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_100))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_30))
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_15))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_45) | (roc_9_4h_lt_30) | (roc_9_1d_lt_200))
            # 4h down move, 15m & 1h high
            & ((rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 4h down move, 4h still high, 1h high
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_40) | (stochrsi_k_1h_lt_70))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_80))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_10))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h downtrend, 1d overbought
            & ((rsi_3_4h_gt_50) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_20))
            # 4h down move, 1h high, 4h overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_20))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_60))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 4h down move, 15m high, 1h high
            & ((rsi_3_4h_gt_60) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_90))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_30))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_30) | roc_9_1d_lt_50)
            # 4h down move, 15m high, 4h high
            & ((rsi_3_4h_gt_65) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_65) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_3) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_50))
            # 1d down move, 15m still high, 4h high
            & ((rsi_3_1d_gt_10) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_60))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_30) | roc_9_1d_gt_neg_50)
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1h_lt_85) | (roc_9_1d_gt_neg_30))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 1d down move, 15m high, 1h high
            & ((rsi_3_1d_gt_20) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_80))
            # 1d down move, 15m high, 1h high
            & ((rsi_3_1d_gt_20) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 1d down move, 4h high, 4h downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1d down move, 15m high, 4h high
            & ((rsi_3_1d_gt_25) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 1d down move, 15m high, 4h downtrend
            & ((rsi_3_1d_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_30))
            # 1d down move, 1h & 1d high
            & ((rsi_3_1d_gt_25) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80))
            # 1d down move, 15m high
            & ((rsi_3_1d_gt_25) | (stochrsi_k_15m_lt_80))
            # 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_30) | (aroonu_14_1d_lt_60) | (roc_9_1d_lt_10))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_20))
            # 1d down move, 1h & 1d high
            & ((rsi_3_1d_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_80))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_10))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_50))
            # 15m still high, 4h high, 1d overbought
            & ((aroonu_14_15m_lt_50) | (rsi_14_4h < 60.0) | (roc_9_1d_lt_70))
            # 15m still high, 1h downtrend, 4h overbought
            & ((aroonu_14_15m_lt_50) | (roc_9_1h_gt_neg_10) | (roc_9_4h_lt_40))
            # 15m high, 4h high & overbought
            & ((aroonu_14_15m_lt_60) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m & 4h high, 1d overbought
            & ((aroonu_14_15m_lt_60) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_10))
            # 15m high, 15m & 4h overbought
            & ((aroonu_14_15m_lt_60) | (roc_9_15m < 10.0) | (roc_9_4h_lt_20))
            # 15m high, 4h downtrend
            & ((aroonu_14_15m_lt_60) | (roc_9_4h_gt_neg_30))
            # 15m & 1h & 4h high
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 15m & 4h & 1d high
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_90))
            # 15m & 4h high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 15m & 4h high, 1d downtrend
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_20))
            # 15m & 1d high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m high, 4h downtrend, 1d overbought
            & ((aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_200))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h high, 1d high & overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h high, 4h downtrend
            & ((aroonu_14_1h_lt_90) | (roc_9_4h_gt_neg_20))
            # 1h high, 4h & 1d overbought
            & ((aroonu_14_1h_lt_90) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_80 | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 4h & 1d high, 1d downtrend
            & (aroonu_14_4h_lt_80 | (aroonu_14_1d_lt_100) | (roc_9_1d_gt_neg_20))
            # 1d high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 1d high, 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_30))
            # 1d high, 4h downtrend, 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_70))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 15m & 1h high, 1d overbought
            & ((stochrsi_k_15m_lt_70) | (stochrsi_k_1h_lt_70) | roc_9_1d_lt_50)
            # 15m & 1d high
            & ((stochrsi_k_15m < 90.0) | (stochrsi_k_1d_lt_90))
            # 1h high, 4h & 1d downtrend
            & ((stochrsi_k_1h_lt_60) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_30))
            # 1h high, 4h downtrend
            & ((stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_30))
            # 1h high, 1d downtrend
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_20))
            # 4h high, 4h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_20))
            # 1d still high, 4h & 1d downtrend
            & ((stochrsi_k_1d_lt_50) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_30))
            # 1d P&D, 4h downtrend
            & ((change_pct_1d_gt_neg_50) | (change_pct_1d_shift_288 < 50.0) | (rsi_3_4h_gt_15))
            # 1d P&D, 15m high
            & ((change_pct_1d_gt_neg_20) | (change_pct_1d_shift_288 < 20.0) | (aroonu_14_15m_lt_70))
            # 1d red with top wick, 4h high
            & ((change_pct_1d_gt_neg_20) | (top_wick_pct_1d_lt_20) | aroonu_14_4h_lt_80)
            # 1d red, previous 1d top wick, 15m high
            & ((change_pct_1d_gt_neg_10) | (top_wick_pct_1d_shift_288 < 40.0) | (aroonu_14_15m_lt_70))
            # 1d green with top wick, 4h overbought
            & ((change_pct_1d_lt_15) | (top_wick_pct_1d_lt_15) | (roc_9_4h_lt_20))
            # 1d green, 15m down move, 1h high
            & ((change_pct_1d_lt_50) | (rsi_3_15m_gt_25) | aroonu_14_1h_lt_70)
            # 1d green, 4h down move, 4h still high
            & ((change_pct_1d_lt_40) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_40))
            # 1d top wick, 4h down move, 1d overbought
            & ((top_wick_pct_1d_lt_50) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_60))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_20 < rsi_20_shift_1)
            & (rsi_4 < 45.0)
            & (rsi_14 > 30.0)
            & (aroonu_14 < 20.0)
            & (stochrsi_k_lt_20)
            & (close < sma_16 * 0.965)
            & (close < sma_16_1h * 0.985)
          )

        # Condition #4 - Normal mode (Long).
        if long_entry_condition_index == 4:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            rsi_3_15m_gt_3
            # 5m & 1h down move, 1d still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_3) | (aroonu_14_1d_lt_40))
            # 5m & 1h & 4h down move
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_10))
            # 5m & 1h down move, 1h still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | rsi_3_1h_gt_20 | aroonu_14_1d_lt_100)
            # 5m & 1h down move, 1h high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_50) | aroonu_14_1h_lt_70)
            # 5m & 1h down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 5m & 1h down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_15) | (roc_9_1d > -30.0))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_25) | aroonu_14_4h_lt_70)
            # 5m & 1d down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_40))
            # 5m down move, 1h high, 4h overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 5m down move, 1d overbought
            & ((rsi_3_gt_3) | (roc_9_1d_lt_80))
            # 5m & 1h & 4h down move
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_5))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50))
            # 5m down move, 4h high, 1h overbought
            & ((rsi_3_gt_10) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_30))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_1d_lt_40))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_70))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (roc_9_1d_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | aroonu_14_1d_lt_100)
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_5) | aroonu_14_1h_lt_70 | (roc_9_1h_lt_10))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_5) | (roc_9_1h_lt_10) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # 15m & 1h down move, 15m stil high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_15m_lt_50))
            # 15m & 1h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_40))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_70))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_55) | (aroonu_14_1h_lt_60))
            # 15m & 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_30))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_50))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_80))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_70))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_80))
            # 15m & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h & 4h high, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_15m_lt_80))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h & 1d down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_70))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 1d down move, 1h high, 1h & 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_20) | (roc_9_1d_lt_20))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_100))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_30))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_80))
            # 15m down move, 4h high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_50))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (aroonu_14_4h_lt_85))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_30))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_30))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_50) | (roc_9_4h_lt_50))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (roc_9_15m > -30.0))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (cmf_20_15m_gt_neg_0_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_70))
            # 1h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_70) | (stochrsi_k_4h_lt_80))
            # 1h down move, 15m still high
            & ((rsi_3_1h_gt_3) | (stochrsi_k_15m_lt_50))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_3) | (stochrsi_k_1h_lt_50) | (roc_9_4h_lt_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (rsi_3_1d_gt_20))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1h_gt_neg_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_40))
            # 1h & 4h & 1d down move, 1d still high, 1d overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_50) | (roc_9_1d_lt_10))
            # 1h down move, 4h high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (stochrsi_k_4h_lt_70) | (roc_9_1h_gt_neg_40))
            # 1h down move, 4h high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (stochrsi_k_4h_lt_70) | (cmf_20_1h_gt_neg_0_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_5) | (roc_9_1d_lt_100))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_20))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40))
            # 1h & 3h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_70))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_85))
            # 1h down move, 1d high, 15m downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_15m > -50.0))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_40))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_60) | (roc_9_4h_lt_10) | (roc_9_1d_lt_30))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50) | (roc_9_4h_gt_neg_50))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_20))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_200))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_80))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_70))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_15m_lt_40) | (aroonu_14_1h_lt_60))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_70))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (roc_9_4h_gt_neg_25) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 1h & 4h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_50))
            # 1h down move, 1h high, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_85) | (roc_9_1d_lt_100))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_200))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h & 1d high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_30))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_40))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 1h high, 4h high & overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_4h_lt_20))
            # 4h down move, 4h high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_40))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1h still not low enough
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_70))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (aroonu_14_1h_lt_40))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_70))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_40))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_70))
            # 4h down move, 4h still high, 1h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1h_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_200))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 4h up move, 1d downtrend, 4h high
            & ((rsi_3_4h_lt_90) | (cmf_20_1d_gt_neg_0_25) | (aroonu_14_4h_lt_100))
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_20) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h high, 4h high & overbought
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 1h still high, 4h & 1d downtrend
            & ((aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h high & overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_30) | (roc_9_4h_lt_30))
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_80))
            # 1h high, 1d overbought
            & ((aroonu_14_1h_lt_70) | (roc_9_1d_lt_70))
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_30))
            # 1h & 4h high & overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 1h & 1d high, 1h overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_90) | (roc_9_1h_lt_30))
            # 4h still not low enough, 4h & 1d downtrend
            & ((aroonu_14_4h_lt_30) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_40))
            # 4h still high, 5m downtrend
            & ((aroonu_14_4h_lt_40) | (roc_9 > -40.0))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_50))
            # 4h high, 1h & 1d overbought
            & ((aroonu_14_4h_lt_100) | (roc_9_1h_lt_30) | (roc_9_1d_lt_100))
            # 4h high, 1h & 4h high
            & ((aroonu_14_4h_lt_100) | (roc_9_1h_lt_50) | (roc_9_4h_lt_100))
            # 1d high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_40))
            # 1d high, 1h & 1d overbought
            & ((aroonu_14_1d_lt_80) | (roc_9_1h_lt_30) | (roc_9_1d_lt_200))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_lt_20) | roc_9_1d_lt_50)
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h & 1d overbought
            & ((roc_9_4h_lt_100) | (roc_9_1d_lt_200))
            # 5m red, 1h & 4h down move
            & ((change_pct > -5.0) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_5))
            # 1d top wick, 1h & 4h down move, 1d high
            & ((top_wick_pct_1d_lt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # drop in last 20 days, 1h high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | aroonu_14_1h_lt_70 | (roc_9_1d_gt_neg_70))
          )

          # Logic
          long_entry_logic.append(
            (aroonu_14_lt_25) & (aroonu_14_15m_lt_25) & (close < (ema_9 * 0.946)) & (close < (ema_20 * 0.960))
          )

        # Condition #5 - Normal mode (Long).
        if long_entry_condition_index == 5:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            (rsi_3_15m_gt_20)
            # 5m & 1h down move, 1h still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100))
            # 5m & 1h down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_60))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (roc_9_4h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80))
            # 15m & 1d down move, 1d high, 4h downtrend
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_40))
            # 15m down move, 15m stil not low enough, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_60))
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_70))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_25) | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_25) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_85))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move, 1h still high, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 15m down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_50) | (stochrsi_k_1d_lt_70))
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_60) | (stochrsi_k_4h_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high, 1h downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_85) | (roc_9_1h_gt_neg_40))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_25))
            # 15m & 1h & 1d down move, 15m high, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (rsi_3_1d_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_1h_lt_85) | (roc_9_4h_lt_80))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5) | (aroonu_14_1d_lt_70))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5) | (rsi_3_1d_gt_50) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (roc_9_1d_lt_15))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_40))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_50))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (roc_9_1h_gt_neg_15))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_40) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_40))
            # 1h down move, 4h downtrend. 4h still not low enough
            & ((rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_20) | (aroonu_14_4h_lt_30))
            # 1h down move, 15m still high, 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_90))
            # 1h down move, 15m high, 4h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_10))
            # 1h down move, 1h still high, 15m downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_40) | (cmf_20_15m_gt_neg_0_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_30))
            # 1h & 4h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h still high, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_100))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_80))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_60) | roc_9_1d_lt_50)
            # 1h down move, 4h high, 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_80) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_60))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_10))
            # 1h down move, 1h downtrend, 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_1d_lt_80))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_4h_lt_10) | (roc_9_1d_lt_60))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_70))
            # 1h & 4h & 1d down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_50))
            # 1h & 4h down move, 4h high, 1h downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_70) | (roc_9_1h_gt_neg_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high and overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_30))
            # 1h & 4h & 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_85) | (roc_2_1d > -30.0))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70))
            # 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 4h downtrend, 4h high
            & ((rsi_3_1h_gt_25) | (cmf_20_4h_gt_neg_0_50) | (aroonu_14_4h_lt_70))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_lt_30) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_85))
            # 1h & 4h down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30))
            # 1h down move, 1h still high, 1h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_85))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_20))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_100))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_15m_lt_40) | (aroonu_14_1h_lt_60))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_50))
            # 1h down move, 4h downtrend, 1d over
            & ((rsi_3_1h_gt_30) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_50))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_25))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_200))
            # 1h down move, 15m high, 1h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_40) | (roc_9_1d_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_30))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1d_lt_80) | roc_9_1d_lt_50)
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_40) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_40) | (roc_9_1h_lt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (roc_9_1d_lt_200))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1h down move, 1h & 4h high, 1h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_20))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_50))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_70) | roc_9_1d_lt_50)
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_40))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_50) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1h down move, 15m high, 1h high
            & ((rsi_3_1h_gt_55) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_80))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_60) | (roc_9_1d_lt_10))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1h still not low enough
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_30))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (roc_9_1h_gt_neg_50))
            # 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_5) | (aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_10))
            # 4h & 1d down move, 15m high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_80))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (roc_9_1d_gt_neg_15))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50))
            # 4h & 1d down move, 1h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (stochrsi_k_4h_lt_40))
            # 4h down move, 15m downtrend, 1d high
            & ((rsi_3_4h_gt_10) | (cmf_20_15m_gt_neg_0_30) | (aroonu_14_1d_lt_80))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 15m still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50) | (roc_9_1d_gt_neg_25))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_80))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h downtrend, 1d overbought
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (roc_9_4h_gt_neg_40))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_10))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h & 4h downtrend, 1d overbought
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_20))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h & 1ddown move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_80))
            # 4h & 1d down move, 1h still high, 4h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_50))
            # 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_10))
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_70))
            # 4h down move, 1h & 4h still high, 1h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_40) | (roc_9_1h_gt_neg_25))
            # 4h down move, 4h still high. 4h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (cmf_20_4h_gt_neg_0_40))
            # 4h down move, 15m still high, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_50) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_50))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_70))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_80))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_40))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_50) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 4h up move, 1d downtrend, 4h high
            & ((rsi_3_4h_lt_90) | (cmf_20_1d_gt_neg_0_25) | (aroonu_14_4h_lt_100))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_10))
            # 1d down move, 1h still low, 4h high, 4h downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_70) | (roc_9_4h_gt_neg_10))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_80))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h high, 4h downtrend
            & ((rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_90) | (roc_9_4h_gt_neg_30))
            # 15m & 1h & 4h downtrend
            & ((cmf_20_15m_gt_neg_0_30) | (cmf_20_1h_gt_neg_0_30) | (cmf_20_4h_gt_neg_0_30))
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_40) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_20))
            # 15m not low enough, 1h & 4h downtrend
            & ((aroonu_14_15m_lt_20) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 15m high, 1h high & overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_85) | (roc_9_1h_lt_10))
            # 1h & 1d high, 1h & 1d overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1h_lt_20) | (roc_9_1d_lt_200))
            # 1h & 4h high, 4h overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h & 1d high, 1d overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_200))
            # 1h high, 1h overbought
            & ((aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h high, 4h & 1d downtrend
            & ((aroonu_14_1h_lt_80) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_40))
            # 4h still high, 5m downtrend
            & ((aroonu_14_4h_lt_40) | (roc_9 > -40.0))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_70) | (roc_9_4h_lt_60) | (roc_9_1d_lt_80))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_80))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_80))
            # 4h high, 1h & 4h overbought
            & ((aroonu_14_4h_lt_85) | (roc_9_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_85) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_40))
            # 4h high, 1h & 1d overbought
            & ((aroonu_14_4h_lt_100) | (roc_9_1h_lt_40) | (roc_9_1d_lt_100))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_100) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1d high, 1h & 4h down move
            & ((aroonu_14_1d_lt_100) | (roc_9_1h_lt_25) | (roc_9_4h_lt_60))
            # 1d high, 1h downtrend, 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_1h_gt_neg_30) | (roc_9_1d_lt_100))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1d high, 1d downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_40))
            # 15m high, 4h & 1d downtrend
            & ((stochrsi_k_15m_lt_70) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_30))
            # 1h high, 4h & 1d downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_40))
            # 1h high, 4h & 1d overbought
            & ((stochrsi_k_1h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 4h high, 1h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_40) | (roc_9_1d_gt_neg_70))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_80) | (roc_9_1d_lt_100))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_80))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_50))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
            # 1d P&D, dh downtrend
            & ((change_pct_1d_gt_neg_50) | (change_pct_1d_shift_288 < 50.0) | (rsi_3_4h_gt_15))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # drop in last 20 days, 1h high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | aroonu_14_1h_lt_70 | (roc_9_1d_gt_neg_70))
            # drop in last 20 days. 4h high
            & ((close > (high_max_20_1d * 0.10)) | (stochrsi_k_4h_lt_90))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_50)
            & (aroonu_14_lt_25)
            & (stochrsi_k_lt_30)
            & (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.020))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
          )

        # Condition #6 - Normal mode (Long).
        if long_entry_condition_index == 6:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 15m down move, 15m still high
            ((rsi_3_gt_3) | (rsi_3_15m_gt_10) | (stochrsi_k_15m_lt_40))
            # 5m & 15m down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40))
            # 5m & 15m down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_15) | (roc_9_1d_gt_neg_20))
            # 5m & 15m down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_25) | (roc_9_1d_gt_neg_30))
            # 5m & 1h down move, 1h still not low enough
            & ((rsi_3_gt_3) | rsi_3_1h_gt_20 | (aroonu_14_1h_lt_30))
            # 5m & 1h down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 5m & 4h down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_50))
            # 5m & 4h & 1d down move
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_35))
            # 5m & 4h & 1d down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_70))
            # 5m & 4h down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_50))
            # 5m & 1d down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_40))
            # 5m down move, 4h & 1d overbought
            & ((rsi_3_gt_3) | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 5m & 1h down move, 4h high
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_40) | (aroonu_14_4h_lt_60))
            # 5m & 1h down move, 1h high
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80))
            # 5m & 4h down move, 1d downtrend
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1d_gt_neg_20))
            # 5m & 4h down move, 4h still high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50))
            # 5m & 4h down move, 1d overbought
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_60))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80))
            # 5m down move, 15m still not low enough, 4h high
            & ((rsi_3_gt_5) | (aroonu_14_15m_lt_20) | (stochrsi_k_4h_lt_70))
            # 5m down move, 1h & 1d high
            & ((rsi_3_gt_5) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100))
            # 5m down move, 4h high & overbought
            & ((rsi_3_gt_5) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_25))
            # 5m down move, 1h high
            & ((rsi_3_gt_5) | (stochrsi_k_1h_lt_80))
            # 5m & 1d down move, 1d still high
            & ((rsi_3_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_1d_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_20))
            # 15m & 1h & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_20))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_10))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_20))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_25))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_60))
            # 15m & 1d down move, 15m still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_10) | (aroonu_14_15m_lt_30))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_55) | (stochrsi_k_4h_lt_70))
            # 1h & 1d downtrend, 1d high
            & ((rsi_3_15m_gt_3) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h & 1d down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_20))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_65) | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_30))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90))
            # 15m & 1h & 4h down move, 15m downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (cmf_20_15m_gt_neg_0_30))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_55) | (aroonu_14_4h_lt_100))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_30))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_60))
            # 15m down move, 15m still high, 1h still high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1h still high, 1d high
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_40) | (aroonu_14_1d_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m & 1h still not low enough
            & ((rsi_3_15m_gt_5) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h & 1d down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_50) | (roc_9_1d_gt_neg_20))
            # 15m & 1h & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_30))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_60))
            # 15m & 1h & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_50))
            # 15m & 1h & 4h down move, 1h still not low enough, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_30) | (aroonu_14_4h_lt_40))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_45) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_1d_gt_neg_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_45) | (roc_9_1d_lt_150))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_65) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_1d_lt_60))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (cmf_20_4h_gt_neg_0_30))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_45) | aroonu_14_4h_lt_70)
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_75))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_75))
            # 15m & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1d > 50.0) | (roc_9_1d_lt_20))
            # 15m down move, 15m downtrend, 4h still high
            & ((rsi_3_15m_gt_10) | (cmf_20_15m_gt_neg_0_40) | (stochrsi_k_4h_lt_50))
            # 15m down move, 1h downtrend, 4h still high
            & ((rsi_3_15m_gt_10) | (cmf_20_1h_gt_neg_0_30) | (stochrsi_k_4h_lt_40))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_60))
            # 15m down move, 15m still high, 1h still high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 15m down move, 1h still not low enough, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_30) | (roc_9_1d_lt_100))
            # 15m down move, 1h still high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (cmf_20_1h_gt_neg_0_30))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | aroonu_14_4h_lt_70)
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_60))
            # 15m & 1h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (stochrsi_k_1d_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_60))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_40) | aroonu_14_4h_lt_80)
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_40) | (roc_9_1d_lt_40))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_45) | (roc_9_1d_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_70))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_30))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_30) | (roc_9_1d_lt_10))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_25) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h still high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_80))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_85))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_85) | (stochrsi_k_4h_lt_90))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_30))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_25))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 15m down move, 1h still high, 4h overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_50) | (roc_9_4h_lt_10))
            # 15m down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_20))
            # 15m & 1h & 4h down move, 15m & 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_40))
            # 15m & 1h & 4h down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (aroonu_14_15m_lt_40) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 1h overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (roc_9_1h_lt_10))
            # 15m & 1h & 4h down move, 1h still not low enough
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_30))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80))
            # 15m & 1h & 4h down move, 15m & 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h & 1d down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_60) | (stochrsi_k_4h_lt_90))
            # 15m & 4h & 1d down move
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_10))
            # 15m & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_4h_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_45) | (stochrsi_k_1d_lt_90))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1d down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_lt_50))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_25) | (stochrsi_k_1h_lt_90))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_70))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_30))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_30))
            # 15m down move, 1d high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 15m down move, 1d high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_15m_lt_60) | (roc_9_4h_gt_neg_50))
            # 15 down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_10))
            # 15m down move, 4h high, 15m downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_4h_lt_70) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h & 4h down move, 1h still not low enough, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (stochrsi_k_1h_lt_30) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_lt_70))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_40))
            # 15m & 1h & 4h down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_60) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_60) | (stochrsi_k_4h_lt_90))
            # 15m & 4h & 1d down move, 15m still not low enough
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_15m_lt_30))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_55) | (roc_9_4h_lt_30))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | aroonu_14_1h_lt_80)
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_25) | (stochrsi_k_1h_lt_90))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_60))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_25) | aroonu_14_1h_lt_70 | (roc_9_4h_lt_40))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_85) | aroonu_14_4h_lt_100)
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | aroonu_14_4h_lt_70 | (roc_9_4h_lt_50))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_25) | aroonu_14_4h_lt_80 | (roc_9_1d_lt_100))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
            # 15m & 1h down move, 4h still high, 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_40) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_50))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h & 4h down move, 1h still high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h down move, 1h still high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_70))
            # 15m & 1d down move, 1h & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_70) | (stochrsi_k_1d_lt_80))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_85))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_40))
            # 15m down move, 15m still high, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (stochrsi_k_15m_lt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_45) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_65) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_80))
            # 15m & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1d_gt_65) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_25) | aroonu_14_1h_lt_80)
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_25) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1m still high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_40) | (roc_9_4h_lt_50))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_70))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | aroonu_14_4h_lt_100)
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_90))
            # 15m down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_40) | (stochrsi_k_15m_lt_40) | (roc_9_1d_lt_100))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_40) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_40))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_50) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_30))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_50))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_10))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 1h & 4h & 1d down move, 1h stil high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_50) | (stochrsi_k_1d_lt_60))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_60) | roc_9_1d_lt_50)
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_20) | (roc_9_4h_gt_neg_10) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_40))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_70))
            # 1h down move, 4h downtrend, 4h high
            & ((rsi_3_1h_gt_25) | (cmf_20_4h_gt_neg_0_50) | aroonu_14_4h_lt_70)
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_40) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_50) | (roc_9_4h_lt_60))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_100))
            # 1h down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (rsi_14_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_60))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_60) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_lt_60))
            # 1h down move, 4h & 1d down move
            & ((rsi_3_1h_gt_30) | aroonu_14_4h_lt_70 | aroonu_14_1d_lt_100)
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_85) | (roc_9_4h_lt_80))
            # 1h down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (roc_9_4h_gt_neg_25) | (roc_9_1d_gt_neg_60))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_75))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_60) | aroonu_14_4h_lt_70)
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | aroonu_14_4h_lt_70 | (roc_9_1d_gt_neg_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_35) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_60))
            # 1h & 1d down move, 1h high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_40))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_85))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_20))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_30))
            # 1h down move, 1h high, 15m downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_15m > -15.0))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1d_lt_80) | roc_9_1d_lt_50)
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_40) | (roc_9_1h_lt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (roc_9_1d_lt_200))
            # 1h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_30) | (roc_9_1d_gt_neg_25))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_40) | (roc_9_1d_lt_100))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_85) | (roc_9_1h_lt_20))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_50) | (roc_9_1h_lt_10) | (roc_9_4h_lt_100))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_50) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_55) | (rsi_3_4h_gt_55) | (stochrsi_k_1h_lt_70))
            # 1h & 1d down move, 1h & 1d high
            & ((rsi_3_1h_gt_55) | (rsi_3_1d_gt_55) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_70))
            # 1h down move, 4 high, 1h overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 1h down move, 1d high, 1h overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1h_lt_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_10))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_65) | aroonu_14_1h_lt_70 | (roc_9_4h_lt_25))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_65) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_20))
            # 4h & 1d down move, 1d still high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_25) | (rsi_14_1d_lt_40) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1h still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_3) | (aroonu_14_1h_lt_20) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_10))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_25) | (stochrsi_k_15m_lt_40))
            # 4h & 1d down move, 1h still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_20))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_100))
            # 4h & 1d down move, 1d still not low enough, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_45) | (rsi_14_4h_lt_30) | (aroonu_14_1d_lt_80))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_70))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (roc_9_1d_gt_neg_15))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_50) | (stochrsi_k_4h_lt_40))
            # 4h down move, 1d still high, 4h still not low enough
            & ((rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (stochrsi_k_4h_lt_30))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_40))
            # 4h & 1d down move, 1h still not low enough, 4h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_30) | (stochrsi_k_4h_lt_40))
            # 4h & 1d down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_40))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_80))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_90))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (cmf_20_4h_gt_neg_0_40))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_90))
            # 4h down move, 1h high, 1h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1h_gt_neg_10))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1h still high, 1d overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_40) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_35) | (rsi_3_1d_gt_50) | (roc_9_1d_lt_100))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_40) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_60))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_20))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_60) | (roc_9_4h_lt_20))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_10))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_10))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_60))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_70))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 4h down move, 4h still high, 4h overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_50) | (roc_9_4h_lt_10))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_65) | (aroonu_14_4h_lt_75) | (roc_9_1d_lt_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_65) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 4h up move, 1d downtrend, 4h high
            & ((rsi_3_4h_lt_90) | (cmf_20_1d_gt_neg_0_25) | (aroonu_14_4h_lt_100))
            # 1d down move, 1d still not low enough, 1d downtrend
            & ((rsi_3_1d_gt_5) | (aroonu_14_1d < 20.0) | (roc_9_1d_gt_neg_20))
            # 1d down move, 15m still high
            & ((rsi_3_1d_gt_5) | (stochrsi_k_15m_lt_40))
            # 1d down move, 1h & 4h still not low enough
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_20) | (stochrsi_k_4h_lt_20))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_10) | (aroonu_14_1h_lt_70))
            # 1d down move, 4h downtrend, 4h high
            & ((rsi_3_1d_gt_20) | (cmf_20_4h_gt_neg_0_25) | (aroonu_14_4h_lt_70))
            # 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1d down move, 15m still high, 1h & 4h high
            & ((rsi_3_1d_gt_30) | (rsi_14_15m_lt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1d down move, 4h & 1d high
            & ((rsi_3_1d_gt_40) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_10))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_60) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_100))
            # 4h downtrend, 4h high & over
            & ((cmf_20_4h_gt_neg_0_10) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_30))
            # 15m still high, 4h high, 1h overbought
            & ((aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_85) | (roc_9_1h_lt_20))
            # 15m still high, 4h high, 1h overbought
            & ((aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h high, 4h high & overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h & 4h high, 1h overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_30))
            # 1h & 4h & 1d high
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_30))
            # 1h high, 1h overbought
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_10))
            # 1h & 1d high, 4h overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_10))
            # 1h high, 1h & 4h overbought
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 1h high, 1h overbought, 1d downtrend
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_50) | roc_9_1d_gt_neg_50)
            # 1h high, 4h &1d overbought
            & ((aroonu_14_1h_lt_85) | (roc_9_4h_lt_30) | (roc_9_1d_lt_30))
            # 1h high, 4h & 1d overbought
            & ((aroonu_14_1h_lt_90) | (roc_9_4h_lt_10) | (roc_9_1d_lt_15))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_70 | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_50))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_70 | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 4h high, 1h & 4h & 1d overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20) | (roc_9_1d_lt_50))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_90) | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h high, 4h overbought, 1d downtrend
            & ((aroonu_14_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_40))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_70) | (roc_9_4h_lt_30) | (roc_9_1d_lt_200))
            # 1d high, 1h & 1d overbought
            & ((aroonu_14_1d_lt_80) | (roc_9_1h_lt_20) | roc_9_1d_lt_50)
            # 1d high, 1d downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 1d high, 1h & 1d overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_1h_lt_10) | roc_9_1d_lt_50)
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 15m still not low enough, 4h high, 1d overbought
            & ((stochrsi_k_15m_lt_30) | aroonu_14_4h_lt_100 | (roc_9_1d_lt_30))
            # 15m still high, 4h high & overbought
            & ((stochrsi_k_15m_lt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h high, 1d overbought
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_lt_40))
            # 1h high, 1h overbought, 4h downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_gt_neg_10))
            # 1h high, 4h & 1d downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_80))
            # 1h down move, 1h & 1d overbought
            & ((stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10) | roc_9_1d_lt_50)
            # 1h high & overbought
            & ((stochrsi_k_1h_lt_90) | (roc_9_1h_lt_40))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 4h high, 1h & 1d overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_lt_20) | (roc_9_1d_lt_200))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30) | (roc_9_1d_lt_30))
            # 4h high, 1d downtrend
            & ((stochrsi_k_4h_lt_80) | roc_9_1d_gt_neg_50)
            # 4h high, 1h & 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_1d_lt_20))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 1d hihg, 1h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_1h_lt_30) | (roc_9_1d_lt_100))
            # 1d P&D, dh downtrend
            & ((change_pct_1d_gt_neg_50) | (change_pct_1d_shift_288 < 50.0) | (rsi_3_4h_gt_15))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # drop in last 20 days, 1h high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | aroonu_14_1h_lt_70 | (roc_9_1d_gt_neg_70))
            # drop in last 20 days. 4h high
            & ((close > (high_max_20_1d * 0.10)) | (stochrsi_k_4h_lt_90))
          )

          # Logic
          long_entry_logic.append(
            (rsi_20 < rsi_20_shift_1)
            & (rsi_3_lt_46)
            & (aroonu_14_lt_25)
            & (stochrsi_k_lt_20)
            & (aroonu_14_15m_lt_50)
            & (close < sma_16 * 0.960)
          )

        # Condition #7 - ADX trend-birth (Long, experimental, RAW — 4h trend ignition; big-win lane).
        if long_entry_condition_index == 7:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # 4h ADX crossing UP through 20 = a trend being born (not yet mature)
          long_entry_logic.append(adx_14_4h > 20.0)
          long_entry_logic.append(np_shift(adx_14_4h, 48) <= 20.0)
          # direction: bulls own it
          long_entry_logic.append(plus_di_14_4h > minus_di_14_4h)
          long_entry_logic.append(close > ema_200)

        # Condition #8 - Donchian 7-day breakout (Long, experimental — turtle-style; big-win lane).
        if long_entry_condition_index == 8:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # first close above the prior 7-DAY high (macro breakout event)
          long_entry_logic.append(close > open_rate)
          long_entry_logic.append(np_shift(close, 1) <= dc_high_7d)
          long_entry_logic.append(close > dc_high_7d)
          # not a one-candle spike fake, and the 4h is not already overheated
          # (measured on the export W/L split; real run: tag 8 84.0%->88.3% WR, damage -50.4K->-27.7K)
          long_entry_logic.append(((high_px - low_px) / close) < 0.025)
          long_entry_logic.append(roc_9_4h < 20.0)

        # Condition #9 - Momentum Continuation (Long, experimental).
        if long_entry_condition_index == 9:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          long_entry_logic.append(
            ((roc_9_1d > -5.0) | (rsi_3_1d > 40.0))
            & ((roc_9_4h > -3.0) | (rsi_3_4h > 50.0))
            & (roc_9_1d < 25.0)
            & (roc_9_4h < 15.0)
            & (roc_9_1h < 10.0)
            & (rsi_3 < 88.0)
            & (rsi_3_15m < 85.0)
            & (rsi_3_1h < 80.0)
            & (rsi_3_4h < 80.0)
            & (stochrsi_k < 90.0)
            & (stochrsi_k_1h < 85.0)
            & (stochrsi_k_4h < 85.0)
            & (willr_14 < -10.0)
            & (mfi_14 > 40.0)
            & (cmf_20 > -0.10)
            & (bbb_20_2_0 < 20.0)
            & (close < (close_max_48 * 0.985))
            & ((rsi_3 > 10.0) | (rsi_3_1h > 20.0) | (roc_9_1d > 0.0))
            & ((rsi_3_15m > 10.0) | (rsi_3_1h > 15.0) | (roc_9_4h > -5.0))
            & ((rsi_3_1h > 20.0) | (rsi_3_4h > 25.0) | (aroonu_14_4h < 60.0))
            & ((rsi_3_15m > 20.0) | (rsi_3_1h > 30.0) | (rsi_3_4h > 35.0))
            # 1h already rolling over — continuation into a fading hour
            & ((willr_14_1h > -35.0) | (aroonu_14_4h > 60.0) | (rsi_3_1h > 65.0))
            # washed-out daily + rolling 4h — the trend is already dead
            & ((rsi_3_1d > 40.0) | (roc_9_4h > 2.0) | (cci_20_4h > -20.0))
          )
          # Logic — full EMA-fan alignment, mature uptrend continuation
          long_entry_logic.append(((ema_9 - ema_50) / close * 100.0) > 0.5)
          long_entry_logic.append(rsi_14_1d > 50.0)
          long_entry_logic.append(rsi_3_1h < 80.0)
          long_entry_logic.append(cmf_20_1h > 0.0)
          long_entry_logic.append(close > ema_9)
          long_entry_logic.append(close > ema_12)
          long_entry_logic.append(close > ema_26)
          long_entry_logic.append(close > ema_50)
          long_entry_logic.append(close > ema_200)
          long_entry_logic.append(ema_9 > ema_26)
          long_entry_logic.append(ema_26 > ema_200)
          long_entry_logic.append(rsi_14 > 55.0)
          long_entry_logic.append(rsi_14 < 65.0)
          long_entry_logic.append(aroonu_14 > 75.0)
          long_entry_logic.append(rsi_14_1h > 50.0)
          long_entry_logic.append(rsi_14_1h < 70.0)
          long_entry_logic.append(rsi_14_4h > 48.0)
          long_entry_logic.append(rsi_14_4h < 68.0)
          long_entry_logic.append(bbp_20_2_0 > 0.55)
          long_entry_logic.append(bbp_20_2_0 < 0.85)
          long_entry_logic.append(obv_change_pct > 0.0)
          long_entry_logic.append(willr_14 > -40.0)
          long_entry_logic.append(willr_14 < -15.0)

        # Condition #10 - CCI Divergence + AROON Trend Birth (Long, experimental).
        if long_entry_condition_index == 10:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          long_entry_logic.append(global_protections_long_pump == True)
          long_entry_logic.append(global_protections_long_dump == True)
          long_entry_logic.append(rsi_14_1d > 30.0)
          long_entry_logic.append(roc_9_1d > -20.0)
          long_entry_logic.append(rsi_14_4h > 25.0)
          long_entry_logic.append((ema_12_4h > ema_200_4h) | (rsi_14_4h > 35.0) | (roc_9_4h > -5.0))
          long_entry_logic.append(
            ((rsi_3 > 3.0) | (rsi_3_15m > 5.0) | (rsi_3_1h > 10.0))
            & ((rsi_3_15m > 5.0) | (rsi_3_1h > 15.0) | (aroonu_14_4h < 90.0))
            & ((rsi_3_1h > 10.0) | (rsi_3_4h > 20.0) | (stochrsi_k_4h < 60.0))
            & ((rsi_3_15m > 10.0) | (rsi_3_4h > 25.0) | (roc_9_1d > -10.0))
          )
          long_entry_logic.append((rsi_3_1d > 20.0) | (roc_2_1d > -3.0) | (cmf_20_1d > -0.10))
          # deep daily outflow (distribution) with no washout — knife, not a dip
          long_entry_logic.append((cmf_20_1d > -0.30) | (rsi_3_1d > 65.0) | (roc_9_4h < -15.0))
          # Logic — 1h CCI recovering from oversold + fresh 15m AROON upswing
          long_entry_logic.append(cci_20_1h < -50.0)
          long_entry_logic.append(cci_20_1h > -200.0)
          long_entry_logic.append(cci_20_change_pct_1h > 0.0)
          long_entry_logic.append(aroonu_14_15m > 50.0)
          long_entry_logic.append(aroonu_14 > 30.0)
          long_entry_logic.append(rsi_14 < 45.0)
          long_entry_logic.append(rsi_14 > 20.0)
          long_entry_logic.append(mfi_14 > 30.0)
          long_entry_logic.append(cmf_20_1h > -0.05)
          long_entry_logic.append(close < (close_max_48 * 0.95))
          long_entry_logic.append(close > close_min_48)
          long_entry_logic.append(stochrsi_k < 30.0)

        # Condition #11 - MFI/CMF Double Divergence + BB Reversion (Long, experimental).
        if long_entry_condition_index == 11:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          long_entry_logic.append(global_protections_long_pump == True)
          long_entry_logic.append(global_protections_long_dump == True)
          long_entry_logic.append(rsi_14_1d > 30.0)
          long_entry_logic.append(roc_9_1d > -20.0)
          long_entry_logic.append((ema_12_4h > ema_200_4h) | (rsi_14_4h > 40.0))
          long_entry_logic.append(
            ((rsi_3 > 2.0) | (rsi_3_15m > 5.0) | (aroonu_14_1h < 80.0))
            & ((rsi_3_15m > 5.0) | (rsi_3_1h > 10.0) | (roc_9_4h > -10.0))
            & ((rsi_3_1h > 8.0) | (rsi_3_4h > 15.0) | (stochrsi_k_1d < 50.0))
            & ((rsi_3_15m > 8.0) | (cmf_20_4h > -0.15) | (aroonu_14_4h < 70.0))
            & ((rsi_3_4h > 15.0) | (roc_9_1d > -15.0))
          )
          long_entry_logic.append((rsi_14_1h > 22.0) | (rsi_14_4h > 25.0))
          # post-pump slow bleed: daily still inflated while 4h drifts slightly
          # negative (0..-15) = distribution, not a dip; real dips wash out below -15
          long_entry_logic.append((roc_9_1d < 25.0) | (roc_9_4h > 0.0) | (roc_9_4h < -15.0))
          # Logic — MFI & CMF both positive (accumulation) at the BB lower band
          long_entry_logic.append(mfi_14 > 30.0)
          long_entry_logic.append(cmf_20 > 0.02)
          long_entry_logic.append(willr_14 < -80.0)
          long_entry_logic.append(willr_14_1h < -45.0)
          long_entry_logic.append(close < (bbl_20_2_0 * 1.015))
          long_entry_logic.append(bbb_20_2_0 > 6.0)
          long_entry_logic.append(rsi_14 < 40.0)
          long_entry_logic.append(rsi_14 > 15.0)
          long_entry_logic.append(rsi_3 > 3.0)
          long_entry_logic.append(rsi_14_1h > 25.0)
          long_entry_logic.append(bbp_20_2_0_1h > 0.05)

        # Condition #21 - Pump mode (Long).
        if long_entry_condition_index == 21:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          # long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m down move, 4h high, 1h overbought
            ((rsi_3_gt_10) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_30))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_5) | (roc_9_1h_lt_25) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | rsi_3_1h_gt_20 | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | aroonu_14_1h_lt_80)
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_80))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_45) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_60) | (roc_9_4h_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_90))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_80))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_70) | roc_9_1d_gt_neg_50)
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 15m down move, 1d high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (roc_9_4h_lt_100))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_90))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40) | aroonu_14_4h_lt_100)
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_40) | aroonu_14_4h_lt_100)
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_60) | (roc_9_4h_lt_80))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_90) | (cmf_20_4h_gt_neg_0_25))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (roc_9_1h_lt_30) | (roc_9_4h_lt_50))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (roc_9_4h_lt_60) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h & 4h high, 1h overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_10))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_1h_lt_10))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_20) | (roc_9_4h_lt_80) | (roc_9_1d_lt_200))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90))
            # 15m down move, 15m still high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_40) | (roc_9_1d_gt_neg_25))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_100))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_20))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_25) | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 15m & 4h & 1d down move, 4h & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_55) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (stochrsi_k_4h_lt_90) | (roc_9_4h < 200.0))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_30) | (roc_9_1h_lt_60) | (roc_9_4h_lt_80))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_40) | (roc_9_4h_lt_100) | (roc_9_1d_lt_100))
            # 1h down move, 4h overbought, 1d downtrend
            & ((rsi_3_1h_gt_15) | (roc_9_4h_lt_50) | (roc_9_1d > -30.0))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (roc_9_4h_lt_50) | aroonu_14_4h_lt_80)
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_20) | (roc_9_4h_lt_50) | (stochrsi_k_1h_lt_40))
            # 1h & 4h down move, 4h overbought
            & ((rsi_3_1h_gt_20) | (roc_9_4h_lt_50) | (roc_9_4h_lt_10))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_50))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_40) | (roc_9_4h_lt_10))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_20) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_60))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_50))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_80) | roc_9_1d_gt_neg_50)
            # 1h down move, 1h & 1d overbought
            & ((rsi_3_1h_gt_40) | (roc_9_1h_lt_30) | (roc_9_1d_lt_60))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_25))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_20))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_1d_gt_neg_25))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h & 1d overbought
            & ((rsi_3_1h_gt_50) | (roc_9_1h_lt_25) | (roc_9_1d_lt_200))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_70))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_1h_lt_10) | (roc_9_1d < 250.0))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_65) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_30))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_65) | (roc_9_1h_lt_40))
            # 4h down move, 1h high & overbought
            & ((rsi_3_4h_gt_3) | (aroonu_14_1h_lt_85) | (roc_9_1h_lt_60))
            # 4h & 1d down move, 1h high & overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 4h & 1d down move, 1h high & overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_70) | (roc_9_1h_lt_10))
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_5) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_50))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_10) | aroonu_14_1h_lt_70)
            # 1d down move, 4h high, 1h overbought
            & ((rsi_3_1d_gt_20) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_25))
            # 1d down move, 4h high, 4h overbought
            & ((rsi_3_1d_gt_20) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_40))
            # 1d down move, 1h & 4h overbought
            & ((rsi_3_1d_gt_30) | (roc_9_1h_lt_30) | (roc_9_4h_lt_60))
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_35) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_20))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_40) | aroonu_14_1h_lt_80 | aroonu_14_4h_lt_100)
            # 1d down move, 4h & 1d high
            & ((rsi_3_1d_gt_40) | aroonu_14_4h_lt_70 | aroonu_14_1d_lt_100)
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_45) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_30))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_60) | (aroonu_14_1h_lt_75) | (roc_9_1d_lt_20))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_65) | (aroonu_14_1h_lt_90) | aroonu_14_4h_lt_100)
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_40) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_20))
            # 15m not low enough, 1h high, 1d overbought
            & ((aroonu_14_15m_lt_25) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_200))
            # 1h still high, 1h & 4h overbought
            & ((aroonu_14_1h_lt_50) | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_4h_lt_20))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_4h_lt_80 | (roc_9_4h_lt_30))
            # 1h & 4h high, 1h overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_30))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_100))
            # 1h & 1d high, 4h overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_30))
            # 1h & 4h high, 1h overbought
            & (aroonu_14_1h_lt_80 | (stochrsi_k_4h_lt_90) | (roc_9_1h_lt_10))
            # 1h high & overbought
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_80))
            # 1h high, 1h & 4h overbought
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 1h high, 4h overbought, 1d downtrend
            & (aroonu_14_1h_lt_80 | (roc_9_4h_lt_10) | roc_9_1d_gt_neg_50)
            # 1h & 4h high, 15m downtrend
            & ((aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_85) | (roc_9_15m > -40.0))
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_10))
            # 4h high, 1h overbought, 1d downtrend
            & (aroonu_14_4h_lt_80 | (roc_9_1h_lt_30) | (roc_9_1d > -30.0))
            # 4h & 1d high, 4h downtrend
            & ((aroonu_14_4h_lt_85) | aroonu_14_1d_lt_100 | (cmf_20_4h_gt_neg_0_30))
            # 4h & 1d high, 1h overbought
            & ((aroonu_14_4h_lt_85) | (aroonu_14_1d_lt_90) | (roc_9_1h_lt_20))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_85) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_60))
            # 4h high, 1h & 4h overbought
            & ((aroonu_14_4h_lt_85) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 4h high, 1d high & overbought
            & ((aroonu_14_4h_lt_90) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_30))
            # 4h high, 1h & 4h overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_100))
            # 4h high, 1h & 4h overbought
            & (aroonu_14_4h_lt_100 | (roc_9_1h_lt_40) | (roc_9_4h_lt_80))
            # 1d high, 1h & 4h overbought
            & (aroonu_14_1d_lt_100 | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 1h high, 1h & 4h overbought
            & ((stochrsi_k_1h_lt_60) | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 1h high, 1h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h high, 4h overbought. 1d downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_40) | (cmf_20_1d_gt_neg_0_25))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 4h high & 4h & 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1d high, 1h & 4h overbought
            & ((stochrsi_k_1d_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 1d hihg, 1h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_1h_lt_30) | (roc_9_1d_lt_100))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
          )

          # Logic
          long_entry_logic.append(
            (aroonu_14_lt_25)
            & (stochrsi_k_lt_20)
            & (aroonu_14_15m_lt_50)
            & (close < ema_16 * 0.960)
            & (((ema_50 - ema_200) / close * 100.0) > 6.0)
          )

        # Condition #41 - Quick mode (Long).
        if long_entry_condition_index == 41:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          # long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1d down move, 4h still high
            ((rsi_3_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (stochrsi_k_1d_lt_50))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_20))
            # 15m & 1h down move, 15m downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (roc_9_1d_gt_neg_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60))
            # 15m & 1h & 4h down move, 1h still not low enough, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_30) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_1d_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (stochrsi_k_1h < 75.0))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_5) | (aroonu_14_4h_lt_80))
            # 15m & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_40) | (aroonu_14_1d_lt_80))
            # 15m down move, 15m still high, 1d downtrend
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_50) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1h still high, 1d high
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1h_lt_80) | (stochrsi_k_4h_lt_80))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1h_lt_90) | (roc_9_4h_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_3) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_80))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_40))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_100) | aroonu_14_4h_lt_100)
            # 15m down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_40))
            # 5m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_5) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_5) | (roc_9_1h_lt_25) | (roc_9_4h_lt_25))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_5) | (roc_9_4h_lt_30) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_55) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_50))
            # 15m & 1h & 1d down move, 1d still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_100))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_30))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_70))
            # 15m down move, 1h high, 15m downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_80) | (roc_9_15m > -10.0))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_30))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_85) | (roc_9_1d_lt_40))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | aroonu_14_1d_lt_100)
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_100) | aroonu_14_4h_lt_100)
            # 15m down move, 4h high, 1h downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_85) | (roc_9_1h_gt_neg_25))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high, 15m downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_100) | (roc_9_15m > -30.0))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_60))
            # 15m down move, 1d high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_85) | (cmf_20_1d_gt_neg_0_40))
            # 15m down move, 1h high, 15m downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_80) | (roc_9_15m > -10.0))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_90) | (roc_9_1d_gt_neg_30))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_30))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 1h & 1d down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 15m still high, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_100))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_30))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_80) | roc_9_1d_gt_neg_50)
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_40))
            # 15m down move, 1h downtrend, 4h overbought
            & ((rsi_3_15m_gt_15) | (roc_9_1h_gt_neg_20) | (roc_9_4h_lt_80))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1h & 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (roc_9_1h_lt_10) | (roc_9_1d_lt_40))
            # 15m &4h down move, 4h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_50))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_40))
            # 15m down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (roc_9_4h_gt_neg_15))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_50))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_60))
            # 15m & 1h down move, 15m still high, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_60))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_90))
            # 15m & 1h & 4h down move, 15m & 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_60))
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_90))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_90) | (roc_9_4h_lt_30))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_15))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_70))
            # 1h down move, 15m & 1h downtrend
            & ((rsi_3_1h_gt_3) | (cmf_20_15m_gt_neg_0_30) | (cmf_20_1h_gt_neg_0_30))
            # 1h down move, 1h still high, 1h downtrend
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_50) | (roc_9_1h_gt_neg_20))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_70))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_3) | (aroonu_14_4h_lt_70))
            # 1h down move, 1d high
            & ((rsi_3_1h_gt_3) | (aroonu_14_1d_lt_70))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_50) | (roc_9_1h_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_3) | (stochrsi_k_1d_lt_60) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (cmf_20_1h_gt_neg_0_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_50))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_70) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h still high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_50) | (roc_9_1h_gt_neg_30))
            # 1h down move, 4h still high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_50) | (roc_9_1h_gt_neg_30))
            # 1h down move, 1d high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_50))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_100) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1d high
            & ((rsi_3_1h_gt_5) | (stochrsi_k_1d_lt_90))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_5) | (roc_9_4h_gt_neg_25) | (roc_9_1d_gt_neg_50))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1h_lt_80))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1d still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_20))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_35))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_15m > -20.0))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h & 1d down move, 1h & 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_80))
            # 1h & 4h & 1d down move, 1h high, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_55) | (rsi_3_1d_gt_65) | (aroonu_14_1h_lt_60) | (stochrsi_k_1d_lt_70))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 1d down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (roc_9_1d_gt_neg_30))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (aroonu_14_4h_lt_40))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_70))
            # 1h & 1d down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_20))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_70))
            # 1h & 1d down move, 1h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_30) | (cmf_20_1h_gt_neg_0_40))
            # 1h down move, 1d downtrend, 4h high
            & ((rsi_3_1h_gt_10) | (cmf_20_1d_gt_neg_0_30) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_50) | (roc_9_4h_lt_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_60))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_60) | (stochrsi_k_1d_lt_90))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | roc_9_1d_lt_50)
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_15))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_25))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_70))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_100))
            # 1h & 4h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_70))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_40))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_1h_lt_80))
            # 1h & 1d down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_50) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 1h downtrend, 1h still high
            & ((rsi_3_1h_gt_15) | (cmf_20_1h_gt_neg_0_30) | (stochrsi_k_1h_lt_40))
            # 1h down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_15) | (cmf_20_1d_gt_neg_0_30) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_40))
            # 1h down move, 1h high, 1h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_80) | (cmf_20_1h_gt_neg_0_25))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_80) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h still high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_60))
            # 1h down move, 4h high, 15m downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_85) | (roc_9_15m > -15.0))
            # 1h down move, 4h high, 1h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_85) | (roc_9_1h_gt_neg_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 1h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_30) | (roc_9_1d > -30.0))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1h downtrend, 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_1d_lt_35))
            # 1h down move, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_4h_gt_neg_25) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h still high, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_70))
            # 1h & 4h down move, 4h still high, 1h downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1h_gt_neg_25))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_70))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_4h_lt_90))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_70))
            # 1h & 1d down move, 1h & 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_70))
            # 1h & 1d down move, 4h overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (roc_9_4h_lt_30))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_60))
            # 1h down move, 1h still high, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_80) | roc_9_1d_gt_neg_50)
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_40))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_20) | (roc_9_1h_lt_20) | (roc_9_4h_lt_40))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_20) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_40))
            # 1h & 4h & 1d down move, 15m still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_lt_50))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (roc_9_1d_lt_100))
            # 1h & 1d down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_200))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_85) | (roc_9_1d_lt_50))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h down move, 15m downtrend, 4h overbought
            & ((rsi_3_1h_gt_25) | (roc_9_15m > -25.0) | (roc_9_4h_lt_30))
            # 1h down move, 1h & 1d downtrend
            & ((rsi_3_1h_gt_25) | (roc_9_1h_gt_neg_50) | roc_9_1d_gt_neg_50)
            # 1h down move, 1h downtrend, 4h overbought
            & ((rsi_3_1h_gt_25) | (roc_9_1h_gt_neg_25) | (roc_9_4h_lt_50))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_25) | (roc_9_1h_lt_30) | (roc_9_4h_lt_100))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_90))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 4h high, 1h downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_1h_gt_neg_40))
            # 1h down move, 1h downtrend, 1h high
            & ((rsi_3_1h_gt_30) | (cmf_20_1h_gt_neg_0_25) | (stochrsi_k_1h_lt_70))
            # 1h down move, 4h downtrend, 4h high
            & ((rsi_3_1h_gt_30) | (cmf_20_4h_gt_neg_0_50) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h still high, 1h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1h_lt_50))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1h & 4h & 1d down move, 1h & 4h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 15m & 1h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_40))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_90) | (roc_9_4h_lt_10))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_200))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h down move, 1h downtrend, 4h overbought
            & ((rsi_3_1h_gt_35) | (roc_9_1h_gt_neg_30) | (roc_9_4h_lt_100))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_35) | (roc_9_4h_lt_20) | (roc_9_1d_lt_70))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_85) | (roc_9_1d_lt_80))
            # 1h down move, 1h high, 15m downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90) | (roc_9_15m > -10.0))
            # 1h down move, 1h  high & overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_40) | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_40) | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_200))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_60) | (roc_9_1d_gt_neg_70))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_60))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_60) | (roc_9_1h_lt_30))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 4h & 1d down move, 1d still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_30))
            # 4h down move, 4h high, 1h downtrend
            & ((rsi_3_4h_gt_3) | (aroonu_14_4h_lt_70) | (roc_9_1h_gt_neg_40))
            # 4h down move, 1h still high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_50))
            # 4h down move, 15m still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (aroonu_14_15m_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | roc_9_1d_gt_neg_50)
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_35))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_15) | (roc_9_1d > -35.0))
            # 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_40))
            # 4h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_70))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_200))
            # 4h down move, 15m & 1h high
            & ((rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_70) | (stochrsi_k_1h_lt_80))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_100))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_80))
            # 4h down move, 1d high, 1h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_1d_lt_100) | (roc_9_1h_gt_neg_40))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_200))
            # 4h down move, 4h still not low enough, 1d overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_20) | (roc_9_1d_lt_60))
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_60) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_55) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_50))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1h_lt_85) | roc_9_1d_lt_50)
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_15))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_25))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_10))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_50) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1d down move, 4h still high, 1d downtrend
            & ((rsi_3_1d_gt_3) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_25))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_10) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_40))
            # 1d down move, 4h high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_80))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_15) | (aroonu_14_1h_lt_90) | aroonu_14_4h_lt_100)
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (aroonu_14_1h_lt_100) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1h still high, 4h downtrend
            & ((rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_30))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m downtrend, 4h & 1d high
            & ((cmf_20_15m_gt_neg_0_30) | aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100)
            # 15m & 1h high, 1h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_50))
            # 15m & 1d high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h & 4h high, 1h downtrend
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (cmf_20_1h_gt_neg_0_30))
            # 1h high, 4h high, 1h overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_1h_lt_20))
            # 1h & 1d high, 1h overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_1d_lt_70) | (roc_9_1h_lt_20))
            # 1h high, 1d high & overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_200))
            # 1h high, 1h & 1d overbought
            & (aroonu_14_1h_lt_70 | (roc_9_1h_lt_20) | (roc_9_1d_lt_200))
            # 1h high, 4h downtrend, 1d overbought
            & (aroonu_14_1h_lt_70 | (roc_9_4h_gt_neg_40) | (roc_9_1d_lt_100))
            # 1h high, 1h & 1d overbought
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_20) | (roc_9_1d_lt_20))
            # 1h high, 1h overbought, 1d downtrend
            & (aroonu_14_1h_lt_80 | (roc_9_1h_lt_30) | (roc_9_1d_gt_neg_40))
            # 1h high, 4h & 1d overbought
            & (aroonu_14_1h_lt_80 | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1h high, 4h & 1d downtrend
            & ((aroonu_14_1h_lt_85) | (roc_9_4h_gt_neg_20) | roc_9_1d_gt_neg_50)
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_100) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_10))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h high, 4h & 1d overbought
            & (aroonu_14_4h_lt_80 | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 4h high, 15m downtrend, 4h overbought
            & (aroonu_14_4h_lt_100 | (roc_9_15m > -30.0) | (roc_9_4h_lt_30))
            # 4h high, 1h & 4h overbought
            & (aroonu_14_4h_lt_100 | (roc_9_1h_lt_30) | (roc_9_4h_lt_70))
            # 4h & 1d high, 1h overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_1h_lt_50))
            # 1d still high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_50) | (roc_9_4h_gt_neg_50) | roc_9_1d_gt_neg_50)
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 1d high, 4h downtrend, 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_25) | roc_9_1d_lt_50)
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 1h high, 1d overbought
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_lt_40))
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 1h high, 1h overbought, 4h downtrend
            & ((stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_gt_neg_15))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_50))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_4h_lt_100) | (roc_9_1d_lt_100))
            # 1d P&D, 4h overbought
            & ((change_pct_1d_gt_neg_10) | (change_pct_1d_shift_288 < 30.0) | (roc_9_4h_lt_10))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_gt_5) & (rsi_14 < 36.0) & (aroonu_14_lt_25) & (aroond_14_gt_75) & (ema_9 < (ema_26 * 0.960))
          )

        # Condition #42 - Quick mode (Long).
        if long_entry_condition_index == 42:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          # long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1h down move, 1d still high
            ((rsi_3_gt_3) | (rsi_3_1h_gt_3) | (stochrsi_k_1d_lt_40))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_25) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 4h high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h downtrend
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_3) | (roc_9_1h_gt_neg_50))
            # 15m & 1h down move, 1d still not low enough
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_5) | (stochrsi_k_1d_lt_30))
            # 15m & 1h down move, 4h still high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_50))
            # 15m & 1h down move, 1d high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_60))
            # 15m & 1h down move, 1h high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60))
            # 15m & 4h down move, 4h still high
            & (rsi_3_15m_gt_3 | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1d still high
            & (rsi_3_15m_gt_3 | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_40))
            # 15m & 1h down move, 1d downtrend
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_15) | (roc_9_1d > -30.0))
            # 15m down move, 4h still high, 1d downtrend
            & (rsi_3_15m_gt_3 | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | rsi_3_4h_gt_20)
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_15))
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 1h downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d > -30.0))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (roc_9_1d_gt_neg_30))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_10))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m & 1d down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_70))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_80))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_50))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_50) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (stochrsi_k_15m_lt_50))
            # 15m & 1h & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_50))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 15m & 4h & 1d down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_40))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_60))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_70))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70))
            # 15m & 1h & 4h down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1h still high, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_40))
            # 15m down move, 15m still not low enough, 1d downtrend
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_25) | (roc_9_1d_gt_neg_50))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_10))
            # 15m & 4h down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_30))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high, 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_3) | rsi_3_4h_gt_20 | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | rsi_3_4h_gt_20 | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_60))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_3) | (aroonu_14_1d_lt_70) | (roc_9_1h_gt_neg_50))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_25) | aroonu_14_1h_lt_70)
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_40))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_5) | (aroonu_14_1h_lt_50))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_75))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_40))
            # 1h & 4h & 1d down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1d_lt_50))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (rsi_14_1d_lt_50))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_70))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h downtrend, 1h high
            & ((rsi_3_1h_gt_10) | (cmf_20_1h_gt_neg_0_30) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_60) | aroonu_14_4h_lt_70)
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_40) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_10) | aroonu_14_4h_lt_70 | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 15m high
            & ((rsi_3_1h_gt_10) | (stochrsi_k_15m_lt_80))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (roc_9_1d_gt_neg_15))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_70))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 4h overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 1h & 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_80))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_60))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (roc_9_1d_lt_10))
            # 1h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 1h down move, 1h downtrend, 1h high
            & ((rsi_3_1h_gt_15) | (cmf_20_1h_gt_neg_0_30) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1d still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_50) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_15) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_60))
            # 1h & 4h down move, 15m still not low enough, 1d still not low enough
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1d_lt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_30))
            # 1h & 4h & 1d down move, 15m still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_15m_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h & 1d down move, 1h still high, 15m still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_50) | (stochrsi_k_15m_lt_50))
            # 1h & 4h & 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_85) | (roc_2_1d > -30.0))
            # 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_80))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_60))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_100))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_20))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_30))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_70))
            # 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_50))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_80))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_45) | (stochrsi_k_1d_lt_80))
            # 1h down move, 4h downtrend, 4h high
            & ((rsi_3_1h_gt_25) | (cmf_20_4h_gt_neg_0_50) | (aroonu_14_4h_lt_70))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_50))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_200))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (roc_9_1d_gt_neg_50))
            # 1h & 4h & 1d down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_50) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_15m_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_75))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_80))
            # 1h & 4h & 1d down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_80))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_50))
            # 1h down move, 1h still high, 1 & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_4h_lt_20))
            # 1h down move, 4h high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (cmf_20_4h_gt_neg_0_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_80))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_10) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_45) | (aroonu_14_15m_lt_90))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_90))
            # 1h down move, 15m high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_60) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | aroonu_14_4h_lt_100)
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | aroonu_14_1d_lt_100)
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_35) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_60) | roc_9_1d_gt_neg_50)
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_100))
            # 4h & 1d down move
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_60))
            # 4h down move, 1h downtrend, 4h still high
            & ((rsi_3_4h_gt_3) | (cmf_20_1h_gt_neg_0_30) | (aroonu_14_4h_lt_40))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_15) | (roc_9_4h_gt_neg_10))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_15) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_40))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_50))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_1h_gt_neg_15) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 15m still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (aroonu_14_15m_lt_30))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_15m_lt_40))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 1d down move, 15m still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_50))
            # 4h & 1d down move, 4d & 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d > 50.0) | (stochrsi_k_4h_lt_20))
            # 4h down move, 15m high, 1h downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_60) | (roc_9_1h_gt_neg_10))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_80))
            # 4h down move, 4h still not low e nough, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_40) | (aroonu_14_1d_lt_80))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (roc_9_1d > -30.0))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_40))
            # 15m & 1d down move, 15m high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_50))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (rsi_14_1d_lt_50))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_50))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_40) | roc_9_1d_gt_neg_50)
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_90) | (roc_9_1d > -30.0))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_70))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_40) | (roc_9_4h_gt_neg_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_80))
            # 4h & 1d down move, 15m high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_lt_80))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d > 50.0) | (stochrsi_k_1d_lt_90))
            # 4h down move, 15m high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_30))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_100))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_70))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_50))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_40))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_70))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_80) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_90))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_90))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h high, 1h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60) | (roc_9_1h_gt_neg_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_25) | aroonu_14_1d_lt_100 | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (roc_9_1d_lt_100))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_60) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1h_gt_neg_40))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_100))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_60))
            # 4h down move, 15m still high, 4h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_50) | aroonu_14_4h_lt_80)
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_1h_lt_70))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_80) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_35) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_50) | (roc_9_1d_lt_200))
            # 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (rsi_14_4h_lt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_150))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h overbought, 1d downtrend
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_60) | (roc_9_1d_lt_80))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h & 1d down move, 15m high, 1d high
            & ((rsi_3_4h_gt_50) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_80))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_55) | (roc_9_4h_lt_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1d still high
            & ((rsi_3_1d_gt_15) | (stochrsi_k_1d_lt_40))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 1d down move, 15m high
            & ((rsi_3_1d_gt_20) | (aroonu_14_15m_lt_80))
            # 1d down move, 4h high, 4h downtrend
            & ((rsi_3_1d_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_40))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1d down move, 4h & 1d high
            & ((rsi_3_1d_gt_30) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_90))
            # 1d down move, 15m still high, 1h high
            & ((rsi_3_1d_gt_40) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90))
            # 1h & 4h downtrend, 4h high
            & ((cmf_20_1h_gt_neg_0_40) | (cmf_20_4h_gt_neg_0_40) | aroonu_14_4h_lt_80)
            # 4h & 1d downtrend, 1d high
            & ((cmf_20_4h_gt_neg_0_50) | (cmf_20_1d_gt_neg_0_50) | (aroonu_14_1d_lt_85))
            # 15m & 1d high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 15m & 4h & 1d high
            & ((aroonu_14_15m_lt_80) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m & 4h high, 1d downtrend
            & ((aroonu_14_15m_lt_85) | (aroonu_14_4h_lt_85) | (roc_9_1d_gt_neg_20))
            # 1h still high, 1h & 4h downtrend
            & ((aroonu_14_1h_lt_50) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_30))
            # 1h & 4h high, 4h overbought
            & ((aroonu_14_1h_lt_80) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_10))
            # 4h high, 4h & 1d downtrend
            & ((aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_30))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_70) | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_70) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_80))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_70) | (roc_9_4h_lt_30) | (roc_9_1d_lt_200))
            # 1d high, 4h downtrend, 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_200))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_100) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 1d high, 1h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_1h_lt_10) | (roc_9_1d_lt_30))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 15m still high, 1h & 4h downtrend
            & ((stochrsi_k_15m_lt_50) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_20))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_30))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1d still high, 4h & 1d downtrend
            & ((stochrsi_k_1d_lt_50) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_30))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (willr_14 < -50.0)
            & (stochrsi_k_lt_20)
            & (willr_84_1h < -70.0)
            & (stochrsi_k_1h_lt_20)
            & (bbb_20_2_0_1h > 16.0)
            & (close_max_48 >= (close * 1.10))
          )

        # Condition #43 - Quick mode (Long).
        if long_entry_condition_index == 43:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          # long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 15m down move, 15m still high
            ((rsi_3_gt_3) | (rsi_3_15m_gt_5) | (aroonu_14_15m_lt_40))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_60))
            # 5m & 1h down move, 1h still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 1h down move, 1h still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_30))
            # 5m & 1h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_60))
            # 5m & 1d down move, 1d still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_30))
            # 5m down move, 1h & 4h high
            & ((rsi_3_gt_3) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 5m down move, 4h high & overbought
            & ((rsi_3_gt_3) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 5m down move, 1d high & overbought
            & ((rsi_3_gt_3) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 5m down move, 1h high, 4h overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 5m down move, 1d high & overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 5m & 1h down move, 1d overbought
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_100))
            # 5m & 1d down move, 1h high
            & ((rsi_3_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_90))
            # 5m & 1h down move, 1h high
            & ((rsi_3_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_10))
            # 15m & 1h & 1d down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_1d_gt_25))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70))
            # 15m & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_1d_lt_90))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (roc_9_1d > -30.0))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_100))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_200))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_50))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_60))
            # 15m & 1d down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_10) | (aroonu_14_1d_lt_40))
            # 15m & 1d down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_50))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_70))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_100))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_40))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 1h downtrend, 4h overbought
            & ((rsi_3_15m_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_lt_100))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_3) | (roc_9_4h_gt_neg_70) | (roc_9_1d_gt_neg_70))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_20))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_5) | rsi_3_1h_gt_20 | (stochrsi_k_1d_lt_50))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 1h downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_50))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_50))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 15m down move, 1d still high, 1d downtrend
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (roc_9_1d_gt_neg_60))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_5) | (roc_9_1h_lt_10) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_15m_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (roc_9_4h_gt_neg_20))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h & 1d down move, 1d still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_60) | (stochrsi_k_1h_lt_30))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_90))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (roc_9_4h_lt_20))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_70))
            # 15m & 1h & 1d down move, 1d still high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_50) | (roc_9_4h_gt_neg_20))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_60))
            # 15m & 1h & 4h & 1d down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (aroonu_14_1d_lt_90))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_90))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_40))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_90))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_50) | aroonu_14_4h_lt_70)
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_70))
            # 15m down move, 15m still high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_40) | (roc_9_1d_gt_neg_30))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_30))
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_80))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_60) | (roc_9_4h_gt_neg_10))
            # 15m down move, 15m high, 4h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_40))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 15m down move, 4h still high, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_50) | (roc_9_1d_lt_30))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_10) | (roc_9_4h_lt_10) | (roc_9_1d_lt_200))
            # 15m & 1h & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_100))
            # 15m & 4h down move, 4h still not low enough, 4h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70))
            # 15m down move. 15m still high, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_40))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_30))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_200))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_100))
            # 15m down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_30))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_25))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_40))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_30))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1h still high, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_lt_70))
            # 15m & 1h down move, 1h downtrend
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (roc_9_1h_gt_neg_30))
            # 15m & 4h down move, 15m & 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_60))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_70))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 1h down move, 1d high, 1h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_1h_gt_neg_40))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_5) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_60))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d > -30.0))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_70))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_50))
            # 1h down move, 15m downtrend, 1d high
            & ((rsi_3_1h_gt_10) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_60) | (roc_9_1d > -30.0))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_15))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | rsi_3_4h_gt_20 | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_70))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_30) | (roc_9_1d > -30.0))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # 1h & 4h & 1d  down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_75))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 1h down move, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_20) | (roc_9_4h_gt_neg_40) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_70))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_80))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_50))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_70))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_25) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_60))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 15m & 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h still high, 1h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_10))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_40))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_30) | (roc_9_1d_lt_200))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_90))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_50))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h down move, 1h & 4h high, 1h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_20))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_40))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_60) | (roc_9_1d_gt_neg_70))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_40))
            # 4h & 1d down move, 1h still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_30))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_3) | (aroonu_14_4h_lt_50))
            # 4h down move, 1h still high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_1h_gt_neg_10) | (roc_9_4h_gt_neg_10))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d  downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_10))
            # 4h down move, 1h still high
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h & 4h downtrend, 1d overbought
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_20))
            # 4h & 1d down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_30))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_90))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_60) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_15))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1h & 1d downtrend
            & ((rsi_3_1d_gt_5) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_30))
            # 1d down move, 4h high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_70))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_80))
            # 4h downtrend, 1h & 4h high
            & ((cmf_20_4h_gt_neg_0_30) | aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100)
            # 15m still high, 1h & 4h overbought
            & ((aroonu_14_15m_lt_50) | (roc_9_1h_lt_100) | (roc_9_4h_lt_100))
            # 15m & 1d high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h still high, 4h & 1d downtrend
            & ((aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h high, 1d downtrend
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_1d_gt_neg_20))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_1d_lt_20))
            # 1h & 1d high, 1d overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_200))
            # 1h high, 4h downtrend, 1d overbought
            & (aroonu_14_1h_lt_70 | (roc_9_4h_gt_neg_40) | (roc_9_1d_lt_100))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_4h_lt_100 | (roc_9_4h_lt_30))
            # 1h high, 1d downtrend
            & (aroonu_14_1h_lt_80 | (roc_9_1d_gt_neg_60))
            # 1h high, 1h & 4h overbought
            & ((aroonu_14_1h_lt_100) | (roc_9_1h_lt_100) | (roc_9_4h_lt_100))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_60) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_70))
            # 4h high, 1h & 4h overbought
            & ((aroonu_14_4h_lt_85) | (roc_9_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h high, 1h downtrend, 4h overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_1h_gt_neg_40) | (roc_9_4h_lt_100))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_90) | aroonu_14_1d_lt_100 | (roc_9_4h_lt_100))
            # 4h high, 1h & 4h overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_40))
            # 1d high, 1h & 4h downtrend
            & (aroonu_14_1d_lt_100 | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 1h high, 1d overbought
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_lt_40))
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 1h high, 4h & 1d downtrend
            & ((stochrsi_k_1h < 85.0) | (roc_9_4h_gt_neg_70) | (roc_9_1d_gt_neg_70))
            # 4h high, 4h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_70) | (roc_9_4h_lt_40) | (roc_9_1d_gt_neg_40))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_40) | (roc_9_4h_lt_100))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 1h & 4h overbought, 1d downtrend
            & ((roc_9_1h_lt_40) | (roc_9_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in last hour, 15m high
            & ((close > (close_max_12 * 0.60)) | (aroonu_14_15m_lt_70))
            # big drop in last hour, 4h high
            & ((close > (close_max_12 * 0.60)) | (aroonu_14_4h_lt_70))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_14 < 40.0)
            & (mfi_14 < 40.0)
            & (aroonu_14_lt_25)
            & (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.024))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
            & (close < (ema_20 * 0.960))
            & (close < (bbl_20_2_0 * 0.999))
          )

        # Condition #44 - Quick mode (Long).
        if long_entry_condition_index == 44:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          # long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1h & 4h down move
            ((rsi_3_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (aroonu_14_1h_lt_60))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_10))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (roc_9_1d_gt_neg_30))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 15m & 4h down move, 15m downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (roc_9_15m > -30.0))
            # 15m & 4h down move, 1h downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_40))
            # 15m down move, 1h still high, 1d overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_40) | (roc_9_1d_lt_70))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_100))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1h_lt_70))
            # 15m down move, 4h high, 15m downtrend
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_70) | (roc_9_15m > -30.0))
            # 15m & 1h & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (roc_9_1h_gt_neg_20))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 14m & 1h & 4h down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50))
            # 15m & 4h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # 15m down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (roc_9_4h_lt_30))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_75))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_90))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (aroonu_14_1h_lt_20))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_10))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (cmf_20_1h_gt_neg_0_40))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_60))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_60))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_60))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (rsi_14_1d_lt_40))
            # 1h & 4h down move, 1h & 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_40))
            # 1h & 1d down move, 15m & 1h downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_20) | (cmf_20_15m_gt_neg_0_35) | (cmf_20_1h_gt_neg_0_40))
            # 1h down move, 1h & 4h still high
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_50))
            # 1h down move, 1h still high, 1h downtrend
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_50) | (roc_9_1h_gt_neg_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_50) | (roc_9_1h_gt_neg_15))
            # 1h downtrend, 4h high
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_70))
            # 1h down move, 1h & 4h downtrend
            & ((rsi_3_1h_gt_3) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_20))
            # 1h & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (aroonu_14_4h_lt_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_90))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40))
            # 1h & 1d down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_5) | (roc_9_1d_gt_neg_20))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_60))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_70))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_5) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_25))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_5) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h & 4h & 1d down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1h_gt_neg_25))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 1h & 4h & 1d down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_20) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_70))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (aroonu_14_4h_lt_40))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_50))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 1h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_60) | (roc_9_1h_gt_neg_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_30))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_80))
            # 1h down move, 4h still high, 15m downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_50) | (cmf_20_15m_gt_neg_0_40))
            # 1h down move, 4h still high, 4h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_100))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_100))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_60))
            # 1h down move, 4h overbought
            & ((rsi_3_1h_gt_10) | (roc_9_4h_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_50))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_80))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_85))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | (roc_9_1d > -30.0))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | roc_9_1d_lt_50)
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 1h down move, 1h & 4h downtrend
            & ((rsi_3_1h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_15) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_15) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1h & 1d down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_50) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 1h high, 1h downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_1h_gt_neg_20))
            # 1h & 4h down move, 4h still high, 1h downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1h_gt_neg_25))
            # 1h & 4h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_80))
            # 1h & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_50) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_20) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_40))
            # 1h & 4h & 1d down move, 5h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_50))
            # 1h & 4h & 1d down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_70))
            # 1h & 4h down ove, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_80))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_80) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_100))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 1h downtrend, 4h overbought
            & ((rsi_3_1h_gt_25) | (roc_9_1h_gt_neg_20) | (roc_9_4h_lt_20))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_1d_lt_200))
            # 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_50))
            # 1h down move, 1h still high, 1h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_3) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 4h down move, 1d still high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1d_lt_50) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d overbought
            & ((rsi_3_4h_gt_3) | (roc_9_1d_lt_200))
            # 4h & 1d down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still not low enough, 1h & 4h downtrend
            & ((rsi_3_4h_gt_5) | (aroonu_14_4h_lt_30) | (roc_9_1h_gt_neg_15) | (roc_9_4h_gt_neg_15))
            # 4h down move, 1h still high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_1h_lt_40))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_1h_gt_neg_15) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_40))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_50))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_80))
            # 4h & 1d down move, 1h & 4h still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_30) | (stochrsi_k_4h_lt_30))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_50) | (stochrsi_k_1h_lt_90))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_25) | (roc_9_4h_gt_neg_50))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 4h still not low enough, 1d overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30) | (roc_9_1d_lt_50))
            # 4h down move, 4h still high, 1h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1h_gt_neg_25))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_40))
            # 15m down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 4h & 1d down move, 4h high, 1h downtrend
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_60) | (roc_9_1h_gt_neg_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 4h down move, 1h high & overbought
            & ((rsi_3_4h_gt_35) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_100))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_70))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_50) | (roc_9_4h_lt_60))
            # 1d down move, 1h & 1d downtrend
            & ((rsi_3_1d_gt_5) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_30))
            # 4h downtrend, 4h high
            & ((cmf_20_4h_gt_neg_0_50) | aroonu_14_4h_lt_70)
            # 1h & 1d high, 4h downtrend
            & ((aroonu_14_1h_lt_40) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h still high, 1h & 4h downtrend
            & ((aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_30))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_1d_lt_20))
            # 1h high, 4h & 1d downtrend
            & (aroonu_14_1h_lt_70 | (roc_9_4h_gt_neg_20) | roc_9_1d_gt_neg_50)
            # 1h high, 4h downtrend
            & (aroonu_14_1h_lt_70 | (roc_9_4h_gt_neg_40))
            # 1h & 1d high, 1d overbought
            & (aroonu_14_1h_lt_80 | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_80))
            # 1h & 1d high, 1h downtrend
            & (aroonu_14_1h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_1h_gt_neg_20))
            # 4h & 1d high, 1h downtrend
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_1h_gt_neg_30))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_40))
            # 4h high, 1h downtrend
            & (aroonu_14_4h_lt_80 | (roc_9_1h_gt_neg_40))
            # 4h high & overbought
            & (aroonu_14_4h_lt_80 | (roc_9_4h_lt_100))
            # 4h high, 1d downtrend
            & (aroonu_14_4h_lt_80 | (roc_9_1d > -30.0))
            # 1d still high, 1d downtrend
            & ((aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_30))
            # 1d high, 15m downtrend
            & ((aroonu_14_1d_lt_70) | (roc_9_15m > -50.0))
            # 1d high, 1h downtrend
            & ((aroonu_14_1d_lt_70) | (roc_9_1h > -70.0))
            # 1d high, 4h downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_70))
            # 1d high, 4h downtrend
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_40))
            # 1d high & overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_1d_lt_200))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1h still high, 4h & 1d downtrend
            & ((stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_20) | roc_9_1d_gt_neg_50)
            # 1h high, 15m downtrend
            & ((stochrsi_k_1h_lt_70) | (roc_9_15m > -30.0))
            # 4h high, 1d downtrend
            & ((stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_70))
            # 1d high, 1h downtrend
            & ((stochrsi_k_1d_lt_90) | (roc_9_1h_gt_neg_20))
            # 1d high, 1d downtrend
            & ((stochrsi_k_1d_lt_60) | (roc_9_1d_gt_neg_30))
            # 15m downtrend, 1d overbought
            & ((roc_9_15m > -60.0) | (roc_9_1d_lt_200))
            # 1h downtrend, 1d overbought
            & ((roc_9_1h > -60.0) | (roc_9_1d_lt_200))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_40)
            & (rsi_3_15m_lt_50)
            & (aroonu_14_15m_lt_25)
            & (stochrsi_k_15m_lt_20)
            & (ema_26_15m > ema_12_15m)
            & ((ema_26_15m - ema_12_15m) > (open_15m * 0.050))
            & ((ema_26_15m_shift_1 - ema_12_15m_shift_1) > (open_15m / 100.0))
          )

        # Condition #45 - Quick mode (Long).
        if long_entry_condition_index == 45:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 15m down move, 4h still high
            ((rsi_3_gt_3) | (rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_50))
            # 15m & 1h down move, 1h still high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 5m & 4h & 1d down move
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20))
            # 15m & 1h & 4h down move, 4h & 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_60))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10))
            # 15m & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_30) | (rsi_14_4h < 35.0))
            # 15m down move, 4h still high, 15m downtrend
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_40) | (cmf_20_15m_gt_neg_0_35))
            # 15m & 1h down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80))
            # 15m down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_30))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_5) | (aroonu_14_4h_lt_90))
            # 15m & 1h & 1d down move
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_1d_gt_10))
            # 15m & 1h & 1d down move, 1d still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_30))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 1h & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (stochrsi_k_1d_lt_80))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_30))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_60))
            # 15m & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80))
            # 15m & 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_65) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 15m & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_75) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (rsi_14_4h_lt_70) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_30))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_70) | (stochrsi_k_4h_lt_90))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_60))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (roc_9_1d_lt_80))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | aroonu_14_1h_lt_70)
            # 1h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_20))
            # 1h down move, 1h still not low enough
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_30))
            # 1h down move, 1h still not low enough
            & ((rsi_3_1h_gt_5) | (stochrsi_k_1h < 25.0))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | rsi_3_4h_gt_20 | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_60))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (aroonu_14_4h_lt_40))
            # 1h & 1d down move, 5m moving down
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (roc_2 > -0.0))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_50))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_70))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 1h & 4h & 1d down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h still not low enough, 1d high
            & ((rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_20) | (aroonu_14_1d_lt_85))
            # 1h down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (stochrsi_k_1h < 25.0))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_85))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_70))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_30))
            # 1h & 4h down move, 4h still high, 1h downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1h_gt_neg_25))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_85) | (roc_2_1d > -30.0))
            # 1h & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_50) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_30))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_90))
            # 1h down move, 4h still high
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_60))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_1d > 50.0) | (stochrsi_k_1h_lt_50))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_14_4h_lt_80))
            # 14 down move, 1h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80))
            # 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_50))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_5) | aroonu_14_1d_lt_100)
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50))
            # 4h downmove, 4h still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (rsi_14_1d_lt_50))
            # 4h down move, 1h still not low enough
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_80))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_90))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_25) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_70))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_80))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80))
            # 1d down move, 1h still not low enough
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_30))
            # 1d down move, 1h & 1d downtrend
            & ((rsi_3_1d_gt_5) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1h still not low enough
            & ((rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_30))
            # 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 1d down move, 4h still high
            & ((rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_50))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m still high, 1h & 4h high
            & ((rsi_14_15m_lt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_90))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 4h high, 1d overbought
            & (aroonu_14_4h_lt_70 | (roc_9_1d_lt_80))
            # 4h high, 1h & 1d downtrend
            & (aroonu_14_4h_lt_70 | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h high, 1h & 4h overbought
            & (aroonu_14_4h_lt_80 | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 4h high & overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_4h_lt_80))
            # 1d high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h high, 1h & 1d downtrend
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30) | (roc_9_1d_lt_30))
            # 1d top wick, 4h still high
            & ((top_wick_pct_1d < 40.0) | (aroonu_14_4h_lt_50))
            # pump, 4h still high
            & ((((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 2.0) | (stochrsi_k_4h_lt_50))
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 2.0)
              | (close > (high_max_6_4h * 0.75))
              | (close < (low_min_24_4h * 1.25))
            )
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_12_1d - low_min_12_1d) / low_min_12_1d) < 2.0)
              | (close > (high_max_24_4h * 0.70))
              | (close < (low_min_12_1d * 1.25))
            )
            # big drop in last hour
            & (close > (close_max_12 * 0.50))
            # big drop in last hour, 1d down move
            & ((close > (close_max_12 * 0.80)) | (rsi_3_1d_gt_15))
            # big drop in the last 12 hours, 4h still high
            & ((close > (high_max_12_1h * 0.50)) | (aroonu_14_4h_lt_50))
            # big drop in the last 6 days, 1h still high
            & ((close > (high_max_6_1d * 0.25)) | (aroonu_14_1h_lt_50))
            # big drop in the last 12 days, 1h down move
            & ((close > (high_max_12_1d * 0.45)) | (rsi_3_1h_gt_5))
            # big drop in the last 12 days, 4h down move
            & ((close > (high_max_12_1d * 0.40)) | (rsi_3_4h_gt_15))
            # big drop in the last 12 days, 1h still high
            & ((close > (high_max_12_1d * 0.25)) | (aroonu_14_1h_lt_75))
            # big drop in the last 20 days, 1h down move
            & ((close > (high_max_20_1d * 0.35)) | (rsi_3_1h_gt_10))
            # big drop in the last 20 days, 1h down move
            & ((close > (high_max_20_1d * 0.25)) | (rsi_3_1h_gt_15))
            # big drop in the last 20 days, 1h down move
            & ((close > (high_max_20_1d * 0.10)) | rsi_3_1h_gt_20)
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # big drop in the last 30 days, 4h down move, 4h still high
            & ((close > (high_max_30_1d * 0.25)) | (rsi_3_4h_gt_45) | (rsi_14_4h_lt_40))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_50) & (aroonu_14_15m_lt_25) & (stochrsi_k_15m_lt_20) & (close_15m < (ema_20_15m * 0.924))
          )

        # Condition #46 - Quick mode (Long).
        if long_entry_condition_index == 46:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1h down move
            ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 15m & 4h down move
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_30))
            # 15m & 1h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_14_4h_lt_30))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_40))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_50))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_60) | (rsi_3_4h_gt_65) | (rsi_3_1d_gt_65) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m down move, 4h still high, 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_90))
            # 15m & 1h & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_60) | (roc_9_1d_lt_20))
            # 15m & 1h & 4h down move, 1d high, 1h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_50) | (stochrsi_k_1d_lt_70) | (roc_9_1h_gt_neg_25))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_40))
            # 15m & 1h & 1d down move, 1h still not low enough, 1d high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (rsi_14_1h < 30.0) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 4h still high, 4h overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_4h_lt_10))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h & 4h still high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_40) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (aroonu_14_4h_lt_40))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_70))
            # 15m & 1h & 4h down move, 1h still high, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_80))
            # 15m & 1h & 4h down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_50) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 15m & 1h & 4h & 1d down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_60) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_85))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_15m < 15.0))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80))
            # 15m & 1d down move, 15m still high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_30) | (rsi_14_15m_lt_40) | (roc_9_1d_gt_neg_50))
            # 15m & 1h & 1d down move, 1h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h still not low enough, 1d high
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_20) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_30))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_70))
            # 1h down move, 1d still high
            & ((rsi_3_1h_gt_5) | (stochrsi_k_1d_lt_50))
            # 1h & 4h & 1d down move, 1d still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_35) | (stochrsi_k_1d_lt_30) | (stochrsi_k_1d_lt_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_14_4h_lt_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_30))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_40))
            # 1h & 1d down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_30))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_50))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_45) | (rsi_14_4h_lt_40))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_50))
            # 1h down move, 4h still high, 1d high
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_90))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 1d stll high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_14_1d_lt_40))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_50))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 1h & 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_14_1h_lt_40) | (rsi_14_4h_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_40))
            # 1h & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_60) | (roc_9_1d_lt_20))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_50))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40) | roc_9_1d_lt_50)
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_70))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_30) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_4h < 65.0))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_40) | (aroonu_14_1d_lt_90))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_25))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_50) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70))
            # 1h & 4h & 1d down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_40) | (aroonu_14_1d_lt_90))
            # 1h down move, 15m still not low enough, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_14_15m_lt_30) | (stochrsi_k_4h_lt_60))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_50))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_80))
            # 1h & 4h & 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_30))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_100) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_90))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_65) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 1h down move, 4h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_70) | (cmf_20_4h_gt_neg_0_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h & 1d down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_55) | (cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_80))
            # 1h & 1d down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_55) | (stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_50) | (roc_9_1h_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_1h_gt_neg_15) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d > 50.0) | (aroonu_14_1d_lt_90))
            # 4h down move, 4h & 1d still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_50))
            # 4h & 1d down move, 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (cmf_20_1d_gt_neg_0_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_50))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_50) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_20) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_90))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_60) | (stochrsi_k_1d_lt_90))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_40))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_40))
            # 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1h high, 1h overbought, 1d downtrend
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10) | (roc_9_1d_gt_neg_40))
            # 4h & 1d downtrend, 1h high
            & ((cmf_20_4h_gt_neg_0_20) | (cmf_20_1d_gt_neg_0_30) | (aroonu_14_1h_lt_70))
            # 4h & 1d downtrend, 1d high
            & ((cmf_20_4h_gt_neg_0_20) | (cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_70))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 4h high, 1h overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_1h_lt_40))
            # 4h high, 4h overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_4h_lt_40))
            # 4h high, 1h overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_lt_40))
            # 4h high, 4h overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_4h_lt_40))
            # 4h high, 4h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_20))
            # 1d green, 4h down move, 4h still high
            & ((change_pct_1d_lt_40) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_40))
            # 4h top wick, 1h down move, 1h still high
            & ((top_wick_pct_4h < 20.0) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_50))
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_6_1d - low_min_6_1d) / low_min_6_1d) < 2.0)
              | (close > (high_max_12_4h * 0.50))
              | (close < (low_min_24_4h * 1.05))
            )
            # 1d overbought, drop but not yet near the previous lows
            & (roc_9_1d_lt_50 | (close > (high_max_6_1d * 0.70)) | (close < (low_min_12_1d * 1.25)))
            # 1d overbought, drop but not yet near the previous lows
            & (
              (((high_max_12_1d - low_min_12_1d) / low_min_12_1d) < 2.5)
              | (close > (high_max_6_1d * 0.60))
              | (close < (low_min_12_1d * 1.25))
            )
            # big drop in the last 2 days, 1d down move
            & ((close > (high_max_12_4h * 0.30)) | (rsi_3_1d_gt_30))
            # big drop in the last 12 days, 1h down move
            & ((close > (high_max_12_1d * 0.30)) | rsi_3_1h_gt_20)
            # big drop in the last 12 days, 4h still high
            & ((close > (high_max_12_1d * 0.40)) | (stochrsi_k_4h_lt_50))
            # big drop in the last 20 days, 1h down move
            & ((close > (high_max_20_1d * 0.40)) | (rsi_3_1h_gt_10))
            # big drop in the last 20 days, 4h down move
            & ((close > (high_max_20_1d * 0.10)) | (rsi_3_4h_gt_25))
            # big drop in the last 30 days, 4h down move
            & ((close > (high_max_30_1d * 0.40)) | (rsi_3_4h_gt_15))
            # big drop in the last 30 days, 4h still not low enough
            & ((close > (high_max_30_1d * 0.25)) | (stochrsi_k_4h_lt_30))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_40)
            & (rsi_3_15m_lt_50)
            & (willr_14_15m < -50.0)
            & (aroonu_14_15m_lt_25)
            & (stochrsi_k_15m_lt_20)
            & (willr_84_1h < -70.0)
            & (stochrsi_k_1h_lt_20)
            & (bbb_20_2_0_1h > 12.0)
            & (close_max_48 >= (close * 1.10))
          )

        # Condition #47 - Trend Reversal mode (Long).
        if long_entry_condition_index == 47:
          # --- Protections ---
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            ((rsi_3 > 5.0) | (rsi_3_1h > 10.0) | (aroonu_14_1h < 30.0))
            & ((rsi_3 > 5.0) | (rsi_3_4h > 20.0) | (aroonu_14_4h < 40.0))
            & ((rsi_3_15m > 5.0) | (rsi_3_1h > 5.0) | (rsi_3_4h > 10.0))
            & ((rsi_3_15m > 10.0) | (rsi_3_1h > 25.0) | (aroonu_14_15m < 40.0))
            & ((rsi_3_1h > 5.0) | (aroonu_14_1h < 20.0))
            & ((rsi_3_1h > 10.0) | (rsi_3_4h > 15.0) | (rsi_14_4h < 40.0))
            & ((rsi_3_4h > 15.0) | (aroonu_14_4h < 50.0) | (roc_9_1d > -30.0))
            & ((roc_9_1d > -15.0) | (rsi_14_1h > 45.0))
            & ((roc_9_1d > -10.0) | (rsi_14_4h > 40.0) | (cmf_20_1h > 0.0))
            & ((rsi_14_1h > 40.0) | (bbp_20_2_0_4h > 0.20))
            & ((rsi_3_1h > 30.0) | (rsi_3_1d > 20.0) | (rsi_14_1h > 45.0))
            & ((cmf_20_1h > -0.10) | (cmf_20_4h > -0.10) | (rsi_14_1h > 50.0))
            & ((close > (close_min_48 * 1.02)) | (rsi_14_4h > 40.0) | (rsi_3_1h > 40.0))
            & ((willr_14_1h > -80.0) | (roc_9_1d > -8.0) | (cmf_20_4h > 0.0))
            ########################################################################################################
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_100))
            # 15m & 1h & 4h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_55) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_60) | (aroonu_14_15m_lt_100))
            # 15m & 1h down move, 1h high, 1d still high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_50))
            # 15m & 1h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_55) | (rsi_3_1h_gt_55) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_70))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_15m_lt_70))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_50))
            # 1h & 1d down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_65) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_30))
            # 1h & 1d down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 15m & 4h high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_50))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_100) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 4h & 1d high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h down move, 15m high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_90))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_50) | (stochrsi_k_15m_lt_80))
            # 1h & 4h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_80) | (stochrsi_k_1h_lt_60))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_90))
            # 1h & 1d down move, 15m high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_50) | (aroonu_14_15m_lt_100))
            # 1h down mov, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 4h & 1d down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_60))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_55) | (aroonu_14_1h_lt_80))
            # 1h & 1d down move, 15m high, 1h high
            & ((rsi_3_1h_gt_50) | (rsi_3_1d_gt_50) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (stochrsi_k_4h_lt_90))
            # 1h down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h down mov, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_40))
            # 1h & 4h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_55) | (rsi_3_4h_gt_65) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_80))
            # 1h & 1d down move, 1h & 1d high
            & ((rsi_3_1h_gt_55) | (rsi_3_1d_gt_55) | (stochrsi_k_1h_lt_70) | (stochrsi_k_1d_lt_80))
            # 1h & 1d down move, 4h high, 1d high
            & ((rsi_3_1h_gt_55) | (rsi_3_1d_gt_55) | (stochrsi_k_4h_lt_90) | (stochrsi_k_1d_lt_70))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_30))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1h & 4h overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h high, 4h high & overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90) | (stochrsi_k_1d_lt_90))
            # 1h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_100) | (stochrsi_k_4h_lt_70))
            # 1h & 4h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 4h & 1d high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 4h & 1d high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_70) | (stochrsi_k_1d_lt_70))
            # 1h & 4h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_90))
            # 1h down move, 15m high, 1d high
            & ((rsi_3_1h_gt_65) | (stochrsi_k_15m_lt_60) | (stochrsi_k_1d_lt_90))
            # 1h down move, 1h & 4h high, 1d high
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_30))
            # 1h down move, 1h still high, 4h high & overbought
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_40))
            # 1h & 1d down move, 1h high, 4h high & overbought
            & ((rsi_3_1h_gt_65) | (rsi_3_1d_gt_65) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h down move, 15m still high, 1h high, 1d high
            & ((rsi_3_1h_gt_65) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_65) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_15) | (aroonu_14_15m_lt_100))
            # 4h & 1d down move, 15m & 1h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 1h high, 15m still high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_80) | (stochrsi_k_15m_lt_40))
            # 4h & 1d down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_90))
            # 4h down move, 1h & 1d high
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_80) | (stochrsi_k_1d_lt_80))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_15))
            # 4h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_4h_gt_35) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 4h down mov, 15m high, 4h overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_15m_lt_80) | (roc_9_4h_lt_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_50))
            # 4h & 1d down move, 1h & 1d high
            & ((rsi_3_4h_gt_40) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80))
            # 4h down move, 15m high, 4h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_100) | (aroonu_14_4h_lt_70))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 4h down move, 4h high, 1d high
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_70) | (stochrsi_k_1d_lt_90))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_15))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_30))
            # 4h down mov, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_40))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_60) | (stochrsi_k_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 4h down move, 1h high, 4h overbought
            & ((rsi_3_4h_gt_65) | (aroonu_14_1h_lt_90) | (stochrsi_k_1h_lt_90) | (roc_9_4h_lt_15))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_65) | (aroonu_14_4h_lt_80) | (stochrsi_k_4h_lt_80))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_15) | (aroonu_14_1h_lt_70) | (stochrsi_k_1h_lt_70))
            # 1d down move, 1h high, 4h high
            & ((rsi_3_1d_gt_20) | (aroonu_14_1h_lt_80) | (stochrsi_k_4h_lt_70))
            # 1d down move, 1d downtrend, 1h high, 4h still high
            & ((rsi_3_1d_gt_30) | (cmf_20_1d_gt_neg_0_25) | (aroonu_14_1h_lt_80) | (stochrsi_k_4h_lt_40))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_90) | (stochrsi_k_1h_lt_90))
            # 1d down move, 15m high, 1d high
            & ((rsi_3_1d_gt_35) | (aroonu_14_15m_lt_100) | (stochrsi_k_1d_lt_70))
            # 1d down move, 1d high, 1h high
            & ((rsi_3_1d_gt_35) | (aroonu_14_1d_lt_70) | (stochrsi_k_1h_lt_80))
            # 1d down move, 15m high, 1d high
            & ((rsi_3_1d_gt_45) | (aroonu_14_15m_lt_60) | (stochrsi_k_1d_lt_80))
            # 1d down move, 1d downtrend, 1h high
            & ((rsi_3_1d_gt_50) | (cmf_20_1d_gt_neg_0_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_1h_lt_90))
            # 1d down move, 1h high, 1d high
            & ((rsi_3_1d_gt_55) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_70))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_65) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h downtrend, 4h high
            & ((cmf_20_1h_gt_neg_0_25) | (aroonu_14_4h_lt_80) | (stochrsi_k_4h_lt_70))
            # 15m still high, 1h high
            & ((aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90) | (stochrsi_k_1h_lt_80))
            # 15m & 4h high
            & ((aroonu_14_15m_lt_100) | (aroonu_14_4h_lt_100))
            # 15m high, 1h high
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_1h_lt_90))
            # 15m high, 4h high
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_4h_lt_70))
            # 1h high, 1h & 1d downtrend
            & ((aroonu_14_1h_lt_90) | (cmf_20_1h_gt_neg_0_30) | (cmf_20_1d_gt_neg_0_40))
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 4h & 1d high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
          )

          # --- Logic ---
          long_entry_logic.append(
            (rsi_14 > 40.0)
            & (rsi_14 < 65.0)
            & (rsi_14_15m > 35.0)
            & (rsi_14_1h > 35.0)
            & (rsi_14_1h < 60.0)
            & (aroonu_14 > 50.0)
            & (aroonu_14_15m > 25.0)
            & (stochrsi_k > 20.0)
            & (stochrsi_k < 80.0)
            & (roc_9_1d > -25.0)
            & (obv_change_pct > 0.0)
            & (ema_12 > ema_26)
            & (np_shift(ema_12, 3) < np_shift(ema_26, 3))
            & (ema_12_4h < ema_200_4h)
            & (close > close_min_48)
            & (close < (close_max_48 * 0.97))
          )

        # Condition #61 - Rebuy mode (Long).
        if long_entry_condition_index == 61:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1h down move, 1h still not low enough
            ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 1h down move, 1d high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_25) | aroonu_14_4h_lt_70)
            # 5m down move, 1d high & overbought
            & ((rsi_3_gt_3) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 5m down move, 1d high & overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 5m & 1h & 4h down move
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_5))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_10))
            # 15m & 1h & 4h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (stochrsi_k_4h_lt_20))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_3))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 4h downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (cmf_20_4h_gt_neg_0_30))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_50))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_40) | (rsi_14_4h_lt_40))
            # 15m down move, 15m downtrend. 4h high
            & ((rsi_3_15m_gt_3) | (cmf_20_15m_gt_neg_0_50) | (aroonu_14_4h_lt_60))
            # 15m down move, 15m still not low enough
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_30))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_80))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_3) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_40))
            # 15m & 1h & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 1h downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 15m & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (roc_9_1d_lt_70))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m still low, 4h still high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_20) | (aroonu_14_4h_lt_50))
            # 15m down move, 15m still high
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_50))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_5) | (roc_9_1h_lt_10) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_50))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_60) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 1h high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_30))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_55) | (roc_9_4h_lt_50))
            # 15m down move, 15m still not low enough, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_30) | (roc_9_1d_gt_neg_30))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_30))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_100))
            # 15m down move, 1d high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_85) | (cmf_20_1d_gt_neg_0_40))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_20))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_70))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_10) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 4h still high, 1d still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (stochrsi_k_1d_lt_50))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_80))
            # 15m & 1h & 4h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 15m still high, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80))
            # 15m & 4h down move, 15m still high, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_80))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_40))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_15) | (roc_9_1h_lt_20) | (roc_9_4h_lt_40))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (roc_9_4h_lt_20) | (roc_9_1d_lt_60))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_80))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_90))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_20) | (stochrsi_k_4h_lt_90))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 15m still high, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 15m high, 1d high & overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_80))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_20))
            # 15m & 1h & 4h down move, 1d high, 4h still not low enough
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (stochrsi_k_4h_lt_30))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | aroonu_14_4h_lt_100)
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_60) | (stochrsi_k_4h_lt_70))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_5) | (stochrsi_k_4h_lt_20))
            # 1h & 4h down move, 15m stil high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h down move, 1h still not low enough
            & ((rsi_3_1h_gt_3) | (aroonu_14_1h_lt_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_70))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_10))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_100) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_20))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_15m > -15.0))
            # 1h & 3h down move, 4h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 15m still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_40) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_80))
            # 1h down move, 15m still high, 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_90))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_100))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_10))
            # 1h down move, 4h still high, 4d downtrend
            & ((rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_50) | roc_9_1d_gt_neg_50)
            # 1h down move, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_10) | (roc_9_1d_lt_40))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 1h down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_15) | (cmf_20_1d_gt_neg_0_30) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_50))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1d high & overbought, 1h downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_200) | (roc_9_1h_gt_neg_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_75))
            # 1h & 4h down move, 4h high, 1h downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_1h_gt_neg_40))
            # 1h & 4h down move, 15m & 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h still high, 1h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_80) | (roc_9_4h_gt_neg_40))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_200))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_35) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_85) | (roc_9_1d_lt_80))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h downtrend, 1h & 4h high
            & ((rsi_3_1h_gt_50) | (cmf_20_1h_gt_neg_0_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_25))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_40))
            # 4h & 1d down move, 1h still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_30))
            # 4h & 1d down move, 1d still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_30))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_3) | (aroonu_14_1d_lt_90))
            # 4h down move, 1h still high, 4h downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1d_lt_90))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d overbought
            & ((rsi_3_4h_gt_3) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40))
            # 4h down move, 4h downtrend, 4h still high
            & ((rsi_3_4h_gt_5) | (cmf_20_4h_gt_neg_0_20) | (aroonu_14_4h_lt_40))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h down move, 4h high, 1h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_1h_gt_neg_20))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_15) | aroonu_14_4h_lt_70 | (aroonu_14_1d_lt_70))
            # 4h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | roc_9_1d_lt_50)
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_30) | aroonu_14_4h_lt_80 | roc_9_1d_lt_50)
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1h_lt_85) | roc_9_1d_lt_50)
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_10))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1h still high, 1d downtrend
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_10) | aroonu_14_1h_lt_80 | (roc_9_1d_gt_neg_10))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_40))
            # 1d down move, 1h still low, 4h high, 4h downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_70) | (roc_9_4h_gt_neg_10))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_100))
            # 15m high, 1h high & overbought
            & ((aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_85) | (roc_9_1h_lt_10))
            # 1h high, 4h high, 1h overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_1h_lt_20))
            # 1h & 1d high, 1h overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_1d_lt_70) | (roc_9_1h_lt_20))
            # 1h & 4h high, 1d downtrend
            & ((aroonu_14_1h_lt_85) | aroonu_14_4h_lt_100 | (roc_9_1d_gt_neg_80))
            # 4h still high, 5m downtrend
            & ((aroonu_14_4h_lt_40) | (roc_9 > -40.0))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | roc_9_1d_lt_50)
            # 4h high, 4h & 1d overbought
            & (aroonu_14_4h_lt_80 | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 1d high, 1h & 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_lt_20) | (roc_9_1d_lt_100))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 1h high, 1d overbought
            & ((stochrsi_k_1h_lt_70) | (roc_9_1d_lt_40))
            # 4h high, 1h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_40) | (roc_9_1d_gt_neg_70))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_50))
            # 1h & 4h overbought
            & ((roc_9_1h_lt_100) | (roc_9_4h_lt_100))
            # 5m red, 1h & 4h down move
            & ((change_pct > -5.0) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_5))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_50)
            & (aroonu_14_lt_25)
            & (stochrsi_k_lt_30)
            & (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.030))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
          )

        # Condition #62 - Rebuy mode (Long).
        if long_entry_condition_index == 62:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 4h down move, 1d high
            ((rsi_3_gt_3) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_90))
            # 5m & 1d down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_40))
            # 5m & 1h down move, 1d high & overbought
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_5) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_20))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50))
            # 5m & 4h down move, 4h still not low enough
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_20))
            # 15m & 1h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_14_4h_lt_30))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_14_4h_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_3) | (aroonu_14_4h_lt_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_20))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (stochrsi_k_15m_lt_20))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_40))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_70))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_30))
            # 15m & 4h down move, 1h downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40))
            # 15m & 1h & 4h down move, 1h still not low enough, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_14_1h_lt_30) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_15m_lt_70))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 15m & 1h & 4h & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_60))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_70))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (cmf_20_4h_gt_neg_0_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (roc_9_1d_lt_200))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_75))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_1d_gt_neg_25))
            # 15m & 1h & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_4h_lt_30))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_75))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (stochrsi_k_4h_lt_40))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_90))
            # 15m & 1h & 1d down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_40))
            # 15m down move, 15m downtrend, 4h high
            & ((rsi_3_15m_gt_15) | (cmf_20_15m_gt_neg_0_30) | (aroonu_14_4h_lt_50))
            # 15m down move, 15m still high, 4h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40) | (roc_9_4h_lt_40))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 4h down move, 1h downtrend, 15m still not low enough
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (cmf_20_1h_gt_neg_0_40) | (stochrsi_k_15m_lt_30))
            # 15m & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 15m down move, 15m still not low enough, 1d overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_15m_lt_30) | (roc_9_1d_lt_80))
            # 15m & 1h & 4h & 1d down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_60) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 15m stil high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_40))
            # 15m down move, 15m still not low enough, 1d downtrend
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_25) | (roc_9_1d_gt_neg_50))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m & 1h & 4h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50))
            # 15m & 1h & 1d down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | (rsi_3_1d_gt_50) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 15m & 1h & 1d down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | (rsi_3_1d_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 1h high, 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_50) | aroonu_14_4h_lt_70)
            # 1h down move, 15m still not low enough
            & ((rsi_3_1h_gt_3) | (stochrsi_k_15m_lt_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_20))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (rsi_14_4h_lt_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_40))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_60))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_lt_10))
            # 1h & 4h & 1d down move, 4h still high, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40) | (stochrsi_k_1d_lt_50))
            # 1h & 4h & 1d down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_40))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_30))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_100))
            # 1h& 1d down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_80))
            # 1h & 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_10))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_14_1d_lt_60))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_70))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_90))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (roc_9_1d_gt_neg_40))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_80))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 4h & 1d still not low enough, 15m still not low enough
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_14_4h_lt_30) | (rsi_14_1d < 30.0) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_70))
            # 1h & 4h & 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_85) | (roc_2_1d > -30.0))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_70))
            # 1h & 4h down move, 4h overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_80))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_85))
            # 1h down move, 1h still not low enough, 4h stil high
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_20) | (aroonu_14_4h_lt_40))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_20))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | roc_9_1d_lt_50)
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_60))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_60) | aroonu_14_1d_lt_100)
            # 1h down move, 4h high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_70) | (cmf_20_4h_gt_neg_0_50))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 15m still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_15m_lt_50) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_100))
            # 1h & dh down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_85))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (roc_9_4h_gt_neg_25) | (roc_9_1d_gt_neg_60))
            # 1h down move, 4h & 1h overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 1h down move, 4h high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (cmf_20_4h_gt_neg_0_40))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_80))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_10) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_40))
            # 1h & 4h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_80))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_30))
            # 1h & 1d down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_55) | (stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_100))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_50) | (roc_9_1h_lt_40))
            # 1h & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_50))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_60) | (roc_9_4h_lt_30) | (roc_9_1d_lt_100))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_40))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_4h_lt_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_5) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_5) | (aroonu_14_4h_lt_60))
            # 4h & 1d down move, 1d still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_30))
            # 4h & 1d down move, 1h & 4h & 1d downtrend
            & (
              (rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (roc_9_1h_gt_neg_10) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_25)
            )
            # 4h down move, 15m still high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_40))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (roc_9_1d_gt_neg_15))
            # 4h down move, 1h downtrend, 1d downtrend
            & ((rsi_3_4h_gt_15) | (cmf_20_1h_gt_neg_0_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_100))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 4h down move, 15m still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_40))
            # 4h down move, 15m high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 4h & 1d high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h down move, 15m high, 4h high
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (cmf_20_4h_gt_neg_0_40))
            # 4h down move, 4h high, 1d high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 4h down move, 4h still not low enough, 1d overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_20) | (roc_9_1d_lt_40))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_1h_lt_70))
            # 4h down move, 1d high, 1d overbought, 4h downtrend
            & ((rsi_3_4h_gt_40) | (rsi_14_1d_lt_70) | (roc_9_1d_lt_200) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (rsi_14_4h_lt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_150))
            # 4h down move, 15m & 4h still high
            & ((rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_50))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_200))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_100))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_55) | (roc_9_4h_lt_30))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_40))
            # 1d down move, 4h high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_50))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 1d down move, 15m still high, 1h high
            & ((rsi_3_1d_gt_40) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90))
            # 4h & 1d downtrend, 1d high
            & ((cmf_20_4h_gt_neg_0_50) | (cmf_20_1d_gt_neg_0_50) | (aroonu_14_1d_lt_85))
            # 4h still not low enough, 4h & 1d downtrend
            & ((aroonu_14_4h_lt_30) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_25))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_70 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_70 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_80))
            # 4h high, 1h & 4h overbought
            & (aroonu_14_4h_lt_80 | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 1d high, 4h downtrend, 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_200))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_lt_40) | (roc_9_4h_lt_40))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1d green, 4h down move, 4h still high
            & ((change_pct_1d_lt_40) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_40))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_40)
            & (aroonu_14_lt_30)
            & (stochrsi_k_lt_20)
            & (stochrsi_k_15m_lt_70)
            & (willr_84_1h < -70.0)
            & (stochrsi_k_1h_lt_30)
            & (bbb_20_2_0_1h > 12.0)
            & (close_max_48 >= (close * 1.10))
          )

        # Condition #63 - Rebuy mode (Long).
        if long_entry_condition_index == 63:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            (rsi_3_15m_gt_5)
            # 5m & 1h down move, 1h still not low enough
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 1d down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_15) | (cmf_20_1d_gt_neg_0_25))
            # 5m down move, 1h high, 4h overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 5m down move, 1d high & overbought
            & ((rsi_3_gt_3) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50))
            # 15m & 1h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_50))
            # 15m & 1h down move 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_4h_lt_10))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_90))
            # 15m & 1d down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_80))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (aroonu_14_1d_lt_70))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_75))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | aroonu_14_4h_lt_80)
            # 15m down move, 1h still high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_60))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_60))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_10))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70))
            # 15m & 4h & 1h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_15m_lt_60))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_60))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_100))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (stochrsi_k_4h_lt_80))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_75) | (aroonu_14_1d_lt_100))
            # 15m down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1h_lt_50))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (roc_9_4h_lt_20) | (roc_9_1d_lt_60))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_85))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_75))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_80))
            # 15m down move, 15m high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (roc_9_1d_gt_neg_25))
            # 15m down move, 15m high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_15m_lt_60) | (roc_9_4h_gt_neg_50))
            # 15m down move, 4h overbought
            & ((rsi_3_15m_gt_20) | (roc_9_4h_lt_40))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_60))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_lt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_70))
            # 15m & 1h & 4h down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (roc_9_1d_lt_80))
            # 15m & 1h & 4h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (stochrsi_k_15m_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_60))
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_25) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m downtrend, 4h high
            & ((rsi_3_15m_gt_30) | (cmf_20_15m_gt_neg_0_30) | (aroonu_14_4h_lt_100))
            # 15m down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_50) | (stochrsi_k_1d_lt_70))
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_60) | (stochrsi_k_4h_lt_70))
            # 15m down move, 4h high, 1h downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_85) | (roc_9_1h_gt_neg_40))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_30) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_45) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m still high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_40) | (roc_9_4h_lt_20))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_40) | (roc_9_1d_lt_30))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_20))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_35) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_40) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m still high, 4h high
            & ((rsi_3_15m < 40.0) | (aroonu_14_4h_lt_85))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h > 2.0) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_30))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (roc_9_15m > -30.0))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_40))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 4h stil high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (rsi_14_4h_lt_40))
            # 1h ^ 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_50))
            # 1h & 4h & 1d down mnove, 15m still high, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_15m_lt_40) | (stochrsi_k_1d_lt_50))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_40))
            # 1h & 1d down move, 1h downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_15) | (roc_9_1h_gt_neg_40))
            # 1h down move, 15m downtrend, 1h still high
            & ((rsi_3_1h_gt_3) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1h_lt_40))
            # 1h down move, 15m still not low enough, 4h still high
            & ((rsi_3_1h_gt_3) | (aroonu_14_15m_lt_30) | (stochrsi_k_4h_lt_40))
            # 1h down move, 1h still not low enough
            & ((rsi_3_1h_gt_3) | (stochrsi_k_1h_lt_30))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_3) | (stochrsi_k_4h_lt_70))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_1d_lt_60))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_20))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30))
            # 1h & 4h & 1d down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (rsi_14_4h_lt_30) | (roc_9_1d_gt_neg_30))
            # 1g & 4h & 1d down move, 1h still not low enough, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_30) | (stochrsi_k_1d_lt_50))
            # 15m & 4h down move, 4h still not low enough, 15m still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_20) | (stochrsi_k_15m_lt_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_40) | (stochrsi_k_1d_lt_90))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_30))
            # 1h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (roc_9_4h_gt_neg_20))
            # 1h, 1d downtrend
            & ((rsi_3_1h_gt_5) | (roc_9_1d_gt_neg_50))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_14_4h_lt_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_30))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_20))
            # & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_70))
            # 1h & 4h & 1d down move, 1d still high, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_50) | (roc_9_1d_lt_40))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_40))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_70))
            # 1h & 1d downtrend, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 1h down move, 1h downtrend, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (cmf_20_1h_gt_neg_0_20) | (aroonu_14_1h_lt_30))
            # 1h down move, 1h downtrend, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (cmf_20_1h_gt_neg_0_20) | (stochrsi_k_1h_lt_30))
            # 1h down move, 1h downtrend
            & ((rsi_3_1h_gt_10) | (cmf_20_1h_gt_neg_0_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_20))
            # 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_10))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (roc_9_1d_lt_100))
            # 1h & 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_10))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_30))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_15m < 90.0))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down mov, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_100))
            # 1h & 4h & 1d down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h & 1d down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_25))
            # 1h down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_15) | (cmf_20_1d_gt_neg_0_30) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_40))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_70))
            # 1h & 4h & 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_85) | (roc_2_1d > -30.0))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_60))
            # 1h & 1d down move, 1h & 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_70))
            # 1h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 4h still high
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_40))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_25))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 1d high, 4h downtrend, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 1d downtrend, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_85))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_50) | (roc_9_1d_lt_100))
            # 1h & 1d down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h still not low enough, 4h still high
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_30) | (stochrsi_k_4h_lt_50))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1h still high, 1h downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_50))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_70))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_60))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | aroonu_14_1h_lt_70)
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h still high, 1h & 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40) | (roc_9_1h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_30))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80))
            # 1h down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_200))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_90) | (roc_9_4h_gt_neg_40))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_80))
            # 1h down move, 1h & 4h still high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_50))
            # 1h down move, 1h highm 1d overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_60) | (roc_9_1d_lt_30))
            # 1h down move, 4h overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_50))
            # 1h & 4h & 1d down move, 1h & 4h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_50))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_40))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_25))
            # 1h down move, 1h still high, 4h & 1d downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_70))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_85) | (roc_9_4h_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_200))
            # 1h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_14_1d_lt_80) | (roc_9_1d_lt_150))
            # 1h down move, 15m high, 1h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_80))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_40) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (roc_9_1d_lt_200))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_40))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_100))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_60))
            # 1h down move, 15m high, 1h high
            & ((rsi_3_1h_gt_55) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_80))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_10))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_4h_lt_20))
            # 4h down move, 1h still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1h_lt_20) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 1h downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (roc_9_1h_gt_neg_50))
            # 4h & 1d down move, 1d still high, 4h downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_5) | (aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1h still high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_1h_lt_50))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (stochrsi_k_4h_lt_40))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_20))
            # 4h down move, 15m high, 15m downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_60) | (roc_9_15m > -10.0))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_70))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h downtrend, 1d overbought
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_30) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_50) | (roc_9_1d > -30.0))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_10))
            # 4h down move, 15m still high
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m < 45.0))
            # 4h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_1h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 4h down move, 15m still high, 4h high
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_70))
            # 4h down move, 1h & 4h still high
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_40))
            # 4h dowqn move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_50))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1d downtrend
            & ((rsi_3_4h_gt_30) | (roc_9_1d_gt_neg_50))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_80))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_20))
            # 1d down move, 1h & 4h still not low enough
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_20) | (stochrsi_k_4h_lt_20))
            # 1d down move, 1h & 1d high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_10))
            # 15m down move, 1h high, 4h & 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_50))
            # 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_1d_gt_15) | (stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 1d down move, 1h still low, 4h high, 4h downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_70) | (roc_9_4h_gt_neg_10))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_60))
            # 1d down move, 1h & 4h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_80) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 1d down move, 4h high, 1d downtrend
            & ((rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_60))
            # 1d down move, 1h high, 1h overbought, 1d downtrend
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_10) | (roc_9_1d_gt_neg_40))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_80))
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_45) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_30))
            # 1h downtrend, 1h high
            & ((cmf_20_1h_gt_neg_0_20) | aroonu_14_1h_lt_80)
            # 4h & 1d downtrend, 1d high
            & ((cmf_20_4h_gt_neg_0_30) | (cmf_20_1d_gt_neg_0_30) | (stochrsi_k_1d_lt_60))
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_100))
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_40) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_20))
            # 15m still high, 1h overbought
            & ((aroonu_14_15m_lt_40) | (roc_9_1h_lt_40))
            # 15m still high, 4h overbought
            & ((aroonu_14_15m_lt_40) | (roc_9_4h_lt_80))
            # 15m still high, 1h high
            & ((aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 15m still high, 4h high & overbought
            & ((aroonu_14_15m_lt_50) | aroonu_14_4h_lt_70 | (roc_9_4h_lt_30))
            # 15m still high, 4h downtrend, 1d overbought
            & ((aroonu_14_15m_lt_50) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_40))
            # 1h still high, 4h & 1d downtrend
            & ((aroonu_14_1h_lt_40) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 1h high, 4h high, 1h overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_1h_lt_20))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_70 | aroonu_14_4h_lt_100 | (roc_9_4h_lt_40))
            # 1h & 1d high, 1h overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_1d_lt_70) | (roc_9_1h_lt_20))
            # 1h high, 1h & 4h overbought
            & (aroonu_14_1h_lt_70 | (roc_9_1h_lt_10) | (roc_9_4h_lt_40))
            # 1h high, 1d downtrend
            & (aroonu_14_1h_lt_80 | (roc_9_1d_gt_neg_40))
            # 4h still not low enough, 4h & 1d downtrend
            & ((aroonu_14_4h_lt_30) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_25))
            # 4h still high, 1d high, 4h downtrend
            & ((aroonu_14_4h_lt_50) | aroonu_14_1d_lt_100 | (roc_9_4h_gt_neg_30))
            # 4h high, 1h & 1d downtrend
            & (aroonu_14_4h_lt_70 | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | roc_9_1d_lt_50)
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_10))
            # 4h high, 1h & 4h overbought
            & (aroonu_14_4h_lt_100 | (roc_9_1h_lt_10) | (roc_9_4h_lt_40))
            # 1d high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_80) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1d high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_50))
            # 1d high, 1h & 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_1h_lt_20) | (roc_9_1d_lt_100))
            # 1d high, 1h & 4h down move
            & (aroonu_14_1d_lt_100 | (roc_9_1h_lt_25) | (roc_9_4h_lt_60))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_20) | (roc_9_1d_lt_30))
            # 1h high, 4h & 1d overbought
            & ((stochrsi_k_1h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 4h still high, 4h & 1d downtrend
            & ((stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 4h high, 1h & 1d downtrend
            & ((stochrsi_k_4h_lt_70) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_4h_lt_20) | (roc_9_1d_lt_30))
            # 4h high, 1h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_40) | (roc_9_1d_gt_neg_70))
            # 4h high, 4h overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_50))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
            # 1h & 4h overbought
            & ((roc_9_1h_lt_30) | (roc_9_4h_lt_80))
            # 1d green with top wick, 4h high
            & ((change_pct_1d_lt_30) | (top_wick_pct_1d_lt_20) | aroonu_14_4h_lt_80)
            # 1d top wick, 4h down move, 1d overbought
            & ((top_wick_pct_1d_lt_50) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_60))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # drop in last 20 days, 4h high
            & ((close > (high_max_20_1d * 0.10)) | (stochrsi_k_4h_lt_90))
            # drop in last 20 days, 1h high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | aroonu_14_1h_lt_70 | (roc_9_1d_gt_neg_70))
            # drop in last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3 > 0.0)
            & (rsi_3_lt_50)
            & (aroonu_14_lt_25)
            & (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.022))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
          )

        # Condition #64 - Trend Pullback mode (Long).
        if long_entry_condition_index == 64:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          long_entry_logic.append(
            # Trend confirmation (higher TF must be bullish)
            (ema_12_4h > ema_200_4h)
            # 15m & 1h down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_50) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 1h & 4h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_65) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_65) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 4h high, 1d high, 4h overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 1h & 4h high & overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 15m down move, 4h & 1d high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m down move. 1d high, 4h overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 4h high, 1h & 4h overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 15m & 1h & 1d down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_4h_lt_100))
            # 15m & 1h & 1d down move, 4h & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (rsi_3_1d_gt_65) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1h still high, 4h & 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_40) | (roc_9_4h_lt_50) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 4h high, 1h & 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_55) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20) | (roc_9_1d_lt_40))
            # 15m & 1d down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m still not low enough, 4h high, 1d overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_20))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h high, 1d high, 4h overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_80))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_80))
            # 15m & 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_65) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_45) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1d downtrend, 1d overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_50) | (cmf_20_1d_gt_neg_0_10) | (roc_9_1d_lt_50))
            # 15m & 1h & 1d down move, 15m still high, 1d high
            & (
              (rsi_3_15m_gt_35) | (rsi_3_1h_gt_55) | (rsi_3_1d_gt_65) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1d_lt_80)
            )
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_55) | (aroonu_14_1h_lt_75) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1h & 4h high, 1h overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_75) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 15m & 1h down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_65) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_65) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_65) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100))
            # 15m & 4h down move, 1h & 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_10))
            # 15m & 1d down move, 1d still high, 4h high, 1h overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1d_gt_35) | (rsi_14_1d_lt_50) | (aroonu_14_4h_lt_80) | (roc_9_1h_lt_10))
            # 15m & 4h down move, 15m still high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_65) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_20))
            # 15m down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_35) | (stochrsi_k_4h_lt_70) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_30))
            # 15m down move, 1h & 1d overbought
            & ((rsi_3_15m_gt_40) | (roc_9_1h_lt_20) | (roc_9_1d_lt_100))
            # 15m & 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_65) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_55) | (aroonu_14_1h_lt_70) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_60) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1h still high, 1d high & overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_65) | (rsi_14_1h_lt_50) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_65) | (stochrsi_k_1d_lt_80) | (roc_9_4h_lt_50) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 15m down move, 4h downtrend, 4h high & overbought
            & ((rsi_3_15m_gt_40) | (cmf_20_4h_gt_neg_0_10) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 15m still high
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_50))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h & 4h high, 4h overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 15m down move, 1h & 4h high, 1d overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_10))
            # 15m down move, 4h & 1d high, 4h overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_50))
            # 15m down move, 4h & 1d high, 4h overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 4h high, 1h & 4h overbought
            & ((rsi_3_15m_gt_40) | (rsi_14_4h_lt_70) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 15m down move, 1h high, 1d high & overbought
            & ((rsi_3_15m_gt_40) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 1h & 4h & 1d high
            & ((rsi_3_15m_gt_40) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_70) | (stochrsi_k_1d_lt_70))
            # 15m down move, 4h high, 1h & 4h overbought
            & ((rsi_3_15m_gt_40) | (stochrsi_k_4h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 15m down move, 1d high & overbought\
            & ((rsi_3_15m_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_80))
            # 15m & 1h & 4h down move, 15m & 4h high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_55) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80))
            # 15m & 1h & 1d down move, 15m high, 1h high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_45) | (rsi_3_1d_gt_50) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_45) | (aroonu_14_15m_lt_60) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m & 1h down move, 15m & 4h high, 1d overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 15m still high, 4h high & overbought
            & (
              (rsi_3_15m_gt_45) | (rsi_3_1h_gt_45) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10)
            )
            # 15m & 1h down move, 15m high, 4h high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_55) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1h high, 4h high, 4h overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_55) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_4h_lt_10))
            # 15m & 1h & 1d down move, 15m high, 1h high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 1h high, 4h high & overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_40))
            # 15m & 1h down move, 15m & 1h still high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_60) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 1h & 4h & 1d overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_65) | (roc_9_1h_lt_20) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 15m & 4h high
            & ((rsi_3_15m_gt_45) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70))
            # 15m & 1d down move, 15m & 4h high
            & ((rsi_3_15m_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_45) | (rsi_3_1d_gt_50) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_20))
            # 15m & 1d down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_45) | (rsi_3_1d_gt_65) | (aroonu_14_15m_lt_40) | (aroonu_14_1d_lt_100))
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m high, 4h high & overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_25))
            # 15m down move, 15m & 4h high, 1d high
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_100) | (stochrsi_k_1d_lt_90))
            # 15m down move, 15m & 1h & 4h high
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m down move, 15m high, 4h high & overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 15m high, 1d high & overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_80) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m down move, 1h & 4h high, 1d overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_20))
            # 15m down move, 4h & 1d high, 4h overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 1h still high, 4h high, 4h overbought
            & ((rsi_3_15m_gt_45) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m down move, 1h & 4h high, 1d overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_30))
            # 15m down move, 1h still high, 4h high, 1h & 1d overbought
            & ((rsi_3_15m_gt_45) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_70) | (roc_9_1h_lt_10) | (roc_9_1d_lt_30))
            # 15m down move, 4h & 1d high, 4h & 1d overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20) | (roc_9_1d_lt_30))
            # 15m down move, 1d high, 1h & 4h & 1d overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_1h_lt_10) | (roc_9_4h_lt_40) | (roc_9_1d_lt_40))
            # 15m down move, 4h high, 4h & 1d overbought
            & ((rsi_3_15m_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m & 1h & 4h down move, 15m high, 1h high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_55) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_80))
            # 15m & 1h & 4h & qd down move, 1d overbought
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_65) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_65) | (stochrsi_k_4h_lt_80) | (roc_9_1h_lt_10))
            # 15m & 4h down move, 15m & 1h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_10))
            # 15m & 4h down move, 1h & 4h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_10))
            # 15m down move, 15m high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_40))
            # 15m down move, 15m & 4h & 1d high
            & ((rsi_3_15m_gt_50) | (aroonu_14_15m_lt_75) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m down move, 15m still high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_30))
            # 15m down move, 15m still high, 4h & 1d overbought
            & ((rsi_3_15m_gt_50) | (stochrsi_k_15m_lt_50) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 15m down move, 1h & 4h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (stochrsi_k_1h_lt_80) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_55) | (rsi_3_1h_gt_55) | (rsi_14_1h_lt_50) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_55) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_90))
            # 15m down move, 15m high, 4h high, 1d overbought
            & ((rsi_3_15m_gt_55) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_30))
            # 15m down move, 1d high, 15m still high, 1d high
            & ((rsi_3_15m_gt_55) | (aroonu_14_1d_lt_100) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1d_lt_90))
            # 15m down move, 4h high, 1h & 4h overbought
            & ((rsi_3_15m_gt_55) | (stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 15m down move, 4h high, 4h & 1d overbought
            & ((rsi_3_15m_gt_55) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 15m & 4h high
            & ((rsi_3_15m > 60.0) | (rsi_3_1h_gt_60) | (stochrsi_k_15m_lt_70) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m still high, 1h high, 4h high
            & ((rsi_3_15m > 60.0) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_60) | (stochrsi_k_4h_lt_80))
            # 1h down move, 15m still high, 1h still high, 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 4h & 1d high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h & 1d down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1h & 1d down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_40) | (stochrsi_k_4h_lt_80))
            # 1h down move, 15m high, 1h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_80))
            # 1h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_50))
            # 1h down move, 15m high, 4h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_60) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_10))
            # 1h down move, 1h high, 1d still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_50) | (roc_9_1d_lt_20))
            # 1h down move, 4h high, 4h & 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_15))
            # 1h down move, 4h & 1d high, 4h overbought
            & ((rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h high, 15m high, 4h high
            & ((rsi_3_1h_gt_45) | (rsi_14_4h_lt_70) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_14_4h_lt_70) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 15m & 1h down move, 1h & 4h & 1d high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_50))
            # 1h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (rsi_3_1d_gt_65) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_20))
            # 1h down move, 15m high, 1h high, 1d overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 1h high, 1d high, 4h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_10))
            # 1h down move, 4h high, 1h & 4h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_80) | (roc_9_1h_lt_20) | (roc_9_4h_lt_30))
            # 1h down move, 4h & 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 1h down move, 1h high, 4h & 1d overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 1h & 4h high
            & ((rsi_3_1h_gt_55) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h still high, 4h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_70) | (roc_9_4h_lt_60))
            # 1h & 4h down move, 1d high, 1d overbought
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 15m & 4h high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_65) | (stochrsi_k_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_65) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_10))
            # 1h down move, 15m & 1h & 4h high
            & ((rsi_3_1h_gt_60) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 4h high & overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_80))
            # 1h down move, 1d downtrend, 1h high, 4h high
            & ((rsi_3_1h_gt_65) | (cmf_20_1d_gt_neg_0_10) | (aroonu_14_1h_lt_90) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1d downtrend, 1h high, 4h high
            & ((rsi_3_1h_gt_65) | (cmf_20_1d_gt_neg_0_20) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h & 4h high, 1d overbought
            & ((rsi_3_1h_gt_65) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_65) | (aroonu_14_1h_lt_100) | (stochrsi_k_4h_lt_90))
            # 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_65) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 1h down move, 1h & 1d high & overbought
            & ((rsi_3_1h_gt_65) | (stochrsi_k_1h_lt_80) | (stochrsi_k_1d_lt_90) | (roc_9_1h_lt_10) | (roc_9_1d_lt_20))
            # 1h down move, 1h & 4h overbought
            & ((rsi_3_1h_gt_65) | (roc_9_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h down move, 1h & 4h & 1d down move
            & ((rsi_3_4h_gt_55) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 4h & 1d down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 15m still high, 1h & 4h & 1d overbought
            & ((rsi_3_1h_gt_65) | (aroonu_14_15m_lt_50) | (roc_9_1h_lt_20) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 4h down move, 15m high, 4h high & overbought
            & ((rsi_3_4h_gt_65) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_30))
            # 4h down move, 1h high, 1h & 4h & 1d overbought
            & ((rsi_3_4h_gt_65) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 4h down move, 4h & 1d high, 1d overbought
            & ((rsi_3_4h_gt_65) | (stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 4h up move, 4h high & overbought
            & ((rsi_3_4h_lt_90) | (rsi_14_4h_lt_70) | (aroonu_14_4h_lt_100) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
            # 1d down move, 1h & 4h high, 1d overbought
            & ((rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_80) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_20))
            # 1d down move, 4h high, 1h & 4h overbought
            & ((rsi_3_1d_gt_40) | (stochrsi_k_4h_lt_80) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 1d down move, 1h high, 1h & 4h & 1d overbought
            & ((rsi_3_1d_gt_60) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 4h high, 1h & 4h downtrend, 4h high
            & ((rsi_14_4h_lt_70) | (cmf_20_1h_gt_neg_0_20) | (cmf_20_4h_gt_neg_0_30) | (stochrsi_k_4h_lt_70))
            # 4h high, 4h & 1d high, 4h high
            & ((rsi_14_4h_lt_70) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (stochrsi_k_4h_lt_90))
            # 4h high & overbought
            & ((rsi_14_4h_lt_80) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h & 4h downtrend, 4h high, 1d high
            & ((cmf_20_1h_gt_neg_0_20) | (cmf_20_4h_gt_neg_0_30) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h high
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 15m & 4h & 1d high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_50))
            # 15m & 4h & 1d high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m high, 4h high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_50))
            # 15m high, 4h high, 4h & 1d overbought
            & ((aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_30))
            # 15m & 1h high, 4h overbought
            & ((aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_10))
            # 15m & 4h high, 1d overbought
            & ((aroonu_14_15m_lt_80) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_10))
            # 1h & 4h & 1d high, 4h overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h & 4h & 1d high, 4h overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20))
            # 1h & 4h & 1d high, 1d overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 1h & 4h & 1d high, 1d overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h & 4h high, 1h & 4h & 1d overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d high, 1d overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d high
            & ((aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1h & 4h high, 1d overbought
            & ((aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_20))
            # 4h uptrend active
            & (aroonu_14_4h_gt_50)
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_80))
            # 4h & 1d high & overbought
            & ((aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_80))
            # 1d high, 1h & 4h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_1h_lt_10) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_4h_lt_80) | (roc_9_1d_lt_80))
            # 15m still high, 1h & 4h high, 1d overbought
            & ((stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_20))
            # 1h still high, 1d high, 4h & 1d overbought
            & ((stochrsi_k_1h_lt_50) | (stochrsi_k_1d_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_150))
            # 1h & 4h & 1d high, 1h overbought
            & ((stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_70) | (stochrsi_k_1d_lt_70) | (roc_9_1h_lt_10))
            # 1h & 4h high, 1d overbought
            & ((stochrsi_k_1h_lt_90) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_20))
            # 1h & 1d high
            & ((stochrsi_k_1h_lt_90) | (stochrsi_k_1d_lt_90))
            # 4h & 1d high, 1d overbought
            & ((stochrsi_k_4h_lt_80) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_50))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 4h high, 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1d_lt_80))
            # Daily not crashing
            & (roc_9_1d > -5.0)
          )

          # Logic — Pullback in uptrend
          long_entry_logic.append(
            (rsi_3_gt_10)
            & (rsi_3_15m_gt_20)
            # & (rsi_3_1h_gt_20)
            & (rsi_14 < 45.0)
            & (willr_14 < -70.0)
            & (stochrsi_k_lt_30)
            & (aroonu_14_15m_lt_90)
            & (stochrsi_k_15m_lt_80)
            & (close < ema_12)
            & (close > ema_200)
            & (close > (bbl_20_2_0 * 1.01))
          )

        # Condition #65 - Breakout mode (Long).
        if long_entry_condition_index == 65:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # Trend confirmation
            (ema_12_4h > ema_200_4h)
            # 4h momentum mid-range
            & (rsi_14_4h_gt_50)
            & (rsi_14_4h_lt_68)
            # 1d up move, 1d not oversold
            & (roc_9_1d_gt_0)
            & (rsi_14_1d_gt_45)
            # 4h overbought, 1d up move, 4h money outflow
            & ((stochrsi_k_4h_lt_90) | (roc_9_1d_lt_20) | (cmf_20_4h_gt_neg_0_0))
            # 4h overbought & up move, 1d low
            & ((rsi_3_4h_lt_70) | (roc_9_4h_lt_5) | (stochrsi_k_1d_gt_70))
            # 15m up move, 4h low
            & ((rsi_3_15m_lt_90) | (stochrsi_k_4h_gt_30))
            # 1d overbought & up move
            & ((rsi_14_1d_lt_75) | (roc_9_1d_lt_30))
            # 1d high, 4h money outflow, 1h up
            & ((aroonu_14_1d_lt_100) | (cmf_20_4h_gt_neg_0_10) | (rsi_14_1h_lt_50))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_60))
            # 4h money outflow & up move
            & ((cmf_20_4h_gt_neg_0_10) | (roc_9_4h_lt_20))
            # 15m high, 1h down move, 1d up move
            & ((roc_9_1d_lt_40) | (rsi_3_1h_gt_60) | (stochrsi_k_15m_lt_50))
            # 1h high, 4h high & down move
            & ((aroonu_14_4h_lt_70) | (rsi_3_4h_gt_65) | (stochrsi_k_1h_lt_50))
            # 5m rollover, 1d low, 4h inflow, 1h narrow bands
            & ((rsi_14_change_pct_gt_0) | (rsi_14_1d_gt_60) | (cmf_20_4h_lt_0_15) | (bbb_20_2_0_1h_gt_20))
            # 1d down move, 1d high & overbought
            & (
              (rsi_3_1d_gt_65)
              | (rsi_3_change_pct_1d_gt_neg_20)
              | (stochrsi_k_1d_lt_70)
              | (rsi_14_1d_lt_60)
              | (roc_9_1d_gt_30)
            )
            # 1h low, 1d low
            & ((rsi_14_1h_gt_65) | (stochrsi_k_1d_gt_40) | (roc_9_1d_gt_25))
            # 15m volume spike, 1d low
            & ((stochrsi_k_1d_gt_70) | (obv_change_pct_15m_lt_50))
            # 15m high, 1d & 4h down move
            & ((aroonu_14_15m_lt_60) | (rsi_3_1d_gt_65) | (rsi_3_4h_gt_55))
            ####################################################################
            # 15m up move, 15m high, 4h high & overbought
            & ((rsi_3_15m_lt_85) | (stochrsi_k_15m_lt_70) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 15m up move, 15m high, 1h high
            & ((rsi_3_15m_lt_90) | (aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100))
            # 15m up move, 1d high, 1h & 1d overbought
            & ((rsi_3_15m_lt_90) | (aroonu_14_1d_lt_100) | (roc_9_1h_lt_10) | (roc_9_1d_lt_20))
            # 15m up move, 15m high, 4h high
            & ((rsi_3_15m_lt_95) | (aroonu_14_15m_lt_90) | (stochrsi_k_4h_lt_80))
            # 15m up move, 15m high, 4h high
            & ((rsi_3_15m_lt_95) | (stochrsi_k_15m_lt_80) | (stochrsi_k_4h_lt_90))
            # 1h & 4h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_80))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90))
            # 1h down move, 15m high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_100) | (roc_9_4h_lt_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 4h high, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_40) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_10))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_80))
            # 1h & 4h & 1d down move, 15m high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_80) | (stochrsi_k_15m_lt_80))
            # 1h & 4h down move, 15m high, 1d overbought
            & ((rsi_3_1h_gt_55) | (rsi_3_4h_gt_55) | (stochrsi_k_15m_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 4h high, 4h & 1d overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_15) | (roc_9_1d_lt_40))
            # 1h down move, 1h & 4h high & overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 1h down move, 1h & 4h high, 1d overbought
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_80))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_65) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_100))
            # 1h up move, 15m high, 1d overbought
            & ((rsi_3_1h_lt_90) | (aroonu_14_15m_lt_90) | (roc_9_1d_lt_50))
            # 1h up move, 4h downtrend, 15m & 1h high
            & ((rsi_3_1h_lt_95) | (cmf_20_4h_gt_neg_0_10) | (aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100))
            # 1h up move, 1d high, 1h & 4h overbought
            & ((rsi_3_1h_lt_95) | (stochrsi_k_1d_lt_90) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 4h down move, 15m & 1d high, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_100) | (roc_9_1d_lt_60))
            # 4h down move, 15m & 4h high, 4h overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 4h down move, 1h high, 15m high
            & ((rsi_3_4h_gt_50) | (aroonu_14_1h_lt_100) | (stochrsi_k_15m_lt_80))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_50) | (roc_9_4h_lt_10) | (roc_9_1d_lt_200))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_15m_lt_90) | (roc_9_1d_lt_100))
            # 4h down move, 15m high, 4h overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_15m_lt_100) | (stochrsi_k_15m_lt_80) | (roc_9_4h_lt_40))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_1h_lt_100) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_60))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_4h_lt_100) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_60) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 4h down move, 15m high, 4h overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_70) | (roc_9_4h_lt_30))
            # 1d down move, 15m high, 1h high, 1d overbought
            & ((rsi_3_1d_gt_35) | (aroonu_14_15m_lt_90) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_20))
            # 1d down move, 1h & 4h high, 1h overbought
            & ((rsi_3_1d_gt_35) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 1d down move, 1h & 4h high, 1d overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_70))
            # 1d down move, 15m high, 1d high
            & ((rsi_3_1d_gt_40) | (aroonu_14_15m_lt_100) | (aroonu_14_1d_lt_100))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_20))
            # 1d down move, 15m & 1h & 4h high
            & ((rsi_3_1d_gt_45) | (aroonu_14_15m_lt_90) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 1d down move, 1h high, 1d high & overbought
            & ((rsi_3_1d_gt_50) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 1d down move, 15m high, 1h high & overbought
            & ((rsi_3_1d_gt_55) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_30))
            # 1d down move, 15m & 4h high, 1d overbought
            & ((rsi_3_1d_gt_55) | (aroonu_14_15m_lt_100) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_10))
            # 1d down move, 15m high, 1d high & overbought
            & ((rsi_3_1d_gt_60) | (aroonu_14_15m_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 1d down move, 15m high, 1h overbought
            & ((rsi_3_1d_gt_60) | (stochrsi_k_15m_lt_80) | (roc_9_1h_lt_10))
            # 1h & 4h downtrend, 15m & 1h high
            & ((cmf_20_1h_gt_neg_0_40) | (cmf_20_4h_gt_neg_0_40) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 1d downtrend, 1h high, 1d overbought
            & ((cmf_20_1d_gt_neg_0_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 1h high, 15m overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_15m_lt_20))
            # 15m & 1h high, 1h & 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_20) | (roc_9_1d_lt_60))
            # 15m high, 1h high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_100))
            # 15m high, 1d high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_100))
            # 15m high, 1h high, 15m high, 1d high
            & ((aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_100) | (stochrsi_k_15m_lt_80) | (stochrsi_k_1d_lt_90))
            # 15m high, 1h high, 1d high, 1h overbought
            & ((aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_100) | (stochrsi_k_1d_lt_80) | (roc_9_1h_lt_15))
            # 15m high, 1h high & overbought
            & ((aroonu_14_15m_lt_80) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_40))
            # 15m high, 1h high, 1d high & overbought
            & ((aroonu_14_15m_lt_90) | (aroonu_14_1h_lt_100) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_30))
            # 15m & 4h high, 1d overbought
            & ((aroonu_14_15m_lt_90) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_60))
            # 15m & 1h & 4h high
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 15m & 1h & 1d high
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (aroonu_14_1d_lt_100))
            # 15m & 1h high, 1d overbought
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (stochrsi_k_15m_lt_70) | (roc_9_1d_lt_30))
            # 15m high, 1h high, 15m high
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (stochrsi_k_15m_lt_80))
            # 15m & 1h high, 1h overbought
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_30))
            # 15m & 1h high, 1d overbought
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_30))
            # 15m & 4h & 1d high
            & ((aroonu_14_15m_lt_100) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 15m high, 4h high & overbought
            & ((aroonu_14_15m_lt_100) | (aroonu_14_4h_lt_100) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 15m & 1d high, 4h overbought
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10))
            # 15m high, 1h high
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_15m_lt_80) | (stochrsi_k_1h_lt_80))
            # 15m high, 4h high
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_15m_lt_80) | (stochrsi_k_4h_lt_80))
            # 15m high, 1d high
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_15m_lt_80) | (stochrsi_k_1d_lt_90))
            # 15m high, 4h & 1d overbought
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_15m_lt_80) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 15m high, 1d overbought
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_15m_lt_80) | (roc_9_1d_lt_60))
            # 15m high, 1h & 1d high
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_1h_lt_80) | (stochrsi_k_1d_lt_80))
            # 15m high, 1d overbought
            & ((aroonu_14_15m_lt_100) | (roc_9_1d_lt_100))
            # 1h & 1d high & overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_80) | (roc_9_1h_lt_30) | (roc_9_1d_lt_60))
            # 1h high, 1h & 1d overbought
            & ((aroonu_14_1h_lt_70) | (roc_9_1h_lt_30) | (roc_9_1d_lt_200))
            # 1h & 4h high, 1h & 4h overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 1h & 4h high, 1d overbought
            & ((aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_100))
            # 1h & 4h high, 15m high, 1d overbought
            & ((aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100) | (stochrsi_k_15m_lt_80) | (roc_9_1d_lt_40))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 15m & 1h high, 1d high & overbought
            & ((stochrsi_k_15m_lt_70) | (stochrsi_k_1h_lt_70) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m high, 1h high & overbought
            & ((stochrsi_k_15m_lt_70) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_40))
          )

          # Logic — Breakout above BB upper with momentum
          long_entry_logic.append(
            (rsi_3 > 70.0)
            & (rsi_14 > 60.0)
            & (rsi_14 < 78.0)
            & (mfi_14 > 50.0)
            & (bbb_20_2_0 > 10.0)
            & (obv_change_pct_15m > 0.0)
            & (close > bbu_20_2_0)
            & (ema_12 > ema_26)
          )

        # Condition #68 - Triple Oversold Flush + Volume Accumulation (Long).
        if long_entry_condition_index == 68:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          long_entry_logic.append(global_protections_long_pump == True)
          long_entry_logic.append(global_protections_long_dump == True)
          long_entry_logic.append(rsi_14_1d > 25.0)
          long_entry_logic.append(rsi_14_4h > 20.0)
          long_entry_logic.append(roc_9_1d > -25.0)
          long_entry_logic.append(
            ((rsi_3 > 2.0) | (rsi_3_15m > 5.0) | (rsi_3_1h > 10.0))
            & ((rsi_3_15m > 3.0) | (rsi_3_1h > 10.0) | (aroonu_14_4h < 90.0))
            & ((rsi_3_1h > 5.0) | (rsi_3_4h > 15.0) | (stochrsi_k_4h < 50.0))
            & ((rsi_3_15m > 5.0) | (rsi_3_4h > 20.0) | (roc_9_1d > -15.0))
            & ((rsi_3_1h > 10.0) | (roc_9_4h > -15.0) | (cmf_20_4h > -0.20))
          )
          long_entry_logic.append((rsi_14_1h > 25.0) | (rsi_14_4h > 25.0) | (rsi_3_1d > 15.0))
          long_entry_logic.append(rsi_3 < 5.0)
          long_entry_logic.append(rsi_14 < 28.0)
          long_entry_logic.append(stochrsi_k < 3.0)
          long_entry_logic.append(willr_14 < -97.0)
          long_entry_logic.append(cmf_20 > 0.05)
          long_entry_logic.append(mfi_14 > 25.0)
          long_entry_logic.append(close < bbl_20_2_0)
          long_entry_logic.append(rsi_14_1h > 35.0)
          long_entry_logic.append(aroonu_14_4h > 25.0)

        # Condition #101 - Rapid mode (Long).
        if long_entry_condition_index == 101:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(rsi_14_1h_lt_80)
          long_entry_logic.append(rsi_14_4h_lt_80)
          long_entry_logic.append(rsi_14_1d_lt_80)
          # big drop in the last hour
          long_entry_logic.append(
            (close > (close_max_12 * 0.50))
            # 5m & 4h down move, 1d downtrend
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50))
            # 5 & 15m down move, 1h high
            & ((rsi_3_gt_10) | (rsi_3_15m_gt_40) | (stochrsi_k_1h_lt_90))
            # 5m down move, 1h & 4h high
            & ((rsi_3_gt_10) | (aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_90))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_50) | (rsi_14_1d_lt_40))
            # 15m & 1h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (stochrsi_k_4h_lt_30))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (aroonu_14_1d_lt_40))
            # 15m & 1h & 4h down move, 4h still not low enough, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_20) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_14_4h_lt_40))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_75))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_30))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_20))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_30))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_20) | (stochrsi_k_1h_lt_60))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_15m_lt_30) | (stochrsi_k_4h_lt_70))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_30))
            # 15m & 1h & 1d down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (rsi_3_1d_gt_20))
            # 15m down move, 1h still not low enough, 1d high
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_30) | (aroonu_14_1d_lt_90))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_55) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_30))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_80))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90))
            # 15m & 4h down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_1d_lt_40))
            # 15m & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_4h_lt_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_50))
            # 15m & 1d down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_5))
            # 15m & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_30))
            # 15m down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_50) | (stochrsi_k_4h_lt_90))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1h_lt_80) | (roc_9_1h_lt_10))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_60) | (aroonu_14_4h_lt_40))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_25))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | aroonu_14_1h_lt_80)
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m < 10.0))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_25))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_85))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_70))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_50))
            # 15m down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_50) | (aroonu_14_4h_lt_85))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h < 75.0))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (stochrsi_k_15m_lt_30))
            # 15m & 1h & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_30))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_55) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_30))
            # 15m & 4h & 1d down move
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_15) | rsi_3_4h_gt_20 | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_50))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (roc_9_1d_lt_10))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_25) | (stochrsi_k_1h_lt_80))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_40))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_70) | (aroonu_14_4h_lt_85))
            # 15m & 1h & 4h down move, 5h & 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_70))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_85))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_25) | (aroonu_14_4h_lt_60))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_25) | (stochrsi_k_15m_lt_30) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (roc_9_1d_lt_150))
            # 15m & 1d down move, 1h & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_70) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 15m downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_3) | (roc_9_15m > -30.0))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_25))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_50) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | rsi_3_4h_gt_20 | (stochrsi_k_4h_lt_20))
            # 1h & 4h down move, 1d low
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (cmf_20_1d_gt_neg_0_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 1h & 1d down move, 5m moving down
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (roc_2 > -0.0))
            # 1h down move, 4h downtrend
            & ((rsi_3_1h_gt_10) | (roc_9_4h_gt_neg_30))
            # 1h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | rsi_3_4h_gt_20 | (rsi_3_1d_gt_30))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_40))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_30))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_10) | (aroonu_14_1h_lt_40))
            # 1h down move, 1d high & overbought
            & (rsi_3_1h_gt_20 | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h down move, 1h still not low enough, 4h high
            & (rsi_3_1h_gt_20 | (stochrsi_k_1h_lt_20) | aroonu_14_4h_lt_80)
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_50))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100))
            # 1h down move, 1d high, 1h & 4h downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_90) | (roc_9_1h_gt_neg_25) | (roc_9_4h_gt_neg_35))
            # 1h down move, 15m high
            & ((rsi_3_1h_gt_35) | (stochrsi_k_15m_lt_80))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_40))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_60) | (aroonu_14_4h_lt_90))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 15m still high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_40))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 15m 4h still high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_40) | (aroonu_14_4h_lt_50))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | aroonu_14_4h_lt_70)
            # 4h down move, 1h still high
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_15))
            # 4h down move, 4h & 1d downtrend
            & (rsi_3_4h_gt_20 | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 4h dowqn move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_35) | aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100)
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_40) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_50))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_60))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_40))
            # 4h down move, 4h overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_20))
            # 4h up move, 1d downtrend, 4h high
            & ((rsi_3_4h_lt_90) | (cmf_20_1d_gt_neg_0_25) | (aroonu_14_4h_lt_100))
            # 1d down move, 1h still high, 4h high
            & ((rsi_3_1d_gt_20) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_85))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 1d down move, 4h high, 1d overbought
            & ((rsi_3_1d_gt_45) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_10))
            # 4h still high, 4h moving lower, 4h overbought
            & ((aroonu_14_4h_lt_50) | (aroonu_14_4h > aroonu_14_4h_shift_48) | (roc_9_4h_lt_40))
            # 1h high, 1d downtrend
            & ((aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_30))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_85) | (roc_9_4h_lt_60) | (roc_9_1d_lt_60))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 1h high, 4h downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h high, 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_lt_80))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30) | (roc_9_1d_lt_30))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_80) | (roc_9_4h_lt_60) | (roc_9_1d_lt_60))
            # 1d red, 4h down move, 1h still high
            & ((change_pct_1d_gt_neg_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 2.0)
              | (close > (high_max_6_4h * 0.75))
              | (close < (low_min_24_4h * 1.25))
            )
            # 4h high, drop but not yet near the previous lows
            & (aroonu_14_4h_lt_70 | (close > (high_max_6_4h * 0.80)) | (close < (low_min_24_4h * 1.25)))
            # 4h high, drop but not yet near the previous lows
            & (aroonu_14_4h_lt_80 | (close > (high_max_6_4h * 0.85)) | (close < (low_min_24_4h * 1.25)))
            # 1h down move, drop but not yet near the previous lows
            & ((rsi_3_1h_gt_30) | (close > (high_max_12_4h * 0.50)) | (close < (low_min_24_4h * 1.25)))
            # 1d overbought, drop but not yet near the previous lows
            & ((roc_9_1d_lt_50) | (close > (high_max_6_1d * 0.70)) | (close < (low_min_12_1d * 1.25)))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in last 6 hours, 1d overbought
            & ((close > (high_max_6_1h * 0.65)) | roc_9_1d_lt_50)
            # big drop in last 4 hours, 4h still not low enough
            & ((close > (high_max_24_4h * 0.50)) | (stochrsi_k_4h_lt_30))
            # big drop in the last 4 days, 4h down move
            & ((close > (high_max_24_4h * 0.20)) | rsi_3_4h_gt_20)
            # big drop in the last 6 days, 1d down move
            & ((close > (high_max_6_1d * 0.30)) | (rsi_3_1d_gt_15))
            # big drop in the last 12 days, 4h high
            & ((close > (high_max_12_1d * 0.50)) | (stochrsi_k_4h_lt_90))
            # big drop in the last 30 days, 4h down move
            & ((close > (high_max_20_1d * 0.10)) | (rsi_3_4h_gt_30))
            # big drop in the last 20 days, 1h still high
            & ((close > (high_max_20_1d * 0.05)) | (aroonu_14_1h_lt_50))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # big drop in the last 30 days, 1h down move
            & ((close > (high_max_30_1d * 0.25)) | (rsi_3_1h_gt_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_gt_3)
            & (rsi_14 < 36.0)
            & (aroonu_14_lt_25)
            & (stochrsi_k_lt_20)
            & (close < (sma_16 * 0.946))
            & (aroonu_14_15m_lt_50)
          )

        # Condition #102 - Rapid mode (Long).
        if long_entry_condition_index == 102:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(rsi_3_lt_46)
          long_entry_logic.append(rsi_3_15m_gt_5)
          long_entry_logic.append(rsi_3_1h_gt_10)
          long_entry_logic.append(rsi_3_4h_gt_10)
          # 5m & 15m down move, 4h still high
          long_entry_logic.append(
            ((rsi_3_gt_3) | (rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_50))
            # 5m & 15m down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_20) | (aroonu_14_15m_lt_40))
            # 5m & 15m down move, 1h still high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_40))
            # 5m & 1h down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_50))
            # 5m & 4h & 1d down move
            & ((rsi_3_gt_3) | rsi_3_4h_gt_20 | (rsi_3_1d_gt_20))
            # 5m & 1d down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_10) | (stochrsi_k_15m_lt_40))
            # 5m down move, 15m high
            & ((rsi_3_gt_3) | (aroonu_14_15m_lt_70))
            # 5m down move, 15m & 1h still high
            & ((rsi_3_gt_3) | (stochrsi_k_15m_lt_40) | (aroonu_14_1h_lt_40))
            # 5m down move, 1h high
            & ((rsi_3_gt_3) | aroonu_14_1h_lt_70 | (stochrsi_k_1h_lt_50))
            # 5m & 1h down move, 1h high
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_60))
            # 5m & 4h down move, 4h high
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_50) | aroonu_14_4h_lt_70)
            # 5m down move, 15m still high, 1h high
            & ((rsi_3_gt_5) | (rsi_14_15m_lt_40) | aroonu_14_1h_lt_80)
            # 5m down move, 15m still high, 1h high
            & ((rsi_3_gt_5) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 5m down move, 15m & 4h high
            & ((rsi_3_gt_5) | (stochrsi_k_15m_lt_70) | (stochrsi_k_4h_lt_90))
            # 5m & 15m down move, 4h high
            & ((rsi_3_gt_10) | (rsi_3_15m_gt_20) | (aroonu_14_4h_lt_90))
            # 5m & 15m down move, 1d high
            & ((rsi_3_gt_10) | (rsi_3_15m_gt_20) | (stochrsi_k_1d_lt_80))
            # 5m & 15m down move, 1h high
            & ((rsi_3_gt_10) | (rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_90))
            # 5m & 1h down move, 4h still high
            & ((rsi_3_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_50))
            # 5m down move, 1h & 4h high
            & ((rsi_3_gt_10) | (aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_90))
            # 5m down move, 4h high, 1d high
            & ((rsi_3_gt_10) | (aroonu_14_4h_lt_60) | (stochrsi_k_1d_lt_90))
            # 5m down move, 15m still high, 1h high
            & ((rsi_3_gt_15) | (rsi_14_15m_lt_40) | (stochrsi_k_1h_lt_90))
            # 5m down move, 15m still high, 4h high
            & ((rsi_3_gt_15) | (rsi_14_15m_lt_40) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m still not low enough, 1h high
            & (rsi_3_15m_gt_3 | (aroonu_14_15m_lt_20) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | rsi_3_1h_gt_20 | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | rsi_3_1h_gt_20 | (stochrsi_k_1h_lt_20))
            # 15m & 1h & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_30))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | aroonu_14_4h_lt_70)
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30))
            # 15m& 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_40))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | rsi_3_4h_gt_20 | (aroonu_14_15m_lt_50))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | rsi_3_4h_gt_20 | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | rsi_3_4h_gt_20 | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_85))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | aroonu_14_4h_lt_70)
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_50))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_10) | aroonu_14_1h_lt_70 | (roc_9_4h_lt_50))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_50) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (stochrsi_k_15m_lt_50))
            # 15m & 4h & 1d down move
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | rsi_3_4h_gt_20 | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_15m < 25.0))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_14_15m_lt_35) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_30) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m & 4h still high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_50))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_70))
            # 15m down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_60))
            # 15m down move, 4h still high 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_50) | roc_9_1d_lt_50)
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_30))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (aroonu_14_15m_lt_60))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_60))
            # 15m & 4h & 1d down move, 4h still high, 1d still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_50) | (rsi_14_4h_lt_40) | (rsi_14_1d_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_14_15m_lt_35) | (rsi_14_4h < 85.0))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_30) | (stochrsi_k_4h_lt_70))
            # 15m down move, 15m still high, 4d downtrend
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_20) | (stochrsi_k_15m_lt_30) | (aroonu_14_1h_lt_50))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_40))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (stochrsi_k_1d_lt_90))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_85))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_50))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_70))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | (stochrsi_k_4h_lt_70))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_100))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_85))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_50))
            # 15m & 1h & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_60))
            # 15m & 1d down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_80))
            # 15m down move, 15m high, 4h still high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_50))
            # 15m down move, 15m still not low enough, 1h high
            & ((rsi_3_15m_gt_30) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m still high, 1d high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_50) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # 15m down move, 1h still high, 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 15m down move, 1d high, 4h & 1d overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_80))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_70))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_70))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_80))
            # 15m down move, 4h still high, 4h overbought
            & ((rsi_3_15m_gt_35) | (stochrsi_k_4h_lt_50) | (roc_9_4h_lt_20))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_14_15m_lt_50) | aroonu_14_1h_lt_80)
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_90))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | rsi_3_4h_gt_20 | (rsi_14_4h_lt_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_40))
            # 1h & 1d down move, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (cmf_20_4h_gt_neg_0_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70))
            # 1h down move, 1h still not low enough, 4h high
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_30) | (stochrsi_k_4h_lt_70))
            # 1h down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | roc_9_1d_gt_neg_50)
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_80))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (rsi_14_4h_lt_75) | (roc_9_1d_lt_100))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_85))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_20))
            # 1h down move 1h high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_90) | (roc_9_1h_lt_10))
            # 1h & 4h & 1d down move, 1h & 1d still high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (stochrsi_k_1h_lt_40) | (stochrsi_k_1d_lt_40))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 1h down move, 1d high, 1h overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1h_lt_10))
            # 4h & 1d down move, 1d still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_30) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h still not low enough, 1d overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30) | (roc_9_1d_lt_100))
            # 4h down move, 1d high, 4h downtrend, 1d overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_4h_gt_neg_20) | (roc_9_1d_lt_30))
            # 4h down move, 15m still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 15m still not low enough
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_30))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h down move, 15m still high, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_90) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_50) | (aroonu_14_1d_lt_60))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_40) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_20))
            # 4h down move, 15m high, 4h overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_80) | (roc_9_4h_lt_20))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_60) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1d down move, 1h & 4h still not low enough
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_20) | (stochrsi_k_4h_lt_20))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (aroonu_14_1h_lt_85) | (roc_9_1d_gt_neg_30))
            # 1d down move, 15m still not low enough, 1h still high
            & ((rsi_3_1d_gt_15) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_50))
            # 15m still not low enough, 1h high, 1d overbought
            & ((aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_100))
            # 15m still high, 4h high & overbought
            & ((aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 15m & 1h & 4h high
            & ((aroonu_14_15m_lt_70) | aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90))
            # 15m & 1h high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90) | (roc_9_4h_lt_20))
            # 15m & 1d high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m high
            & ((aroonu_14_15m_lt_80) | (stochrsi_k_15m_lt_60))
            # 15m & 4h high
            & ((aroonu_14_15m_lt_80) | (stochrsi_k_4h_lt_70))
            # 15m high, 1d overbought
            & ((aroonu_14_15m_lt_80) | roc_9_1d_lt_50)
            # 15m & 4h high
            & ((aroonu_14_15m_lt_90) | aroonu_14_4h_lt_70)
            # 15m & 1h high
            & ((aroonu_14_15m_lt_90) | (aroonu_14_1h_lt_90))
            # 1h still high, 4h high & overbought
            & ((aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_80))
            # 1h & 4h high, 1h overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_4h_lt_100 | (roc_9_1h_lt_40))
            # 1h & 1d high, 1d overbought
            & (aroonu_14_1h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_30))
            # 1h high, 4h & 1d overbought
            & ((aroonu_14_1h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_80 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_30))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_70 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_10))
            # 4h high & overbought
            & ((aroonu_14_4h_lt_90) | (stochrsi_k_4h < 85.0) | (roc_9_4h_lt_50))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_70) | (roc_9_4h_lt_30) | (roc_9_1d_lt_30))
            # 5m red, 1h still high
            & ((change_pct > -5.0) | (stochrsi_k_1h_lt_50))
            # 1d top wick, 4h down move, 4h still high
            & ((top_wick_pct_1d_lt_30) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_50))
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 2.0)
              | (close > (high_max_6_4h * 0.75))
              | (close < (low_min_24_4h * 1.25))
            )
            # 4h high, drop but not yet near the previous lows
            & ((stochrsi_k_4h_lt_90) | (close > (close_max_48 * 0.85)) | (close < (low_min_24_1h * 1.25)))
            # 4h high, drop but not yet near the previous lows
            & (aroonu_14_4h_lt_70 | (close > (high_max_6_4h * 0.80)) | (close < (low_min_24_4h * 1.25)))
            # 1d overbought, drop but not yet near the previous lows
            & (roc_9_1d_lt_50 | (close > (high_max_6_1d * 0.70)) | (close < (low_min_12_1d * 1.25)))
            # big drop in the last 4 days, 4h down move
            & ((close > (high_max_24_4h * 0.20)) | rsi_3_4h_gt_20)
            # big drop in the last 12 days, 1h high
            & ((close > (high_max_12_1d * 0.30)) | (stochrsi_k_1h_lt_90))
            # big drop in the last 20 days, 1d down move
            & ((close > (high_max_20_1d * 0.40)) | (rsi_3_1d_gt_30))
            # big drop in the last 30 days, 4h down move, 4h still high
            & ((close > (high_max_30_1d * 0.25)) | (rsi_3_4h_gt_45) | (rsi_14_4h_lt_40))
            # big drop in the last 30 days, 1h high
            & ((close > (high_max_30_1d * 0.20)) | (stochrsi_k_1h_lt_80))
          )

          # Logic
          long_entry_logic.append(
            (willr_14 < -95.0) & (stochrsi_k < 10.0) & (close < (bbl_20_2_0 * 0.999)) & (close < (ema_20 * 0.960))
          )

        # Condition #103 - Rapid mode (Long).
        if long_entry_condition_index == 103:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(roc_2 > -0.0)
          long_entry_logic.append(
            # 15m & 1h & 4h down move, 15m still high
            ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_80))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80))
            # 15m & 1h & 1d down move, 1h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_80))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | rsi_3_4h_gt_20 | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_30))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_50))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_14_15m_lt_40) | (stochrsi_k_1h_lt_70))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_14_15m_lt_40) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_70))
            # 15m down move, 15m high, 4h still high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_50))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_20) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 15m down move, 4h overbought
            & ((rsi_3_15m_gt_20) | (roc_9_4h_lt_70))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_80))
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_90) | (stochrsi_k_1d_lt_90))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_80) | (stochrsi_k_1d_lt_90))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_70))
            # 15m & 1h & 4h down move, 15m high, 4h overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (roc_9_4h_lt_20))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_80))
            # 15m & 4h & 1d down move, 4h & 1d high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_55) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (stochrsi_k_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_1h_lt_85) | (roc_9_4h_lt_80))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_20))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_50) | (stochrsi_k_15m_lt_80))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 1h & 4h & 1d down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_100))
            # 1h down move, 4h still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_80) | (stochrsi_k_1d_lt_90))
            # 1h & 1d down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_60) | (roc_9_1d_lt_20))
            # 1h down move, 15m still not low enough, 4h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_15m_lt_25) | (aroonu_14_4h_lt_80))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_30) | (roc_9_4h_lt_30) | (roc_9_1d_lt_40))
            # 1h down move, 15m & 1h still high
            & ((rsi_3_1h_gt_40) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_50))
            # 1h down move, 1h overbought
            & ((rsi_3_1h_gt_40) | (roc_9_1h_lt_30))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 15m & 1h still high
            & ((rsi_3_1h_gt_50) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d high, 1d overbought, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50) | (roc_9_4h_gt_neg_30))
            # 4h & 1d down move, 15m high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_15m_lt_60) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_10))
            # 4h & 1d down move, 15m downtrend, 4h still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_50) | (cmf_20_15m_gt_neg_0_35) | (aroonu_14_4h_lt_50))
            # 4h down move, 15m & 1d high, 1h downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1h_gt_neg_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 1h down move, 15m & 1h still high
            & ((rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 4h down move, 15m still high, 4h high
            & ((rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_50) | (aroonu_14_4h_lt_70))
            # 4h & 1d down move, 1h high & overbought
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_100))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1h high, 4h & 1d downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_90) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_40))
            # 4h down move, 1d high, 1d overbought, 4h downtrend
            & ((rsi_3_4h_gt_40) | (rsi_14_1d_lt_70) | (roc_9_1d_lt_200) | (roc_9_4h_gt_neg_10))
            # 4h down move, 15m still not low enough, 4h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_70))
            # 1d down move, 4h & 1d high
            & ((rsi_3_1d_gt_55) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_60) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90))
            # 4h down move, 1h high, 1d overbought
            & ((rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_30))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_10) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_10))
            # 1d down move, 4h high
            & ((rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_80))
            # 1d down move, 15m still high, 1h high
            & ((rsi_3_1d_gt_15) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1d down move, 1h & 1d overbought
            & ((rsi_3_1d_gt_45) | (roc_9_1h_lt_80) | (roc_9_1d_lt_80))
            # 15m still high, 1h & 4h high
            & ((rsi_14_15m_lt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_90))
            # 15m & 1h still high, 4h high
            & ((rsi_14_15m < 45.0) | (aroonu_14_1h_lt_40) | (stochrsi_k_4h_lt_70))
            # 15m still high, 4h high & overbought
            & ((rsi_14_15m_lt_50) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_80))
            # 15m still high, 1h high, 4h still high
            & ((aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_90) | (stochrsi_k_4h_lt_50))
            # 15m still high, 1d high
            & ((aroonu_14_15m_lt_50) | (stochrsi_k_1d_lt_90))
            # 15m & 1h
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90))
            # 15m & 1h & 4h high
            & ((aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 1h & 1d high, 4h downtrend
            & ((aroonu_14_1h_lt_40) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h & 4h high, 4h overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h high, 1h & 1d overbought
            & ((aroonu_14_1h_lt_90) | (roc_9_1h_lt_10) | (roc_9_1d_lt_30))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_10))
            # 4h high, 1h & 4h & 1d overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_1h_lt_10) | (roc_9_4h_lt_20) | (roc_9_1d_lt_50))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_4h_lt_80) | (roc_9_1d_lt_100))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 15m still high, 1h high
            & ((stochrsi_k_15m_lt_40) | (aroonu_14_1h_lt_90) | (stochrsi_k_1h_lt_90))
            # 15m still high, 1d high
            & ((stochrsi_k_15m_lt_50) | (stochrsi_k_1d_lt_90))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_80) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
            # 1d green, 4h down move, 4h still high
            & ((change_pct_1d_lt_40) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_40))
            # 1d top wick, 4h high
            & ((top_wick_pct_1d_lt_30) | (aroonu_14_4h_lt_90))
            # pump, 4h overbought
            & ((((high_max_6_1h - low_min_6_1h) / low_min_6_1h) < 0.5) | (roc_9_4h_lt_50))
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 2.0)
              | (close > (high_max_6_4h * 0.85))
              | (close < (low_min_24_4h * 1.25))
            )
            # pump, 1h high
            & ((((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 4.0) | (stochrsi_k_1h_lt_90))
            # big drop in the last 2 days, 1d down move
            & ((close > (high_max_12_4h * 0.30)) | (rsi_3_1d_gt_30))
            # big drop in the last 12 days, 1h still high
            & ((close > (high_max_12_1d * 0.25)) | (aroonu_14_1h_lt_50))
            # big drop in the last 12 days, 1h still not low enough
            & ((close > (high_max_12_1d * 0.10)) | (stochrsi_k_1h_lt_30))
            # big drop in the last 12 days, 15m still high
            & ((close > (high_max_12_1d * 0.20)) | (aroonu_14_15m_lt_50))
            # big drop in the last 20 days, 4h down move
            & ((close > (high_max_20_1d * 0.10)) | rsi_3_4h_gt_20)
          )

          # Logic
          long_entry_logic.append(
            (rsi_4 < 45.0) & (rsi_14 > 35.0) & (rsi_20 < rsi_20_shift_1) & (aroonu_14_lt_25) & (close < sma_16 * 0.960)
          )

        # Condition #104 - Rapid mode (Long).
        if long_entry_condition_index == 104:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          # 5m & 4h & 1d down move
          long_entry_logic.append(
            ((rsi_3_gt_3) | rsi_3_4h_gt_20 | (rsi_3_1d_gt_20))
            # 5m & 4h down move, 1d downtrend
            & ((rsi_3_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 5m & 1h down move, 1h still high
            & ((rsi_3_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 4h & 1d down move
            & (rsi_3_15m_gt_3 | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 15m & 1h down move
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_3))
            # 15m & 1h down move, 4h still not low enough
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_5) | (rsi_14_4h < 35.0))
            # 15m & 1h down move, 1d still high
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_50))
            # 15m & 1h down move, 1h still not low enough
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_30))
            # 15m & 4h down move, 4h still high
            & (rsi_3_15m_gt_3 | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15))
            # 15m & 1h & 4h down move, 15m downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (cmf_20_15m_gt_neg_0_20))
            # 15m & 1h down move, 4h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_20))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50))
            # 15m & 1h down move, 15m & 1h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (cmf_20_15m_gt_neg_0_40) | (cmf_20_1h_gt_neg_0_40))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_20))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m & 1h & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_80))
            # 15m & 1h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_40) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80))
            # 15m & 4h & 1d down move, 1h still not low enough, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_30) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 1h & 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (cmf_20_1h_gt_neg_0_20) | (cmf_20_4h_gt_neg_0_20))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_gt_neg_25))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_20))
            # 15m & 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_10))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 15m & 1d down move, 1h high, 4h downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_90) | (roc_9_4h_gt_neg_20))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_40))
            # 15m down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_50))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 3h down move, 15m still not low enough
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_20))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 1h & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (roc_9_4h_gt_neg_40))
            # 15m & 1d down move, 1d high, 1h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_1h_gt_neg_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_14_1h_lt_40))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_70))
            # 15m down move, 15m still not low enough, 1d overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_15m_lt_20) | (roc_9_1d_lt_80))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50))
            # 1h down move, 1h still high
            & ((rsi_3_1h_gt_5) | (aroonu_14_1h_lt_50))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_85))
            # 1h & 4h down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h & 1d down move, 1h still moving lower
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (cci_20_change_pct_1h_gt_neg_0))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_85) | (roc_9_4h_gt_neg_10))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_50))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_30))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_80))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_70))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_50))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_70))
            # 4h & 1d down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_70))
            # 1h down move, 4h high
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_25) | aroonu_14_1h_lt_70 | (aroonu_14_1d_lt_90))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | aroonu_14_4h_lt_80)
            # 1h & dh down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_85))
            # 1h down move, 4h still not low enough, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_30) | roc_9_1d_lt_50)
            # 1h down move, 1h still not low enough, 4h downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_30) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_40) | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 4h down move, 15m not low enough, 1h still high
            & ((rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_20) | (stochrsi_k_1h_lt_40))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_70))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_5) | (stochrsi_k_1d_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 1h downtrend, 1h still not low enough
            & ((rsi_3_4h_gt_10) | (cmf_20_1h_gt_neg_0_25) | (aroonu_14_1h_lt_30))
            # 4h down move, 1h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (stochrsi_k_4h_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_60))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_50))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_80))
            # 4h down move, 1d high, 1h downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_70) | (roc_9_1h_gt_neg_10))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_100))
            # 4h down move, 4h high, 1h downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (roc_9_1h_gt_neg_30))
            # 4h down move, 4h still high, 1d overbought
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_40))
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_100))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1d down move, 1h still not low enough
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_20))
            # 1h & 4h high, 4h overbought
            & ((aroonu_14_1h_lt_60) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_30))
            # 4h & 1d high, 4h overbought
            & ((aroonu_14_4h_lt_60) | aroonu_14_1d_lt_100 | (roc_9_4h_lt_40))
            # 4h & 1d high,1d overbought
            & (aroonu_14_4h_lt_70 | aroonu_14_1d_lt_100 | roc_9_1d_lt_50)
            # 1d red, 4h down move, 1h still high
            & ((change_pct_1d_gt_neg_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_50))
            # 1d top wick, 4h down move, 1d high
            & ((top_wick_pct_1d_lt_20) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100))
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_24_4h - low_min_24_4h) / low_min_24_4h) < 2.0)
              | (close > (high_max_12_4h * 0.60))
              | (close < (low_min_24_4h * 1.10))
            )
            # pump, drop but not yet near the previous lows
            & (
              (((high_max_12_1d - low_min_12_1d) / low_min_12_1d) < 5.0)
              | (close > (high_max_6_1d * 0.30))
              | (close < (low_min_12_1d * 1.25))
            )
            # big drop in the last hour
            & (close > (close_max_12 * 0.50))
            # big drop in the last 12 days, 15m & 4h down move
            & ((close > (high_max_12_1d * 0.40)) | (rsi_3_15m_gt_10) | (rsi_3_4h_gt_10))
            # big drop in the last 20 days, 15m & 1h down move
            & ((close > (high_max_20_1d * 0.40)) | (rsi_14_15m < 10.0) | (rsi_14_1h < 10.0))
            # big drop in the last 20 days, 1d down move
            & ((close > (high_max_20_1d * 0.25)) | (rsi_3_1d_gt_30))
            # big drop in the last 20 days, 4h still not low enough
            & ((close > (high_max_20_1d * 0.10)) | (rsi_14_4h_lt_30))
            # big drop in the last 30 days, 4h down move
            & ((close > (high_max_30_1d * 0.25)) | rsi_3_4h_gt_20)
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_40)
            & (aroonu_14_lt_25)
            & (stochrsi_k_lt_20)
            & (aroonu_14_15m_lt_25)
            & (stochrsi_k_15m_lt_30)
            & (close < ema_16 * 0.975)
            & (((ema_50 - ema_200) / close * 100.0) < -5.5)
          )

        # Condition #105 - Williams %R snapback (Long, experimental — Goodwin mean-reversion port).
        if long_entry_condition_index == 105:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # money still flowing in on the hour and a healthy 4h — no dip-buying a bleed
          long_entry_logic.append(cmf_20_1h > -0.02)
          long_entry_logic.append(rsi_14_4h > 45.0)
          # 1h close crosses INTO the oversold extreme (source strategy runs on 30m/1h scale)
          long_entry_logic.append(willr_14_1h < -90.0)
          long_entry_logic.append(np_shift(willr_14_1h, 12) >= -90.0)
          # mean-revert WITH the daily trend: only long when the day is up
          long_entry_logic.append(change_pct_1d > 0.0)

        # Condition #120 - Grind mode (Long).
        if long_entry_condition_index == 120:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(num_open_long_grind_mode < self.grind_mode_max_slots)
          long_entry_logic.append(protections_long_global == True)
          long_entry_logic.append(is_pair_long_grind_mode)
          long_entry_logic.append(rsi_3 <= 50.0)
          long_entry_logic.append(rsi_3_15m >= 20.0)
          long_entry_logic.append(rsi_3_1h >= 20.0)
          long_entry_logic.append(rsi_3_4h >= 20.0)
          long_entry_logic.append(rsi_14_1h_lt_80)
          long_entry_logic.append(rsi_14_4h_lt_80)
          long_entry_logic.append(rsi_14_1d_lt_80)
          long_entry_logic.append(aroonu_14_15m_lt_70)
          long_entry_logic.append(aroonu_14_1h_lt_100)
          long_entry_logic.append(aroonu_14_4h_lt_100)
          long_entry_logic.append(aroonu_14_1d_lt_100)
          long_entry_logic.append(stochrsi_k_15m_lt_50)
          long_entry_logic.append(stochrsi_k_1h_lt_70)
          long_entry_logic.append(stochrsi_k_4h_lt_70)
          long_entry_logic.append(stochrsi_k_1d_lt_90)

          # Logic
          long_entry_logic.append(
            (stochrsi_k_lt_20) & (willr_14 < -80.0) & (aroonu_14_lt_25) & (close < (ema_20 * 0.978))
          )

        # Condition #141 - Top Coins mode (Long).
        if long_entry_condition_index == 141:
          # Protections
          long_entry_logic.append(is_pair_long_top_coins_mode)
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 15m down move, 15m high
            ((rsi_3_gt_3) | (rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70))
            # 5m & 15m down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_50))
            # 5m & 15m down move, 15m high
            & ((rsi_3_gt_3) | (rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70))
            # 5m & 1h down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_15m_lt_40))
            # 5m & 1h down move, 1h high
            & ((rsi_3_gt_3) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_80))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_5) | (aroonu_14_15m_lt_40))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_40))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_3) | rsi_3_4h_gt_20 | (stochrsi_k_15m_lt_50))
            # 5m & 4h down move, 1h high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_80))
            # 5m & 1d down move, 15m high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_10) | (aroonu_14_15m_lt_70))
            # 5m & 1d down move, 15m stil high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_10) | (stochrsi_k_15m_lt_40))
            # 5m & 1d down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_40))
            # 5m down move, 1h high
            & ((rsi_3_gt_3) | (stochrsi_k_1h_lt_90))
            # 5m down move, 15m & 1d high
            & ((rsi_3_gt_5) | (aroonu_14_15m_lt_60) | (aroonu_14_1d_lt_100))
            # 5m down move, 1h & 1d high
            & ((rsi_3_gt_10) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h & 1d down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_20))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (roc_9_1d_lt_60))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (stochrsi_k_1d_lt_50))
            # 15m & 1h & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_25) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_45) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 15m downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_3) | (cmf_20_15m_gt_neg_0_30))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h down move, 15m still not low enough, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_80))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_50) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80))
            # 15m & 1d down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_10) | (aroonu_14_1d_lt_40))
            # 15m down move, 15m downtrend, 1d high
            & ((rsi_3_15m_gt_5) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 15m & 1h & 4h & 1d down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (roc_9_1d_gt_neg_10))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (rsi_14_1d_lt_40))
            # 15m & 1h & 4h down move, 4h still high, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_85))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_85))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_50) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_15m_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_50))
            # 15m & 1h & 4h & 1d down move, 1h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_30))
            # 15m & 1h & 4h & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_4h_lt_60))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_80))
            # 15m & 1h & 4h down move, 15m & 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_40))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_60))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_15m_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_lt_20))
            # 15m & 4h & 1d down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (aroonu_14_15m_lt_40) | (aroonu_14_1d_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (rsi_14_1d_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_60))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_50))
            # 15m & 4h & 1d down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70))
            # 15m down move, 1h high
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_90))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_50))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_60))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_60) | (aroonu_14_4h_lt_70))
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h & 4h high, 4h overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 1h & 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_50))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_80))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 15m & 1h & 1d down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_80) | (stochrsi_k_4h_lt_90))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_50))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_90))
            # 15m & 4h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_45) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_90))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_30))
            # 15m down move, 15m downtrend, 1h high
            & ((rsi_3_15m_gt_15) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1h_lt_60))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_20))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h high, 4h overbought, 1d downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 15m & 1h & 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m & 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 4h & 1d down move
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 15m & 4h & 1d down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_55) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_40))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_10))
            # 15m down move, 4h & 1d high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_70))
            # 15m & 1h down move, 15m high, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_45) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 15m & 4h down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_10))
            # 15m & 4h down mve, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80))
            # 15m & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_10))
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_90))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_10))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_10))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_20))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_10))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_60))
            # 1h & 4h & 1d down move, 4h still not low enough, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_50) | (aroonu_14_4h_lt_30) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | rsi_3_4h_gt_20 | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_60))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | aroonu_14_4h_lt_70)
            # 1h & 1d down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_20))
            # 1h & 1d down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_30))
            # 1h down move, 15m downtrend, 1d high
            & ((rsi_3_1h_gt_10) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_10) | (aroonu_14_1h_lt_70) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50))
            # 1h & 1d down move, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_15) | (roc_9_4h_gt_neg_30))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_50))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_70))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (stochrsi_k_1d_lt_80))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_4h_lt_10))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_1d > -30.0))
            # 1h down move, 4h still high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_100))
            # 1h & 4h & 1d down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | aroonu_14_1h_lt_70)
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | aroonu_14_4h_lt_100)
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_25) | (roc_9_1d_gt_neg_30))
            # 1h down move, 15m still high, 1d high
            & ((rsi_3_1h_gt_20) | (aroonu_14_15m_lt_40) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | aroonu_14_1h_lt_80)
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (rsi_14_1d_lt_80))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_20))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_80))
            # 1h down move, 1h high , 1d overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_40))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_75) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_25))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_1h_lt_70))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_20) | (rsi_14_1d_lt_40))
            # 4h down move, 1h still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_3) | (aroonu_14_1h_lt_20) | (roc_9_4h_gt_neg_10))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_1h_lt_90))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_10))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_60))
            # 4h & 1d down move, 4h downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_40))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (roc_9_1d > -30.0))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (aroonu_14_1h_lt_100))
            # 4h down move, 15m still high, 1h still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_80))
            # 4h down move, 1h still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_20) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_50))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | aroonu_14_4h_lt_70)
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d > 50.0) | (stochrsi_k_4h_lt_40))
            # 4h down move, 1d still high, 4h still not low enough
            & ((rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (stochrsi_k_4h_lt_30))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h downtrend, 1d overbought
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_10) | (roc_9_1d_lt_200))
            # 4h down move, 4h high, 4h downtrend
            & (rsi_3_4h_gt_20 | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 4h down move, 1d high & overbought
            & (rsi_3_4h_gt_20 | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_70))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_25) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_10))
            # 1h down move, 4h still not low enough, 1d downtrend
            & (rsi_3_4h_gt_20 | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_80))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_70))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_90))
            # 4h down move, 15m high, 1h high
            & ((rsi_3_4h_gt_30) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_80))
            # 4h down move, 15m & 4h high
            & ((rsi_3_4h_gt_30) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_70))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_30) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_20))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_1h_lt_80))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_55) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_80))
            # 1d down move, 1d high, 4h downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_40))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_45) | (stochrsi_k_1h_lt_90) | (roc_9_1d_lt_10))
            # 1d down move, 4h high, 1d overbought
            & ((rsi_3_1d_gt_45) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_10))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_55) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 1d down move, 1d overbought
            & ((rsi_3_1d_gt_60) | (roc_9_1d_lt_200))
            # 15m & 1h high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_15))
            # 15m & 1h high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_100))
            # 15m & 1h high, 1d downtrend
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_1d_gt_neg_10))
            # 15m high, 1d high & overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 15m high, 1d high & overbought
            & ((aroonu_14_15m_lt_70) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_20))
            # 15m high, 1h high, 1d downtrend
            & ((aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 1h & 4h high, 4h overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 1h & 4h high, 1d overbought
            & ((aroonu_14_1h_lt_90) | aroonu_14_4h_lt_100 | roc_9_1d_lt_50)
            # 1h & 1d high, 1d overbought
            & ((aroonu_14_1h_lt_100) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_40))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_50))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_90) | aroonu_14_1d_lt_100 | roc_9_1d_lt_50)
            # 1h high, 1h & 4h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 4h & 1d overbought
            & ((roc_9_4h_lt_100) | (roc_9_1d_lt_200))
          )

          # Logic
          long_entry_logic.append(
            (rsi_20 < rsi_20_shift_1) & (rsi_3 < 30.0) & (aroonu_14_lt_25) & (close < sma_16 * 0.960)
          )

        # Condition #142 - Top Coins mode (Long).
        if long_entry_condition_index == 142:
          # Protections
          long_entry_logic.append(is_pair_long_top_coins_mode)
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 4h down move, 15m high
            ((rsi_3_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_15m_lt_40))
            # 5m & 1d down move, 15m high
            & ((rsi_3_gt_10) | (rsi_3_1d_gt_30) | (aroonu_14_15m_lt_80))
            # 5m down move, 15m & 1h high
            & ((rsi_3_gt_10) | (aroonu_14_15m_lt_85) | (aroonu_14_1h_lt_100))
            # 5m down move, 1h & 1d high
            & ((rsi_3_gt_10) | (aroonu_14_1h_lt_80) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h down move
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_15))
            # 15m & 1h & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_20))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (roc_9_1d_lt_60))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_90))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_75))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_40))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_3) | (aroonu_14_4h_lt_90))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_3) | (stochrsi_k_1h_lt_60) | (roc_9_1d_lt_20))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_80))
            # 15m & 1d down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_1d_lt_40))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (stochrsi_k_15m_lt_30))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h & 1d down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_30))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_85))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_60))
            # 15m & 1h & 4h down move, 15m still not low enough, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_40))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (aroonu_14_15m_lt_30) | (aroonu_14_4h_lt_70))
            # 15m & 1h down move, 4h high, 4h overbought, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80))
            # 15m down move, 4h high, 1h overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10))
            # 15m & 1h & 4h down move, 4h still high, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40) | (rsi_14_1d_lt_50))
            # 15m & 1h & 4h & 1d down mode, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (roc_9_1d_gt_neg_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_85))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_60))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_4h_lt_60))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (aroonu_14_15m_lt_40))
            # 15m & 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_60))
            # 15m & 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_55) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_50))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_lt_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (rsi_14_1d_lt_70))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 14m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | roc_9_1d_lt_50)
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_90))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_35) | (roc_9_4h_lt_10))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_70))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_50))
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_80))
            # 15m down move, 1h & 4h high, 4h overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (aroonu_14_4h_lt_100))
            # 15m & 1h & 4h down move, 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_50))
            # 15m & 4h & 1d down move, 1d stil high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_70))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_90))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_45) | (roc_9_4h_lt_20))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m downtrend, 1h high
            & ((rsi_3_15m_gt_15) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1h_lt_60))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_50) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | (roc_9_1d_lt_10))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_60))
            # 15m & 1h & 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m & 1h & 4h & 1d down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_40) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_70))
            # 15m & 4h & 1d down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_55) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_50))
            # 15m down move, 15m still high, 1h high, 4h & 1d overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_50))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m high, 1d high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_90) | aroonu_14_1d_lt_100)
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_90) | (roc_9_1h_lt_10))
            # 15m & 1h & 4h & 1d down move, 15m high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_lt_70))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_60))
            # 15m & 4h down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_10))
            # 15m & 4h down mve, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80))
            # 15m & 1d down move, 15m & 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 15m & 1d down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_10))
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_80) | (roc_9_1d_lt_50))
            # 15m & 4h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_90))
            # 15m down move, 1d high, 1h overbought
            & ((rsi_3_15m_gt_40) | (stochrsi_k_1d_lt_80) | (roc_9_1h_lt_20))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_40))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_60))
            # 1h & 4h & 1d down move, 4h still not low enough, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_50) | (aroonu_14_4h_lt_30) | (aroonu_14_1d_lt_40))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 1d still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_20))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 1h & 4h & 1d down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 1d downtrend, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_70))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_lt_20))
            # 1h & 4h down move. 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_30))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_40))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_40))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1d_lt_70))
            # 1h down move, 15m & 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_4h_lt_10))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 1h & 4h & 1d down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_80))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (rsi_14_1d_lt_40))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_50))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_100))
            # 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 4h & 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_60) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_40))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_50))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_60))
            # 1h & 4g down move, 4h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_50))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1h down move, 4h & 1d high & overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_60) | (roc_9_1d_lt_60))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_40))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_75) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_60) | (stochrsi_k_1d_lt_70) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_200))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_25))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_10) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_20) | (rsi_14_1d_lt_40))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_70))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_5) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_10))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_5) | (stochrsi_k_1h_lt_90))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_50))
            # 4h & 1d down move, 15m downtrend, 1d still not low enough
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_10) | (cmf_20_15m_gt_neg_0_30) | (aroonu_14_1d_lt_30))
            # 4h & 1d down move, 1h still high, 15m high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_50) | (stochrsi_k_15m_lt_60))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_1h_lt_70))
            # 4h down move, 15m still high, 1h still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_80))
            # 4h down move, 15m still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1h high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_70) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_50))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_4h_lt_40))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_70))
            # 4h & 1d down move, 1d still high, 4h & 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_40) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 15m high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_lt_80))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_50) | (stochrsi_k_4h_lt_40))
            # 4h down move, 1d still high, 4h still not low enough
            & ((rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (stochrsi_k_4h_lt_30))
            # 4h down move, 15m still not low enough, 1d high
            & ((rsi_3_4h_gt_15) | (aroonu_14_15m_lt_30) | (aroonu_14_1d_lt_70))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_70))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_80))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_70))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_50) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d overbought
            & ((rsi_3_4h_gt_20) | (roc_9_1d_lt_80))
            # 4h & 1d down move, 4h overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (roc_9_4h_lt_5))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h down move, 15m still not low enough, 4h still high
            & ((rsi_3_4h_gt_25) | (aroonu_14_15m_lt_30) | (stochrsi_k_4h_lt_40))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_5))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_90))
            # 4h down move, 15m high, 1h high
            & ((rsi_3_4h_gt_30) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_80))
            # 4h down move, 4h high, 1d high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 4h down move, 1d stil high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_50) | (aroonu_14_1d_lt_60))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_20))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_1h_lt_80))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_20))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_25))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_200))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_50) | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_55) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_80))
            # 1d down move, 1d high, 4h downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_40))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 1h high, 4h overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_15))
            # 15m & 1h high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_100))
            # 15m & 1h high, 1d downtrend
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100) | (roc_9_1d_gt_neg_10))
            # 15m & 4h & 1d high
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90) | aroonu_14_1d_lt_100)
            # 15m high, 1d high & overbought
            & ((aroonu_14_15m_lt_70) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_20))
            # 15m high, 1h & 4h overbought
            & ((aroonu_14_15m_lt_70) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 15m high, 4h overbought, 1d downtrend
            & ((aroonu_14_15m_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_30))
            # 15m & 1h high
            & ((aroonu_14_15m_lt_90) | (aroonu_14_1h_lt_100))
            # 15m & 4h high
            & ((aroonu_14_15m_lt_90) | aroonu_14_4h_lt_100)
            # 1h & 1d high, 1d overbought
            & ((aroonu_14_1h_lt_100) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_10))
            # 1h & 4h high, 1h overbought
            & ((aroonu_14_1h_lt_100) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_10))
            # 1h & 4h high, 4h overbought
            & ((aroonu_14_1h_lt_100) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_10))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_4h_lt_20))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_30))
            # 4h high, 1h & 4h overbought
            & (aroonu_14_4h_lt_100 | (roc_9_1h_lt_20) | (roc_9_4h_lt_40))
            # 1d high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_60) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 1d high, 4h & 1d overbought
            & (aroonu_14_1d_lt_100 | (roc_9_4h_lt_60) | (roc_9_1d_lt_100))
            # 15m high, 4h & 1d overbought
            & ((stochrsi_k_15m_lt_70) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1h high, 1h & 1d overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20) | (roc_9_1d_lt_100))
            # 4h high, 4h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_20))
            # 1d high, 1h & 4h overbought
            & ((stochrsi_k_1d_lt_80) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_gt_5)
            & (rsi_4 < 46.0)
            # & (stochrsi_k < 20.0)
            & (rsi_20 < rsi_20_shift_1)
            & (close < sma_16 * 0.960)
          )

        # Condition #143 - Top Coins mode (Long).
        if long_entry_condition_index == 143:
          # Protections
          long_entry_logic.append(is_pair_long_top_coins_mode)
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 4h & 1d down move
            ((rsi_3_gt_3) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_10))
            # 5m & 4h down move, 4h still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (stochrsi_k_1d_lt_70))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (aroonu_14_1h_lt_25))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_10))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_20) | (aroonu_14_4h_lt_20))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (stochrsi_k_1d_lt_50))
            # 15m & 1h & 4h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_15m_lt_40))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_90))
            # 15m & 1h & 4h & 1d down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_4h_lt_50))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_70))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_35) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_85))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_3) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_50))
            # 15m & 1d down move, 4h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_50))
            # 15m & 1h & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_50))
            # 15m & 1h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (rsi_14_4h_lt_40))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_15) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_1h_gt_50) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_60))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_40) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_90))
            # 15m & 4h down move, 1d still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (rsi_14_1d_lt_40))
            # 15m & 4h down move, 15m still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_15m_lt_30))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_80))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_40))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_10) | (aroonu_14_1h_lt_50))
            # 15m & 1d down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_3) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_3) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_20))
            # 15m & 1h & 4h & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (roc_9_1d_lt_10))
            # 15m down move, 15m still high, 1d downtrend
            & ((rsi_3_15m_gt_5) | (aroonu_14_15m_lt_50) | (roc_9_1d_gt_neg_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_5) | (stochrsi_k_1h_lt_50) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h & 1d down mode, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (roc_9_1d_gt_neg_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_60))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_60))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (stochrsi_k_4h_lt_90))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_80))
            # 15m & 1h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h & 4h & 1d down move, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (aroonu_14_1h_lt_80))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80))
            # 15m & 1h & 4h down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50))
            # 15m & 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_10))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_lt_70))
            # 15m & 4h down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_35) | (roc_9_4h_lt_10))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_70))
            # 15m & 1d down move, 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_40))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_15m_lt_70))
            # 15m down move, 15m high, 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_60) | (aroonu_14_1d_lt_100))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 15m down move, 1h still high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_20))
            # 15m & 1h & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 15m & 1h down move, 1h high, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_70))
            # 15m & 1h & 4h down move, 15m still high, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_90))
            # 15m down move, 4h high, 4h overbought, 1d downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 1h & 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_10))
            # 15m & 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_10))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (stochrsi_k_1h_lt_80))
            # 15m & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 15m & 1h & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (roc_9_1d_lt_150))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_1d_gt_25) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_20))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30))
            # 1h & 4h & 1d down move, 1h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_30))
            # 1h down move, 4h & 1d downtrend
            & ((rsi_3_1h_gt_5) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_20))
            # 1h & 4h & 1d down move, 4h & 1d still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_30) | (stochrsi_k_1d_lt_30))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_40) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1h still not low enough, 1d overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_30) | (roc_9_1d_lt_50))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_100))
            # 1h & 1d down move, 1d overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_30))
            # 1h down move, 1d high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h & 1d down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_30) | (roc_9_1d_gt_neg_40))
            # 1h & 4h & 1d down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_4h_lt_20) | (roc_9_1d_lt_30))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_60))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_85))
            # 1h down move, 4h & 1d high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_40) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_50) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_80))
            # 1h down move, 4h & 1d high & overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_100) | (roc_9_1d_lt_100))
            # 4h & 1d down move, 15m still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_15m_lt_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_5) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_50))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_5) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_lt_40))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_10))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_40))
            # 4h & 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_4h_gt_neg_10))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_60))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_60))
            # 4h down move, 1d still high, 4h still not low enough
            & ((rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (stochrsi_k_4h_lt_30))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_60) | (roc_9_1d_lt_100))
            # 1h down move, 1h still high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_15) | aroonu_14_4h_lt_70 | (aroonu_14_1d_lt_70))
            # 4h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1h_lt_80))
            # 4h down move, 1h downtrend, 1d overbought
            & ((rsi_3_4h_gt_15) | (roc_9_1h_gt_neg_10) | (roc_9_1d_lt_200))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_50))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_70))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_70))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_60) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_60) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_40))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_20))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_lt_50) | (aroonu_14_1h_lt_100))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_1h_lt_80))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high, 4h & 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_100) | (roc_9_1d_lt_100))
            # 1h high, 4h & 1d overbought
            & ((aroonu_14_1h_lt_70) | (roc_9_4h_lt_40) | (roc_9_1d_lt_80))
            # 1h & 4h high, 1d overbought
            & ((aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_100) | (roc_9_1d_lt_40))
            # 1h & 4h & 1d high
            & ((aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1d high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_60) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
          )

          # Logic
          long_entry_logic.append(
            (rsi_3_lt_40)
            & (stochrsi_k_lt_20)
            & (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.020))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
          )

        # Condition #144 - Top Coins mode (Long).
        if long_entry_condition_index == 144:
          # Protections
          long_entry_logic.append(is_pair_long_top_coins_mode)
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 1h down move, 1h still not low enough
            ((rsi_3_gt_3) | (rsi_3_1h_gt_10) | (aroonu_14_1h_lt_30))
            # 5m & 4h down move, 15m still high
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_5) | (aroonu_14_15m_lt_40))
            # 5m & 4h & 1d down move
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_10))
            # 5m & 4h down move, 1d downtrend
            & ((rsi_3_gt_3) | (rsi_3_4h_gt_10) | (roc_9_1d_gt_neg_10))
            # 5m & 4h down move, 15m high
            & ((rsi_3_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_15m_lt_40))
            # 15m & 1h down move, 1h still not low enough
            & (rsi_3_15m_gt_3 | (rsi_3_1h_gt_3) | (aroonu_14_1h_lt_25))
            # 15m & 1h & 4h down move, 15m still not low enough, 4h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_20) | (aroonu_14_4h_lt_20))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_40))
            # 15m & 1h & 1d down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_5) | (aroonu_14_1d_lt_70))
            # 15m & 1h & 4h & 1d down move, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_lt_30))
            # 15m & 1h down move, 1d high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_1d_lt_100))
            # 15m & 1h & 4h down move, 15m still not low enough, 1h still not low enough
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h_lt_30))
            # 15m  & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 4h down move, 4h downtrend
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_5) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 4h still high, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_14_4h_lt_40) | (rsi_14_1d_lt_50))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (rsi_14_4h < 20.0))
            # 15m & 4h & 1d down move, 15m high, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_60) | (aroonu_14_1d_lt_70))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (stochrsi_k_15m_lt_50))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_30))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (roc_9_1d_lt_30))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_40))
            # 15m down move, 4h high, 4h overbought, 1d downtrend
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_70) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_15) | (roc_9_4h_lt_20) | (roc_9_1d_lt_200))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 1h still high, 15m still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_50) | (stochrsi_k_15m_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_100))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (stochrsi_k_4h_lt_90))
            # 15m down move, 4h & 1d high, 4h overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10))
            # 15m & 1h & 4h down move, 1d high & overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_200))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_45) | (stochrsi_k_15m_lt_70))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_100))
            # 15m & 4h & 1d down move, 1d stil high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50) | (roc_9_4h_gt_neg_20))
            # 15m & 4h down move, 1d downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_20))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (stochrsi_k_4h_lt_80))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_30))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_50) | aroonu_14_4h_lt_80)
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_30))
            # 15m down move, 1h & 4h overbought
            & ((rsi_3_15m_gt_25) | (roc_9_1h_lt_10) | (roc_9_4h_lt_30))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 1h downtrend
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (cmf_20_1h_gt_neg_0_20))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_1d_lt_40))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_40))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_20))
            # 1h & 4h down move, 1d still high
            & ((rsi_3_1h_gt_5) | rsi_3_4h_gt_20 | (aroonu_14_1d_lt_50))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_30))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_5) | (aroonu_14_1h_lt_40))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_5) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 1h & 4h & 1d down move, 4h downtrend, 1d still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (rsi_14_4h_gt_30) | (aroonu_14_1d_lt_40))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_50))
            # 1h & 4h & 1d down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (stochrsi_k_15m_lt_60))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_10))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_70))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_70))
            # 1h down move, 1d high, 1h downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_70) | (roc_9_1h_gt_neg_10))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (roc_9_1d_gt_neg_40))
            # 1h & 1d down move, 15m & 1h still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1h_lt_30))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_80))
            # 1h down move, 4h still high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 4h high, 4h overbought, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1d high, 4h downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (stochrsi_k_4h_lt_80) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 1d still high, 1h still not low enough
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_50) | (stochrsi_k_1h_lt_20))
            # 1h & 4h & 1d down move, 1h still not low enough, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_45) | (aroonu_14_1h_lt_30) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_40))
            # 1h & 4h & 1d down move, 1h stil high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_80))
            # 1h & 4h down move, 4h overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_100))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_50))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_70))
            # 1h down move, 1h high, 1h still not low enough
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_80) | (stochrsi_k_1h_lt_20))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h down move, 4h still high, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high & overbought, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h & 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h high, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_lt_70))
            # 1h & 4h down move, 4h still not low enough
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_4h_lt_30))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (roc_9_1d_lt_100))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_60))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (rsi_14_1d_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80) | (stochrsi_k_4h_lt_80))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_1h_lt_10))
            # 1h & 4h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h & 4h down move, 4h & 1d high
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h high, 15m high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 15m still not low enough
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_15) | (aroonu_14_15m_lt_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_lt_40))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_3) | (rsi_3_1d_gt_25) | (aroonu_14_1d_lt_70))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_60))
            # 4h & 1d down move, 1d still high, 1h still low enough
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_35) | (rsi_14_1d_lt_40) | (stochrsi_k_1h_lt_20))
            # 4h down move, 15m still high, 4h still not low enough
            & ((rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_50) | (aroonu_14_4h_lt_30))
            # 4h & 1d down move, 15m still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_lt_40))
            # 4h down move, 4h still not low enough, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_20) | (roc_9_1d_gt_neg_10))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_40) | (roc_9_1d > -30.0))
            # 4h down move, 1d high, 15m high
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_80) | (stochrsi_k_15m_lt_60))
            # 4h down move, 1d high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_100) | (roc_9_4h_gt_neg_10))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1d_lt_50))
            # 4h & 1d down move, 1d still high, 4h & 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (rsi_14_1d_lt_40) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_lt_50))
            # 4h & 1d down move, 4h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (stochrsi_k_4h_lt_40))
            # 4h down move, 4h still not low enough, 1d high
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_30) | (aroonu_14_1d_lt_70))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_70))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (roc_9_1d_gt_neg_30))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_70))
            # 4h & 1d down move, 4h overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (roc_9_4h_lt_5))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (roc_9_1d_lt_10))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_30) | (rsi_3_1d > 70.0) | (roc_9_1d_lt_20))
            # 4h down move, 4h high, 1d high
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_70) | (stochrsi_k_1d_lt_80))
            # 4h down move, 1d stil high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_1d_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h still high, 4h downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_40) | (roc_9_4h_gt_neg_15))
            # 4h & 1d down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_50) | (aroonu_14_1d_lt_60))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d high & overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_55) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_100))
            # 1d down move, 4h still not low enough, 4h downtrend
            & ((rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_30) | (roc_9_4h_gt_neg_15))
            # 1d down move, 4h & 1d downtrend
            & ((rsi_3_1d_gt_10) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1d high, 4h downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_20))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_25) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_30) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h high, 4h & 1d overbought
            & ((aroonu_14_1h_lt_70) | (roc_9_4h_lt_40) | (roc_9_1d_lt_80))
            # 4h & 1d high & overbought
            & ((aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_40) | (roc_9_1d_lt_60))
            # 4h & 1d high, 1h overbought
            & ((aroonu_14_4h_lt_85) | (aroonu_14_1d_lt_100) | (roc_9_1h_lt_10))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 15m high, 4h & 1d overbought
            & ((stochrsi_k_15m_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 15m still high, 4h & 1d overbought
            & ((stochrsi_k_15m_lt_50) | (roc_9_4h_lt_40) | (roc_9_1d_lt_100))
            # 4h high, 4h & 1d overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_60))
            # 1d high, 4h & 1d overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_4h_lt_30) | (roc_9_1d_lt_100))
            # 4h & 1d overbought
            & ((roc_9_4h_lt_100) | (roc_9_1d_lt_200))
            # 1d P&D, 4h overbought
            & ((change_pct_1d_gt_neg_10) | (change_pct_1d_shift_288 < 50.0) | (roc_9_4h_lt_30))
          )

          # Logic
          long_entry_logic.append(
            (willr_14 < -50.0)
            & (stochrsi_k_lt_30)
            # & (df["STOCHRSIk_14_14_3_3_15m"] < 40.0)
            & (stochrsi_k_1h_lt_40)
            & (bbb_20_2_0_1h > 12.0)
            & (close_max_48 >= (close * 1.10))
          )

        # Condition #145 - Top Coins mode (Long).
        if long_entry_condition_index == 145:
          # Protections
          long_entry_logic.append(is_pair_long_top_coins_mode)
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # 5m & 4h down move, 1d downtrend
            ((rsi_3_gt_3) | (rsi_3_4h_gt_3) | (roc_9_1d_gt_neg_20))
            # 5m down move, 15m & 1h high
            & ((rsi_3_gt_10) | (aroonu_14_15m_lt_85) | (aroonu_14_1h_lt_100))
            # 15m & 1h & 4h down move
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (rsi_3_4h_gt_5))
            # 15m & 1h down move, 1h downtrend
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_3) | (roc_9_1h_gt_neg_20))
            # 15m & 1h down move, 1h still not low enough
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_10) | (stochrsi_k_1h_lt_20))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_3) | (rsi_3_1h_gt_15) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_10) | (aroonu_14_4h_lt_70))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 1d high, 4h downtrend, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_80) | (roc_9_4h_gt_neg_10) | (roc_9_1d_lt_20))
            # 15m & 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (rsi_14_1d_lt_50))
            # 15m & 1h & 4h & 1d down move, 1d high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_55) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_80))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70))
            # 15m & 4h down move, 4h still not low enough
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_30))
            # 15m & 4h down move, 15m & 4h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_40) | (aroonu_14_4h_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_lt_70))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_4h_lt_70))
            # 15m & 4h down move, 15m & 4h, 1d overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_15m_lt_60) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_20))
            # 15m & 1h & 4h & 1d down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_lt_50))
            # 15m & 1h & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_4h_lt_100))
            # 15m & 4h & 1d down move, 15m still high, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (aroonu_14_15m_lt_50) | (aroonu_14_1d_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1d_lt_90))
            # 15m & 4h & 1d down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_90))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_90))
            # 15m down move, 15m downtrend, 1h high
            & ((rsi_3_15m_gt_15) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1h_lt_60))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_40) | (stochrsi_k_4h_lt_60))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 15m down move, 1h high, 1d downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_90) | (roc_9_1d_gt_neg_30))
            # 15m & 1h down move, 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (roc_9_1d_gt_neg_30))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 4h high, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (aroonu_14_4h_lt_80) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_40))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m & 4h & 1d down move, 4h still high, 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_50))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_100))
            # 15m & 1h & 4h down move, 1d still high, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_45) | (rsi_14_1d_lt_50) | (stochrsi_k_4h_lt_80))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (stochrsi_k_15m_lt_50))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_25) | (stochrsi_k_15m_lt_50) | (roc_9_1d_lt_30))
            # 15h & 1h & 4h down move, 15m high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_15m_lt_70))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | aroonu_14_4h_lt_70)
            # 15m down move, 15m high, 1h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_70))
            # 15m down move, 15m high, 4h high
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_80))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_30) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_20))
            # 15m down move, 4h & 1d high, 4h & 1d overbought
            & ((rsi_3_15m_gt_35) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 15m down move, 4h & 1d overbought
            & ((rsi_3_15m_gt_35) | (roc_9_4h_lt_30) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_3) | rsi_3_4h_gt_20 | (aroonu_14_4h_lt_40))
            # 1h down move, 4h still high, 1d high
            & ((rsi_3_1h_gt_3) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_90))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_40))
            # 1h & 1d down move, 1h still not low enough
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (rsi_3_1d_gt_15))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 1h & 4h down move, 4h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_10))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (roc_9_4h_gt_neg_30))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (stochrsi_k_15m_lt_80))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_90))
            # 1h & 4h down move, 4h high, 1d high & overbought
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_45) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_20))
            # 1h & 1d down move, 1h still not low enough
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_1h_lt_30))
            # 1h down move, 15m downtrend, 1d high
            & ((rsi_3_1h_gt_10) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_1d_lt_70))
            # 1h down move, 4h still high, 1d overbought
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_lt_40) | (roc_9_1d_lt_40))
            # 1h down move, 1d still high, 1d downtrend
            & ((rsi_3_1h_gt_10) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_20))
            # 1h & 4h & 1d down move
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (rsi_3_1d_gt_20))
            # 1h & 4h down move, 15m still not low enough
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_lt_30))
            # 1h & 4h down move, 15m still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_15m_lt_50))
            # 1h & 4h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (rsi_14_1d_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (roc_9_1d_gt_neg_40))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_60))
            # 1h down move, 1h still high, 4h overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_50) | (roc_9_4h_lt_10))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | (roc_9_1d_gt_neg_30))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_4h_lt_30) | (roc_9_1d_lt_50))
            # 1h & 4h & 1d down move, 1d still high, 4h downtrend
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_35) | (stochrsi_k_1d_lt_40) | (roc_9_4h_gt_neg_10))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70))
            # 1h & 4h down move, 1d high & overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_30))
            # 1h & 1d down move, 4h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_50))
            # 1h & 1d down move, 1h still high
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_50))
            # 1h down move, 15m still high, 1h high
            & ((rsi_3_1h_gt_20) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_80))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_20) | (aroonu_14_4h_lt_80) | (roc_9_4h_lt_60))
            # 1h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_30) | (roc_9_1d_gt_neg_30))
            # 1h & 4h & 1d down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_10))
            # 1h & 4h down move, 1h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_20))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_85))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_30))
            # 1h down move, 1h still high, 4h downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_50) | (roc_9_4h_gt_neg_20))
            # 1h down move, 1d overbought
            & ((rsi_3_1h_gt_25) | (roc_9_1d_lt_80))
            # 1h down move, 1h still high, 4h high & overbought
            & ((rsi_3_1h_gt_30) | (rsi_14_1h_lt_40) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_20))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_70) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_40) | (stochrsi_k_4h_lt_80))
            # 1h & 1d down move, 1h high
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_1h_lt_70))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_40) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_60))
            # 1h down move, 4h high, 1d downtrend
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_1d_gt_neg_30))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_70) | (roc_9_1d_gt_neg_30))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_80) | (roc_9_4h_lt_10))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_25))
            # 1h down move, 4h high, 1h & 4h overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_10) | (roc_9_4h_lt_10))
            # 4h down move, 4h & 1d downtrend
            & ((rsi_3_4h_gt_5) | (roc_9_4h_gt_neg_15) | (roc_9_1d_gt_neg_20))
            # 4h & 1d down move, 1d still high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_lt_50))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_60) | (aroonu_14_1d_lt_70))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_50) | (roc_9_1d_gt_neg_30))
            # 4h down move, 15m & 1h still not low enough
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1h_lt_30))
            # 4h down move, 15m stil high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50) | (roc_9_4h_gt_neg_20))
            # 4h & 1d down move, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (roc_9_1d > -30.0))
            # 4h & 1d down move, 1h still high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_50))
            # 4h & 1d down move, 4h high
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_70))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_lt_60))
            # 4h & 1d down move, 15m still high, 4h downtrend
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_lt_50) | (roc_9_4h_gt_neg_20))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_20) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_70))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_20) | (stochrsi_k_15m < 90.0))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_30))
            # 4h & 1d down move, 1d overbought
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (roc_9_1d_lt_10))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1d_lt_80))
            # 4h down move, 15m high, 1d overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_15m < 90.0) | (roc_9_1d_lt_10))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_40))
            # 4h & 1d down move, 1h high
            & ((rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (stochrsi_k_1h_lt_70))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_55) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_80))
            # 1d down move, 1d high, 1d downtrend
            & ((rsi_3_1d_gt_15) | (aroonu_14_1d_lt_70) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_70))
            # 1d down move, 1h high, 1d downtrend
            & ((rsi_3_1d_gt_25) | (stochrsi_k_1h_lt_60) | (roc_9_1d_gt_neg_30))
            # 1d down move, 1d high, 4h downtrend
            & ((rsi_3_1d_gt_35) | (aroonu_14_1d_lt_70) | (roc_9_4h_gt_neg_10))
            # 1d down move, 4h high, 1d overbought
            & ((rsi_3_1d_gt_60) | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_40))
            # 15m high, 1d high & overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 15m high, 4h overbought, 1d downtrend
            & ((aroonu_14_15m_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_gt_neg_30))
            # 1h & 4h high, 4h overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10))
            # 1h high, 1d overbought
            & ((aroonu_14_1h_lt_85) | (roc_9_1d_lt_80))
            # 1h high, 4h & 1d downtrend
            & ((aroonu_14_1h_lt_100) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_25))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_100) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_60))
            # 1h high, 4h & 1d downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_25))
            # 1h & 4h high, 4h overbought
            & ((stochrsi_k_1h_lt_90) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_10))
          )

          # Logic
          long_entry_logic.append(
            (rsi_14 < 36.0)
            & (bbd_40_2_0 > close * 0.020)
            & (close_delta > close * 0.02)
            & (bbt_40_2_0 < bbd_40_2_0 * 0.3)
            & (close < bbl_40_2_0_shift_1)
            & (close <= close_shift_1)
          )

        # Condition #161 - Scalp mode (Long).
        if long_entry_condition_index == 161:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          # 5m down move, 15m high
          long_entry_logic.append(
            ((rsi_3_gt_15) | (aroonu_14_15m_lt_80))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | aroonu_14_4h_lt_70)
            # 15m & 4h down move, 4h still high
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_50) | (aroonu_14_4h_lt_50))
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_80))
            # 15m down move, 4h still high, 1d high
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_50) | (aroonu_14_1d_lt_90))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_60) | (aroonu_14_15m_lt_50))
            # 15m & 4h & 1d down move, 15m high
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_50) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_70))
            # 15m down move, 15m & 4h still high
            & ((rsi_3_15m_gt_30) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_50))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_60) | aroonu_14_4h_lt_80)
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | aroonu_14_1h_lt_70)
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_40) | (rsi_3_1h_gt_60) | aroonu_14_4h_lt_80)
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_50))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_70))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_40) | (aroonu_14_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_40) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 15m down move, 4h still high, 1d overbought
            & ((rsi_3_15m_gt_40) | (aroonu_14_4h_lt_50) | (roc_9_1d_lt_100))
            # 15m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_45) | (rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_40))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_60) | roc_9_1d_lt_50)
            # 15m down move, 15m high, 4h still high
            & ((rsi_3_15m_gt_45) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m still not low enough, 4h still high
            & ((rsi_3_15m_gt_45) | (stochrsi_k_15m_lt_30) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_45) | (stochrsi_k_15m < 45.0) | (stochrsi_k_1h_lt_40))
            # 15m & 1h down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_60) | (stochrsi_k_4h_lt_70) | (roc_9_1d_lt_20))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_50) | (stochrsi_k_15m_lt_30) | (stochrsi_k_4h_lt_90))
            # 15m down move, 15m still high, 1d overbought
            & ((rsi_3_15m_gt_50) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_50))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_55) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_70))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_55) | (stochrsi_k_15m_lt_50) | (aroonu_14_4h_lt_85))
            # 15m down move, 15m & 1h still high
            & ((rsi_3_15m_gt_55) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 1h down move, 4h still high, 1d high
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_50) | (stochrsi_k_1d_lt_90))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_50))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_40) | (stochrsi_k_1d_lt_90))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_55) | (stochrsi_k_4h_lt_50))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_80))
            # 1h down move, 15m & 1h still high
            & ((rsi_3_1h_gt_40) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_50) | (stochrsi_k_4h_lt_70))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_60))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_40) | (aroonu_14_4h_lt_85) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_45) | (stochrsi_k_1h_lt_60))
            # 1h & 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_lt_60) | (roc_9_1d_lt_50))
            # 1h & 4h down move, 15m high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (aroonu_14_15m_lt_70))
            # 1h down move, 15m still high, 4h high
            & ((rsi_3_1h_gt_50) | (aroonu_14_15m_lt_50) | aroonu_14_4h_lt_80)
            # 1h down move, 15m high, 1h still high
            & ((rsi_3_1h_gt_50) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_40))
            # 1h down move, 15m still high, 4h high
            & ((rsi_3_1h_gt_50) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_80))
            # 1h down move, 15m & 1h high
            & ((rsi_3_1h_gt_50) | (stochrsi_k_15m_lt_60) | (aroonu_14_1h_lt_60))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_70) | (stochrsi_k_1d_lt_80))
            # 1h down move, 4h still high, 1d high
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_50) | (stochrsi_k_1d_lt_90))
            # 1h down move, 1h still high, 1d high
            & ((rsi_3_1h_gt_50) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_90))
            # 1h down move, 4h overbought
            & ((rsi_3_1h_gt_50) | (roc_9_4h_lt_40))
            # 1h & 4h down move, 1h & 4h high
            & ((rsi_3_1h_gt_55) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_70))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_55) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100))
            # 1h down move, 5m up move, 1h still high
            & ((rsi_3_1h_gt_60) | (rsi_3 < 60.0) | (stochrsi_k_1h_lt_50))
            # 1h & 4h down move, 1h stil high, 1d high
            & ((rsi_3_1h_gt_60) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_50) | (aroonu_14_1d_lt_90))
            # 1h down move, 15m still not low enough, 4h high
            & ((rsi_3_1h_gt_60) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_90))
            # 1h down move, 15m still not low enough, 1h high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_15m_lt_30) | aroonu_14_1h_lt_70)
            # 1h down move, 15m still not low enough, 1h high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_15m_lt_30) | (stochrsi_k_1h_lt_60))
            # 1h down move, 15m & 4h still high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_50))
            # 1h down move, 15m & 1h high
            & ((rsi_3_1h_gt_60) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_90))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_50) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h high, 4h still high
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_40))
            # 1h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_40) | aroonu_14_4h_lt_70)
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_70) | (aroonu_14_1d_lt_90))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_60) | (rsi_14_4h_lt_70) | (rsi_14_1d_lt_80))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_50) | (rsi_3_1h_gt_65) | (rsi_3_4h_gt_65) | (aroonu_14_4h_lt_85))
            # 4h down move, 15m high
            & (rsi_3_4h_gt_20 | (aroonu_14_15m_lt_80))
            # 4h down move, 1h high
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_80))
            # 4h down move, 15m & 4h still high
            & ((rsi_3_4h_gt_30) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_50))
            # 4h down move, 15m still high, 1d overbought
            & ((rsi_3_4h_gt_30) | (stochrsi_k_15m_lt_50) | (roc_9_1d_lt_10))
            # 4h down move, 1h & 4h still high
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1h_lt_50) | (aroonu_14_4h_lt_50))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_40))
            # 4h down move, 15m & 1h high
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_80) | (stochrsi_k_1h_lt_70))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_40) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_80))
            # 4h down move, 1h & 4h still high
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_50) | (rsi_14_4h_lt_50))
            # 4h down move, 1h still high, 4h still moving down
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_50) | (cci_20_change_pct_4h > -0.0))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_10))
            # 4h & 1d down move, 15m high, 1h high
            & ((rsi_3_4h_gt_45) | (rsi_3_1d_gt_55) | (aroonu_14_15m_lt_70) | (stochrsi_k_1h_lt_80))
            # 4h down move, 1h high, 4h still high
            & ((rsi_3_4h_gt_45) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_50))
            # 4h down move, 4h still high, 1d high & overbought
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_50) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_30))
            # 4h down move, 15m high, 4h still high
            & ((rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (stochrsi_k_4h_lt_40))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_50) | (stochrsi_k_15m_lt_40) | (stochrsi_k_1h_lt_70))
            # 4h down move, 15m & 4h still high
            & ((rsi_3_4h_gt_50) | (stochrsi_k_15m_lt_50) | (aroonu_14_4h_lt_50))
            # 4h down move, 15m high, 1h high, 1d overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_20))
            # 4h down move, 15m high, 4h still not low enough
            & ((rsi_3_4h_gt_50) | (stochrsi_k_15m_lt_70) | (stochrsi_k_4h_lt_30))
            # 4h down move, 1h still high, 4h high
            & ((rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_50) | aroonu_14_4h_lt_70)
            # 4h down move, 15m & 1d high
            & ((rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_50) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 15m & 4h high
            & ((rsi_3_4h_gt_60) | (aroonu_14_15m_lt_70) | aroonu_14_4h_lt_70)
            # 4h down move, 15m high, 4h still high
            & ((rsi_3_4h_gt_60) | (aroonu_14_15m_lt_80) | (aroonu_14_4h_lt_40))
            # 4h down move, 15m still high, 1h high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_50) | aroonu_14_1h_lt_70)
            # 4h down move, 15m still high, 4h high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_50) | (stochrsi_k_4h_lt_70))
            # 4h down move, 15m & 4h high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_15m_lt_70) | (stochrsi_k_4h_lt_60))
            # 4h down move, 1h & 4h high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_1h_lt_70) | aroonu_14_4h_lt_70)
            # 4h down move, 4h still high, 1d high
            & ((rsi_3_4h_gt_60) | (stochrsi_k_4h_lt_50) | (stochrsi_k_1d_lt_80))
            # 15m still high, 1d high & overbought
            & ((aroonu_14_15m_lt_50) | aroonu_14_1d_lt_100 | (roc_9_1d_lt_100))
            # 15m high, 4h high
            & ((aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_85))
            # 15m & 1d high, 1d overbought
            & ((aroonu_14_15m_lt_70) | (aroonu_14_1d_lt_90) | (roc_9_1d_lt_20))
            # 15m & 1d high, 4h overbought
            & ((aroonu_14_15m_lt_70) | aroonu_14_1d_lt_100 | (roc_9_4h_lt_10))
            # 15m high, 4h still high
            & ((aroonu_14_15m_lt_80) | (stochrsi_k_4h_lt_50))
            # 4h & 1d high, 1d overbought
            & (aroonu_14_4h_lt_100 | aroonu_14_1d_lt_100 | (roc_9_1d_lt_20))
            # 4h high, 4h overbought
            & (aroonu_14_4h_lt_70 | (roc_9_4h_lt_40))
            # 4h high, 1d overbought
            & (aroonu_14_4h_lt_70 | (roc_9_1d_lt_40))
            # 1d high, 4h overbought
            & ((aroonu_14_1d_lt_90) | (roc_9_4h_lt_40))
            # 1d high & overbought
            & (aroonu_14_1d_lt_100 | (roc_9_1d_lt_200))
            # 15m high, 1h still high
            & ((stochrsi_k_15m_lt_70) | (stochrsi_k_1h_lt_40))
            # 15m & 4h high
            & ((stochrsi_k_15m_lt_70) | aroonu_14_4h_lt_70)
            # 15m high, 1d overbought
            & ((stochrsi_k_15m_lt_70) | (roc_9_1d_lt_10))
            # 15m high, 1h still not low enough
            & ((stochrsi_k_15m_lt_80) | (stochrsi_k_1h_lt_30))
            # 1d high, 4h overbought
            & ((stochrsi_k_1d_lt_80) | (roc_9_4h_lt_40))
            # 1d high & overbought
            & ((stochrsi_k_1d_lt_90) | (roc_9_1d_lt_30))
            # 4h & 1d overbought
            & ((roc_9_4h_lt_40) | (roc_9_1d_lt_40))
            # 1d green with top wick, 1d overbought
            & ((change_pct_1d_lt_25) | (top_wick_pct_1d_lt_25) | roc_9_1d_lt_50)
          )

          # Logic
          long_entry_logic.append(
            (rsi_14 < 50.0)
            & aroonu_14_15m_lt_90
            & (stochrsi_k_15m < 90.0)
            & (sma_21_shift_1 < sma_200_shift_1)
            & ~np.isnan(sma_200_shift_1)
            & (sma_21 > sma_200)
            & ~np.isnan(sma_200)
            & (close > ema_200_1h)
            & ~np.isnan(ema_200_1h)
            & (close > ema_200_4h)
            & ~np.isnan(ema_200_4h)
            & (bbb_20_2_0 > 1.5)
            & (bbb_20_2_0_1h > 6.0)
          )

        # Condition #162 - Scalp mode (Long).
        if long_entry_condition_index == 162:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append((rsi_3_gt_5) & (rsi_3_15m_gt_5) & (roc_9_15m > -10.0) & (roc_9_1d_lt_200))

          long_entry_logic.append(
            # 15m & 1h down move, 4h high
            ((rsi_3_15m_gt_10) | rsi_3_1h_gt_20 | (stochrsi_k_4h_lt_70))
            # 15m & 1d down move, 1h high & overbought
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (rsi_14_1h_lt_50))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_4h_lt_90))
            # 15m down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_50) | aroonu_14_1h_lt_80)
            # 15m down move, 15m high
            & ((rsi_3_15m_gt_10) | (aroonu_14_15m_lt_70))
            # 15m down move, 1h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_1h_lt_90) | aroonu_14_1d_lt_100)
            # 15m down move, 4h & 1d high
            & ((rsi_3_15m_gt_10) | (aroonu_14_4h_lt_75) | aroonu_14_1d_lt_100)
            # 15m down move, 1d high, 1d downtrend
            & ((rsi_3_15m_gt_10) | (aroonu_14_1d_lt_85) | (cmf_20_1d_gt_neg_0_40))
            # 15m & 1h down move, 15m still not low enough
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (stochrsi_k_15m_lt_30))
            # 15m & 1h down nove, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (stochrsi_k_1h_lt_50))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (aroonu_14_4h_lt_100))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_90))
            # 15m & 1d down move, 15m high, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_50) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 15m down move, 4h high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_60) | (roc_9_4h_gt_neg_20))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_10) | (roc_9_1d_gt_neg_40))
            # 15m & 1h & 4h & 1d down move, 15m downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (cmf_20_15m_gt_neg_0_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_70))
            # 15m & 1h down move, 1d high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_50) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_100))
            # 15m & 4h down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (roc_9_4h_gt_neg_40) | (roc_9_1d_gt_neg_50))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_4h_lt_70) | (roc_9_4h_lt_20))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_90))
            # 15m & 1h & 4h down move, 15m high, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 15m down move, 15m high, 1d overbought
            & ((rsi_3_15m_gt_25) | (aroonu_14_15m_lt_60) | (roc_9_1d_lt_150))
            # 15m down move, 15m still high, 1d high, 1d downtrend
            & ((rsi_3_15m_gt_30) | (aroonu_14_15m_lt_50) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
            # 15m & 1h & 4h down move, 1d high, 4h still not low enough
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100) | (stochrsi_k_4h_lt_30))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_35) | (aroonu_14_1h_lt_80) | (rsi_14_4h_lt_80))
            # 1h & 4h down move, 15m stil high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_10) | (stochrsi_k_15m_lt_50))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_25) | (aroonu_14_1h_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_20) | (aroonu_14_4h_lt_60))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_5) | (rsi_3_4h_gt_30) | (aroonu_14_4h_lt_90))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_5) | (aroonu_14_4h_lt_60) | (roc_9_1d_lt_10))
            # 1h & 4h down move, 4h still not low enough, 1h downtrend
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_20) | (roc_9_1h_gt_neg_10))
            # 1h & 4h down move, 4h still high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_10) | (aroonu_14_4h_lt_50))
            # 1h & 3h down move, 1d high
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_4h_lt_70))
            # 1h down move, 1h downtrend, 1d overbought
            & ((rsi_3_1h_gt_15) | (roc_9_1h_gt_neg_30) | (roc_9_1d_lt_80))
            # 1h & 4h down move, 1d downtrend
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (roc_9_1d_gt_neg_30))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | (aroonu_14_1d_lt_85))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_15) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_50))
            # 1h down move, 1d high & overbought
            & ((rsi_3_1h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_40))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | aroonu_14_4h_lt_70)
            # 4h down move, 1h & 4h still high, 1h downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_1h_lt_40) | (aroonu_14_4h_lt_40) | (roc_9_1h_gt_neg_25))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60) | (roc_9_1d_lt_100))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_90))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70))
            # 1h & 4h down move, 15m & 4h high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_50) | (aroonu_14_15m_lt_70) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_80) | (roc_9_1d_gt_neg_50))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_60) | (roc_9_4h_lt_50))
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80) | (roc_9_1d_lt_80))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_100))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_4h_lt_80) | (roc_9_4h_lt_30))
            # 1h down move, 1h high, 4h downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_20))
            # 1h down move, 15m still high, 1d overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_50))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_45) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1h down move,  4h high, 1d overbought
            & ((rsi_3_1h_gt_50) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_150))
            # 1h down move, 1h high & overbought
            & ((rsi_3_1h_gt_60) | (aroonu_14_1h_lt_70) | (roc_9_1h_lt_20))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_3) | (aroonu_14_1d_lt_90))
            # 4h down move, 15m still high
            & ((rsi_3_4h_gt_3) | (stochrsi_k_15m_lt_50))
            # 4h down move, 1d high
            & ((rsi_3_4h_gt_3) | (stochrsi_k_1d_lt_90))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_3) | (roc_9_1h_gt_neg_30) | (roc_9_4h_gt_neg_30))
            # 4h down move, 1d overbought
            & ((rsi_3_4h_gt_3) | (roc_9_1d_lt_40))
            # 4h & 1d down move
            & ((rsi_3_4h_gt_5) | (rsi_3_1d_gt_10))
            # 4h & 1d down move, 1d high & overbought
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_50))
            # 4h down move, 1d high, 1h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_1d_lt_85) | (roc_9_1h_gt_neg_30))
            # 4h down move, 1h & 4h downtrend
            & ((rsi_3_4h_gt_10) | (roc_9_1h_gt_neg_40) | (roc_9_4h_gt_neg_40))
            # 4h & 1d down move, 4h still not low enough
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_30))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_40))
            # 4h down move, 15m still high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_50))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | (roc_9_1d_lt_50))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_3) | (stochrsi_k_1h_lt_70))
            # 1d down move, 15m still high
            & ((rsi_3_1d_gt_3) | (aroonu_14_15m_lt_50))
            # 1d down move, 15m still high, 1h high
            & ((rsi_3_1d_gt_10) | (aroonu_14_15m_lt_40) | (stochrsi_k_1h_lt_70))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_10) | aroonu_14_1h_lt_70 | (aroonu_14_4h_lt_90))
            # 1d down move, 4h high
            & ((rsi_3_1d_gt_20) | (rsi_14_4h_lt_80))
            # 1d downtrend, 1d high & overbought
            & ((cmf_20_1d_gt_neg_0_30) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_100))
            # 1h & 4h high, 1d overbought
            & (aroonu_14_1h_lt_70 | (aroonu_14_4h_lt_70) | (roc_9_1d_lt_30))
            # 1h & 4h high & overbought
            & ((aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_30) | (roc_9_4h_lt_30))
            # 1h & 4h high, 1d overbought
            & ((aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_90) | (roc_9_1d_lt_20))
            # 1h & 4h high
            & ((aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 4h & 1d high, 4h overbought
            & (aroonu_14_4h_lt_80 | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30))
            # 4h high, 4h & 1d overbought
            & (aroonu_14_4h_lt_80 | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 1d still high, 1h & 4h downtrend
            & ((aroonu_14_1d_lt_50) | (roc_9_1h_gt_neg_20) | (roc_9_4h_gt_neg_20))
            # 1h high, 1h overbought
            & ((stochrsi_k_1h_lt_80) | (roc_9_1h_lt_50))
            # 1h high, 1d downtrend
            & ((stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_60))
            # 4h high, 1h overbought, 1d downtrend
            & ((stochrsi_k_4h_lt_80) | (roc_9_1h_lt_10) | (roc_9_1d_gt_neg_70))
            # 4h high, 1h & 4h overbought
            & ((stochrsi_k_4h_lt_90) | (roc_9_1h_lt_20) | (roc_9_4h_lt_50))
            # 1h & 4h overbought
            & ((roc_9_1h_lt_100) | (roc_9_4h_lt_100))
            # 1h P&D, 1h down move
            & ((change_pct_1h > -10.0) | (change_pct_1h_shift_12 < 10.0) | (rsi_3_1h_gt_50))
            # 4h P&D, 4h high
            & ((change_pct_4h > -15.0) | (change_pct_4h_shift_48 < 30.0) | (aroonu_14_4h_lt_90))
            # 4h green, 15m & 1h down move
            & ((change_pct_4h < 10.0) | (rsi_3_15m_gt_10) | (rsi_3_1h_gt_35))
            # 4h green, 1h down move
            & ((change_pct_4h < 40.0) | (rsi_3_1h_gt_50))
            # 4h green with top wick
            & ((change_pct_4h < 50.0) | (change_pct_4h < 50.0))
            # 1d green with top wick, 15m still high
            & ((change_pct_1d_lt_10) | (top_wick_pct_1d_lt_8) | (aroonu_14_15m_lt_50))
            # 1d green, 4h down move, 4h still high
            & ((change_pct_1d_lt_40) | (rsi_3_4h_gt_35) | (aroonu_14_4h_lt_50))
            # 1d green with top wick, 4h down move
            & ((change_pct_1d_lt_40) | (top_wick_pct_1d_lt_8) | (rsi_3_4h_gt_55))
            # 1d top wick, 1h & 4h down move, 1d high
            & ((top_wick_pct_1d_lt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1d_lt_100))
            # 1d top wick, 4h still high
            & ((top_wick_pct_1d_lt_50) | (aroonu_14_4h_lt_50))
            # big drop in last 4 days, 1d down move
            & ((close > (high_max_24_4h * 0.20)) | (rsi_3_1d_gt_20))
            # big drop in the last 20 days, 4h down move
            & ((close > (high_max_20_1d * 0.15)) | rsi_3_4h_gt_20)
            # big drop in the last 20 days, 1d down move
            & ((close > (high_max_20_1d * 0.05)) | (rsi_3_1d_gt_20))
            # big drop in the last 20 days, 1h still high
            & ((close > (high_max_20_1d * 0.05)) | (stochrsi_k_1h < 45.0))
            # big drop in the last 20 days, 4h high
            & ((close > (high_max_20_1d * 0.05)) | (stochrsi_k_4h_lt_70))
          )

          # Logic
          long_entry_logic.append(
            (aroonu_14_lt_25)
            & (aroond_14_gt_75)
            & (stochrsi_k_lt_30)
            & (ema_26 > ema_12)
            & ((ema_26 - ema_12) > (open_rate * 0.030))
            & ((ema_26_shift_1 - ema_12_shift_1) > (open_rate / 100.0))
            & (close < sma_9)
          )

        # Condition #163 - Scalp mode (Long).
        if long_entry_condition_index == 163:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append((rsi_3_gt_10) & (rsi_3_15m_gt_10) & rsi_3_1h_gt_20)

          long_entry_logic.append(
            # 5m & 15m & 4h down mnove, 4h high
            ((rsi_3_gt_15) | (rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | aroonu_14_4h_lt_80)
            # 5m & 15m & 1d down move, 1h high
            & ((rsi_3_gt_15) | (rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_lt_90))
            # 5m & 1h down move, 15m still high, 4h high
            & ((rsi_3 > 20.0) | (rsi_3_1h_gt_40) | (rsi_14_15m_lt_40) | aroonu_14_4h_lt_100)
            # 5m & 1h & 15m down move, 1h still not low enough
            & ((rsi_3_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_30))
            # 15m & 4h down move, 4h high
            & ((rsi_3_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_70))
            # 5m & 4h down move, 15m high
            & ((rsi_3_gt_15) | (rsi_3_4h_gt_45) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m > 12.0) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_100))
            # 15m & 1h & 4h & 1d down move
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_75) | (aroonu_14_4h_lt_100))
            # 15m & 1h & 4h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (roc_9_1d_lt_40))
            # 15m & 1h & 4h down move, 1h downtrend, 4h high
            & (
              (rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_55) | (cmf_20_1h_gt_neg_0_10) | (aroonu_14_4h_lt_80)
            )
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_14_4h < 85.0))
            # 15m & 1h down move, 15m still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_40))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | aroonu_14_1h_lt_70)
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (stochrsi_k_1h_lt_70))
            # 15m & 1h down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (roc_9_1d_lt_30))
            # 15m & 1h & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_65) | (mfi_14_4h < 85.0))
            # 15m & 1h & 1d down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_15m_lt_60))
            # 15m & 1h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_70))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (stochrsi_k_1h < 85.0))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m & 1h & 4h down move, 1h & 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_50) | (aroonu_14_1h_lt_70) | (aroonu_14_1d_lt_100))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_45) | (rsi_14_4h_lt_70) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_50) | (stochrsi_k_1h_lt_90))
            # 15m & 1h & 1d down move, 1h & 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_55) | (rsi_3_4h_gt_65) | (stochrsi_k_1h_lt_70) | (stochrsi_k_4h_lt_70))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_15m_lt_60))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_30) | aroonu_14_4h_lt_80)
            # 15m & 4h down move, 1h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_40) | (aroonu_14_1h_lt_40))
            # 15m & 4h down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_1d_lt_90))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (stochrsi_k_1h_lt_60))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_50) | (stochrsi_k_1h_lt_80))
            # 15m down move, 4h & 1d up move, 1d downtrend
            & ((rsi_3_15m_gt_15) | (rsi_3_4h < 90.0) | (rsi_3_1d_lt_80) | (cmf_20_1d_gt_neg_0_20))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_10) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h & 4h still high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_50))
            # 15m & 1d down move, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1h_lt_100))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_20) | (aroonu_14_1d_lt_80))
            # 15m & 1d down move, 1d overbought
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_40) | roc_9_1d_lt_50)
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_50) | (aroonu_14_1d_lt_70))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_60) | (stochrsi_k_1d_lt_80))
            # 15m down move, 4h still high, 15m high, 1h high
            & ((rsi_3_15m_gt_15) | (rsi_14_4h_lt_50) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100))
            # 15m down move, 4h high
            & ((rsi_3_15m_gt_15) | (rsi_14_4h_lt_70) | (stochrsi_k_4h_lt_90) | (ema_9 < (ema_26 * 0.972)))
            # 15m down move, 4h high and downtrend
            & ((rsi_3_15m_gt_15) | (cmf_20_4h_gt_neg_0_20) | (aroonu_14_4h_lt_80))
            # 15m down move, 15m & 1h & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_80) | (aroonu_14_4h_lt_80))
            # 15m down move, 15m & 4h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_80))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_15) | (aroonu_14_15m_lt_75) | (aroonu_14_1h_lt_100))
            # 15m down move, 1h high, 4h overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_90) | (roc_9_4h_lt_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_80))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_40))
            # 15m down move, 4h still high, 4h downtrend
            & ((rsi_3_15m_gt_15) | (aroonu_14_4h_lt_40) | (roc_9_4h_gt_neg_20))
            # 15m down move, 1d high & overbought
            & ((rsi_3_15m_gt_15) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_100))
            # 15m down move, 15m still not low enough, 4h high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_15m_lt_30) | (stochrsi_k_4h_lt_50))
            # 15m down move, 15m & 1h high
            & ((rsi_3_15m_gt_15) | (stochrsi_k_15m_lt_50) | (stochrsi_k_1h_lt_50))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_30))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_70) | (roc_9_1d_lt_150))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20))
            # 15m down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_1h_lt_80) | (roc_9_1d_lt_100))
            # 15m down move, 4h high, 1d overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_80) | (roc_9_1d_lt_25))
            # 15m down move, 4h high & overbought
            & ((rsi_3_15m_gt_15) | (stochrsi_k_4h_lt_90) | (roc_9_4h_lt_25))
            # 15m down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_15) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_20))
            # 15m & 1h & 4h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_60) | (aroonu_14_4h_lt_60) | (roc_9_4h_lt_10))
            # 16m & 1h down move, 1h still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_40))
            # 15m & 1h & 4h & 1d down move, 15m still high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_15m_lt_50))
            # 15m & 1h down move, 15m still high, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (aroonu_14_15m_lt_40) | (aroonu_14_1h_lt_85))
            # 15m & 1h down move, 4h high & overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (rsi_14_4h_lt_70) | (roc_9_4h_lt_50))
            # 15m & 1h down move, 1h high, 1d overbought
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_45) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_40))
            # 15m & 4h down move, 4h & 1d downtrend
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_50))
            # 15m & 4h down move, 15m high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_15m_lt_60))
            # 15m & 4h down move, 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_1h_lt_100))
            # 15m & 1d down move, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_70))
            # 15m down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_20) | (rsi_14_15m_lt_40) | (rsi_14_4h_lt_75) | (aroonu_14_4h_lt_100))
            # 15m down move, 4h downtrend, 4h overbought
            & ((rsi_3_15m_gt_20) | (cmf_20_4h_gt_neg_0_0) | (roc_9_4h_lt_40))
            # 15m down move, 1h & 4h high, 1f overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_85) | (rsi_14_4h_lt_70) | (roc_9_1d_lt_80))
            # 15m down move, 1h & 4h high
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_lt_90) | (aroonu_14_4h_lt_100))
            # 15m down move, 1d high, 4h overbought
            & ((rsi_3_15m_gt_20) | (aroonu_14_1d_lt_100) | (roc_9_4h_lt_30))
            # 15m down move, 1h high & overbought
            & ((rsi_3_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_10))
            # 15m & 1h down move, 1h still high, 4h high & overbought
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (aroonu_14_1h_lt_50) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_10))
            # 15m & 1h down move, 15m still high, 4h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_45) | (rsi_14_15m_lt_40) | (aroonu_14_4h_lt_100))
            # 15m & 1h & 4h down move, 1h high
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_50) | (rsi_3_4h_gt_60) | (aroonu_14_1h_lt_100))
            # 15m & 1d down move, 1d high
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_80))
            # 15m down move, 4h high, 1d downtrend
            & ((rsi_3_15m_gt_25) | (stochrsi_k_4h_lt_90) | (roc_9_1d_gt_neg_30))
            # 15m & 1h & 1d down move, 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_4h_lt_70))
            # 15m & 1h down move, 1h & 4h high
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_45) | (rsi_14_4h_lt_70) | (aroonu_14_1h_lt_60) | (aroonu_14_4h_lt_100))
            # 15m & 4h down move, 4h overbought
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_60) | (roc_9_4h_lt_60))
            # 15m & 4h down move, 4h high
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_1d_lt_80))
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | aroonu_14_4h_lt_70)
            # 1h & 4h down move, 4h high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (stochrsi_k_4h_lt_80))
            # 1h & 4h down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_65) | aroonu_14_1d_lt_100)
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70))
            # 1h down move, 15m downtrend, 4h still high
            & ((rsi_3_1h_gt_25) | (cmf_20_15m_gt_neg_0_40) | (aroonu_14_4h_lt_50))
            # 1h down move, 4h downtrend, 4h high
            & ((rsi_3_1h_gt_25) | (cmf_20_4h_gt_neg_0_25) | aroonu_14_4h_lt_70)
            # 1h down move, 15m still high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_15m_lt_40) | (roc_9_1d_gt_neg_20))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_60) | aroonu_14_4h_lt_100)
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_lt_90) | (cmf_20_1d_gt_neg_0_20))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_25) | (aroonu_14_4h_lt_90) | (roc_9_4h_lt_20))
            # 1h down move, 1h still not low enough, 1d downtrend
            & ((rsi_3_1h_gt_25) | (stochrsi_k_1h_lt_30) | (roc_9_1d_gt_neg_40))
            # 1h down move, 4h high, 1d overbought
            & ((rsi_3_1h_gt_25) | (stochrsi_k_4h_lt_90) | (roc_9_1d_lt_25))
            # 1h & 4h & 1d down move, 1d high & overbought
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_80) | (roc_9_1d_lt_20))
            # 1h & 4h down move, 1h still high
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_1h_lt_40))
            # 1h & 1d down move, 1d still high
            & ((rsi_3_1h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1d_lt_40))
            # 1h down move, 15m & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_60) | (stochrsi_k_4h < 95.0))
            # 1h down move, 15m & 4h high
            & ((rsi_3_1h_gt_30) | (aroonu_14_15m_lt_70) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h high
            & ((rsi_3_1h_gt_30) | (mfi_14_1h < 80.0) | (aroonu_14_1h_lt_90))
            # 1h down move, 1h still high, 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_50) | (roc_9_1d_lt_40))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_30) | aroonu_14_1h_lt_80 | aroonu_14_4h_lt_100)
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_90) | (cmf_20_1d_gt_neg_0_20))
            # 1h down move, 1h highm 1d overbought
            & ((rsi_3_1h_gt_30) | (aroonu_14_1h_lt_90) | (roc_9_1d_lt_40))
            # 1h down move, 4h high & overbought
            & ((rsi_3_1h_gt_30) | aroonu_14_4h_lt_100 | (roc_9_4h_lt_30))
            # 1h down move, 1d high, 4h overbought
            & ((rsi_3_1h_gt_30) | aroonu_14_1d_lt_100 | (roc_9_4h_lt_20))
            # 1h & 4h down move, 1h still high, 4h high
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_60) | (rsi_14_1h_lt_50) | (rsi_14_4h_lt_70))
            # 1h down move, 1d downtrend, 15m still high, 1d high
            & ((rsi_3_1h_gt_35) | (cmf_20_1d_gt_neg_0_0) | (aroonu_14_15m_lt_50) | (aroonu_14_1d_lt_90))
            # 1h down move, 15m still not low enough, 1h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_lt_30) | aroonu_14_1h_lt_80)
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_60) | aroonu_14_1d_lt_100)
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_25))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_70) | (aroonu_14_4h_lt_90))
            # 1h down move, 1h & 1d high
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_lt_90) | (aroonu_14_1d_lt_90))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_35) | (stochrsi_k_1h_lt_60) | (roc_9_4h_lt_10))
            # 1h down move, 4h & 1d overbought
            & ((rsi_3_1h_gt_35) | (roc_9_4h_lt_20) | (roc_9_1d_lt_80))
            # 1h & 1d down move, 1d high
            & ((rsi_3_1h_gt_40) | (rsi_3_1d_gt_55) | (aroonu_14_1d_lt_100))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_70) | (roc_9_4h_lt_40))
            # 1h down move, 1h & 4h high
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_80) | aroonu_14_4h_lt_80)
            # 1h down move, 1h high, 1d overbought
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_85) | (roc_9_1d_lt_80))
            # 1h down move, 1h high, 15m downtrend
            & ((rsi_3_1h_gt_40) | (aroonu_14_1h_lt_90) | (roc_9_15m > -10.0))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1d overbought
            & ((rsi_3_1h_gt_45) | (rsi_3_4h_gt_65) | (roc_9_1d_lt_200))
            # 1h & 1d down move, 4h high
            & ((rsi_3_1h_gt_45) | (rsi_3_1d_gt_50) | (stochrsi_k_4h_lt_90))
            # 1h down move, 1h high, 4h overbought
            & ((rsi_3_1h_gt_45) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_10))
            # 1h & 4h & 1d down move, 4h still high, 1h high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_55) | (rsi_3_1d_gt_55) | (rsi_14_4h_lt_40) | (aroonu_14_1h_lt_70))
            # 1h & 4h down move, 1h & 4h high
            & ((rsi_3_1h_gt_50) | (rsi_3_4h_gt_65) | (aroonu_14_1h_lt_85) | (aroonu_14_4h_lt_100))
            # 1h down move, 15m & 1h high
            & ((rsi_3_1h_gt_50) | (aroonu_14_15m_lt_60) | (stochrsi_k_1h_lt_80))
            # 1h down move, 4h & 1d high
            & ((rsi_3_1h_gt_50) | (aroonu_14_4h_lt_90) | (aroonu_14_1d_lt_90))
            # 1h down move, 4h overbought
            & ((rsi_3_1h_gt_50) | (roc_9_4h_lt_100))
            # 1h down move, 4h high, 1h overbought
            & ((rsi_3_1h_gt_55) | (aroonu_14_4h_lt_100) | (roc_9_1h_lt_20))
            # 1h down move, 15m & 1h high, 1d downtrend
            & ((rsi_3_1h_gt_60) | (aroonu_14_15m < 65.0) | (stochrsi_k_1h_lt_80) | (cmf_20_1d_gt_neg_0_0))
            # 1h down move, 1h high, 1d downtrend
            & ((rsi_3_1h_gt_60) | (stochrsi_k_1h_lt_90) | (roc_9_1d_gt_neg_20))
            # 4h down move, 15m high
            & ((rsi_3_4h_gt_3) | (aroonu_14_15m_lt_50))
            # 4h & 1d down move, 1d high
            & ((rsi_3_4h_gt_10) | (rsi_3_1d > 50.0) | (aroonu_14_1d_lt_90))
            # 4h down move, 15m still not low enough, 4h downtrend
            & ((rsi_3_4h_gt_10) | (aroonu_14_15m_lt_30) | (cmf_20_4h_gt_neg_0_30))
            # 4h down move, 15m & 1h still not low enough
            & ((rsi_3_4h_gt_10) | (aroonu_14_15m_lt_30) | (stochrsi_k_1h < 25.0))
            # 4h down move, 4h still high
            & ((rsi_3_4h_gt_10) | (aroonu_14_4h_lt_40))
            # 4h down move, 1h still high, 4h downtrend
            & ((rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_50) | (cmf_20_4h_gt_neg_0_30))
            # 4h down move, 1d still high, 1d downtrend
            & ((rsi_3_4h_gt_15) | (rsi_14_1d_lt_40) | (roc_9_1d_gt_neg_10))
            # 4h down move, 4h high
            & ((rsi_3_4h_gt_15) | (aroonu_14_4h_lt_60))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_15) | (stochrsi_k_1d_lt_90) | (roc_9_1d_lt_20))
            # 4h down move, 15m still high, 1d overbought
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_lt_40) | (roc_9_1d_lt_20))
            # 4h & 1d down move, 1h & 4h low
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (cmf_20_1h_gt_neg_0_30) | (cmf_20_4h_gt_neg_0_40))
            # 4h down move, 4h still high 1d downtrend
            & ((rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 4h down move, 1d high & overbought
            & ((rsi_3_4h_gt_25) | (stochrsi_k_1d_lt_80) | (roc_9_1d_lt_25))
            # 4h down move, 4h high, 1d downtrend
            & ((rsi_3_4h_gt_30) | (stochrsi_k_4h_lt_70) | (roc_9_1d_gt_neg_60))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_lt_70) | (aroonu_14_1d_lt_100))
            # 4h down move, 15m still high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_15m_lt_50) | (roc_9_1d_lt_50))
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_40) | (aroonu_14_4h_lt_80) | (roc_9_1d_lt_20))
            # 4h down move, 1h high, 1d downtrend
            & ((rsi_3_4h_gt_40) | (stochrsi_k_1h_lt_80) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h & 1d overbought
            & ((rsi_3_4h_gt_40) | (roc_9_4h_lt_10) | roc_9_1d_lt_50)
            # 4h down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_45) | aroonu_14_4h_lt_70 | (roc_9_1d_lt_20))
            # 4h down move, 1d high, 4h overbought
            & ((rsi_3_4h_gt_45) | (aroonu_14_1d_lt_90) | (roc_9_4h_lt_10))
            # 4h down move, 4h still high, 1d downtrend
            & ((rsi_3_4h_gt_50) | (rsi_14_4h_lt_40) | (roc_9_1d_gt_neg_30))
            # 4h down move, 4h high & overbought
            & ((rsi_3_4h_gt_50) | aroonu_14_4h_lt_70 | (roc_9_4h_lt_10))
            # 4h down move, 15m still high, 1d overbought
            & ((rsi_3_4h_gt_55) | (aroonu_14_15m_lt_40) | (roc_9_1d_lt_100))
            # 4h & 1d down move, 4h high, 1d overbought
            & ((rsi_3_4h_gt_60) | (rsi_3_1d_gt_60) | (aroonu_14_4h_lt_75) | (roc_9_1d_lt_40))
            # 4h down move, 4h & 1d high
            & ((rsi_3_4h > 70.0) | (aroonu_14_4h_lt_90) | aroonu_14_1d_lt_100)
            # 4h up move, 1d downtrend, 4h high
            & ((rsi_3_4h_lt_90) | (cmf_20_1d_gt_neg_0_25) | (aroonu_14_4h_lt_100))
            # 1d down move, 4h high
            & ((rsi_3_1d_gt_3) | (stochrsi_k_4h_lt_60))
            # 1d down move, 1h high
            & ((rsi_3_1d_gt_5) | (stochrsi_k_1h_lt_80))
            # 1d down move, 15m & 1h still high
            & ((rsi_3_1d_gt_10) | (rsi_14_15m_lt_40) | (stochrsi_k_1h_lt_50))
            # 1d down move, 1h & 4h high
            & ((rsi_3_1d_gt_10) | aroonu_14_1h_lt_80 | (aroonu_14_4h_lt_90))
            # 1d down move, 1h & 4h still high
            & ((rsi_3_1d_gt_10) | (stochrsi_k_1h_lt_40) | (aroonu_14_4h_lt_40))
            # 1d down move, 1h high & overbought
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_1h_lt_20))
            # 1d down move, 1d high & overbought
            & ((rsi_3_1d_gt_40) | (aroonu_14_1d_lt_70) | (roc_9_1d_lt_20))
            # 1d down move, 4h high & overbought
            & ((rsi_3_1d_gt_45) | aroonu_14_4h_lt_80 | (roc_9_4h_lt_30))
            # 1d down move, 1h high, 1d overbought
            & ((rsi_3_1d_gt_60) | aroonu_14_1h_lt_80 | (roc_9_1d_lt_80))
            # 1d down move, 15m still high, 1d overbought
            & ((rsi_3_1d_gt_65) | (aroonu_14_15m_lt_40) | (roc_9_1d_lt_100))
            # 1d down move, 4h & 1d high
            & ((rsi_3_1d_gt_65) | (roc_9_4h_lt_10) | (roc_9_1d_lt_10))
            # 5m still high, 1h down move, 15m still high, 1h high
            & ((rsi_3_lt_40) | (rsi_3_1h_gt_30) | (aroonu_14_15m_lt_50) | (aroonu_14_4h_lt_90))
            # 5m still high, 15m high
            & ((rsi_3 < 45.0) | (aroonu_14_15m_lt_70))
            # 5m still high, 1h down move, 4h high
            & ((rsi_3_lt_50) | (rsi_3_1h_gt_30) | aroonu_14_4h_lt_100)
            # 15m down move, 1h high
            & ((rsi_14_15m > 25.0) | (stochrsi_k_1h_lt_80))
            # 15m down move, 4h & 1d high
            & ((rsi_14_15m > 30.0) | (stochrsi_k_4h_lt_90) | (stochrsi_k_1d_lt_70))
            # 1h downtrend, 4h high, 1d downtrend
            & ((cmf_20_1h_gt_neg_0_20) | (stochrsi_k_4h_lt_90) | (cmf_20_1d_gt_neg_0_25))
            # 15m & 1h high, 1d overbought
            & ((aroonu_14_15m_lt_60) | (aroonu_14_1h_lt_100) | (roc_9_1d_lt_20))
            # 4h high, 4h & 1d overbought
            & ((aroonu_14_4h_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_20))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_85) | (aroonu_14_1d_lt_85) | (roc_9_1d_lt_60))
            # 4h & 1d high, 1d overbought
            & ((aroonu_14_4h_lt_100) | (aroonu_14_1d_lt_100) | (roc_9_1d_lt_30))
            # 1d still high, 4h & 1d downtrend
            & ((aroonu_14_1d_lt_50) | (roc_9_4h_gt_neg_20) | (roc_9_1d_gt_neg_30))
            # 1d high, 4h & 1d overbought
            & ((aroonu_14_1d_lt_100) | (roc_9_4h_lt_100) | (roc_9_1d_lt_200))
            # 1h & 4h & 1d overbought
            & ((roc_9_1h_lt_20) | (roc_9_4h_lt_100) | (roc_9_1d_lt_200))
            # 4h top wick, 15m & 1h down move
            & ((top_wick_pct_4h < 10.0) | (rsi_3_15m_gt_15) | (rsi_3_1h_gt_40))
            # 4h top wick, 1h down move, 1h high
            & ((top_wick_pct_4h < 10.0) | (rsi_3_1h_gt_30) | aroonu_14_1h_lt_70)
            # 1d red, 1h down move, 1h still high
            & ((change_pct_1d_gt_neg_15) | (rsi_3_1h_gt_25) | (aroonu_14_1h_lt_50))
            # 1d P&D, 1h high
            & ((change_pct_1d_gt_neg_15) | (change_pct_1d_shift_288 < 15.0) | (stochrsi_k_1h_lt_80))
            # 1d P&D, 1d downtrend
            & ((change_pct_1d_gt_neg_5) | (change_pct_1d_shift_288 < 30.0) | (cmf_20_1d_gt_neg_0_10))
            # 1d P&D, 15m high
            & ((change_pct_1d_gt_neg_10) | (change_pct_1d_shift_288 < 40.0) | (aroonu_14_15m_lt_50))
            # 1d P&D, 1h high
            & ((change_pct_1d_gt_neg_10) | (change_pct_1d_shift_288 < 40.0) | (stochrsi_k_1h_lt_70))
            # 1d red with top wick, 1h high
            & ((change_pct_1d_gt_neg_10) | (top_wick_pct_1d_lt_10) | aroonu_14_1h_lt_80)
            # 1d green, 4m down move, 4h high
            & ((change_pct_1d_lt_25) | (rsi_3_4h_gt_55) | (aroonu_14_4h_lt_50))
            # 1d green with top wick, 1d low
            & ((change_pct_1d_lt_25) | (top_wick_pct_1d_lt_10) | (cmf_20_1d_gt_neg_0_20))
            # 1d top wick, 1h still high
            & ((top_wick_pct_1d_lt_25) | (aroonu_14_1h_lt_50))
            # 1d top wick, 4h still high
            & ((top_wick_pct_1d_lt_30) | (stochrsi_k_4h_lt_50))
            # 1d top wick, 1h down move
            & ((top_wick_pct_1d_lt_50) | (rsi_3_1h_gt_30))
            # big drop in last hough, 4h down move, 1h still not low enough
            & ((close > (close_max_12 * 0.90)) | (rsi_3_4h_gt_10) | (stochrsi_k_1h_lt_30))
            # big drop in the last 12 days, 1h down move, 1h high
            & ((close > (high_max_12_1d * 0.35)) | (rsi_3_1h_gt_35) | aroonu_14_1h_lt_70)
            # big drop in the last 20 days, 1h down move, 1h high
            & ((close > (high_max_20_1d * 0.30)) | (rsi_3_1h_gt_30) | (stochrsi_k_1h < 75.0))
            # big drop in the last 20 days, 1d high, 1d downtrend
            & ((close > (high_max_20_1d * 0.20)) | (stochrsi_k_1d_lt_70) | (roc_9_1d_gt_neg_15))
          )

          # Logic
          long_entry_logic.append(
            (rsi_14 < 30.0)
            & (aroonu_14_lt_25)
            & (aroond_14_gt_75)
            & (stochrsi_k_lt_20)
            & (ema_9 < (ema_26 * 0.982))
            & (close < sma_9)
          )

        ###############################################################################################

        # LONG ENTRY CONDITIONS ENDS HERE

        ###############################################################################################

        # Condition #164 - 4h opening-range fakeout (Long, experimental).
        if long_entry_condition_index == 164:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # only fade a downside break into an already-deeply-sold 4h (a flush into oversold = spring)
          long_entry_logic.append((willr_14_4h < -70.0) | (stoch_k_4h < 40.0))
          # prev 5m candle CLOSED below the day's first-4h range low; current closes back INSIDE
          long_entry_logic.append(np_shift(close, 1) < orange_l)
          long_entry_logic.append(close > orange_l)
          long_entry_logic.append(close < orange_h)

        # Condition #165 - Fib golden-pocket continuation (Long, experimental, RAW — The Moving Average port).
        if long_entry_condition_index == 165:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          # Require a mature squeeze, daily money-flow reset, or washed-out 4h range around the retracement.
          long_entry_logic.append((sqz_cnt_24 > 14) | (mfi_14_1d < 45.0) | (willr_14_4h < -50.0))

          # Logic
          # trend filter (video: "only clear trends") + impulse quality (never draw fibs in chop)
          long_entry_logic.append(ema_12_4h > ema_200_4h)
          # R1 (eyeball): only a CLEAN ACTIVE uptrend — whipsaw chop (RIVER) has rsi_4h ~50 and stale 4h highs
          long_entry_logic.append(rsi_14_4h > 55.0)
          long_entry_logic.append(aroonu_14_4h > 70.0)
          # R1: anti-blow-off — don't buy the retrace of a parabolic final leg (ARIA top)
          long_entry_logic.append(roc_9_1d < 30.0)
          long_entry_logic.append((close_max_48 - close_min_48) > (close_min_48 * 0.04))
          # golden pocket: FIRST entry into the 0.5-0.618 retrace band of the 48-candle impulse (from above)
          _fib_rng_165 = close_max_48 - close_min_48
          _fib_retr_165 = (close_max_48 - close) / _fib_rng_165
          long_entry_logic.append(np_shift(_fib_retr_165, 1) < 0.5)
          long_entry_logic.append(_fib_retr_165 >= 0.5)
          long_entry_logic.append(_fib_retr_165 <= 0.618)

        # Condition #166 - Squeeze Momentum release (Long, experimental, RAW — LazyBear port).
        if long_entry_condition_index == 166:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # squeeze RELEASE this candle after a coil (>=12 of the prior 24 candles squeezed)
          long_entry_logic.append(np_shift(sqz_on, 1) > 0.5)
          long_entry_logic.append(sqz_on < 0.5)
          long_entry_logic.append(np_shift(sqz_cnt_24, 1) >= 12.0)
          # expansion direction: close breaks through the upper band
          long_entry_logic.append(close > bbu_20_2_0)

        # Condition #167 - Engulfing continuation (Long, experimental, RAW — TradingLab port).
        if long_entry_condition_index == 167:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # daily in its lower half, no recent 1h low, 5m cutting a fresh one
            # 1h & 4h have both already run, 1h bands still wide from it
            ((bbb_20_2_0 < 9) | (roc_9_1h < 14) | (change_pct_4h < 5))
            # a strong 5m candle with the 4h oscillator not even positive
            & ((change_pct < 1) | (cci_20_4h > 50))
            # 4h & 5m money both saturated — no one left to buy the continuation
            & ((cmf_20 < 0.2) | (mfi_14_4h < 85))
            # 1d oscillator at its ceiling, no new 1d high in a fortnight, money already in
            & ((cmf_20 < 0.3) | (aroonu_14_1d > 5) | (stochrsi_k_1d < 85))
            # 1h money saturated and the last 24h went nowhere
            & ((roc_288 > 2) | (mfi_14_1h < 70))
            # 4h RSI jumping a fifth in one bar with the 5m RSI only just over the line
            & ((rsi_14 > 55) | (rsi_14_change_pct_4h < 21))
            # the hour has already run and the fast tape underneath is not confirming it
            & ((rsi_4 > 50) | (roc_9_1h < 3))
            # 5m stochastic in its lower half, neither 1h nor 1d strong enough to carry it
            & ((stoch_4_4 > 45) | (rsi_14_1h > 60) | (rsi_14_1d > 55))
            # a dead tape bought at the top of its own noise — flat 1h bands, thin candle, fast stochastic high
            & ((stoch_4_4 < 65) | (vol_rel > 1) | (bbb_20_2_0_1h > 12))
            # nothing rising — 5h stochastic under half, 15m middling, 4h up-side weak
            & ((stoch_60_10 > 45) | (rsi_3_15m > 55) | (plus_di_14_4h > 30))
            # a listless tape — no 4h money, no 4h trend, a thin entry candle
            & ((vol_rel > 0.5) | (adx_14_4h > 30) | (cmf_20_4h > 0.05))
            # a volume spike under a 1d bar that already printed a long lower wick
            & ((vol_rel < 3.5) | (bot_wick_pct_1d < 5))
            # 15m stretched, 1h still low in its range, 4h down-side still stronger
            & ((cci_20_15m < 25) | (willr_14_1h > -60) | (minus_di_14_4h < 15))
            # 15m oscillator collapsing under a 4h bar with a long upper wick
            & ((cci_20_change_pct_15m > -165) | (top_wick_pct_4h < 6))
            # 15m money in but its stochastic on the floor, under an already-high 1h
            & ((cmf_20_15m < 0) | (stochk_14_3_3_15m > 30) | (stochk_14_3_3_1h < 65))
            # a 15m momentum spike bought without the 15m money to back it, inside a daily that is not strong
            & ((mfi_14_15m > 85) | (rsi_3_15m < 85) | (rsi_14_1d > 55))
            # the 4h bar jumped without its stochastic confirming, no 15m money left
            & ((mfi_14_15m > 45) | (change_pct_4h < 5) | (stochrsi_k_4h > 80))
            # no 1d high in a fortnight, 1h falling, 15m momentum and RSI both flat
            & ((rsi_14_15m > 65) | (rsi_3_15m < 80) | (aroond_14_1h < 40) | (aroonu_14_1d > 20))
            # a bounce bought while the daily has rolled over, the 4h is weak and 15m momentum is already down
            & ((rsi_3_15m > 45) | (rsi_14_4h > 55) | (aroonu_14_1d > 5))
            # the momentum clocks disagree — 15m spent, 1h dead, 4h high
            & ((rsi_3_15m < 75) | (rsi_3_1h > 35) | (rsi_3_4h < 65))
            # no push in the quarter-hour and no money coming into the hour
            & ((rsi_3_15m > 50) | (mfi_14_1h > 40))
            # the quarter-hour is weak while the hour has already run
            & ((stochrsi_k_15m > 40) | (roc_2_1h < 5))
            # 1d stochastic pinned high while its StochRSI has already turned down
            & ((uo_7_14_28_15m > 45) | (stochk_14_3_3_1d < 80) | (stochrsi_k_1d > 60))
            # a quiet tape already bought — narrow 1h bands, money in on 1h and 1d
            & ((bbb_20_2_0_1h > 14) | (mfi_14_1h < 55) | (mfi_14_1d < 45))
            # 1h stochastic at its ceiling with the 1h CCI still accelerating into it
            & ((cci_20_change_pct_1h < 70) | (stochrsi_k_1h < 90))
            # no 1h money, 1h oscillator not high, 4h leg barely moved
            & ((cmf_20_1h > 0.05) | (stochrsi_k_1h > 80) | (roc_9_4h > 10))
            # 1d already overbought, no 1h money behind it, no upper wick to say it was tested
            & ((mfi_14_1h > 55) | (rsi_14_1d < 80) | (top_wick_pct_1d > 5))
            # an hourly already overbought inside a 4h trend that has run a long way
            & ((rsi_14_1h < 75) | (adx_14_4h < 45))
            # 1h strong but off its high, bought with 1d money flow already saturated
            & ((rsi_14_1h > 70) | (willr_14_1h < -30) | (mfi_14_1d < 85))
            # 1h short-term momentum more than doubled while the 4h RSI is also jumping
            & ((rsi_3_change_pct_1h < 110) | (rsi_14_change_pct_4h < 2))
            # the hour's momentum has just spiked while the 4h is already extended
            & ((rsi_3_change_pct_1h < 75) | (roc_2_4h < 3))
            # still well off the two-day high, 1d momentum tripled, 1d stochastic low
            & ((willr_84_1h > -15) | (rsi_3_change_pct_1d < 145) | (stochk_14_3_3_1d > 45))
            # a 4h trend that has already run hard and is still accelerating
            & ((adx_14_4h < 45) | (rsi_3_change_pct_4h < 15))
            # a 4h stretched far above its mean while daily money is leaving
            & ((cci_20_4h < 225) | (cmf_20_1d > 0))
            # a 5m bounce bought while the 4h leg is falling and the 4h down-trend is the strong side
            & ((minus_di_14_4h < 20) | (roc_9_4h > -5))
            # a day that has gone vertical while the 4h has no directional strength behind it
            & ((plus_di_14_4h > 20) | (roc_9_1d < 30))
            # a blow-off day bought at the top — 1d up hundreds of percent, 4h pinned
            & ((rsi_14_4h < 90) | (roc_9_1d < 100))
            # a 1d neither moving nor holding — momentum middling, the 1d low still fresh
            & ((aroond_14_1d < 65) | (rsi_3_1d > 55))
          )

          # Logic
          long_entry_logic.append(
            # a bullish engulfing inside an uptrend, in the upper half of the range, with the daily
            # leg rising and the 4h both making recent highs and swinging up in its own range
            (close > ema_200)
            & (rsi_14 > 50.0)
            & (willr_14 > -50.0)
            & (aroonu_14_4h > 45.0)
            & (stochrsi_k_4h > 50.0)
            & (change_pct_15m < 2.0)
            & (roc_9_1d > 0.0)
            & (engulf_bull > 0.5)
          )

        # Condition #168 - Swing-failure pattern (Long, experimental, RAW — liquidity-sweep reclaim).
        if long_entry_condition_index == 168:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # prior 48-candle low swept by the wick, candle closes back above it
          long_entry_logic.append(sfp_bull > 0.5)

        # Condition #169 - 1h inside-bar breakout (Long, experimental, RAW — TradingLab port).
        if long_entry_condition_index == 169:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # trend side (source: trade only WITH the trend)
          long_entry_logic.append(close > ema_200)
          # 4h must participate in the breakout (fresh 4h upswing, not a stale drift)
          long_entry_logic.append(aroonu_14_4h > 50.0)
          long_entry_logic.append(stochrsi_k_4h > 55.0)
          # last completed 1h candle was an inside bar; this 5m candle CROSSES above the mother high
          long_entry_logic.append(ib_ready > 0.5)
          long_entry_logic.append(np_shift(close, 1) <= ib_mother_h)
          long_entry_logic.append(close > ib_mother_h)
        # Condition #170 - Crash-bounce hunter (Long, experimental — capitulation relief rally).
        if long_entry_condition_index == 170:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # capitulation context: crashed hard over the rolling 24h, daily fully washed
          long_entry_logic.append(roc_288 < -15.0)
          # ...but not a free-fall (deeper than -30 keeps falling)
          long_entry_logic.append(roc_288 > -30.0)
          long_entry_logic.append(rsi_3_1d < 15.0)
          # fresh bounce only — 1h still deeply down; a half-recovered 1h means we are late
          # (losses entered the SECOND leg / dead-cat top)
          long_entry_logic.append(roc_9_1h < -5.0)
          # real buyers on the reclaim candle: ~1.3x+ its 24h average volume
          long_entry_logic.append(vol_rel > 1.3)
          # still near the bottom (not already rallied away)
          long_entry_logic.append(close < (close_min_48 * 1.08))
          # the right side of the V: FIRST confirmed green close above the prior candle's high
          long_entry_logic.append(close > open_rate)
          long_entry_logic.append(close > np_shift(high_px, 1))

        # Condition #171 - Pump hunter (Long, experimental, RAW — ignition candle rider).
        if long_entry_condition_index == 171:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # --- 5m: the ignition candle has to be a real move on a base that is not collapsing
            (roc_2 > 0.5)
            # the base is overbought, its 14 barely moved and the 12-candle floor is already high:
            # a stalled push, not an ignition
            & ((rsi_4 > 85.0) | (rsi_14_change_pct < 16.0) | (quad_s93_min_12 < 40.0))
            & (rsi_14_change_pct < 30.0)
            & (cmf_20 > 0.05)
            # the base low is stale, the 4h CCI is positive and 15m money flow is rich: buying
            # into a market that has already been bid up
            & ((aroond_14 < 70.0) | (cci_20_4h < 0.0) | (mfi_14_15m > 65.0))
            # no fresh 4h low, the 15m oscillator is not up and the candle itself is small:
            # an ignition without any of its usual company
            & ((aroond_14_4h > 0.0) | stochrsi_k_15m_gt_60 | (change_pct > 0.5))
            & (stoch_9_3 > 80.0)
            & (willr_14 < -5.0)
            # price pinned at the top of its own 14-bar range, the 4h RSI already rising and
            # 15m money flow not rich: the ignition is the last buyer, not the first
            & ((willr_14 > -15.0) | (rsi_14_change_pct_4h < 8.0) | (cmf_20_15m > 0.15))
            # the base ROC is not extended — unless the 15m momentum is genuinely turning up
            & ((roc_9 < 5.0) | (rsi_3_change_pct_15m > 20.0))
            # the ignition is not the first cross of a loose base: either the coil has crossed
            # a few times already, or the base was tight to begin with
            & ((ph_cross_cnt_12 < 5.0) | (ph_pre_tight < 5.0))
            # --- 15m: the fast timeframe must confirm, not cave
            & (rsi_3_change_pct_15m > -10.0)
            # the 15m RSI is genuinely turning up, or the hour is hot while the 4h is not
            & ((rsi_14_change_pct_15m > 10.0) | rsi_3_1h_gt_60 | rsi_3_4h_lt_60)
            # 15m money flow is not pouring in, the 15m is not overheated and the 12-candle
            # low sits high in its range: the ignition has no fuel under it
            & ((cmf_20_15m > 0.2) | (mfi_14_15m < 80.0) | (quad_s93_min_12 < 70.0))
            # the base RSI is not stretched, or the 15m is quiet with rich money flow
            & ((mfi_14_15m > 65.0) | (rsi_14_change_pct < 20.0) | (change_pct_15m < 1.0))
            # daily money flow is alive, the 15m RSI is rising, or the 15m oscillator is maxed
            & ((mfi_14_1d > 30.0) | (rsi_14_change_pct_15m > 5.0) | stochrsi_k_15m_gt_90)
            # no fresh 15m low, 4h direction weak and the 4h RSI already mid-band: nothing is
            # actually leading this ignition
            & ((aroond_14_15m < 20.0) | (minus_di_14_4h < 20.0) | rsi_14_4h_lt_50)
            # the 15m CCI is extreme and rising while volume is only ordinary: a spike on the
            # oscillator, not in the tape
            & ((cci_20_15m < 250.0) | (cci_20_change_pct_15m < 225.0) | (vol_rel > 8.0))
            # the 15m CCI is not snapping up while the day has already fallen
            & ((cci_20_change_pct_15m < 50.0) | (change_pct_1d > -5.0))
            & (cci_20_change_pct_15m < 500.0)
            & (willr_14_15m > -50.0)
            # volume is not pouring into the 15m — unless the daily candle has a real lower
            # wick, i.e. the day was already bought once
            & ((obv_change_pct_15m < 15.0) | (bot_wick_pct_1d > 1.0))
            & (sqz_cnt_24 < 15.0)
            # the 40-candle band is not wide, or the 15m RSI is genuinely strong
            & ((bbd_40_2_0 < 15.0) | (rsi_14_15m > 60.0))
            # --- 1h: the hour must not already have tripled its momentum
            & (rsi_3_change_pct_1h < 100.0)
            # hourly money flow is not rich — unless the 4h oscillator is still falling, where
            # a rich hour is the start of the move rather than its end
            & ((mfi_14_1h < 60.0) | (stochrsi_k_change_pct_4h > -25.0))
            & (mfi_14_1h > 45.0)
            # the hour has made a recent low, or the 4h CCI has not collapsed under it
            & ((aroond_14_1h > 30.0) | (cci_20_change_pct_4h > -600.0))
            # the 4h low is not fresh, hourly money flow is thin and the daily RSI_3 is snapping
            # up: the higher timeframes are not behind this move
            & ((aroond_14_4h > 20.0) | (cmf_20_1h > 0.05) | (rsi_3_change_pct_1d < 50.0))
            & ((aroond_14_4h > 20.0) | (rsi_3_change_pct_1d < 50.0) | (vol_rel < 6.0))
            # the hourly CCI is positive, or the 4h has not just jumped
            & ((cci_20_1h > 50.0) | (roc_2_4h < 2.0))
            # --- 4h: the higher timeframe must be in shape and must not have exploded
            # the 4h RSI_3 is exploding while daily money flow is rich and the 4h sits at its
            # low: a spike into a market that is already fully bid
            & ((rsi_3_change_pct_4h < 100.0) | (mfi_14_1d < 70.0) | (willr_14_4h > -50.0))
            # same spike with the base stochastic maxed and the 12-candle low already high
            & ((rsi_3_change_pct_4h < 125.0) | (stoch_4_4 < 85.0) | (quad_s93_min_12 < 30.0))
            & (rsi_3_change_pct_4h < 150.0)
            & (rsi_3_change_pct_4h > -30.0)
            # the 4h RSI is rising, the hour has already tripled its momentum, and the hourly
            # stochastic is below mid-band: the move is late on every reading
            & ((rsi_14_change_pct_4h < 5.0) | (rsi_3_change_pct_1h < 30.0) | (stochk_14_3_3_1h > 50.0))
            # 15m flow thin while the 4h has already jumped and shows no rejection wick:
            # entering an extended higher timeframe
            & ((cmf_20_15m > 0.05) | (rsi_14_change_pct_4h < 15.0) | (top_wick_pct_4h > 1.0))
            # 4h money flow is not deeply negative — unless the day itself has already dropped,
            # where negative 4h flow is the wash rather than the trend
            & ((cmf_20_4h > -0.2) | (roc_2_1d < -2.0))
            # 4h money flow is healthy, or the day has not already run
            & ((mfi_14_4h > 40.0) | roc_9_1d_lt_15)
            # 4h money flow is healthy, or volume is still coming in
            & ((mfi_14_4h > 45.0) | (obv_change_pct > -5.0))
            # the 4h low is genuinely fresh, the day has fallen and the base ROC is up: buying
            # a bounce inside a falling day
            & ((aroond_14_4h > 60.0) | (roc_2_1d > -5.0) | (roc_9 > 1.0))
            & (stochk_14_3_3_4h < 90.0)
            & (stochrsi_k_4h < 95.0)
            & (stochrsi_k_change_pct_4h < 180.0)
            & (cci_20_4h < 100.0)
            & (cci_20_4h > -100.0)
            # the 4h CCI is not collapsing — unless volume is still coming in, or hourly money
            # flow is not yet rich
            & ((cci_20_change_pct_4h < 50.0) | (obv_change_pct > -10.0))
            & ((cci_20_change_pct_4h < 50.0) | cmf_20_1h_lt_0_30)
            # the 4h is not pinned at its low — unless the day is quiet enough for it to matter
            & ((willr_14_4h > -60.0) | (change_pct_1d < 2.0))
            # the 4h has turned up but on weak money flow with a flat hour: a hollow recovery
            & ((roc_2_1h > 0.5) | (mfi_14_4h > 40.0) | cci_20_change_pct_4h_lt_0)
            # a big 15m candle chasing a 4h that already ran, with the hour not confirming
            & ((change_pct_15m < 1.5) | (stochk_14_3_3_1h > 60.0) | (rsi_3_4h < 65.0))
            # the base is off its floor on a small candle while the 4h stochastic is maxed:
            # a tired push under a ceiling
            & ((ph_base_pos > 4.0) | (change_pct < 1.0) | stochrsi_k_4h_lt_80)
            & (plus_di_14_4h > 15.0)
            # 4h direction is real, or the day has not already run
            & ((plus_di_14_4h > 20.0) | roc_9_1d_lt_15)
            & (top_wick_pct_4h < 2.0)
            # --- 1d: the day must not be caving underneath the ignition
            # 15m money flow already rich, no 4h rejection wick and the day pinned at its high
            & (cmf_20_15m_lt_0_30 | (top_wick_pct_4h < 0.5) | aroonu_14_1d_lt_100)
            # the daily low is not fresh, or the 15m CCI has genuinely turned up
            & ((aroond_14_1d > 0.0) | (rsi_3_15m > 80.0))
            # price is not at the very top of its 40h range while the day is already up
            & ((willr_480 > -15.0) | (change_pct_1d < 5.0))
            # the ignition candle is small, the 15m ultimate oscillator is caving and the day
            # already printed an upper wick
            & ((roc_2 < 1.5) | (uo_7_14_28_change_pct_15m > -5.0) | (top_wick_pct_1d > 1.5))
            & (roc_2_1d > -10.0)
            # the base has no push left and the day is a doji-ish candle rejected on both ends
            & ((roc_9 > 2.0) | (bot_wick_pct_1d < 4.0) | (top_wick_pct_1d < 2.0))
            & (roc_9_1d > -30.0)
            & (change_pct_1d > -10.0)
            # the base is barely off its floor, the 15m is accelerating hard and the day printed
            # a long upper wick: a spike into supply
            & ((ph_base_pos > 3.0) | (rsi_3_change_pct_15m < 60.0) | (top_wick_pct_1d < 1.5))
            # 4h directional strength is real, or the day has not fallen far
            & ((plus_di_14_4h > 20.0) | (change_pct_1d > -5.0))
          )

          # Logic
          long_entry_logic.append(
            # calm base: not already pumped over the rolling 24h (ride the ignition, don't chase)
            (roc_288 < 8.0)
            # ignition: green candle with a real body, closing in its upper half, CROSSING above
            # the prior 48-candle high (a doji-sized ignition, or one closing back in the lower
            # half of its own range, has no follow-through: -4,693 and -4,587 respectively)
            & (close > (open_rate * 1.002))
            & (close > ((high_px + low_px) / 2.0))
            & (np_shift(close, 1) <= np_shift(close_max_48, 1))
            & (close > np_shift(close_max_48, 1))
            # ...on explosive volume. Unlike the dump hunter, where 3.0 is the sweet spot, the
            # pump side loses in the 3-4x band (-5,767 over 343 trades): the ignition needs real
            # participation, not a routine tick up in volume
            & (vol_rel > 4.0)
          )

          # NOTE: the measured PUMP CHARACTER columns (PH_BASE_POS d=0.95, PH_PRE_TIGHT d=0.65,
          # PH_CROSS_CNT_12 first-fire counter) are defined above and ready for your protection
          # pass — shipped RAW per our measurements (character gates halved damage but the raw
          # form carries the highest WR; full matrix in the PR)

        # Condition #172 - Marubozu momentum (Long, experimental — full-body ignition).
        if long_entry_condition_index == 172:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # trend side + momentum side (the frame proven on the engulfing pair)
          long_entry_logic.append(close > ema_200)
          long_entry_logic.append(rsi_14 > 50.0)
          # hourly money-flow must support the ignition (no conviction candle in a bleed)
          long_entry_logic.append(cmf_20_1h > 0.02)
          # 4h trend must agree — conviction candles inside brief above-EMA windows of a
          # chronic downtrend are traps (the SOON cluster, verified on the chart)
          long_entry_logic.append(ema_12_4h > ema_200_4h)
          # full-body green candle: body >90% of range and a meaningful size
          long_entry_logic.append(mrb_bull > 0.5)

        # Condition #173 - Hammer pin-bar (Long, experimental, RAW — rejection wick at a dip).
        if long_entry_condition_index == 173:
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          # dip context: near the 4h low, 5m washed
          long_entry_logic.append(close < (close_min_48 * 1.03))
          long_entry_logic.append(rsi_3 < 40.0)
          # the fact: long lower rejection wick, tiny upper wick
          long_entry_logic.append(pb_hammer > 0.5)

        # Condition #192 - Quad-rotation stochastic pullback (Long, experimental).
        if long_entry_condition_index == 192:
          # Protections
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)

          long_entry_logic.append(
            # a long-divergence entry with nothing turning: 5m trend still down, no money coming in,
            # the 15m dead and the hour not rising (API3)
            ((aroond_14 < 90.0) | (cmf_20 > 0.12) | (rsi_3_15m > 30.0) | (roc_9_1h > 1.0))
            # a 1d capitulation with money leaving at the same time — a knife, not a dip (RUNE)
            & ((cmf_20 > -0.10) | (rsi_3_1d > 15.0))
            # the 15m money flow collapsing under a 4h that is still stretched (ETH 22-04)
            & ((obv_change_pct_15m > -60.0) | (willr_14_4h < -20.0))
            # the 15m momentum snapping higher right before the top (LINK 24-03)
            & ((uo_7_14_28_change_pct_15m < 15.0) | (mfi_14_15m < 85.0))
            # the hour is rising, the 4h has not stopped making lows, and the day shows no inflow —
            # a dead-cat fade rather than a reversal (DOT 21, ETH 24, LINK 24, DOGE 25, GALA 26)
            & ((cci_20_change_pct_1h_lt_0) | (aroond_14_4h_lt_80) | (mfi_14_1d > 45.0))
            # a pullback into a weak day with no hourly money behind it — a falling-knife day
            # (SAND 21, AXS 24, AVAX 24, GALA 25)
            & ((cmf_20_1h >= 0.0) | (rsi_14_1d >= 40.0))
            # a mid-range 1h RSI dip inside a 1d downtrend: not oversold enough to bounce (SOL x2)
            & ((rsi_14_1h < 55.0) | (rsi_14_1h > 65.0) | (roc_9_1d > 0.0))
            # a fade at a 4h top that is already stretched, with the hour hot — chasing the top
            # (CRV 21-09, CRV 25-03, AXS 25-08)
            & ((rsi_14_1h < 70.0) | (roc_9_4h < 13.0))
            # the 1h RSI collapsing at the entry candle — a knife, not a dip (LINK 24-06)
            & ((rsi_3_change_pct_1h > -30.0) | (rsi_3_1h < 50.0))
            # the 4h actively collapsing — a knife, not a dip (XRP 21-04)
            & ((roc_9_4h > -15.0) | (rsi_14_4h > 40.0))
          )

          # Logic: embedded up-regime + quad-oversold pullback + 5-candle shift kink
          long_entry_logic.append(
            (stoch_60_10 > 80.0)
            & (stoch_9_3 < 20.0)
            & (stoch_14_3 < 20.0)
            & (stoch_4_4 < 20.0)
            & (close < np_shift(close, 5))
            & (stoch_9_3 > np_shift(stoch_9_3, 5))
          )

        # Condition #193 - Quad-rotation TRUE pivot divergence (Long, experimental).
        if long_entry_condition_index == 193:
          # --- Protections ---
          long_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          long_entry_logic.append(protections_long_global == True)
          long_entry_logic.append(
            # Negative 15m flow is ongoing sell pressure, not a pivot recovery (COMP/BAND/MTL);
            # require short-term money flow to turn positive.
            (cmf_20_15m > 0.0)
            # A divergence in trendless 4h chop has no recovery structure; require a real trend.
            & (adx_14_4h > 20.0)
            # A 4h candle already down 8% is a falling knife (RUNE 2024-06), not a pivot.
            & (change_pct_4h > -8.0)
            # A hot 15m pulse inside an unrecovered day is a false counter-trend bounce (1INCH
            # 2022-12); need 15m relief OR cooler momentum OR daily recovery.
            & ((willr_14_15m > -40.0) | (uo_7_14_28_15m < 50.0) | (stochrsi_k_1d > 25.0))
            # Positive hourly flow without a price response while the day is pinned is trapped
            # inflow (EGLD 2022-11, MTL/ZEN 2024); need low flow OR hourly lift OR a daily reset.
            & ((cmf_20_1h < 0.05) | (stochk_14_3_3_1h > 80.0) | stochrsi_k_1d_gt_10)
            # Daily capitulation with no sustained 1h/4h flow is a dead-cat bounce (THETA/EGLD
            # 2024, BAND/ZEN 2026); need hourly inflow OR positive 4h flow OR daily RSI recovery.
            & ((cmf_20_1h > 0.15) | (cmf_20_4h > 0.0) | rsi_3_1d_gt_20)
          )
          # --- Logic: embedded up-regime + quad-oversold + two-pivot bullish divergence ---
          long_entry_logic.append(
            (stoch_60_10 > 80.0)
            & (stoch_9_3 < 20.0)
            & (stoch_14_3 < 20.0)
            & (stoch_4_4 < 20.0)
            # Price makes a lower low while stochastic makes a higher low (real divergence).
            & (quad_low_min_12 < np_shift(quad_low_min_12, 12))
            & (quad_s93_min_12 > np_shift(quad_s93_min_12, 12))
          )

        long_entry_logic.append(df["volume"] > 0)
        item_long_entry = _and_entry_conditions(long_entry_logic)
        _append_entry_tag(entry_tags, item_long_entry, f"{long_entry_condition_index} ")
        long_entry_conditions.append(item_long_entry)
        df.loc[:, "enter_long"] = item_long_entry.astype(int)

    if long_entry_conditions:
      df.loc[:, "enter_long"] = _or_entry_conditions(long_entry_conditions).astype(int)

    ###############################################################################################

    # SHORT ENTRY CONDITIONS STARTS HERE

    ###############################################################################################

    #   ______  __    __  ______  _______ ________        ________ __    __ ________ ________ _______
    #  /      \|  \  |  \/      \|       |        \      |        |  \  |  |        |        |       \
    # |  $$$$$$| $$  | $|  $$$$$$| $$$$$$$\$$$$$$$$      | $$$$$$$| $$\ | $$\$$$$$$$| $$$$$$$| $$$$$$$\
    # | $$___\$| $$__| $| $$  | $| $$__| $$ | $$         | $$__   | $$$\| $$  | $$  | $$__   | $$__| $$
    #  \$$    \| $$    $| $$  | $| $$    $$ | $$         | $$  \  | $$$$\ $$  | $$  | $$  \  | $$    $$
    #  _\$$$$$$| $$$$$$$| $$  | $| $$$$$$$\ | $$         | $$$$$  | $$\$$ $$  | $$  | $$$$$  | $$$$$$$\
    # |  \__| $| $$  | $| $$__/ $| $$  | $$ | $$         | $$_____| $$ \$$$$  | $$  | $$_____| $$  | $$
    #  \$$    $| $$  | $$\$$    $| $$  | $$ | $$         | $$     | $$  \$$$  | $$  | $$     | $$  | $$
    #   \$$$$$$ \$$   \$$ \$$$$$$ \$$   \$$  \$$          \$$$$$$$$\$$   \$$   \$$   \$$$$$$$$\$$   \$$
    #

    for enabled_short_entry_signal in short_entry_signal_params:
      short_entry_condition_index = int(enabled_short_entry_signal.rsplit("_", 2)[1])
      if short_entry_signal_params[enabled_short_entry_signal]:
        # Short Entry Conditions Starts Here
        # -----------------------------------------------------------------------------------------
        # IMPORTANT: Short Condition Descriptions are not for shorts. These are for longs but completely mirrored opposite side
        # Please dont change these comment descriptions. With these descriptions we are comparing long/short positions.

        short_entry_logic = []
        short_entry_logic.append(True)

        # Condition #501 - Normal mode (Short).
        if short_entry_condition_index == 501:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(global_protections_short_pump == True)
          short_entry_logic.append(global_protections_short_dump == True)

          short_entry_logic.append(rsi_3_1h >= 5.0)
          short_entry_logic.append(rsi_3_4h >= 20.0)
          short_entry_logic.append(rsi_3_1d >= 20.0)
          short_entry_logic.append(rsi_14_1h_gt_20)
          short_entry_logic.append(rsi_14_4h_gt_20)
          short_entry_logic.append(rsi_14_1d_gt_10)
          short_entry_logic.append(
            # 5m up move, 4h still not high enough
            ((rsi_3_lt_97) | (aroonu_14_4h > 60.0))
            # 5m up move, 4h still low
            & ((rsi_3_lt_97) | (stochrsi_k_4h_gt_50))
            # 5m & 15m strong up move
            & ((rsi_3_lt_95) | (rsi_3_15m_lt_95))
            # 5m & 1h up move, 1d uptrend
            & ((rsi_3_lt_95) | (rsi_3_1h_lt_90) | (roc_9_1d_lt_100))
            # 5m up move, 15m & 1h still not high enough
            & ((rsi_3_lt_95) | (aroond_14_15m_lt_25) | (aroond_14_1h_lt_25))
            # 4m up move, 1h & 4h still low
            & ((rsi_3_lt_95) | (stochrsi_k_1h_gt_70) | (stochrsi_k_4h_gt_70))
            # 4m & 1h up move, 1h still low
            & ((rsi_3_lt_90) | (rsi_3_1h_lt_80) | (stochrsi_k_1h_gt_50))
            # 15m & 1h up move, 4h low
            & ((rsi_3_lt_90) | (rsi_3_1h_lt_80) | (aroonu_14_4h_gt_20))
            # 5m up move, 15m & 1h uptrend
            & ((rsi_3_lt_90) | (cmf_20_15m_lt_0_30) | (cmf_20_1h_lt_0_30))
            # 5m up move, 15m stil low
            & ((rsi_3_lt_90) | (aroonu_14_15m_gt_50))
            # 5m up move, 15m & 1h still not high enough
            & ((rsi_3_lt_90) | (stochrsi_k_15m_gt_60) | (stochrsi_k_1h_gt_75))
            # 15m up move, 1h low
            & ((rsi_3_15m_lt_97) | (aroonu_14_1h_gt_30))
            # 15m & 1h up move, 4h still going up
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (cci_20_change_pct_4h_lt_neg_0))
            # 15m & 1h up move, 4h still not high enough
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_90) | (stochrsi_k_4h_gt_80))
            # 15m & 1h up move, 4h still not high enough
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_50))
            # 15m & 1h up move, 1h still low
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_70) | (stochrsi_k_1h_gt_50))
            # 15m & 4h up move, 1h still not high enough
            & ((rsi_3_15m_lt_95) | (rsi_3_4h_lt_95) | (stochrsi_k_1h_gt_75))
            # 15m up move, 1d lost, 1h low
            & ((rsi_3_15m_lt_95) | (rsi_14_1d_gt_40) | (aroonu_14_1h_gt_40))
            # 15m up move, 15m & 4h uptrend
            & ((rsi_3_15m_lt_95) | (aroonu_14_15m_lt_90) | (aroonu_14_4h_lt_90))
            # 15m up move, 15m stil not high enough, 1h low
            & ((rsi_3_15m_lt_95) | (stochrsi_k_15m_gt_70) | (stochrsi_k_1h_gt_10))
            # 15m up move, 1h still not high enough, 4h low
            & ((rsi_3_15m_lt_95) | (stochrsi_k_1h_gt_70) | (aroonu_14_4h_gt_20))
            # 15m up move, 1h & 4h still not high enough
            & ((rsi_3_15m_lt_95) | (stochrsi_k_1h_gt_70) | (stochrsi_k_4h_gt_80))
            # 15m up move, 4h still not high enough
            & ((rsi_3_15m_lt_95) | (aroonu_14_4h_gt_70))
            # 15m up move, 4h & 1d uptrend
            & ((rsi_3_15m_lt_95) | (roc_9_4h_lt_30) | roc_9_1d_lt_50)
            # 15m up move, 1h up move, 1h still not high enough
            & ((rsi_3_15m_lt_95) | (rsi_3_change_pct_1h < 80.0) | (stochrsi_k_1h_gt_50))
            # 15m & 1h up move, 1h still not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_85) | (stochrsi_k_1h_gt_70))
            # 15m & 1h up move, 1h not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_90) | (aroond_14_1h_lt_50))
            # 15m & 1h up move, 1d stil not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_90) | (rsi_14_1h > 80.0))
            # 15m & 1h up move, 1d uptrend
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_80) | (roc_9_1d_lt_40))
            # 15m & 1h up move, 15m still not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_80) | (stochrsi_k_15m_gt_60))
            # 15m & 4h up move, 1h still not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_1h_gt_80))
            # 15m & 4h up move, 1h still not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_1h_gt_90))
            # 15m & 4h up move, 4h not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_90) | (aroond_14_4h_lt_50))
            # 15m & 4h up move, 1d low
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_85) | (stochrsi_k_1d_gt_30))
            # 15m & 4h up move, 1h low
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_70) | (stochrsi_k_1h_gt_20))
            # 15m & 4h up move, 4h low
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_60) | (aroonu_14_4h_gt_30))
            # 15m up move, 15m high, 1d low, 1d oversold
            & ((rsi_3_15m_lt_90) | (aroonu_14_15m_lt_100) | (stochrsi_k_1d_gt_20) | (roc_9_1d_gt_neg_20))
            # 15m up move, 15m high, 1d oversold
            & ((rsi_3_15m_lt_90) | (aroonu_14_15m_lt_100) | (roc_9_1d_gt_neg_30))
            # 15m up move, 15m high, 1d uptrend
            & ((rsi_3_15m_lt_90) | (aroonu_14_15m_lt_100) | (roc_9_1d_lt_40))
            # 15m up move, 1h & 4h low
            & ((rsi_3_15m_lt_90) | (aroonu_14_1h_gt_40) | (aroonu_14_4h_gt_10))
            # 15m up move, 1h still low, 4h low
            & ((rsi_3_15m_lt_90) | (aroonu_14_1h_gt_60) | (stochrsi_k_4h_gt_30))
            # 15m up move, 1h low, 4h still not high enough
            & ((rsi_3_15m_lt_90) | (stochrsi_k_1h_gt_30) | (stochrsi_k_4h_gt_70))
            # 15m & 4h up move, 1d low
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_70) | (stochrsi_k_1d_gt_20))
            # 15m & 1h up move, 4h low
            & ((rsi_3_15m_lt_85) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_20))
            # 15m & 1h up move, 1d still low
            & ((rsi_3_15m_lt_85) | (rsi_3_1h_lt_85) | (stochrsi_k_1d_gt_60))
            # 15m & 1h up move, 1h low
            & ((rsi_3_15m_lt_85) | (rsi_3_1h_lt_70) | (stochrsi_k_1h_gt_30))
            # 15m & 1h up move, 4h low
            & ((rsi_3_15m_lt_85) | (rsi_3_1h_lt_70) | (stochrsi_k_4h_gt_30))
            # 15m & 4h down move, 4h still not high enough
            & ((rsi_3_15m_lt_85) | (rsi_3_4h_lt_90) | (stochrsi_k_4h_gt_75))
            # 15m & 4h up move, 15m low
            & ((rsi_3_15m_lt_85) | (rsi_3_4h_lt_85) | (stochrsi_k_15m_gt_50))
            # 15m down move, 15m still not high enough, 4h low
            & ((rsi_3_15m_lt_85) | (rsi_14_15m > 70.0) | (stochrsi_k_4h_gt_40))
            # 15m up move, 4h overbought
            & ((rsi_3_15m_lt_85) | (roc_9_4h_lt_50))
            # 15m & 1h up move, 1h still not high enough
            & ((rsi_3_15m_lt_80) | (rsi_3_1h_lt_70) | (aroonu_14_1h_gt_60))
            # 15m & 4h up move, 15m still low
            & ((rsi_3_15m_lt_80) | (rsi_3_4h_lt_80) | (aroonu_14_15m_gt_50))
            # 15m up move, 1h low
            & ((rsi_3_15m_lt_80) | (stochrsi_k_1h_gt_20))
            # 15m & 1h up move, 1h low
            & ((rsi_3_15m_lt_70) | (rsi_3_1h_lt_70) | (aroonu_14_1h_gt_30))
            # 15m up move, 15m still not high enough, 1h still low
            & ((rsi_3_15m_lt_70) | (stochrsi_k_15m_gt_90) | (stochrsi_k_1h_gt_50))
            # 1h & 4h up move, 1h still not high enough
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_95) | (stochrsi_k_1h_gt_70))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_95) | (stochrsi_k_4h_gt_30))
            # 1h & 4h up move, 4h still not high enough
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_95) | (uo_7_14_28_4h > 60.0))
            # 1h & 4h up move, 4h still low
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_85) | (stochrsi_k_4h_gt_50))
            # 1h & 4h up move, 4h uptrend
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_85) | (roc_9_4h_lt_40))
            # 1h & 1d strong up move
            & ((rsi_3_1h_lt_95) | (rsi_3_1d_lt_95))
            # 1h up move, 4h still low
            & ((rsi_3_1h_lt_95) | (rsi_14_4h_gt_60))
            # 1h up move, 1d still low, 1h uptrend
            & ((rsi_3_1h_lt_95) | (rsi_14_1d_gt_50) | (roc_9_1h_lt_30))
            # 1h & 4h strong up move
            & ((rsi_3_1h_lt_95) | (mfi_14_1h < 95.0) | (rsi_3_4h_lt_95))
            # 1h up move, 1d still low, 1h uptrend
            & ((rsi_3_1h_lt_95) | (stochrsi_k_1d_gt_50) | (roc_9_1h_lt_20))
            # 1h strong up move, 15m still move higher
            & ((rsi_3_1h_lt_95) | (cci_20_change_pct_15m < -0.0))
            # 1h & 4h up move, 1h still low
            & ((rsi_3_1h_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_1h_gt_50))
            # 1h & 4h up move, 1d still not high enough
            & ((rsi_3_1h_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_1d_gt_70))
            # 1h up move, 4h low, 1d overbought
            & ((rsi_3_1h_lt_90) | (aroonu_14_4h_gt_20) | roc_9_1d_lt_50)
            # 1h up move, 1h still low, 1d uptrend
            & ((rsi_3_1h_lt_90) | (stochrsi_k_1h_gt_60) | roc_9_1d_lt_50)
            # 1h up move, 1h still not high enough, 1d low
            & ((rsi_3_1h_lt_90) | (stochrsi_k_1h_gt_70) | (stochrsi_k_1d_gt_30))
            # 1h up move, 4h low, 1h uptrend
            & ((rsi_3_1h_lt_90) | (stochrsi_k_4h_gt_20) | (roc_9_1h_lt_10))
            # 1h up move, 4h low, 1h overbought
            & ((rsi_3_1h_lt_90) | (stochrsi_k_4h_gt_40) | (roc_9_1h_lt_30))
            # 1h up move, 15m & 1h uptrend
            & ((rsi_3_1h_lt_90) | (roc_9_15m < 15.0) | (roc_9_1h_lt_15))
            # 1h up move, 15m & 4h still low
            & ((rsi_3_1h_lt_85) | (stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_50))
            # 1h & 4h up move, 15m still not high enough
            & ((rsi_3_1h_lt_85) | (rsi_3_4h_lt_85) | (aroond_14_15m_lt_50))
            # 1h & 4h up move, 15m still not high enough
            & ((rsi_3_1h_lt_85) | (rsi_3_4h_lt_85) | (stochrsi_k_15m_gt_90))
            # 1h up move, 15m still not high enough, 1h still low
            & ((rsi_3_1h_lt_80) | (stochrsi_k_15m_gt_80) | (stochrsi_k_1h_gt_50))
            # 1h up move, 1h still low
            & ((rsi_3_1h_lt_80) | (stochrsi_k_1h_gt_60))
            # 1h up move, 1d uptrend
            & ((rsi_3_1h_lt_80) | (roc_9_1d_lt_200))
            # 4h & 1d strong up move
            & ((rsi_3_4h_lt_95) | (rsi_3_1d_lt_95))
            # 4h up move, 15m still low, 1h not high enough
            & ((rsi_3_4h_lt_95) | (stochrsi_k_15m_gt_50) | (aroond_14_1h_lt_25))
            # 4h up move, 15m still not high enough, 4h overbought
            & ((rsi_3_4h_lt_95) | (stochrsi_k_15m_gt_70) | (roc_9_4h_lt_60))
            # 4h up move, 15m uptrend
            & ((rsi_3_4h_lt_95) | (roc_9_15m < 20.0))
            # 4h up move, 1h uptrend
            & ((rsi_3_4h_lt_95) | (roc_9_1h_lt_20))
            # 4h up move, 1h & 4h overbought
            & ((rsi_3_4h_lt_95) | (roc_9_1h_lt_30) | (roc_9_4h_lt_60))
            # 4h up move, 1h still low
            & ((rsi_3_4h_lt_90) | (aroonu_14_1h_gt_40))
            # 4h up move, 1d still low, 4h uptrend
            & ((rsi_3_4h_lt_85) | (rsi_14_1d_gt_40) | (roc_9_4h_lt_20))
            # 4h up move, 4h still low
            & ((rsi_3_4h_lt_80) | (stochrsi_k_4h_gt_50))
            # 4h up move, 1h low
            & ((rsi_3_4h_lt_70) | (aroonu_14_1h > 25.0))
            # 4h up move, 1d low
            & ((rsi_3_4h_lt_70) | (aroonu_14_1d > 20.0))
            # 4h up move, 1h low
            & ((rsi_3_4h_lt_70) | (stochrsi_k_1h_gt_20))
            # 4h up move, 1d low
            & ((rsi_3_4h_lt_70) | (stochrsi_k_1d_gt_20))
            # 1d up move, 1h & 4h still not low enough
            & ((rsi_3_1d_lt_90) | (stochrsi_k_1h_gt_80) | (stochrsi_k_4h_gt_50))
            # 4h still not high enough, 4h overbought, 4h uptrend
            & ((rsi_14_4h_gt_80) | (roc_9_4h_lt_40) | (cci_20_change_pct_4h_lt_0))
            # 15m & 1h uptrend, 4h still low
            & ((cmf_20_15m_lt_0_30) | (cmf_20_1h_lt_0_30) | (stochrsi_k_4h_gt_60))
            # 15m & 1h uptrend
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100))
            # 15m uptrend, 1h low
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_1h_gt_20))
            # 15m uptrend, 1d uptrend
            & ((aroonu_14_15m_lt_100) | (roc_9_1d_lt_60))
            # 1h & 4h uptrend
            & ((aroonu_14_1h_lt_100) | (aroonu_14_4h_lt_100))
            # 1h uptrend, 4h uptrend
            & ((aroonu_14_1h_lt_100) | (roc_9_4h_lt_20))
            # 4h uptrend, 1d uptrend
            & (aroonu_14_4h_lt_100 | (aroonu_14_1d_lt_100))
            # 4h uptrend, 15m uptrend
            & (aroonu_14_4h_lt_100 | (roc_9_15m < 10.0))
            # 4h uptrend, 1h uptrend
            & (aroonu_14_4h_lt_100 | (roc_9_1h_lt_20))
            # 1d uptrend, 15m uptrend
            & (aroonu_14_1d_lt_100 | (roc_9_15m < 20.0))
            # 1d uptrend, 1h uptrend
            & (aroonu_14_1d_lt_100 | (roc_9_1h_lt_20))
            # 15m still not high enough, 1h & 4h overbought
            & ((stochrsi_k_15m_gt_70) | (roc_9_1h_lt_30) | (roc_9_4h_lt_60))
            # 1h & 4h overbought, 1h uptrend
            & ((roc_9_1h_lt_10) | (roc_9_4h_lt_40) | (cci_20_change_pct_1h_lt_0))
            # 1h & 4h overbought, 4h uptrend
            & ((roc_9_1h_lt_10) | (roc_9_4h_lt_40) | (cci_20_change_pct_4h_lt_0))
            # 1h & 4h & 1d uptrend
            & ((roc_9_1h_lt_10) | (roc_9_4h_lt_10) | (roc_9_1d_lt_20))
            # 5m green, 15m still not high enough
            & ((change_pct < 5.0) | (aroond_14_15m_lt_50))
            # 5m green, 15m still not high enough
            & ((change_pct < 5.0) | (stochrsi_k_15m_gt_90))
            # pump in the last half hour, 1h low
            & ((close < (close_min_6 * 1.20)) | (aroonu_14_1h_gt_30))
            # pump in the last half hour, 15m still low
            & ((close < (close_min_6 * 1.20)) | (stochrsi_k_15m_gt_40))
            # pump in the last half hour, 1d uptrend
            & ((close < (close_min_6 * 1.20)) | (roc_9_1d_lt_20))
            # big pump in the last 4 hours, 15m still low
            & ((close < (close_min_48 * 1.50)) | (aroonu_14_15m_gt_50))
          )

          # Logic
          short_entry_logic.append(
            (ema_12 > ema_26)
            & ((ema_12 - ema_26) > (open_rate * 0.030))
            & ((ema_12_shift_1 - ema_26_shift_1) > (open_rate / 100.0))
            & (close > (bbu_20_2_0 * 1.004))
          )

        # Condition #502 - Normal mode (Short).
        if short_entry_condition_index == 502:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          # 5m & 15m & 1h & 4h up move
          short_entry_logic.append(
            ((rsi_3_lt_97) | (rsi_3_15m_lt_90) | (rsi_3_1h_lt_90) | (rsi_3_4h_lt_80))
            # 5m & 4h up move
            & ((rsi_3_lt_97) | (rsi_3_4h_lt_95))
            # 5m up move, 4h still not high enough
            & ((rsi_3_lt_97) | (stochrsi_k_4h_gt_80))
            # 5m & 15m strong up move
            & ((rsi_3_lt_95) | (rsi_3_15m_lt_95))
            # 5m & 15m up move, 4h low
            & ((rsi_3_lt_95) | (rsi_3_15m_lt_90) | (aroonu_14_4h_gt_30))
            # 5m & 1h & 4h up move
            & ((rsi_3_lt_95) | (rsi_3_1h_lt_90) | (rsi_3_4h_lt_90))
            # 5m & 1h up move, 15m still not high enough
            & ((rsi_3_lt_95) | (rsi_3_1h_lt_85) | (stochrsi_k_15m_gt_70))
            # 5m up move, 15m still low
            & ((rsi_3_lt_95) | (stochrsi_k_15m_gt_50))
            # 5m up move, 4h low
            & ((rsi_3_lt_90) | (aroonu_14_4h_gt_20))
            # 15m & 1h down move, 4h still not high enough
            & ((rsi_3_15m_lt_97) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_80))
            # 15m up move, 1h still low
            & ((rsi_3_15m_lt_97) | (stochrsi_k_1h_gt_60))
            # 15m & 1h & 4h up move
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_90) | (rsi_3_4h_lt_85))
            # 15m & 1h up move, 4h still low
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_60))
            # 15m up move, 1h still low
            & ((rsi_3_15m_lt_95) | (stochrsi_k_1h_gt_40))
            # 15m up move, 4h still not high enough
            & ((rsi_3_15m_lt_95) | (aroonu_14_4h_gt_70))
            # 15m & 1h & 4h up move
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_90) | (rsi_3_4h_lt_90))
            # 15m & 1h up move, 15m still not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_90) | (stochrsi_k_15m_gt_80))
            # 15m & 1h up move, 1d low
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_90) | (stochrsi_k_1d > 40.0))
            # 15m & 1h up move, 1h still not high enough
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_85) | (stochrsi_k_1h_gt_80))
            # 15m & 1h up move, 4h stil low
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_80) | (aroonu_14_4h_gt_50))
            # 15m & 4h up move, 1d low
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_85) | (rsi_14_1d_gt_40))
            # 15m & 4h up move, 1d low
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_85) | (stochrsi_k_1d_gt_30))
            # 15m up move, 1h still low, 1d low
            & ((rsi_3_15m_lt_90) | (aroonu_14_1h > 50.0) | (aroonu_14_1d_gt_30))
            # 15m up move, 1h high
            & ((rsi_3_15m_lt_90) | (aroonu_14_1h_lt_100))
            # 15m up move, 1h still low
            & ((rsi_3_15m_lt_90) | (stochrsi_k_1h_gt_50))
            # 15m up move, 4h uptrend
            & ((rsi_3_15m_lt_90) | (roc_9_4h_lt_20))
            # 15m & 1h up move, 1h still low
            & ((rsi_3_15m_lt_85) | (rsi_3_1h_lt_65) | (stochrsi_k_1h_gt_60))
            # 15m up move, 1h low
            & ((rsi_3_15m_lt_85) | (stochrsi_k_1h_gt_30))
            # 15m & 1h & 4h up move, 4h uptrend
            & ((rsi_3_15m_lt_80) | (rsi_3_1h_lt_80) | (rsi_3_4h_lt_80) | (aroonu_14_4h_lt_100))
            # 15m & 4h up move, 15m still low
            & ((rsi_3_15m_lt_80) | (rsi_3_4h_lt_75) | (aroonu_14_15m_gt_50))
            # 15m up move, 4h low, 15m uptrend, 4h oversold
            & ((rsi_3_15m_lt_80) | (rsi_14_4h_gt_20) | (aroonu_14_15m_lt_100) | (roc_9_4h_gt_neg_20))
            # 15m up move, 15m high, 4h & 1d oversold
            & ((rsi_3_15m_lt_80) | (aroonu_14_15m_lt_100) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_60))
            # 15m up move, 15m high, 1h & 4h uptrend
            & ((rsi_3_15m_lt_80) | (aroonu_14_15m_lt_100) | (roc_9_1h_lt_20) | (roc_9_4h_lt_30))
            # 15m up move, 1h low
            & ((rsi_3_15m_lt_80) | (aroonu_14_1h_gt_10))
            # 15m up move, 1h low, 1d uptrend
            & ((rsi_3_15m_lt_80) | (aroonu_14_1h_gt_40) | (roc_9_1d_lt_100))
            # 15m up move, 1h still low, 1d oversold
            & ((rsi_3_15m_lt_80) | (stochrsi_k_1h_gt_50) | (roc_9_1d_gt_neg_30))
            # 15m up move, 4h low
            & ((rsi_3_15m_lt_80) | (stochrsi_k_4h_gt_40))
            # 15m up move, 1h uptrend
            & ((rsi_3_15m_lt_75) | (roc_9_1h_lt_40))
            # 1h & 1d strong up move
            & ((rsi_3_1h_lt_95) | (rsi_3_1d_lt_95))
            # 1h up move, 1h still not high enough
            & ((rsi_3_1h_lt_95) | (stochrsi_k_1h_gt_70))
            # 1h up move, 4h still low, 1h moving higher
            & ((rsi_3_1h_lt_95) | (stochrsi_k_4h_gt_60) | (cci_20_change_pct_1h_lt_neg_0))
            # 1h up move, 1d low
            & ((rsi_3_1h_lt_95) | (rsi_14_1d_gt_40))
            # 1h strong up move, 15m still move higher
            & ((rsi_3_1h_lt_95) | (cci_20_change_pct_15m < -0.0))
            # 1h up move, relative stable before the hour
            & ((rsi_3_1h_lt_95) | (close_min_12 > (close_min_48 * 1.10)))
            # 1h up move, 15m uptrend
            & ((rsi_3_1h_lt_90) | (aroonu_14_15m_lt_100))
            # 1h up move, 1d low
            & ((rsi_3_1h_lt_90) | (stochrsi_k_1d_gt_10))
            # 1h up move, 1h & 4h uptrend
            & ((rsi_3_1h_lt_90) | (roc_9_1h_lt_30) | (roc_9_4h_lt_30))
            # 1h up move, 4h uptrend
            & ((rsi_3_1h_lt_90) | (roc_9_4h_lt_20))
            # 1h up move, 4h still low
            & ((rsi_3_1h_lt_85) | (aroonu_14_4h_gt_50))
            # 1h up move, 4h still low
            & ((rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_50))
            # 1h & 4h up move, 1d low
            & ((rsi_3_1h_lt_80) | (rsi_3_4h_lt_80) | (stochrsi_k_1d_gt_30))
            # 1h up move, 15m & 1h high, 1h uptrend
            & ((rsi_3_1h_lt_80) | (aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (roc_9_1h_lt_20))
            # 1h up move, 1h still not high enough
            & ((rsi_3_1h_lt_80) | (stochrsi_k_1h_gt_70))
            # 1h up move, 4h still low, 1h still moving higher
            & ((rsi_3_1h_lt_80) | (rsi_14_4h_gt_60) | (cci_20_change_pct_1h_lt_neg_0))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_80) | (stochrsi_k_4h_gt_20))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_80) | (aroonu_14_4h_gt_10))
            # 1h up move, 1h still low
            & ((rsi_3_1h_lt_75) | (stochrsi_k_1h_gt_50))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_70) | (rsi_14_4h_gt_40))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_70) | (stochrsi_k_4h_gt_40))
            # 1h up move, 1h uptrend
            & ((rsi_3_1h_lt_70) | (roc_9_1h_lt_40))
            # 1h up move, 1h low
            & ((rsi_3_1h_lt_60) | (stochrsi_k_1h_gt_20))
            # 4h up move, 1d still low
            & ((rsi_3_4h < 97.0) | (rsi_14_1d_gt_50))
            # 4h up move, 1h still not high enough
            & ((rsi_3_4h_lt_95) | (stochrsi_k_1h_gt_70))
            # 4h up move, 4h still not high enough
            & ((rsi_3_4h_lt_95) | (stochrsi_k_4h_gt_80))
            # 4h up move, 15m still not high enough, 4h moving higher
            & ((rsi_3_4h_lt_90) | (stochrsi_k_15m_gt_80) | (cci_20_change_pct_4h_lt_0))
            # 4h up move, 15m still low
            & ((rsi_3_4h_lt_90) | (stochrsi_k_15m_gt_50))
            # 4h up move, 1h still low
            & ((rsi_3_4h_lt_90) | (aroonu_14_1h_gt_40))
            # 4h up move, 4h still not high enough
            & ((rsi_3_4h_lt_90) | (stochrsi_k_4h_gt_75))
            # 4h up move, 4h still not high enough
            & ((rsi_3_4h_lt_85) | (stochrsi_k_4h_gt_70))
            # 4h up move, 1d still low, 4h uptrend
            & ((rsi_3_4h_lt_85) | (rsi_14_1d_gt_50) | (roc_9_4h_lt_20))
            # 4h up move, 4h high, 4h & 1d uptrend
            & ((rsi_3_4h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_10) | (roc_9_1d_lt_40))
            # 4h up move, 4h uptrend
            & ((rsi_3_4h_lt_80) | (roc_9_4h_lt_20))
            # 4h up move, 1h low
            & ((rsi_3_4h_lt_75) | (stochrsi_k_1h_gt_20))
            # 4h up move, 4h low
            & ((rsi_3_4h_lt_70) | (stochrsi_k_4h_gt_40))
            # 1d up move, 1h still not high enough
            & ((rsi_3_1d_lt_95) | (stochrsi_k_1h_gt_90))
            # 1d up move, 1h still low
            & ((rsi_3_1d_lt_90) | (stochrsi_k_1h_gt_50))
            # 1d up move, 4h still low
            & ((rsi_3_1d_lt_80) | (stochrsi_k_4h_gt_40))
            # 15m low, 1h still low
            & ((aroonu_14_15m_gt_20) | (stochrsi_k_1h_gt_50))
            # 15m low, 4h low
            & ((aroonu_14_15m_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m still low, 1h low
            & ((aroonu_14_15m_gt_50) | (stochrsi_k_1h_gt_30))
            # 15m still not high enough, 4h low
            & ((stochrsi_k_15m_gt_70) | (aroonu_14_4h_gt_10))
            # 1h & 4h low
            & ((aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_20))
            # 1h & 4h low
            & ((aroonu_14_1h_gt_20) | (stochrsi_k_4h_gt_20))
            # 1h low, 1d low
            & ((aroonu_14_1h_gt_30) | (stochrsi_k_1d_gt_30))
            # 4h low, 1d uptrend
            & ((aroonu_14_4h_gt_30) | (roc_9_1d_lt_80))
            # 4h still not high enough, 4h & 1d uptrend
            & ((aroonu_14_4h_gt_70) | (roc_9_4h_lt_60) | (roc_9_1d_lt_200))
            # 1h & 4h low
            & ((stochrsi_k_1h_gt_20) | (aroonu_14_4h_gt_20))
            # 1d big green, 1d still not high enough
            & ((change_pct_1d_lt_30) | (rsi_14_1d > 65.0))
            # rise in the last hour, relatively stable before the hour
            & ((close < (close_min_12 * 1.10)) | (close_min_12 > (close_min_48 * 1.10)))
            # big pump in the last 6 days, 4h still not high enough
            & ((close < (low_min_6_1d * 4.0)) | (stochrsi_k_4h_gt_80))
            # big pump in the last 20 days, 1h up move
            & ((close < (low_min_20_1d * 6.0)) | (rsi_3_1h_lt_90))
          )

          # Logic
          short_entry_logic.append(
            (aroond_14_lt_25)
            & (stochrsi_k_gt_80)
            & (close > (ema_20 * 1.060))
            & (close > (bbu_20_2_0 * 0.995))
            & (aroond_14_15m_lt_25)
          )

        # Condition #503 - Normal mode (Short).
        if short_entry_condition_index == 503:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          short_entry_logic.append(rsi_3_1h >= 5.0)
          short_entry_logic.append(rsi_3_4h >= 20.0)
          short_entry_logic.append(rsi_3_1d >= 20.0)
          short_entry_logic.append(rsi_14_1h_gt_20)
          short_entry_logic.append(rsi_14_4h_gt_20)
          short_entry_logic.append(rsi_14_1d_gt_10)
          # 5m strong down move
          short_entry_logic.append((rsi_3_lt_98) | (roc_9 < 50.0))
          # 5m down move, 4h still high
          short_entry_logic.append((rsi_3_lt_90) | (mfi_14 > 10.0) | (stochrsi_k_4h_gt_30))
          # 5m & 1h down move, 1h still high
          short_entry_logic.append((rsi_3_lt_90) | (rsi_3_1h_lt_90) | (stochrsi_k_1h_gt_70))
          # 5m down move, 4h downtrend, 1h still high
          short_entry_logic.append((rsi_3_lt_95) | (rsi_3_4h_lt_85) | (stochrsi_k_1h_gt_30))
          # 5m & 4h strong down move, 4h still not low enough
          short_entry_logic.append((rsi_3_lt_95) | (rsi_3_1h_lt_95) | (stochrsi_k_4h_gt_60))
          # 5m down move, 1h high, 1d overbought
          short_entry_logic.append((rsi_3_lt_90) | (roc_9_1h_lt_15) | (roc_9_1d_gt_neg_40))
          # 5m down move, 1h & 4h high
          short_entry_logic.append((rsi_3_lt_90) | (uo_7_14_28_1h > 40.0) | (stochrsi_k_4h_gt_30))
          # 5m down move, 1h high, 4h downtrend
          short_entry_logic.append((rsi_3_lt_98) | (stochrsi_k_1h_gt_10) | (roc_9_4h_lt_10))
          # 5m & 1h down move, 4h down
          short_entry_logic.append((rsi_3_lt_90) | (rsi_3_1h_lt_85) | (cmf_20_4h_gt_neg_0_20))
          # 5m down move, 1h high
          short_entry_logic.append((rsi_14_change_pct < 40.0) | (stochrsi_k_1h_gt_30))
          # 5m down move, 1h high
          short_entry_logic.append((rsi_14_change_pct < 40.0) | (stochrsi_k_4h_gt_30))
          # 15m & 1h down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_50))
          # 15m down move, 15m still not low enough, 1h & 4h still not low enough
          short_entry_logic.append(
            (rsi_3_15m_lt_95) | (aroond_14_15m_lt_25) | (stochrsi_k_1h_gt_75) | (mfi_14_4h > 50.0)
          )
          # 5m & 1h down move, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_85) | (stochrsi_k_1h_gt_50))
          # 15m & 4h down move, 1h still not low
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_4h_lt_90) | (stochrsi_k_1h_gt_70))
          # 15m & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_4h_lt_80) | (stochrsi_k_4h_gt_60))
          # 15m down move, 1h & 4h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (stochrsi_k_1h_gt_50) | (rsi_14_4h_gt_50))
          # 15m & 1h & 4h down move
          short_entry_logic.append((rsi_3_15m_lt_90) | (rsi_3_change_pct_1h > -60.0) | (rsi_3_change_pct_4h > -40.0))
          # 15m down move, 1d downtrend, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (roc_9_1d_gt_neg_25) | (stochrsi_k_1h_gt_30))
          # 15m & 1d down move, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (rsi_3_1d_lt_90) | (stochrsi_k_1h_gt_30))
          # 15m & 4h down move, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (rsi_3_4h_lt_95) | (stochrsi_k_1h_gt_50))
          # 15m down move, 15m still not low enough, 4h down move
          short_entry_logic.append((rsi_3_15m_lt_90) | (aroond_14_15m_lt_50) | (rsi_3_4h_lt_85))
          # 15m down move, 1h still high, 1d strong downtrend
          short_entry_logic.append((rsi_3_15m_lt_80) | (aroond_14_1h_lt_25) | (mfi_14_1d < 90.0))
          # 15m down move, 1h still high, 1d downtrend
          short_entry_logic.append((rsi_3_15m_lt_85) | (stochrsi_k_1h_gt_30) | roc_9_1d_lt_50)
          # 15m down move, 4h still high, 1d downtrend
          short_entry_logic.append((rsi_3_15m_lt_85) | (stochrsi_k_4h_gt_30) | roc_9_1d_lt_50)
          # 15m & 4h down move, 1d downtrend
          short_entry_logic.append((rsi_3_15m_lt_85) | (rsi_3_4h_lt_85) | (roc_9_1d_gt_neg_70))
          # 15m down move, 15m not low enough, 1h overbought
          short_entry_logic.append((rsi_14_change_pct_15m > -40.0) | (stochrsi_k_15m_gt_90) | (rsi_14_1h > 30.0))
          # 15m strong down move, 1h still high
          short_entry_logic.append((roc_9_15m < 15.0) | (stochrsi_k_1h_gt_50))
          # 15m downtrend, 1h & 4h still high
          short_entry_logic.append((roc_9_15m < 10.0) | (stochrsi_k_1h_gt_50) | (stochrsi_k_4h_gt_50))
          # 15m & 1h & 4h down move
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (cci_20_change_pct_4h_lt_0))
          # 15m strong down move
          short_entry_logic.append((rsi_3_15m_lt_90) | (mfi_14_15m < 85.0) | (aroond_14_15m_lt_25))
          # 14m down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_80) | (aroond_14_15m_lt_50) | (uo_7_14_28_4h > 50.0))
          # 15m down move, 1h stil high, 1d overbought
          short_entry_logic.append((rsi_3_15m_lt_85) | (aroond_14_1h_lt_25) | (roc_9_1d_gt_neg_80))
          # 15m down move, 1h high, 1d overbought
          short_entry_logic.append((rsi_3_15m_lt_90) | (stochrsi_k_1h_gt_30) | roc_9_1d_gt_neg_50)
          # 1h & 4h down move, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_change_pct_4h < 65.0) | (stochrsi_k_4h_gt_50))
          # 1h & 4h down move, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_85) | (stochrsi_k_4h_lt_10))
          # 1h down move, 4h still not low enough, 1d overbought
          short_entry_logic.append((rsi_3_1h_lt_90) | (aroond_14_4h_lt_25) | (roc_9_1d > -120.0))
          # 1h down move, 1h still not low enough, 4h still not low
          short_entry_logic.append((rsi_3_1h_lt_90) | (stochrsi_k_1h_gt_70) | (rsi_14_4h_gt_50))
          # 1h down move, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_14_4h_gt_60))
          # 1h down move, 4h still high, 1d downtrend
          short_entry_logic.append((rsi_3_1h_lt_80) | (stochrsi_k_4h_gt_30) | roc_9_1d_lt_50)
          # 1h down move, 4h still high, 1d downtrend
          short_entry_logic.append((rsi_3_change_pct_1h > -65.0) | (stochrsi_k_4h_gt_30) | roc_9_1d_lt_50)
          # 4h & 1d down move, 1h still high
          short_entry_logic.append((rsi_3_4h_lt_90) | (roc_2_1d < 20.0) | (stochrsi_k_1h_gt_50))
          # 15m still high, 1h down move, 4h high
          short_entry_logic.append((aroond_14_15m_lt_50) | (rsi_3_change_pct_1h < 50.0) | (stochrsi_k_4h_gt_30))
          # 15m still high, 1h & 4h down move, 4h still high
          short_entry_logic.append((aroond_14_15m_lt_50) | (rsi_3_1h_lt_85) | (rsi_3_4h_lt_80) | (stochrsi_k_4h_gt_80))
          # 15m & 1h still high, 4h overbought
          short_entry_logic.append((aroond_14_15m_lt_50) | (aroond_14_1h_lt_50) | (roc_9_4h_gt_neg_40))
          # 15m still high, 1h down move, 1d downtrend
          short_entry_logic.append((stochrsi_k_15m_gt_30) | (rsi_3_4h_lt_90) | roc_9_1d_lt_50)
          # 1h & 4h still high, 1d strong down move
          short_entry_logic.append((stochrsi_k_1h_gt_50) | (uo_7_14_28_4h > 55.0) | (rsi_3_1d_lt_90))
          # 1h still high, 4h & 1d downtrend
          short_entry_logic.append((aroond_14_1h_lt_25) | (roc_9_4h_lt_20) | roc_9_1d_lt_50)
          # 4h moving down, 1d P&D
          short_entry_logic.append((roc_9_4h_lt_30) | (rsi_3_change_pct_1d < 50.0) | roc_9_1d_gt_neg_50)
          # 1d strong downtrend, 4h still high
          short_entry_logic.append((roc_2_1d < 20.0) | roc_9_1d_lt_50 | (stochrsi_k_4h_gt_70))
          # 1d P&D, 1d overbought
          short_entry_logic.append((roc_2_1d < 10.0) | roc_9_1d_gt_neg_50 | (stochrsi_k_1h > 5.0))
          # 1h red, previous 1h green, 1h overbought
          short_entry_logic.append(
            (change_pct_1h < 1.0) | (change_pct_1h_shift_12 > -5.0) | (rsi_14_1h_shift_12 < 80.0)
          )
          # 1h red, 1h stil high, 4h downtrend
          short_entry_logic.append((change_pct_1h < 5.0) | (stochrsi_k_1h_gt_50) | (roc_9_4h_gt_neg_25))
          # 4h red, 15m down move, 4h still high
          short_entry_logic.append((change_pct_4h < 5.0) | (rsi_3_15m_lt_90) | (stochrsi_k_4h_gt_30))
          # 4h red, previous 4h green, 4h overbought
          short_entry_logic.append(
            (change_pct_4h < 5.0) | (change_pct_4h_shift_48 > -5.0) | (roc_9_4h_shift_48 > -25.0)
          )
          # 4h red, 4h still not low enough, 1h downtrend, 1h overbought
          short_entry_logic.append(
            (change_pct_4h < 10.0) | (aroond_14_4h_lt_25) | (roc_9_1h_lt_20) | (roc_9_1d_gt_neg_40)
          )
          # 4h red, 4h still high, 1d downtrend
          short_entry_logic.append((change_pct_4h < 10.0) | (stochrsi_k_4h_gt_30) | (roc_9_1d_lt_40))
          # 1d P&D, 1d overbought
          short_entry_logic.append((change_pct_1d_lt_10) | (change_pct_1d_shift_288 > -10.0) | (roc_9_1d_gt_neg_100))
          # 1d P&D, 4h still high
          short_entry_logic.append((change_pct_1d_lt_15) | (change_pct_1d_shift_288 > -15.0) | (aroond_14_4h_lt_50))
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_95) | (cci_20_change_pct_4h_lt_0))

          # Logic
          short_entry_logic.append(rsi_20 > rsi_20_shift_1)
          short_entry_logic.append(rsi_4 > 54.0)
          short_entry_logic.append(aroond_14_lt_25)
          short_entry_logic.append(close > sma_16 * 1.058)

        # Condition #504 - Normal mode (Short).
        if short_entry_condition_index == 504:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          short_entry_logic.append(rsi_3_1h >= 5.0)
          short_entry_logic.append(rsi_3_4h >= 20.0)
          short_entry_logic.append(rsi_3_1d >= 20.0)
          short_entry_logic.append(rsi_14_1h_gt_20)
          short_entry_logic.append(rsi_14_4h_gt_20)
          short_entry_logic.append(rsi_14_1d_gt_10)
          # 15m & 1h down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (mfi_14_15m < 90.0) | (rsi_3_1h_lt_80) | (stochrsi_k_4h_gt_50))
          # 15m & 1h down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (mfi_14_15m < 85.0) | (stochrsi_k_4h_gt_30))
          # 14m & 4h down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (rsi_3_4h_lt_85) | (stochrsi_k_4h_gt_60))
          # 15m down move, 1h & 4h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (uo_7_14_28_1h < 45.0) | (stochrsi_k_4h_gt_30))
          # 1h strong down move, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_14_change_pct_1h < 40.0) | (stochrsi_k_4h_gt_30))
          # 1h strong down move, 4h down move, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_change_pct_4h < 50.0) | (stochrsi_k_4h_gt_50))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_4h_lt_90) | (stochrsi_k_4h_gt_75))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_4h_lt_75) | (aroond_14_4h_lt_50))
          # 15m down move, 1h strong downtrend
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (mfi_14_1h > 5.0))
          # 15m downtrend, 4h down move, 4h stil high
          short_entry_logic.append((roc_9_15m > -20.0) | (rsi_3_4h_lt_75) | (stochrsi_k_4h_gt_30))

          # Logic
          short_entry_logic.append(aroond_14_lt_25)
          short_entry_logic.append(aroond_14_15m_lt_25)
          short_entry_logic.append(close > (ema_9 * 1.058))
          short_entry_logic.append(close > (ema_20 * 1.040))

        # Condition #505 - ADX trend-birth (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 505:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          short_entry_logic.append(
            # 5m no recent low, 15m money coming in, 1h pinned at its low
            ((aroond_14 > 5.0) | (mfi_14_15m < 40.0) | (willr_14_1h > -85.0))
            # 5m no recent low, 15m weak, 4h stoch lifted
            & ((aroond_14 > 5.0) | (rsi_14_15m > 40.0) | (stochrsi_k_4h < 40.0))
            # 5m a fresh high, 15m pinned at its low
            & ((aroonu_14 < 95.0) | (willr_14_15m > -60.0))
            # 5m no recent high, 15m rising
            & ((aroonu_14 > 5.0) | (roc_9_15m < 1.5))
            # 5m a fresh high, 15m stoch on the floor
            & (aroonu_14_lt_30 | (stochrsi_k_15m > 5.0))
            # 5m money coming in, 15m a fresh low
            & ((cmf_20 < 0.15) | aroond_14_15m_lt_80)
            # 5m money going out, 1h stoch on the floor
            & ((cmf_20 > -0.3) | (stochk_14_3_3_1h > 10.0))
            # 5m money coming in, 4h stoch lifted, 4h money gone
            & ((mfi_14 < 35.0) | (stochrsi_k_4h < 40.0) | (mfi_14_4h > 25.0))
            # 5m money back in, 15m still reading oversold, 1d stochastic low
            & ((mfi_14 < 50.0) | (cci_20_15m > -75.0) | (stochk_14_3_3_1d > 50.0))
            # 5m money gone, 15m no recent low, 15m weak
            & ((mfi_14 > 15.0) | (aroond_14_15m > 10.0) | (rsi_14_15m > 35.0))
            # 5m money gone, 4h RSI climbing
            & ((mfi_14 > 15.0) | (rsi_14_change_pct_4h < 10.0))
            # 5m money gone, 15m money coming in
            & ((mfi_14 > 25.0) | (mfi_14_15m < 55.0))
            # 5m money gone, 15m stretched
            & ((mfi_14 > 25.0) | (rsi_14_15m < 45.0))
            # 5m money gone, 15m rising
            & ((mfi_14 > 40.0) | (roc_9_15m < 1.5))
            # 5m rising, 1d stoch lifted
            & ((roc_2 < 0.5) | (stochrsi_k_1d < 80.0))
            # 5m rising, 1h stoch lifted, 1h money gone
            & ((roc_2 < 0.5) | (stochrsi_k_1h < 30.0) | (mfi_14_1h > 30.0))
            # up over 24h, 15m money coming in, 1d thrusting up
            & ((roc_288 < -2.0) | (mfi_14_15m < 40.0) | (rsi_3_1d < 40.0))
            # down over 24h, 5m a fresh high, 15m falling hard
            & ((roc_288 > -15.0) | (aroonu_14 < 85.0) | rsi_3_15m_gt_50)
            # down over 24h, 15m money gone
            & ((roc_288 > -15.0) | (mfi_14_15m > 15.0))
            # down over 24h, 1h money gone, 4h rising
            & ((roc_288 > -15.0) | (mfi_14_1h > 15.0) | (roc_2_4h < -5.0))
            # down over 24h, 15m stretched, 1h money gone
            & ((roc_288 > -15.0) | (rsi_14_15m < 40.0) | (mfi_14_1h > 20.0))
            # 5m rising, 15m RSI climbing, 15m pinned at its low
            & ((roc_9 < 0.5) | (rsi_14_change_pct_15m < 15.0) | (willr_14_15m > -70.0))
            # 5m falling, 15m thrusting up, 1h money gone
            & ((roc_9 > -4.0) | (rsi_3_15m < 20.0) | (mfi_14_1h > 15.0))
            # 5m stretched, down over 24h, 15m no recent low
            & ((rsi_14 < 60.0) | (roc_288 > -5.0) | (aroond_14_15m > 20.0))
            # 5m weak, 15m near the top of its range
            & ((rsi_14 > 40.0) | (willr_14_15m < -40.0))
            # 5m stretched, 1h no recent low
            & ((rsi_20 < 55.0) | (aroond_14_1h > 35.0))
            # 5m weak, 1h no recent low, 4h a fresh high
            & ((rsi_20 > 30.0) | (aroond_14_1h > 65.0) | (aroonu_14_4h < 50.0))
            # 5m thrusting up, 15m money gone, 4h near the top of its range
            & ((rsi_3 < 70.0) | (mfi_14_15m > 30.0) | (willr_14_4h < -70.0))
            # 5m thrusting up, well up its 40h range
            & ((rsi_3 < 85.0) | (willr_480 < -75.0))
            # 5m thrusting up, 1h pinned at its low
            & ((rsi_4 < 70.0) | (willr_14_1h > -90.0))
            # 5m fast stoch topped, 1d stretched
            & ((stoch_4_4 < 80.0) | (rsi_14_1d < 55.0))
            # 5m stoch lifted, 15m stoch on the floor
            & ((stochrsi_k < 50.0) | (stochk_14_3_3_15m > 10.0))
            # 5m stoch lifted, up over 24h, 15m pinned at its low
            & ((stochrsi_k < 95.0) | (roc_288 < -5.0) | (willr_14_15m > -70.0))
            # 5m near the top of its range, 15m falling
            & ((willr_14 < -30.0) | (roc_9_15m > -2.0))
            # 5m pinned at its low, 15m thrusting up
            & ((willr_14 > -80.0) | rsi_3_15m_lt_60)
            # 5m pinned at its low, 5m money coming in, 15m money gone
            & ((willr_14 > -90.0) | (mfi_14 < 55.0) | (mfi_14_15m > 45.0))
            # 5m pinned at its low, 15m rising
            & ((willr_14 > -90.0) | (roc_9_15m < 1.5))
            # well up its 40h range, 1h a fresh high
            & ((willr_480 < -60.0) | (aroonu_14_1h < 55.0))
            # at its 40h floor, 4h thrusting up, 1d near the top of its range
            & ((willr_480 > -85.0) | (rsi_3_4h < 35.0) | (willr_14_1d < -50.0))
            # 15m no recent low, 15m falling hard, 1d falling hard
            & ((aroond_14_15m > 10.0) | (rsi_3_15m > 25.0) | (rsi_3_1d > 15.0))
            # 15m no recent low, 1h stretched, 1h money gone
            & ((aroond_14_15m > 5.0) | (rsi_14_1h < 45.0) | (mfi_14_1h > 35.0))
            # 15m no recent low, 1h at its 3-day floor
            & ((aroond_14_15m > 5.0) | (willr_84_1h > -95.0))
            # 15m a fresh low, 4h money coming in, 1d stoch lifted
            & (aroond_14_15m_lt_80 | (cmf_20_4h < 0.0) | stochrsi_k_1d_lt_80)
            # 15m a fresh high, 1h RSI collapsing, 1h stoch lifted
            & ((aroonu_14_15m < 15.0) | (rsi_14_change_pct_1h > -20.0) | stochrsi_k_1h_lt_40)
            # 15m a fresh high, 1h no recent low
            & ((aroonu_14_15m < 65.0) | (aroond_14_1h > 35.0))
            # 15m a fresh high, 1d pinned at its low
            & (aroonu_14_15m_lt_80 | (willr_14_1d > -90.0))
            # 15m a fresh high, 1h well up its 3-day range, 4h falling hard
            & (aroonu_14_15m_lt_80 | (willr_84_1h < -80.0) | rsi_3_4h_gt_15)
            # 15m money coming in, 1d RSI_3 collapsing
            & ((cmf_20_15m < 0.15) | (rsi_3_change_pct_1d > -50.0))
            # 15m money going out, 1d up
            & ((cmf_20_15m > -0.25) | (change_pct_1d < -1.0))
            # 15m money going out, 1h stoch lifted, 1h at its 3-day floor
            & ((cmf_20_15m > 0.0) | (stochrsi_k_1h < 80.0) | (willr_84_1h > -85.0))
            # 15m money coming in, 15m RSI_3 jumping, 1d falling
            & ((mfi_14_15m < 30.0) | (rsi_3_change_pct_15m < 80.0) | (roc_2_1d > -10.0))
            # 15m money coming in, 1h rising, 1d stoch on the floor
            & ((mfi_14_15m < 55.0) | (roc_2_1h < 1.5) | (stochrsi_k_1d > 25.0))
            # 15m money coming in, 4h falling
            & ((mfi_14_15m < 55.0) | (roc_2_4h > -3.0))
            # 15m money coming in, 1h a fresh high
            & ((mfi_14_15m < 60.0) | (aroonu_14_1h < 55.0))
            # 15m money gone, 1h weak, 4h money gone
            & ((mfi_14_15m > 20.0) | (rsi_14_1h > 15.0) | (mfi_14_4h > 20.0))
            # 15m money gone, 4h falling, 1d rising
            & ((mfi_14_15m > 25.0) | (roc_9_4h > -15.0) | (roc_9_1d < 15.0))
            # 15m rising, 4h rising
            & ((roc_9_15m < -0.5) | (roc_9_4h < -1.0))
            # 15m rising, 1d stoch on the floor, 1d a fresh high
            & ((roc_9_15m < 1.5) | (stochrsi_k_1d > 25.0) | (aroonu_14_1d < 35.0))
            # 15m falling, 15m money coming in, 1h stretched
            & ((roc_9_15m > -2.0) | (cmf_20_15m < 0.0) | (rsi_14_1h < 45.0))
            # 15m RSI collapsing, 1h stoch lifted, 1h RSI climbing
            & ((rsi_14_change_pct_15m > 5.0) | (stochrsi_k_1h < 80.0) | (rsi_14_change_pct_1h < 20.0))
            # 15m thrusting up, 1h at its 3-day floor, 4h a fresh high
            & ((rsi_3_15m < 20.0) | (willr_84_1h > -95.0) | (aroonu_14_4h < 50.0))
            # 15m thrusting up, 4h pinned at its low
            & ((rsi_3_15m < 30.0) | (willr_14_4h > -95.0))
            # 15m thrusting up, 1h a fresh high, 4h stoch collapsing
            & ((rsi_3_15m < 55.0) | (aroonu_14_1h < 30.0) | (stochrsi_k_change_pct_4h > -100.0))
            # 15m thrusting up, 15m a fresh high, 1d stoch on the floor
            & ((rsi_3_15m < 70.0) | (aroonu_14_15m < 80.0) | (stochrsi_k_1d > 25.0))
            # 15m falling hard, 15m no recent low, 1d thrusting up
            & ((rsi_3_15m > 20.0) | (aroond_14_15m > 20.0) | (rsi_3_1d < 45.0))
            # 15m falling hard, 4h money coming in, 1d money coming in
            & ((rsi_3_15m > 25.0) | (mfi_14_4h < 35.0) | (mfi_14_1d < 70.0))
            # 15m falling hard, 1h money coming in, 1d near the top of its range
            & ((rsi_3_15m > 30.0) | (mfi_14_1h < 45.0) | (willr_14_1d < -50.0))
            # 15m falling hard, 4h falling, 1d rising
            & (rsi_3_15m_gt_15 | (roc_9_4h > -15.0) | roc_9_1d_lt_15)
            # 15m thrusting up, 15m a fresh low
            & (rsi_3_15m_lt_60 | aroond_14_15m_lt_80)
            # 15m thrusting up, 1d stoch on the floor
            & (rsi_3_15m_lt_75 | stochrsi_k_1d_gt_20)
            # 15m RSI_3 jumping, 1h pinned at its low, 1h no recent high
            & ((rsi_3_change_pct_15m < 50.0) | (willr_14_1h > -95.0) | (aroonu_14_1h > 5.0))
            # 15m stoch on the floor, 1h money coming in
            & ((stochrsi_k_15m > 5.0) | (mfi_14_1h < 50.0))
            # 15m near the top of its range, 15m stoch on the floor
            & ((willr_14_15m < -20.0) | (stochrsi_k_15m > 65.0))
            # 15m pinned at its low, 15m no recent low, 4h money coming in
            & ((willr_14_15m > -40.0) | (aroond_14_15m > 20.0) | (mfi_14_4h < 45.0))
            # 1h a fresh high, 4h pinned at its low, 1d stretched
            & ((aroonu_14_1h < 50.0) | (willr_14_4h > -90.0) | (rsi_14_1d < 50.0))
            # 1h a fresh high, 4h RSI climbing
            & ((aroonu_14_1h < 55.0) | (rsi_14_change_pct_4h < 10.0))
            # 1h at a recent high, 4h fall flat, 4h money spent
            & (aroonu_14_1h_lt_25 | (roc_9_4h < -5.0) | (mfi_14_4h > 25.0))
            # 1h squeezed flat, 1h money coming in
            & ((bbb_20_2_0_1h > 5.0) | (mfi_14_1h < 55.0))
            # 1h up, 4h down
            & ((change_pct_1h < 0.0) | (change_pct_4h > -5.0))
            # 1h money coming in, 4h falling, 4h stoch lifted
            & ((cmf_20_1h < 0.0) | (roc_9_4h > -10.0) | (stochrsi_k_4h < 15.0))
            # 1h money coming in, 1h at its 3-day floor, 1d thrusting up
            & ((cmf_20_1h < 0.0) | (willr_84_1h > -90.0) | (rsi_3_1d < 45.0))
            # 1h money going out, 4h strong
            & ((cmf_20_1h > -0.25) | (uo_7_14_28_4h < 45.0))
            # 1h money coming in, 1d thrusting up
            & ((mfi_14_1h < 40.0) | (rsi_3_1d < 45.0))
            # 1h money coming in, 1d rising
            & ((mfi_14_1h < 45.0) | (roc_2_1d < -3.0))
            # 1h money gone, 4h stretched, 1d stoch lifted
            & ((mfi_14_1h > 15.0) | (rsi_14_4h < 35.0) | (stochrsi_k_1d < 80.0))
            # 1h fall stalled, 4h at a fresh high
            & ((roc_9_1h < -5.0) | aroonu_14_4h_lt_60)
            # 1h stoch lifted, 1h falling hard, 4h a fresh high
            & ((stochrsi_k_1h < 55.0) | (rsi_3_1h > 10.0) | (aroonu_14_4h < 50.0))
            # 1h stoch lifted, 4h RSI collapsing, 1d falling hard
            & ((stochrsi_k_1h < 80.0) | (rsi_14_change_pct_4h > -5.0) | (rsi_3_1d > 25.0))
            # 1h stoch lifted, 1d falling hard
            & (stochrsi_k_1h_lt_20 | rsi_3_1d_gt_20)
            # 1h stoch lifted, 1h weak
            & (stochrsi_k_1h_lt_60 | (rsi_14_1h > 40.0))
            # 1h stoch lifted, 1h falling
            & (stochrsi_k_1h_lt_80 | (roc_2_1h > -2.5))
            # 1h strong, 4h RSI_3 collapsing
            & ((uo_7_14_28_1h < 55.0) | (rsi_3_change_pct_4h > -30.0))
            # 1h well up its 3-day range, 1h a fresh high, 4h money coming in
            & ((willr_84_1h < -70.0) | (aroonu_14_1h < 50.0) | (mfi_14_4h < 45.0))
            # 1h at its 3-day floor, 4h thrusting up
            & ((willr_84_1h > -95.0) | (rsi_3_4h < 30.0))
            # 4h at a fresh 14-period low, 4h momentum not spent, the day barely down
            & ((aroond_14_4h < 95.0) | (rsi_3_4h < 30.0) | (roc_9_1d < -5.0))
            # 4h no recent high, 1d stretched, 1d a long lower wick
            & (aroonu_14_4h_gt_30 | (rsi_14_1d < 55.0) | (bot_wick_pct_1d < 1.5))
            # 4h a fresh high, 4h money coming in
            & (aroonu_14_4h_lt_50 | (mfi_14_4h < 35.0))
            # 4h down, 1d stretched
            & ((change_pct_4h > -5.0) | rsi_14_1d_lt_50)
            # 4h money gone, 4h falling
            & ((mfi_14_4h > 15.0) | (roc_9_4h > -10.0))
            # 4h stretched, 1d rising
            & ((rsi_14_4h < 45.0) | (roc_9_1d < 5.0))
            # 1d money leaving and 1d washed out, but price not near its 1d low
            & ((cmf_20_1d > -0.05) | rsi_3_1d_gt_30 | (willr_14_1d < -80.0))
            # 1d stoch lifted, 1d a fresh low
            & ((stochk_14_3_3_1d < 40.0) | (aroond_14_1d < 90.0))
            # 1d near the top of its range, 1d falling
            & ((willr_14_1d < -45.0) | (roc_2_1d > -10.0))
          )

          # Logic
          short_entry_logic.append(
            # 4h trend birth: ADX up through 20 after 8 quiet days
            (adx_14_4h > 20.0)
            & (np_shift(adx_14_4h, 48) <= 20.0)
            # pointing down, under the 200 EMA
            & (minus_di_14_4h > plus_di_14_4h)
            & (close < ema_200)
          )

        # Condition #506 - Donchian 7-day breakdown (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 506:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          short_entry_logic.append(
            # 5m momentum alive, a volume spike and 4h a trend established
            ((rsi_3 < 10) | (vol_rel < 16) | (adx_14_4h < 20))
            # 4h a long upper wick, 5m momentum alive and daily a long lower wick
            & ((rsi_3 < 20) | (top_wick_pct_4h < 2) | (bot_wick_pct_1d < 2))
            # 4h a long upper wick, 5m momentum alive and a trend established
            & ((rsi_3 < 20) | (adx_14_4h < 25) | (top_wick_pct_4h < 2.5))
            # 15m high in its range, 5m momentum alive and 1h a new high
            & ((rsi_3 < 25) | (willr_14_15m < -70) | (aroonu_14_1h < 30))
            # 15m stochastic high, 5m momentum alive and daily no recent low
            & ((stochrsi_k_15m < 45) | (rsi_3 < 25) | (aroond_14_1d > 85))
            # 5m not oversold, a volume spike and 4h a trend established
            & ((rsi_4 < 20) | (vol_rel < 16) | (adx_14_4h < 15))
            # 5m money flowing in, the coil's roof low and not oversold
            & ((mfi_14 < 40) | (quad_s93_max_12 > 60) | (rsi_4 < 25))
            # 15m a new high, 5m the coil's floor lifted and not oversold
            & ((quad_s93_min_12 < 10) | (rsi_4 < 15) | (aroonu_14_15m < 45))
            # 5m not oversold, tightly squeezed and 1h stochastic at the floor
            & ((rsi_4 < 20) | (sqz_cnt_24 < 15) | (stochrsi_k_1h > 5))
            # 4h at an extreme low, 5m not oversold and 1h not down
            & ((rsi_4 < 25) | (change_pct_1h < -1) | (cci_20_4h > -230))
            # 1h momentum collapsing, 5m not oversold and 4h no upward push
            & ((rsi_3_change_pct_1h > -60.0) | (rsi_14 < 35) | (plus_di_14_4h > 10))
            # daily a long upper wick, 5m not oversold and not falling
            & ((top_wick_pct_1d < 4.5) | (rsi_14 < 35) | (roc_2_1d < -1.5))
            # daily falling, 5m not oversold and 4h stochastic high
            & ((rsi_14 < 35) | (stochrsi_k_4h < 30) | (roc_2_1d > -8))
            # 4h money leaving, 5m not oversold and daily not down
            & ((rsi_14 < 35) | (cmf_20_4h > -0.2) | (change_pct_1d < -2.5))
            # 4h downtrend set, 5m not oversold and 15m oscillator lifting
            & ((rsi_14 < 35) | (uo_7_14_28_change_pct_15m < 0) | (minus_di_14_4h < 35))
            # 15m high in its range, 4h stochastic high and 5m not oversold
            & ((rsi_14 < 30) | (willr_14_15m < -75) | (stochrsi_k_4h < 65))
            # 5m momentum rising, high in its range and 4h money drained
            & ((rsi_14_change_pct < -2.0) | (willr_14 < -75) | (mfi_14_4h > 20))
            # 5m the last 24h fell hard, momentum falling and 4h stochastic high
            & ((roc_288 > -11) | (rsi_14_change_pct > -30) | (stochrsi_k_4h < 25))
            # 4h no recent low, daily falling and 5m momentum falling
            & ((rsi_14_change_pct > -20) | (aroond_14_4h > 50) | (roc_2_1d > -8))
            # 4h stochastic high, 5m momentum falling and daily falling
            & ((rsi_14_change_pct > -30) | (stochrsi_k_4h < 70) | (roc_2_1d > -4.5))
            # 15m oscillator falling, 5m momentum rising and daily money drained
            & ((rsi_14_change_pct < -5) | (uo_7_14_28_change_pct_15m > -20) | (mfi_14_1d > 35))
            # 15m money flowing in, 5m momentum falling and 4h not falling
            & ((rsi_14_change_pct > -30) | (mfi_14_15m < 40) | (roc_9_4h < -1.5))
            # 1h not falling, 5m oversold and the coil's roof low
            & ((roc_2_1h < 0.0) | (rsi_20 > 20) | (quad_s93_max_12 > 65))
            # 1h momentum collapsing, 5m not oversold and cycle falling
            & ((rsi_3_change_pct_1h > -65.0) | (rsi_20 < 35) | (cci_20_change_pct_1h > 10.0))
            # 1h stochastic high, 5m oversold and 4h at an extreme low
            & ((stochrsi_k_1h < 75) | (rsi_20 > 20) | (cci_20_4h > -160.0))
            # 1h momentum dead, 5m tightly squeezed and not oversold
            & ((rsi_20 < 35) | (sqz_cnt_24 < 12) | (rsi_3_1h > 5))
            # 1h momentum snapping up, 5m stochastic high and a new high
            & ((aroonu_14 < 45) | (stochrsi_k < 60) | (rsi_3_change_pct_1h < 90))
            # 15m oscillator lifting, 4h stochastic turning up and 5m stochastic at the floor
            & ((uo_7_14_28_change_pct_15m < 10.0) | (stochrsi_k_change_pct_4h < 65.0) | (stochrsi_k > 15))
            # 4h momentum rising, 5m tightly squeezed and stochastic high
            & ((sqz_cnt_24 < 10) | (stochrsi_k < 25) | (rsi_14_change_pct_4h < 5))
            # 5m fast stochastic high, stochastic high and 15m stochastic high
            & ((stoch_4_4 < 25) | (stochrsi_k < 55) | (stochrsi_k_15m < 60))
            # 5m stochastic high, 15m money leaving and 1h not extended
            & ((stochrsi_k < 35) | (cmf_20_15m > -0.2) | (cci_20_1h < -65))
            # 1h oscillator high, daily oversold and 5m stochastic high
            & ((stochrsi_k < 20) | (uo_7_14_28_1h < 50) | (rsi_14_1d > 35))
            # daily falling, 5m stochastic high and 1h no new high
            & ((stochrsi_k < 65) | (aroonu_14_1h > 5) | (roc_9_1d > -30))
            # 1h money flowing in, 5m stochastic high and 15m money leaving
            & ((stochrsi_k < 40) | (cmf_20_15m > -0.25) | (mfi_14_1h < 50))
            # 1h stochastic high, 5m stochastic high and daily stochastic at the floor
            & ((stochrsi_k < 50) | (stochk_14_3_3_1h < 35) | (stochrsi_k_1d > 5))
            # 15m momentum alive, 5m stochastic at the floor and 4h money drained
            & ((rsi_3_15m < 20) | (stochrsi_k > 0) | (mfi_14_4h > 20))
            # 5m a volume spike, stochastic high and daily a recent low
            & ((vol_rel < 15) | (stochrsi_k < 50) | (aroond_14_1d < 90))
            # 5m falling and daily at the floor of its range
            & ((roc_9 > -4) | (stochrsi_k_lt_20) | (willr_14_1d > -90))
            # daily stochastic high, not falling and 5m stochastic high
            & ((stoch_14_3 < 15) | (roc_2_1d < 2) | (stochk_14_3_3_1d < 50))
            # 15m not down, 5m fast stochastic high and daily a recent low
            & ((change_pct_15m < 0.0) | (stoch_4_4 < 40) | (aroond_14_1d < 45))
            # 5m fast stochastic at the floor, the coil's floor lifted and daily no upper wick
            & ((stoch_4_4 > 10) | (quad_s93_min_12 < 15) | (top_wick_pct_1d > 1.0))
            # 5m fast stochastic at the floor, the coil's floor lifted and 4h a recent low
            & ((stoch_4_4 > 5) | (quad_s93_min_12 < 15) | (aroond_14_4h < 90))
            # daily stochastic high, 5m fast stochastic high and money drained
            & ((stoch_4_4 < 35) | (mfi_14_1d > 40) | (stochrsi_k_1d < 80))
            # 1h stochastic at the floor, 5m long cycle high and no recent low
            & ((stochrsi_k_1h > 0) | (stoch_60_10 < 20) | (aroond_14_1h > 75))
            # 4h momentum snapping up, 5m stochastic high and no trend established
            & ((stoch_9_3 < 25) | (adx_14_4h > 20) | (rsi_3_change_pct_4h < 45))
            # 4h a long upper wick, 5m stochastic high and 1h at an extreme low
            & ((stoch_9_3 < 20) | (cci_20_1h > -185) | (top_wick_pct_4h < 2.5))
            # 15m money drained, daily at the floor of its range and 5m stochastic high
            & ((stoch_9_3 < 20) | (mfi_14_15m > 10) | (willr_14_1d > -95))
            # 4h momentum dead, 5m stochastic at the floor and 1h the two-day window off its floor
            & ((stoch_9_3 > 5) | (willr_84_1h < -85) | (rsi_3_4h > 5))
            # a 7-day low broken on drained 5m money while the two days above it rose and the daily sits mid-range
            & ((mfi_14 > 20) | (roc_2_1d < 2) | (willr_14_1d < -60))
            # 1h money flowing in, 5m money flowing in and cycle turning up
            & ((mfi_14_1h < 50) | (mfi_14 < 35) | (cci_20_change_pct_1h < 25.0))
            # 1h money flowing in, 5m money flowing in and cycle turning up
            & ((mfi_14_1h < 50) | (mfi_14 < 40) | (cci_20_change_pct_1h < -0.3))
            # 1h money draining and the 5m washed out, but the 15m is not making fresh lows
            & ((mfi_14 > 30) | (willr_14_15m < -95) | (cmf_20_1h > -0.3))
            # 4h at an extreme low, 5m money flowing in and downtrend weak
            & ((mfi_14 < 45) | (cci_20_4h > -230) | (minus_di_14_4h > 30))
            # 5m money flowing in, the two-day window off its floor and daily a recent low
            & ((mfi_14 < 45) | (willr_480 < -90) | (aroond_14_1d < 65))
            # 5m the last 24h fell hard, money drained and 1h high in its range
            & ((mfi_14 > 15) | (roc_288 > -23) | (willr_14_1h < -90))
            # 15m stochastic at the floor, 5m money flowing in and 4h no trend established
            & ((mfi_14 < 40) | (stochrsi_k_15m > 5) | (adx_14_4h > 25))
            # 1h momentum alive, 5m money flowing in and daily no recent low
            & ((mfi_14 < 40) | (rsi_3_1h < 40) | (aroond_14_1d > 5))
            # 5m money flowing in, 15m money flowing in and stochastic high
            & ((cmf_20 < 0) | (mfi_14_15m < 45) | (stochrsi_k_15m < 60))
            # 5m money flowing in, the coil's roof low and 1h falling
            & ((cmf_20 < 0.05) | (quad_s93_max_12 > 45) | (roc_2_1h > -2))
            # 4h stochastic high, daily not falling and 5m money leaving
            & ((cmf_20 > -0.3) | (stochrsi_k_4h < 70) | (roc_9_1d < 0))
            # 4h a new high, 5m money flowing in and daily stochastic high
            & ((cmf_20 < 0) | (aroonu_14_4h < 50) | (stochrsi_k_1d < 10))
            # 15m stochastic high, 5m money leaving and 4h stochastic at the floor
            & ((cmf_20 > -0.45) | (stochrsi_k_15m < 25) | (stochrsi_k_4h > 5))
            # 15m momentum collapsing, 5m money flowing in and 1h no recent low
            & ((rsi_3_change_pct_15m > -75.0) | (cmf_20 < 0.05) | (aroond_14_1h > 80))
            # daily oversold, 5m volume flow rising and 4h momentum falling
            & ((rsi_14_1d > 35) | (obv_change_pct < 3.5) | (rsi_14_change_pct_4h > -15.0))
            # 4h stochastic high, 5m volume flow falling and a trend established
            & ((stochrsi_k_4h < 65) | (obv_change_pct > -1.0) | (adx_14_4h < 30))
            # 5m no recent low, 4h money drained and oscillator high
            & ((aroond_14 > 75) | (mfi_14_4h > 30) | (uo_7_14_28_4h < 50))
            # daily a long upper wick, 5m no recent low and 1h money leaving
            & ((top_wick_pct_1d < 4.0) | (aroond_14 > 45) | (cmf_20_1h > -0.2))
            # 15m oscillator lifting, 5m no recent low and 1h down
            & ((uo_7_14_28_change_pct_15m < 10.0) | (aroond_14 > 60) | (change_pct_1h > -2.0))
            # 5m a new high, the coil's roof low and 4h no new high
            & ((aroonu_14 < 15) | (quad_s93_max_12 > 35) | (aroonu_14_4h > 5))
            # 15m money flowing in, daily falling and 5m a new high
            & ((aroonu_14 < 40) | (cmf_20_15m < 0.05) | (roc_2_1d > -8))
            # 1h money flowing in, 5m high in its range and 4h no new high
            & ((willr_14 < -70) | (cmf_20_1h < 0.1) | (aroonu_14_4h > 5))
            # 5m the two-day window off its floor and 1h money flowing in
            & ((willr_480 < -90) | (cmf_20_1h < 0.15))
            # a vertical ten-minute drop while the 4h high is over a day old
            & ((roc_2 > -5.0) | (aroonu_14_4h > 40.0))
            # 15m cycle turning up, 5m the last 24h fell hard and daily not falling
            & ((cci_20_change_pct_15m < 170.0) | (roc_288 > -13.0) | (roc_9_1d < -6.0))
            # 15m down, 5m the last 24h is flat and 4h a trend established
            & ((change_pct_15m > -2.0) | (roc_288 < -2.0) | (adx_14_4h < 30))
            # the nine-day trend is still up while the last 24h flushed hard
            & ((roc_288 > -15.0) | (roc_9_1d < 0.0))
            # 4h at an extreme low, daily money drained and 5m the last 24h fell hard
            & ((roc_288 > -10) | (cci_20_4h > -205) | (mfi_14_1d > 20))
            # 1h momentum alive, 5m the last 24h fell hard and 4h no trend established
            & ((rsi_3_1h < 45) | (roc_288 > -14.0) | (adx_14_4h > 25.0))
            # 4h stochastic falling, 5m the last 24h is flat and no trend established
            & ((stochrsi_k_change_pct_4h > -100.0) | (roc_288 < -3.0) | (adx_14_4h > 20))
            # 1h down, 5m not falling and a new high
            & ((roc_9 < -1.5) | (aroonu_14_1h < 45) | (change_pct_1h > -4.5))
            # 15m no new high, 4h momentum rising and 5m not falling
            & ((roc_9 < -0.95) | (aroonu_14_15m > 5) | (rsi_14_change_pct_4h < 5))
            # 15m at an extreme low, 5m not falling and 1h at an extreme low
            & ((roc_9 < -1.5) | (cci_20_15m > -340) | (cci_20_1h > -145))
            # 15m money drained, 5m falling and 1h momentum rising
            & ((roc_9 > -5.5) | (mfi_14_15m > 5) | (rsi_14_change_pct_1h < -15))
            # 5m not falling, 15m momentum dead and 1h momentum snapping up
            & ((roc_9 < -2.5) | (rsi_3_15m > 10) | (rsi_3_change_pct_1h < 80))
            # 1h down, 5m not falling and tightly squeezed
            & ((change_pct_1h > -3.0) | (roc_9 < -1.5) | (sqz_cnt_24 < 9))
            # 1h stochastic at the floor, oscillator high and 5m not falling
            & ((stochrsi_k_1h > 0) | (uo_7_14_28_1h < 45) | (roc_9 < -0.65))
            # 4h stochastic turning up, 5m not falling and daily a recent low
            & ((stochrsi_k_change_pct_4h < 40.0) | (roc_9 < -0.5) | (aroond_14_1d < 80))
            # daily a long lower wick, 5m a volume spike and 4h no recent low
            & ((bot_wick_pct_1d < 4.5) | (vol_rel < 15) | (aroond_14_4h > 40))
            # daily down, 5m a volume spike and money leaving
            & ((change_pct_1d > -9.0) | (vol_rel < 8.0) | (cmf_20_1d > -0.1))
            # 4h momentum collapsing, 5m quiet volume and a trend established
            & ((rsi_3_change_pct_4h > -75.0) | (vol_rel > 1.0) | (adx_14_4h < 25))
            # 5m a volume spike and 4h a trend established
            & ((vol_rel < 10) | (adx_14_4h < 50))
            # 5m quiet volume, a bear regime and 4h cycle turning up
            & ((vol_rel > 1.0) | (mrb_bear < 0.9) | (cci_20_change_pct_4h < 175.0))
            # 4h momentum dead, 5m a volume spike and money flowing in
            & ((vol_rel < 12) | (mfi_14_4h < 30) | (rsi_3_4h > 5))
            # 5m tightly squeezed, the coil's floor lifted and 1h at the floor of its range
            & ((quad_s93_min_12 < 10) | (sqz_cnt_24 < 15) | (willr_14_1h > -90))
            # 4h falling, 5m tightly squeezed and 1h money leaving
            & ((sqz_cnt_24 < 15) | (cmf_20_1h > -0.2) | (roc_2_4h > -7))
            # daily a long lower wick, 5m tightly squeezed and at the floor of its range
            & ((sqz_cnt_24 < 16) | (bot_wick_pct_1d < 3) | (willr_14_1d > -85))
            # daily momentum snapping up, 5m tightly squeezed and stochastic at the floor
            & ((sqz_cnt_24 < 15) | (rsi_3_change_pct_1d < 35) | (stochrsi_k_1d > 5))
            # 4h stochastic high, daily not oversold and 5m tightly squeezed
            & ((sqz_cnt_24 < 10) | (stochrsi_k_4h < 50) | (rsi_14_1d < 55))
            # 15m no new high, 4h money drained and 5m tightly squeezed
            & ((sqz_cnt_24 < 10) | (aroonu_14_15m > 20) | (mfi_14_4h > 15))
            # 1h cycle falling, 5m tightly squeezed and money drained
            & ((cci_20_change_pct_1h > -25.0) | (sqz_cnt_24 < 16) | (mfi_14_1h > 30))
            # 1h momentum collapsing, 5m tightly squeezed and 4h cycle turning up
            & ((rsi_3_change_pct_1h > -70.0) | (sqz_cnt_24 < 17) | (cci_20_change_pct_4h < 95.0))
            # 4h stochastic turning up, 5m tightly squeezed and stochastic high
            & ((stochrsi_k_change_pct_4h < 65.0) | (sqz_cnt_24 < 13) | (stochrsi_k_4h < 25))
            # 15m oscillator low, 5m tightly squeezed and daily no lower wick
            & ((uo_7_14_28_15m > 30) | (sqz_cnt_24 < 16) | (bot_wick_pct_1d > 0.4))
            # 1h not down, daily not down and 5m tightly squeezed
            & ((change_pct_1h < 0.0) | (change_pct_1d < 2.0) | (sqz_cnt_24 < 15))
            # 1h stochastic at the floor, 5m the coil's roof low and daily money flowing in
            & ((quad_s93_max_12 > 35) | (stochk_14_3_3_1h > 10) | (mfi_14_1d < 60))
            # 15m money drained, 5m the coil's roof lifted and daily at the floor of its range
            & ((quad_s93_max_12 < 85) | (mfi_14_15m > 10) | (willr_14_1d > -90))
            # 15m momentum alive, 5m the coil's roof low and daily no recent low
            & ((quad_s93_max_12 > 55) | (rsi_3_15m < 35) | (aroond_14_1d > 45))
            # 15m no recent low, 5m the coil's roof low and 1h falling
            & ((quad_s93_max_12 > 55) | (aroond_14_15m > 55) | (roc_9_1h > -6.5))
            # 4h a long upper wick, 5m the coil's roof low and a new high
            & ((quad_s93_max_12 > 25) | (aroonu_14_4h < 45) | (top_wick_pct_4h < 1.5))
            # 5m the coil's roof low, 1h oversold and 15m momentum falling
            & ((quad_s93_max_12 > 60) | (rsi_14_change_pct_15m > -20) | (rsi_14_1h > 20))
            # 4h a long upper wick, 5m the coil's roof low and daily money flowing in
            & ((quad_s93_max_12 > 25) | (top_wick_pct_4h < 1.5) | (cmf_20_1d < 0.05))
            # 4h oversold, 5m the coil's roof low and daily no upper wick
            & ((quad_s93_max_12 > 35) | (rsi_14_4h > 25) | (top_wick_pct_1d > 0.6))
            # 15m money flowing in, 4h a trend established and 5m the coil's roof low
            & ((cmf_20_15m < 0.05) | (adx_14_4h < 45) | (quad_s93_max_12 > 65))
            # 4h money drained, 5m the coil's roof low and 15m not extended
            & ((mfi_14_4h > 20) | (quad_s93_max_12 > 25) | (cci_20_15m < -170.0))
            # 1h the two-day window off its floor, 5m the coil's roof lifted and 4h no trend established
            & ((willr_84_1h < -75) | (quad_s93_max_12 < 100) | (adx_14_4h > 15))
            # 5m the coil's floor lifted, 15m stochastic at the floor and daily money drained
            & ((quad_s93_min_12 < 10) | (stochrsi_k_15m > 10) | (mfi_14_1d > 25))
            # 4h falling, 5m the coil's floor lifted and 15m money drained
            & ((quad_s93_min_12 < 10) | (mfi_14_15m > 20) | (roc_9_4h > -8))
            # 1h no new high, 5m the coil's floor lifted and stochastic high
            & ((quad_s93_min_12 < 5) | (aroonu_14_1h > 10) | (stochk_14_3_3_1h < 35))
            # 4h not down, 5m the coil's floor lifted and daily at the floor of its range
            & ((quad_s93_min_12 < 10) | (change_pct_4h < 0) | (willr_14_1d > -85))
            # daily a long lower wick, 5m the coil's floor lifted and 4h momentum falling
            & ((bot_wick_pct_1d < 4.0) | (quad_s93_min_12 < 10) | (rsi_14_change_pct_4h > -15.0))
            # 4h money leaving, 5m the coil's floor lifted and 1h a new high
            & ((cmf_20_4h > -0.2) | (quad_s93_min_12 < 15) | (aroonu_14_1h < 15))
            # 1h stochastic high, 5m the coil's floor lifted and 4h a trend established
            & ((stochk_14_3_3_1h < 45) | (quad_s93_min_12 < 15) | (adx_14_4h < 20))
            # 4h falling, 5m no pre-break coil and cycle turning up
            & ((roc_9_4h > -12.0) | (ph_pre_tight > 2.0) | (cci_20_change_pct_4h < 20.0))
            # 4h money leaving, momentum falling and 15m momentum alive
            & ((cmf_20_4h > -0.25) | (rsi_14_change_pct_4h > -20.0) | (rsi_3_15m < 25))
            # 4h not falling, stochastic falling and 15m momentum alive
            & ((roc_9_4h < -2.0) | (stochrsi_k_change_pct_4h > -70.0) | (rsi_3_15m < 30))
            # 15m momentum alive, 1h cycle turning up and 4h at an extreme low
            & ((rsi_3_15m < 25) | (cci_20_change_pct_1h < 255.0) | (cci_20_4h > -125.0))
            # 15m momentum alive, 1h at an extreme low and 4h a new high
            & ((rsi_3_15m < 35) | (cci_20_1h > -240.0) | (aroonu_14_4h < 15))
            # 15m momentum dead, no recent low and 1h cycle turning up
            & ((rsi_3_15m > 5) | (aroond_14_15m > 80) | (cci_20_change_pct_1h < 120.0))
            # 15m at an extreme low, momentum alive and 4h stochastic at the floor
            & ((cci_20_15m > -195) | (rsi_3_15m < 25) | (stochrsi_k_4h > 15))
            # 4h momentum falling, daily a long upper wick and 15m momentum alive
            & ((rsi_3_15m < 5) | (rsi_14_change_pct_4h > -25) | (top_wick_pct_1d < 3))
            # 15m momentum alive, 1h money flowing in and 4h money flowing in
            & ((rsi_3_15m < 35) | (cmf_20_1h < 0.05) | (cmf_20_4h < 0.05))
            # 15m momentum snapping up, 4h no upward push and not falling
            & ((rsi_3_change_pct_15m < -40.0) | (plus_di_14_4h > 5) | (roc_2_4h < -1.5))
            # 15m momentum snapping up, a new high and 4h falling
            & ((aroonu_14_15m < 45) | (rsi_3_change_pct_15m < 50) | (roc_2_4h > -2))
            # 15m not oversold, 4h cycle turning up and downtrend weak
            & ((rsi_14_15m < 35) | (cci_20_change_pct_4h < 180.0) | (minus_di_14_4h > 25))
            # 15m not oversold, 4h downtrend set and daily momentum snapping up
            & ((rsi_14_15m < 35) | (minus_di_14_4h < 40) | (rsi_3_change_pct_1d < -25.0))
            # 15m oversold, 1h oscillator high and a new high
            & ((rsi_14_15m > 25) | (uo_7_14_28_1h < 55) | (aroonu_14_1h < 65))
            # 15m momentum falling, money flowing in and 4h stochastic high
            & ((cmf_20_15m < -0.05) | (rsi_14_change_pct_15m > -35) | (stochrsi_k_4h < 50))
            # 15m momentum falling, money flowing in and 1h a new high
            & ((cmf_20_15m < 0.05) | (rsi_14_change_pct_15m > -25) | (aroonu_14_1h < 30))
            # 1h stochastic high, 4h momentum falling and 15m momentum falling
            & ((rsi_14_change_pct_15m > -25) | (stochk_14_3_3_1h < 35) | (rsi_14_change_pct_4h > -22))
            # 15m stochastic high, 4h not oversold and daily a recent low
            & ((stochrsi_k_15m < 50) | (rsi_14_4h < 45) | (aroond_14_1d < 40))
            # 15m stochastic high, 4h not falling and money drained
            & ((stochrsi_k_15m < 65) | (roc_9_4h < -1.0) | (mfi_14_4h > 30))
            # 15m stochastic high, daily oversold and 4h at an extreme low
            & ((stochrsi_k_15m < 65) | (rsi_14_1d > 30) | (cci_20_4h > -195.0))
            # 15m stochastic high, 1h momentum collapsing and at an extreme low
            & ((stochrsi_k_15m < 70) | (rsi_3_change_pct_1h > -40.0) | (cci_20_15m > -135.0))
            # 4h stochastic turning up, a long upper wick and 15m stochastic high
            & ((stochrsi_k_change_pct_4h < 40.0) | (top_wick_pct_4h < 2.0) | (stochrsi_k_15m < 10))
            # 15m no recent low, stochastic at the floor and daily stochastic high
            & ((aroond_14_15m > 45) | (stochrsi_k_15m > 15) | (stochrsi_k_1d < 20))
            # 15m stochastic high, daily a long upper wick and 4h no trend established
            & ((stochrsi_k_15m < 65) | (adx_14_4h > 30) | (top_wick_pct_1d < 6))
            # 15m stochastic high, 1h oversold and 4h stochastic high
            & ((stochrsi_k_15m < 65) | (rsi_14_1h > 20) | (stochrsi_k_4h < 20))
            # 15m money flowing in, daily a long lower wick and stochastic high
            & ((cmf_20_15m < 0.05) | (bot_wick_pct_1d < 3.5) | (stochk_14_3_3_15m < 45))
            # 15m stochastic high, daily down and no upper wick
            & ((stochk_14_3_3_15m < 40) | (change_pct_1d > -9.0) | (top_wick_pct_1d > 0.15))
            # 15m stochastic high, 4h momentum alive and a recent low
            & ((stochk_14_3_3_15m < 40) | (rsi_3_4h < 40) | (aroond_14_4h < 95))
            # 15m stochastic high, 1h oscillator low and 4h at an extreme low
            & ((stochk_14_3_3_15m < 40) | (uo_7_14_28_1h > 35) | (cci_20_4h > -250.0))
            # 15m stochastic at the floor, oscillator high and 4h no trend established
            & ((stochk_14_3_3_15m > 10) | (uo_7_14_28_15m < 50) | (adx_14_4h > 15))
            # 15m stochastic at the floor and daily a long lower wick
            & ((stochk_14_3_3_15m > 5) | (bot_wick_pct_1d < 6.0))
            # daily money leaving, high in its range and 15m money flowing in
            & ((cmf_20_1d > -0.1) | (willr_14_1d < -45) | (mfi_14_15m < 40))
            # 15m money still flowing while the 4h is drained and its downtrend set
            & ((mfi_14_15m < 25) | (cmf_20_4h > -0.2) | (minus_di_14_4h < 30))
            # 15m money flowing in, 4h cycle turning up and money flowing in
            & ((mfi_14_15m < 45) | (cci_20_change_pct_4h < 95.0) | (cmf_20_4h < 0.05))
            # 15m money drained, 4h downtrend set and high in its range
            & ((mfi_14_15m > 10) | (minus_di_14_4h < 40) | (willr_14_4h < -80))
            # 15m money drained, 4h money flowing in and no trend established
            & ((mfi_14_15m > 5) | (cmf_20_4h < 0.1) | (adx_14_4h > 20))
            # 15m money drained, 4h oscillator low and stochastic high
            & ((mfi_14_15m > 5) | (uo_7_14_28_4h > 35) | (stochrsi_k_4h < 15))
            # 15m money out and the 4h downtrend set, but the 15m has already lifted off the floor
            & ((cmf_20_15m > -0.3) | (mfi_14_15m < 15) | (minus_di_14_4h < 30))
            # the 15m has stopped making new lows and money is still flowing into it, and the 5m breaks a 7-day low anyway
            & ((aroond_14_15m > 50) | (mfi_14_15m < 40))
            # 15m money flowing in, 4h stochastic high and daily no recent low
            & ((mfi_14_15m < 35) | (stochk_14_3_3_4h < 40) | (aroond_14_1d > 5))
            # 15m money flowing in and daily a long lower wick
            & ((cmf_20_15m < 0.1) | (bot_wick_pct_1d < 3.5))
            # money is leaving on the 15m while the 4h is mid-range and has made no new low — a liquidity flush, not a breakdown
            & ((cmf_20_15m > -0.3) | (aroond_14_4h > 35) | (willr_14_4h < -60))
            # 4h stochastic falling, momentum falling and 15m money leaving
            & ((stochrsi_k_change_pct_4h > -100.0) | (rsi_14_change_pct_4h > -15.0) | (cmf_20_15m > -0.2))
            # 15m money flowing in, daily falling and 1h money flowing in
            & ((cmf_20_15m < -0.05) | (cmf_20_1h < 0) | (roc_2_1d > -13))
            # 1h a new high, 15m money flowing in and daily a long upper wick
            & ((cmf_20_15m < 0.1) | (aroonu_14_1h < 10) | (top_wick_pct_1d < 2))
            # 15m oscillator high, daily money leaving and 4h not extended
            & ((uo_7_14_28_15m < 50) | (cmf_20_1d > -0.2) | (cci_20_4h < -160.0))
            # 15m oscillator low, daily a long upper wick and 4h stochastic at the floor
            & ((uo_7_14_28_15m > 30) | (stochk_14_3_3_4h > 20) | (top_wick_pct_1d < 4))
            # daily no new high, 4h momentum snapping up and 15m oscillator high
            & ((uo_7_14_28_15m < 50) | (rsi_3_change_pct_4h < -20) | (aroonu_14_1d > 20))
            # 15m oscillator high, 4h not falling and a recent low
            & ((uo_7_14_28_15m < 50) | (aroond_14_4h < 90) | (roc_9_4h < -2))
            # 15m oscillator high, 1h stochastic high and daily no new high
            & ((uo_7_14_28_15m < 50) | (stochk_14_3_3_1h < 40) | (aroonu_14_1d > 5))
            # 15m oscillator lifting, 1h no recent low and daily a recent low
            & ((uo_7_14_28_change_pct_15m < 10.0) | (aroond_14_1h > 15) | (aroond_14_1d < 25))
            # 15m oscillator lifting, daily falling and 4h stochastic falling
            & ((uo_7_14_28_change_pct_15m < 10.0) | (roc_9_1d > -20.0) | (stochrsi_k_change_pct_4h > -45.0))
            # 15m oscillator lifting, 1h not down and 4h a recent low
            & ((uo_7_14_28_change_pct_15m < 10) | (change_pct_1h < 0) | (aroond_14_4h < 95))
            # 15m oscillator lifting, 4h money leaving and 1h falling
            & ((uo_7_14_28_change_pct_15m < 5) | (roc_2_1h > -5) | (cmf_20_4h > -0.25))
            # 15m at an extreme low, 4h oversold and 1h no recent low
            & ((cci_20_15m > -310.0) | (rsi_14_4h > 25) | (aroond_14_1h > 75))
            # 15m at an extreme low, 4h falling and 1h not falling
            & ((cci_20_15m > -290) | (roc_2_1h < -2.5) | (roc_2_4h > -7))
            # 4h oscillator low, daily not falling and 15m no recent low
            & ((uo_7_14_28_4h > 35) | (roc_2_1d < 1.0) | (aroond_14_15m > 60))
            # 15m a new high, no recent low and daily money flowing in
            & ((aroond_14_15m > 75) | (aroonu_14_15m < 45) | (cmf_20_1d < 0.15))
            # the daily is being bought and has not made a low in two weeks, and the 15m just printed a fresh high
            & ((aroonu_14_15m < 45) | (aroond_14_1d > 25) | (mfi_14_1d < 65))
            # 1h at an extreme low, 4h momentum dead and 15m a new high
            & ((cci_20_1h > -225.0) | (rsi_3_4h > 5) | (aroonu_14_15m < 40))
            # 15m a new high, daily money drained and stochastic high
            & ((aroonu_14_15m < 45) | (mfi_14_1d > 45) | (stochrsi_k_1d < 80))
            # 15m a new high, daily momentum snapping up and 4h not falling
            & ((aroonu_14_15m < 65) | (roc_2_4h < -1) | (rsi_3_change_pct_1d < 40))
            # 15m a new high, daily momentum snapping up and 1h not falling
            & ((aroonu_14_15m < 65) | (roc_9_1h < -1.5) | (rsi_3_change_pct_1d < 15))
            # 15m a new high, falling and 1h money flowing in
            & ((aroonu_14_15m < 45) | (roc_9_15m > -7) | (cmf_20_1h < -0.15))
            # 15m high in its range, 4h stochastic at the floor and no trend established
            & ((willr_14_15m < -75) | (stochk_14_3_3_4h > 5) | (adx_14_4h > 15))
            # 15m high in its range, 4h stochastic high and 1h money leaving
            & ((willr_14_15m < -70) | (cmf_20_1h > -0.15) | (stochrsi_k_4h < 65))
            # 1h no recent low, oscillator low and 15m not falling
            & ((aroond_14_1h > 35) | (uo_7_14_28_1h > 35) | (roc_9_15m < -2.0))
            # 15m not falling, 1h high in its range and daily a long upper wick
            & ((roc_9_15m < -1) | (willr_14_1h < -70) | (top_wick_pct_1d < 3.5))
            # 1h a new high, 4h money leaving and 15m falling
            & ((roc_9_15m > -6) | (aroonu_14_1h < 60) | (cmf_20_4h > -0.1))
            # 1h a new high, daily money leaving and 15m falling
            & ((roc_9_15m > -3) | (aroonu_14_1h < 50) | (cmf_20_1d > -0.2))
            # 15m not down, 1h oversold and daily no new high
            & ((change_pct_15m < 0.0) | (rsi_14_1h > 20) | (aroonu_14_1d > 10))
            # the hour has turned up hard — momentum, its rate of change and the oscillator all lifted — and the 5m sells the 7-day low into it
            & ((rsi_3_1h < 25) | (rsi_3_change_pct_1h < 65) | (stochrsi_k_1h < 45))
            # 1h momentum alive, momentum collapsing and 4h no trend established
            & ((rsi_3_1h < 30) | (rsi_3_change_pct_1h > -55.0) | (adx_14_4h > 25))
            # momentum has exploded upward on the hour and the day at once, and the 5m sells the 7-day low into the bounce
            & ((rsi_3_change_pct_1h < 200) | (rsi_3_change_pct_1d < 300))
            # 1h momentum collapsing, 4h at an extreme low and stochastic high
            & ((rsi_3_change_pct_1h > -65.0) | (cci_20_4h > -250.0) | (stochrsi_k_1h < 25))
            # 1h not oversold, 4h momentum dead and a trend established
            & ((rsi_14_1h < 40) | (rsi_3_4h > 10) | (adx_14_4h < 40))
            # 1h not oversold, money leaving and a new high
            & ((aroonu_14_1h < 15) | (cmf_20_1h > -0.2) | (rsi_14_1h < 35))
            # 1h oversold, daily high in its range and at an extreme low
            & ((cci_20_1h > -300) | (rsi_14_1h > 20) | (willr_14_1d < -30))
            # 1h no new high, 4h falling and momentum rising
            & ((aroonu_14_1h > 10) | (rsi_14_change_pct_1h < 5) | (roc_2_4h > -8))
            # 1h stochastic high, 4h downtrend weak and stochastic at the floor
            & ((stochrsi_k_1h < 60) | (minus_di_14_4h > 20) | (stochk_14_3_3_1h > 40))
            # 1h stochastic at the floor, 4h falling and no upper wick
            & ((stochrsi_k_1h > 0) | (roc_9_4h > -10.0) | (top_wick_pct_4h > 0.05))
            # 1h stochastic high, 4h no recent low and oversold
            & ((stochrsi_k_1h < 35) | (aroond_14_4h > 45) | (rsi_14_4h > 30))
            # daily money drained, a new high and 1h stochastic at the floor
            & ((stochrsi_k_1h > 15) | (aroonu_14_1d < 55) | (mfi_14_1d > 30))
            # 1h stochastic high, 4h stochastic high and a trend established
            & ((stochk_14_3_3_1h < 50) | (stochrsi_k_4h < 65) | (adx_14_4h < 20))
            # 4h a trend established, money leaving and 1h stochastic high
            & ((stochk_14_3_3_1h < 20) | (adx_14_4h < 45) | (cmf_20_4h > -0.2))
            # 1h stochastic high, 4h a trend established and daily oversold
            & ((stochk_14_3_3_1h < 50) | (adx_14_4h < 35) | (rsi_14_1d > 35))
            # 1h money flowing in, 4h stochastic at the floor and a trend established
            & ((mfi_14_1h < 50) | (stochrsi_k_4h > 5) | (adx_14_4h < 40))
            # 1h money drained, 4h a trend established and stochastic falling
            & ((mfi_14_1h > 10) | (adx_14_4h < 40) | (stochrsi_k_change_pct_4h > -45.0))
            # 1h money exhausted after a two-day drop
            & ((mfi_14_1h > 25.0) | (roc_2_1d > -7.0))
            # 1h money drained, daily momentum dead and at an extreme low
            & ((cci_20_1h > -250) | (mfi_14_1h > 15) | (rsi_3_1d > 20))
            # 1h money flowing in, 4h momentum falling and daily a recent low
            & ((mfi_14_1h < 50) | (rsi_14_change_pct_4h > -25) | (aroond_14_1d < 30))
            # 1h money leaving, daily oversold and 4h a new high
            & ((cmf_20_1h > -0.3) | (rsi_14_1d > 30) | (aroonu_14_4h < 25))
            # daily stochastic high, falling and 1h money leaving
            & ((stochrsi_k_1d < 50) | (roc_9_1d > -17.0) | (cmf_20_1h > -0.2))
            # 4h stochastic at the floor, momentum falling and 1h money leaving
            & ((stochrsi_k_4h > 0) | (rsi_14_change_pct_4h > -20.0) | (cmf_20_1h > -0.35))
            # 1h no recent low, 4h no trend established and money leaving
            & ((aroond_14_1h > 15) | (adx_14_4h > 15) | (cmf_20_1h > -0.05))
            # 1h money flowing in, 4h a trend established and daily a new high
            & ((cmf_20_1h < 0.15) | (adx_14_4h < 40) | (aroonu_14_1d < 40))
            # 1h money leaving, daily a long lower wick and 4h stochastic high
            & ((cmf_20_1h > -0.25) | (stochrsi_k_4h < 55) | (bot_wick_pct_1d < 4))
            # 1h oscillator high, daily no recent low and 4h money flowing in
            & ((uo_7_14_28_1h < 55) | (cmf_20_4h < -0.05) | (aroond_14_1d > 5))
            # 1h oscillator high, daily not falling and 4h stochastic falling
            & ((uo_7_14_28_1h < 50) | (stochrsi_k_change_pct_4h > -60) | (roc_9_1d < 4))
            # 1h at an extreme low, 4h stochastic turning up and daily no recent low
            & ((cci_20_1h > -300.0) | (stochrsi_k_change_pct_4h < 45.0) | (aroond_14_1d > 10))
            # 1h cycle turning up, daily at the floor of its range and 4h no trend established
            & ((cci_20_change_pct_1h < 255.0) | (willr_14_1d > -95) | (adx_14_4h > 15))
            # nothing is making new lows — not the hour, not the day — and the 15m just printed a fresh high, yet the 5m breaks a 7-day low
            & (aroonu_14_15m_lt_50 | (aroond_14_1h > 25) | (aroond_14_1d > 15))
            # 4h momentum falling, daily momentum snapping up and 1h a recent low
            & ((aroond_14_1h < 90) | (rsi_14_change_pct_4h > -25) | (rsi_3_change_pct_1d < 110))
            # 1h no recent low, 4h stochastic high and daily not falling
            & ((aroond_14_1h > 15) | (stochrsi_k_4h < 65) | (roc_9_1d < -10))
            # 4h stochastic high, 1h high in its range and daily down
            & ((willr_14_1h < -95) | (stochrsi_k_4h < 40) | (change_pct_1d > -10))
            # 1h the two-day window off its floor, daily oversold and 4h a trend established
            & ((willr_84_1h < -80) | (rsi_14_1d > 30) | (adx_14_4h < 45))
            # 1h the two-day window off its floor, 4h at the floor of its range and a trend established
            & ((willr_84_1h < -80) | (willr_14_4h > -95) | (adx_14_4h < 30))
            # 1h the two-day window off its floor, 4h a trend established and oversold
            & ((willr_84_1h < -85) | (adx_14_4h < 45) | (rsi_14_4h > 25))
            # 1h falling, 4h no upward push and daily not falling
            & ((roc_9_1h > -6.0) | (plus_di_14_4h > 5.0) | (roc_9_1d < -20.0))
            # 1h down, 4h at an extreme low and daily no recent low
            & ((change_pct_1h > -4.0) | (cci_20_4h > -250.0) | (aroond_14_1d > 20.0))
            # 4h momentum alive, a recent low and daily no new high
            & ((rsi_3_4h < 40) | (aroond_14_4h < 95) | (aroonu_14_1d > 30))
            # 4h momentum alive, daily stochastic at the floor and not falling
            & ((rsi_3_4h < 50) | (stochrsi_k_1d > 5) | (roc_9_1d < -15.0))
            # 4h momentum dead, stochastic turning up and no trend established
            & ((rsi_3_4h > 10) | (stochrsi_k_change_pct_4h < 40.0) | (adx_14_4h > 25))
            # 4h momentum dead, cycle turning up and daily no new high
            & ((rsi_3_4h > 5) | (cci_20_change_pct_4h < 180.0) | (aroonu_14_1d > 10))
            # daily momentum alive, 4h momentum alive and stochastic at the floor
            & ((rsi_3_4h < 30) | (rsi_3_1d < 45) | (stochrsi_k_1d > 50))
            # 4h momentum alive, at the floor of its range and daily no new high
            & ((rsi_3_4h < 25) | (willr_14_4h > -95) | (aroonu_14_1d > 10))
            # the 4h has already snapped up while the day is still washed out
            & ((rsi_3_change_pct_4h < 65) | rsi_3_1d_gt_30)
            # 4h stochastic falling, momentum collapsing and no trend established
            & ((stochrsi_k_change_pct_4h > -70.0) | (rsi_3_change_pct_4h > -75.0) | (adx_14_4h > 30))
            # 4h momentum collapsing, daily a recent low and money leaving
            & ((cmf_20_4h > -0.15) | (rsi_3_change_pct_4h > -75) | (aroond_14_1d < 95))
            # 4h a new high, momentum rising and daily a recent low
            & ((aroonu_14_4h < 80) | (rsi_14_change_pct_4h < 5) | (aroond_14_1d < 30))
            # 4h stochastic high, at an extreme low and a trend established
            & ((stochrsi_k_4h < 65) | (cci_20_4h > -195.0) | (adx_14_4h < 15))
            # the 7-day low breaks while neither the hourly nor the 4h is anywhere near oversold
            & (stochrsi_k_1h_lt_40 | (stochrsi_k_4h < 35))
            # the 4h has already rallied hard — oscillator topped, no new 4h low for days — and the 5m breaks a 7-day low against it
            & ((adx_14_4h < 40) | (aroond_14_4h > 30) | (stochrsi_k_4h < 75))
            # 4h down, stochastic high and daily a new high
            & ((change_pct_4h > -6) | (stochrsi_k_4h < 60) | (aroonu_14_1d < 45))
            # 4h stochastic at the floor, daily money drained and high in its range
            & ((stochrsi_k_4h > 10) | (mfi_14_1d > 30) | (willr_14_1d < -65))
            # daily money flowing in, a long lower wick and 4h stochastic at the floor
            & ((mfi_14_1d < 70) | (bot_wick_pct_1d < 5.0) | (stochk_14_3_3_4h > 20))
            # the 4h stochastic is pinned at the floor and the day is washed out, but the daily stochastic has not followed
            & ((stochk_14_3_3_4h > 15) | rsi_3_1d_gt_30 | (stochk_14_3_3_1d < 35))
            # 4h money drained, daily a long upper wick and momentum alive
            & ((mfi_14_4h > 20) | (top_wick_pct_1d < 4.0) | (rsi_3_1d < 30))
            # the 4h is drained but has printed no new low for days — the decline has stalled, and the 5m sells the 7-day low into the stall
            & ((aroond_14_4h > 20) | (mfi_14_4h > 25))
            # 4h a trend established, money drained and daily a new high
            & ((adx_14_4h < 45) | (mfi_14_4h > 15) | (aroonu_14_1d < 25))
            # 4h money flowing in, at an extreme low and daily falling
            & ((cci_20_4h > -230) | (mfi_14_4h < 45) | (roc_2_1d > -1.5))
            # 4h money flowing in, daily down and no recent low
            & ((cmf_20_4h < 0.1) | (change_pct_1d > -9.0) | (aroond_14_1d > 20.0))
            # daily no recent low, falling and 4h money flowing in
            & ((cmf_20_4h < 0) | (aroond_14_1d > 5) | (roc_9_1d > -19))
            # 4h oscillator high, daily a long upper wick and no recent low
            & ((uo_7_14_28_4h < 55) | (top_wick_pct_1d < 3.0) | (aroond_14_1d > 25))
            # 4h oscillator high, falling and a trend established
            & ((adx_14_4h < 40) | (roc_2_4h > -6) | (uo_7_14_28_4h < 50))
            # daily momentum alive, stochastic at the floor and 4h not extended
            & ((rsi_3_1d < 35) | (stochrsi_k_1d > 5) | (cci_20_4h < -90.0))
            # daily stochastic high, a long lower wick and 4h not extended
            & ((stochrsi_k_1d < 85) | (bot_wick_pct_1d < 5.0) | (cci_20_4h < -250.0))
            # daily money flowing in, momentum snapping up and 4h at an extreme low
            & ((cci_20_4h > -100) | (mfi_14_1d < 55) | (rsi_3_change_pct_1d < 145))
            # 4h at an extreme low, daily money drained and stochastic at the floor
            & ((cci_20_4h > -195) | (mfi_14_1d > 25) | (stochrsi_k_1d > 5))
            # 4h cycle turning up, daily stochastic at the floor and a trend established
            & ((cci_20_change_pct_4h < 150.0) | (stochrsi_k_1d > 0) | (adx_14_4h < 30))
            # 4h not falling, cycle falling and daily a new high
            & ((roc_2_4h < -1.0) | (cci_20_change_pct_4h > -265.0) | (aroonu_14_1d < 5))
            # 4h a new high, a long upper wick and a recent low
            & ((aroond_14_4h < 60) | (aroonu_14_4h < 80) | (top_wick_pct_4h < 2.5))
            # 4h no trend established, daily oversold and a new high
            & ((adx_14_4h > 15) | (aroonu_14_4h < 30) | (rsi_14_1d > 40))
            # daily momentum alive, money drained and 4h at the floor of its range
            & ((willr_14_4h > -90) | (mfi_14_1d > 30) | (rsi_3_1d < 35))
            # daily stochastic high, money leaving and 4h no trend established
            & ((adx_14_4h > 15) | (cmf_20_1d > -0.2) | (stochk_14_3_3_1d < 35))
            # 4h no trend established, daily oversold and falling
            & ((adx_14_4h > 25) | (roc_2_4h > -4) | (rsi_14_1d > 35))
            # daily stochastic at the floor, stochastic high and 4h down
            & ((change_pct_4h > -1) | (stochk_14_3_3_1d > 20) | (stochrsi_k_1d < 60))
            # 4h a long upper wick, daily a long upper wick and momentum alive
            & ((top_wick_pct_4h < 2) | (rsi_3_1d < 45) | (top_wick_pct_1d < 4.5))
            # daily stochastic high, money drained and momentum alive
            & ((mfi_14_1d > 35) | (rsi_3_1d < 40) | (stochrsi_k_1d < 80))
            # daily stochastic high, money drained and momentum alive
            & ((mfi_14_1d > 40) | (rsi_3_1d < 40) | (stochrsi_k_1d < 80))
            # daily money flowing in, at the floor of its range and a new high
            & ((aroonu_14_1d < 75) | (mfi_14_1d < 55) | (willr_14_1d > -90))
            # daily no new high, no recent low and a long lower wick
            & ((aroond_14_1d > 5) | (aroonu_14_1d > 5) | (bot_wick_pct_1d < 3))
          )

          # Logic
          short_entry_logic.append(
            # first close below the prior 7-day low
            (close < open_rate) & (np_shift(close, 1) >= dc_low_7d) & (close < dc_low_7d)
          )

        # Condition #541 - Quick mode (Short).
        if short_entry_condition_index == 541:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          # 5m & 15m down move, 4h still high
          short_entry_logic.append((rsi_3_lt_95) | (rsi_3_change_pct_15m < 50.0) | (rsi_14_4h_gt_50))
          # 5m & 15m & 1h down move
          short_entry_logic.append((rsi_3_lt_95) | (rsi_3_15m_lt_95) | (rsi_3_1h_lt_95))
          # 5m strong down move
          short_entry_logic.append((rsi_3_lt_98) | (roc_9 < 50.0))
          # 15m & 1h strong down move & downtrend
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (mfi_14_1h > 5.0))
          # 15m strong down move, 4h high
          short_entry_logic.append((rsi_3_15m_lt_95) | (stochrsi_k_4h_gt_10))
          # 15m & 1h down move
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (cci_20_change_pct_1h > 0.0))
          # 15m & 1h down move, 4h high
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_30))
          # 15m & 1h down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_change_pct_1h < 50.0) | (mfi_14_4h > 50.0))
          # 15m strong down move, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (mfi_14_15m < 90.0) | (stochrsi_k_1h_gt_50))
          # 15m & 1h down move, 1h not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (stochrsi_k_1h_gt_80))
          # 15m down move, 1h strong down move
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_14_change_pct_1h < 70.0))
          # 15m down move, 4h & 1d downtrend
          short_entry_logic.append((rsi_3_15m_lt_95) | (roc_9_4h_lt_30) | roc_9_1d_lt_50)
          # 15m down move, 1h strong down move, 4h stil high
          short_entry_logic.append((rsi_3_15m_lt_90) | (rsi_3_1h_lt_95) | (stochrsi_k_4h_gt_50))
          # 15m down move, 1h & 4h still high
          short_entry_logic.append((rsi_3_15m_lt_85) | (stochrsi_k_1h_gt_50) | (stochrsi_k_4h_gt_50))
          # 15m down move, 1h downtrend, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (roc_9_1h_lt_20) | (stochrsi_k_4h_gt_50))
          # 15m & 1h down move, 4h high
          short_entry_logic.append((rsi_3_15m_lt_90) | (rsi_3_1h_lt_85) | (stochrsi_k_4h_gt_30))
          # 15m down move, 1h down move, 4h high
          short_entry_logic.append((rsi_3_15m_lt_85) | (rsi_3_change_pct_1h < 30.0) | (stochrsi_k_4h_gt_10))
          # 1m down move, 1h still dropping, 4h overbought
          short_entry_logic.append((rsi_3_15m_lt_90) | (cci_20_change_pct_1h_lt_0) | (rsi_14_4h_gt_20))
          # 15m down move, 1h high
          short_entry_logic.append((rsi_3_change_pct_15m < 70.0) | (stochrsi_k_1h_gt_10))
          # 1h strong down move, 4h high
          short_entry_logic.append((rsi_3_1h_lt_95) | (stochrsi_k_4h_gt_10))
          # 1h down move, 4h downtrend, 4h not low enough
          short_entry_logic.append((rsi_3_1h_lt_95) | (cmf_20_4h_gt_neg_0_25) | (stochrsi_k_4h_gt_70))
          # 1h down move, 4h high, 1d overbought
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_14_4h_gt_40) | roc_9_1d_gt_neg_50)
          # 1h down move, 4h strong down move
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_14_change_pct_4h < 40.0))
          # 1h & 4h down move, 4h still going down
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_4h_lt_95) | (cci_20_change_pct_4h_lt_0))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_change_pct_4h < 65.0) | (stochrsi_k_4h_gt_70))
          # 1h down move, 4h down move, 4h P&D
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_change_pct_4h < 70.0) | (rsi_14_4h_shift_48 > 30.0))
          # 1h & 4h down move, 4h still not low enough, 1d still high
          short_entry_logic.append(
            (rsi_3_1h_lt_90) | (rsi_3_change_pct_4h < 50.0) | (aroond_14_4h_lt_25) | (stochrsi_k_1d_gt_60)
          )
          # 1h down move, 1h still high, 1d going down
          short_entry_logic.append((rsi_3_1h_lt_85) | (stochrsi_k_1h_gt_50) | (roc_2_1d > -50.0))
          # 4h downtrend, 4h still high, 1d strong downtrend
          short_entry_logic.append((rsi_3_4h_lt_85) | (stochrsi_k_4h_gt_70) | (roc_9_1d_lt_60))
          # 15m down move, 1h strong down move, 1d overbought
          short_entry_logic.append((mfi_14_15m < 80.0) | (rsi_3_change_pct_1h < 80.0) | roc_9_1d_gt_neg_50)
          # 1h not low enough, 4h high, 1d strong downtrend
          short_entry_logic.append((stochrsi_k_1h_gt_70) | (stochrsi_k_4h_gt_10) | (roc_9_1d_lt_60))
          # 1h down move, 4h still high, 1d downtrend
          short_entry_logic.append((rsi_3_change_pct_1h < 65.0) | (stochrsi_k_4h_gt_30) | roc_9_1d_lt_50)
          # 15m strong down move, 1h still high
          short_entry_logic.append((roc_9_15m < 15.0) | (stochrsi_k_1h_gt_30))
          # 15m downtrend, 4h down move, 4h stil high
          short_entry_logic.append((roc_9_15m < 15.0) | (rsi_3_4h_lt_75) | (stochrsi_k_4h_gt_30))
          # 1h downtrend, 4h overbought
          short_entry_logic.append((roc_2_1h < 5.0) | (rsi_14_4h_gt_20) | (roc_9_4h_gt_neg_25))
          # 1h P&D, 4h still high
          short_entry_logic.append((roc_2_1h < 10.0) | (roc_9_1h > -5.0) | (stochrsi_k_4h_gt_30))
          # 1h downtrend, 4h down move, 1d downtrend
          short_entry_logic.append((roc_9_1h_lt_40) | (rsi_3_4h_lt_90) | roc_9_1d_lt_50)
          short_entry_logic.append((roc_9_4h > -200.0) | (rsi_14_4h_gt_20))
          # 4h down move, 1d P&D
          short_entry_logic.append((roc_9_4h_lt_20) | (roc_2_1d < 20.0) | roc_9_1d_gt_neg_50)
          # 1h P&D, 4h overbought
          short_entry_logic.append((change_pct_1h < 2.0) | (change_pct_1h_shift_12 > 2.0) | (rsi_14_4h_gt_20))
          # 1h P&D, 1d overbought
          short_entry_logic.append((change_pct_1h < 5.0) | (change_pct_1h_shift_12 > -5.0) | (roc_9_1d_gt_neg_100))
          # 1h & 4h red, 1h not low enough
          short_entry_logic.append((change_pct_1h < 10.0) | (change_pct_4h < 10.0) | (mfi_14_1h > 50.0))
          # 1h red, 1h still not low enough, 1d down move
          short_entry_logic.append((change_pct_1h < 15.0) | (mfi_14_1h > 50.0) | (rsi_3_1d_lt_90))
          # 4h red, previous 4h green, 4h overbought
          short_entry_logic.append(
            (change_pct_4h < 5.0) | (change_pct_4h_shift_48 > -5.0) | (rsi_14_4h_shift_48 > 20.0)
          )
          # 1d P&D, 1d overbought
          short_entry_logic.append((change_pct_1d_lt_10) | (change_pct_1d_shift_288 > -10.0) | (roc_9_1d_gt_neg_100))
          # 1d P&D, 4h still high
          short_entry_logic.append((change_pct_1d_lt_15) | (change_pct_1d_shift_288 > -15.0) | (aroond_14_4h_lt_50))

          # Logic
          short_entry_logic.append(rsi_14 > 64.0)
          short_entry_logic.append(aroond_14_lt_25)
          short_entry_logic.append(aroonu_14_gt_75)
          short_entry_logic.append(ema_9 > (ema_26 * 1.040))

        # Condition #542 - Quick mode (Short).
        if short_entry_condition_index == 542:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          # 5m & 15m up move, 15m stil low
          short_entry_logic.append(
            ((rsi_3_lt_90) | (rsi_3_15m_lt_80) | (aroonu_14_15m_gt_60))
            # 15m & 1h up move, 4h still low
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (rsi_14_4h_gt_60))
            # 15m & 1h up move, 4h still not high enough
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (stochrsi_k_4h_gt_80))
            # 15m & 1h up move, 1h still moving higher
            & ((rsi_3_15m_lt_95) | (rsi_3_1h_lt_90) | (cci_20_change_pct_1h_lt_neg_0))
            # 15m & 1d up move, 1d uptrend
            & ((rsi_3_15m_lt_90) | (rsi_3_1h_lt_80) | (roc_9_1d_lt_50))
            # 15m & 4h up move, 4h still moving higher
            & ((rsi_3_15m_lt_90) | (rsi_3_4h_lt_95) | (cci_20_change_pct_4h_lt_neg_0))
            # 15m & 1d up move, 4h uptrend
            & ((rsi_3_15m_lt_90) | (rsi_3_1d_lt_80) | (roc_9_4h_lt_20))
            # 15m up move, 15m & 4h high
            & ((rsi_3_15m_lt_90) | (aroonu_14_15m_lt_100) | (aroonu_14_4h_lt_100))
            # 15m up move, 15m still not high enough, 1d uptrend
            & ((rsi_3_15m_lt_90) | (stochrsi_k_15m_gt_80) | (roc_9_1d_lt_80))
            # 15m & 4h up move, 15m still not high enough
            & ((rsi_3_15m_lt_85) | (rsi_3_4h_lt_90) | (stochrsi_k_15m_gt_70))
            # 15m & 4h up move, 1d uptrend
            & ((rsi_3_15m_lt_85) | (rsi_3_4h_lt_85) | roc_9_1d_lt_50)
            # 15m & 4h up move, 4h still not high enough
            & ((rsi_3_15m_lt_85) | (rsi_3_4h_lt_80) | (rsi_14_4h_gt_60))
            # 15m up move, 15m still not high enough, 4h still low
            & ((rsi_3_15m_lt_85) | (stochrsi_k_15m_gt_80) | (aroonu_14_4h_gt_50))
            # 15m up move, 4h overbought
            & ((rsi_3_15m_lt_85) | (roc_9_4h_lt_50))
            # 15m & 1h up move, 15m & 1h uptrend
            & ((rsi_3_15m_lt_80) | (rsi_3_1h_lt_80) | (aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100))
            # 15m & 1h up move, 1h uptrend, 4h uptrend
            & ((rsi_3_15m_lt_80) | (rsi_3_1h_lt_80) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_10))
            # 15m & 1h up move, 15m still low
            & ((rsi_3_15m_lt_70) | (rsi_3_1h_lt_70) | (aroonu_14_15m_gt_40))
            # 15m & 1h up move, 15m still low
            & ((rsi_3_15m_lt_70) | (rsi_3_1h_lt_70) | (stochrsi_k_15m_gt_40))
            # # 15m & 1h up move, 4h low
            & ((rsi_3_15m_lt_70) | (rsi_3_1h_lt_60) | (aroonu_14_4h > 40.0))
            # 1h & 1d up move, 1h still moving higher
            & ((rsi_3_1h < 97.0) | (rsi_3_1d_lt_95) | (cci_20_change_pct_1h_lt_neg_0))
            # 1h & 4h up move, 15m still not high enough
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_95) | (stochrsi_k_15m_gt_80))
            # 1h & 4h up move, 1d uptrend
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_95) | (roc_9_1d_lt_100))
            # 1h & 4h up move, 1d still low
            & ((rsi_3_1h_lt_95) | (rsi_3_4h_lt_85) | (rsi_14_1d_gt_50))
            # 1h up move, 4h still low, 1h still moving higher
            & ((rsi_3_1h_lt_95) | (rsi_14_4h_gt_60) | (cci_20_change_pct_1h_lt_neg_0))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_95) | (aroonu_14_4h_gt_10))
            # 1h & 4h up move, 1h still moving higher
            & ((rsi_3_1h_lt_90) | (rsi_3_4h_lt_85) | (cci_20_change_pct_1h_lt_neg_0))
            # 1h & 4h up move, 4h still not high enough
            & ((rsi_3_1h_lt_90) | (rsi_3_4h_lt_70) | (stochrsi_k_4h_gt_80))
            # 1h & 1d up move, 15m still low
            & ((rsi_3_1h_lt_90) | (rsi_3_1d_lt_90) | (stochrsi_k_15m_gt_60))
            # 1h up move, 15m high
            & ((rsi_3_1h_lt_90) | (aroonu_14_15m_lt_100))
            # 1h up move, 4h low
            & ((rsi_3_1h_lt_90) | (stochrsi_k_4h_gt_30))
            # 1h up move, 4h still low, 1h still moving higher
            & ((rsi_3_1h_lt_90) | (stochrsi_k_4h_gt_60) | (cci_20_change_pct_1h_lt_neg_0))
            # 1h up move, 15m uptrend
            & ((rsi_3_1h_lt_90) | (roc_9_15m < 30.0))
            # 1h up move, 15m & 4h uptrend
            & ((rsi_3_1h_lt_90) | (roc_9_15m < 20.0) | (roc_9_4h_lt_20))
            # 1h & 4h up move, 4h still moving higher
            & ((rsi_3_1h_lt_85) | (rsi_3_4h_lt_80) | (cci_20_change_pct_4h_lt_neg_0))
            # 1h up move, 15m low
            & ((rsi_3_1h_lt_85) | (aroonu_14_15m_gt_40))
            # 1h up move, 4h still not high enough, 1d low
            & ((rsi_3_1h_lt_85) | (aroonu_14_4h_gt_80) | (rsi_14_1d_gt_40))
            # 1h & 4h up move, 4h still low
            & ((rsi_3_1h_lt_80) | (rsi_3_4h_lt_80) | (aroonu_14_4h_gt_50))
            # 1h & 4h up move, 1d still low
            & ((rsi_3_1h_lt_80) | (rsi_3_4h_lt_80) | (aroonu_14_1d_gt_50))
            # 1h & 4h up move, 1d low
            & ((rsi_3_1h_lt_80) | (rsi_3_4h_lt_70) | (stochrsi_k_1d_gt_30))
            # 1h up move, 1d still low, 1d uptrend
            & ((rsi_3_1h_lt_80) | (aroonu_14_1d_gt_50) | (roc_9_1d_lt_30))
            # 1h up move, 1d low
            & ((rsi_3_1h_lt_80) | (stochrsi_k_1d_gt_20))
            # 1h up move, 4h & 1d uptrend
            & ((rsi_3_1h_lt_80) | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 4h up move, 1d low
            & ((rsi_3_4h_lt_95) | (rsi_14_1d_gt_40))
            # 4h down move, 15m still not high enough, 1d low
            & ((rsi_3_4h_lt_95) | (stochrsi_k_15m_gt_80) | (aroond_14_1d < 75.0))
            # 4h up move, 1h & 4h uptrend
            & ((rsi_3_4h_lt_95) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 4h up move, 15m low
            & ((rsi_3_4h_lt_90) | (stochrsi_k_15m > 45.0))
            # 4h up move, 4h & 1d uptrend
            & ((rsi_3_4h_lt_90) | (roc_9_4h_lt_20) | (roc_9_1d_lt_40))
            # 4h up move, 15m still not high enough
            & ((rsi_3_4h_lt_85) | (aroonu_14_15m_gt_60))
            # 4h up move, 15m low
            & ((rsi_3_4h_lt_85) | (stochrsi_k_15m_gt_30))
            # 4h up move, 4h uptrend
            & ((rsi_3_4h_lt_80) | (aroonu_14_4h_lt_100) | (roc_9_4h_lt_20))
            # 4h up move, 15m still low, 4h still not high enough
            & ((rsi_3_4h_lt_80) | (stochrsi_k_15m_gt_60) | (aroonu_14_4h_gt_80))
            # 4h up move, 15m still low, 4h still not high enough
            & ((rsi_3_4h_lt_75) | (stochrsi_k_15m_gt_60) | (stochrsi_k_4h_gt_80))
            # 1d up move, 4h low
            & ((rsi_3_1d < 85.0) | (stochrsi_k_4h_gt_40))
            # 4h still not high enough, 4h overbought, 4h uptrend
            & ((rsi_14_4h_gt_80) | (roc_9_4h_lt_40) | (cci_20_change_pct_4h_lt_0))
            # 15m & 1h high, 4h uptrend
            & ((aroonu_14_15m_lt_100) | (aroonu_14_1h_lt_100) | (roc_9_4h_lt_20))
            # 15m & 1h high, 1d uptrend
            & ((aroonu_14_15m_lt_100) | aroonu_14_1h_lt_100 | (roc_9_1d_lt_50))
            # 15m & 4h high, 1h uptrend
            & ((aroonu_14_15m_lt_100) | aroonu_14_4h_lt_100 | (roc_9_1h_lt_20))
            # 15m & 4h high, 1d uptrend
            & ((aroonu_14_15m_lt_100) | aroonu_14_4h_lt_100 | (roc_9_1d_lt_50))
            # 15m high, 1d low
            & ((aroonu_14_15m_lt_100) | (stochrsi_k_1d_gt_20))
            # 15m high & uptrend
            & ((aroonu_14_15m_lt_100) | (roc_9_15m < 30.0))
            # 15m high, 1h & 4h uptrend
            & ((aroonu_14_15m_lt_100) | (roc_9_1h_lt_20) | (roc_9_4h_lt_20))
            # 1h high, 15m uptrend
            & ((aroonu_14_1h_lt_100) | (roc_9_15m < 20.0))
            # 15m & 4h still not high enough
            & ((stochrsi_k_15m_gt_70) | (stochrsi_k_4h_gt_70))
            # 1h & 4h overbought, 1h uptrend
            & ((roc_9_1h_lt_10) | (roc_9_4h_lt_40) | (cci_20_change_pct_1h_lt_0))
            # 1h & 4h overbought, 4h uptrend
            & ((roc_9_1h_lt_10) | (roc_9_4h_lt_40) | (cci_20_change_pct_4h_lt_0))
            # 1d bot wick, 4h still not high enough
            & ((bot_wick_pct_1d < 30.0) | (stochrsi_k_4h_gt_80))
            # rise in the last 12 hours, relatively stable before the 12 hours
            & ((close < (low_min_12_1h * 1.30)) | (low_min_12_1h > (low_min_24_1h * 1.10)))
            # big pump in the last 30 days, 4h up move
            & ((close < (low_min_30_1d * 4.0)) | (rsi_3_4h_lt_85))
          )

          # Logic
          short_entry_logic.append(
            (willr_14 > -50.0)
            & (aroonu_14_gt_75)
            & (aroond_14_lt_25)
            & (stochrsi_k_gt_80)
            & (willr_84_1h > -30.0)
            & (stochrsi_k_1h_gt_80)
            & (bbb_20_2_0_1h > 20.0)
            & (close_min_48 <= (close * 0.90))
          )

        # Condition #543 - Overbought Exhaustion (Short).
        # Shorts an exhausted overbought spike: RSI/StochRSI/WillR maxed with close well above
        # BB-upper and momentum rolling over (cci_change < 0). Guards reject spikes that keep
        # running (mid-band 4h ROC / extreme multi-TF momentum = squeeze). 2022 + 2021: 100% WR.
        if short_entry_condition_index == 543:
          # --- Global / base protections ---
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(cci_20_4h < 220.0)
          short_entry_logic.append(rsi_14_1h < 72.0)
          # --- Regime / momentum squeeze guards ---
          short_entry_logic.append(roc_9_1d < 35.0)  # 1d pump-exhaustion ceiling (+35%+ = still ripping)
          short_entry_logic.append(roc_9_1d > -12.0)  # 1d crash floor (bounce squeeze)
          short_entry_logic.append(
            (roc_9_4h < 3.0) | (roc_9_4h > 10.0)
          )  # 4h-ROC mid-band = still climbing; safe = cooled(<3) | blow-off(>10)
          short_entry_logic.append(roc_9_4h < 20.0)  # caps the blow-off branch at +20%
          short_entry_logic.append(
            (rsi_3_4h < 78.0) | (cci_20_1h < 140.0) | (mfi_14_1h < 78.0)
          )  # extreme multi-TF momentum top
          short_entry_logic.append(
            (roc_9_1d < 15.0) | (rsi_14_4h < 65.0) | (aroonu_14_4h < 55.0)
          )  # 1d-pump + 4h-strong top
          # --- Logic (entry trigger) ---
          short_entry_logic.append(rsi_14 > 72.0)
          short_entry_logic.append(stochrsi_k > 85.0)
          short_entry_logic.append(willr_14 > -10.0)
          short_entry_logic.append(close > (bbu_20_2_0 * 1.005))
          short_entry_logic.append(cci_20_change_pct_1h < 0.0)
          short_entry_logic.append(rsi_3 > 85.0)
          short_entry_logic.append(cmf_20 < 0.25)
          short_entry_logic.append(mfi_14 < 65.0)
          short_entry_logic.append(close > (close_max_48 * 0.99))

        # Condition #544 - Momentum Breakdown / Rollover Continuation (Short).
        # Shorts a confirmed 4h momentum rollover (ema_12 < ema_26, rsi_3 flushed under 30). The
        # breakdown-quality guards keep it off uptrend-dips and spent-aroon late entries (both
        # squeeze). Robust in both regimes — 2022 + 2021: 100% WR / 0 loss.
        if short_entry_condition_index == 544:
          # --- Global / base protections ---
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(roc_9_4h < 25.0)
          short_entry_logic.append(rsi_14_4h > 35.0)  # oversold floor
          # --- Breakdown-quality guards (squeeze avoidance) ---
          short_entry_logic.append(roc_9_1d < 2.0)  # 1d still rising = uptrend-dip, not a breakdown
          short_entry_logic.append((roc_9_1h > 1.5) | (aroonu_14_4h > 85.0) | (roc_9_4h < 3.0))  # uptrend-dip squeeze
          short_entry_logic.append(aroonu_14_4h > 25.0)  # aroon-up spent = late / weak breakdown
          short_entry_logic.append(
            (roc_9_4h < 3.5) | (rsi_3_4h < 50.0) | (roc_9_1h > 8.0)
          )  # all-highs squeeze (each win escapes one clause)
          short_entry_logic.append(
            (roc_9_4h < 2.5) | (rsi_14_4h < 58.0)
          )  # 4h still up + 4h-RSI mid = breakdown not confirmed
          # --- Logic (entry trigger) ---
          short_entry_logic.append(rsi_3 < 30.0)
          short_entry_logic.append(rsi_14_1h > 55.0)
          short_entry_logic.append(aroonu_14_1h > 60.0)
          short_entry_logic.append(cmf_20_1h < 0.0)
          short_entry_logic.append(mfi_14_1h < 50.0)
          short_entry_logic.append(close > (ema_26 * 0.97))
          short_entry_logic.append(roc_9_1h > -8.0)
          short_entry_logic.append(ema_12 < ema_26)

        # Condition #545 - Distribution / Failed Breakout (Short).
        # Shorts a rejected breakout / distribution top (close pushed above BB-upper then fading).
        # Profitable in bear markets (tops resolve down, 2022: 100% WR); the guards below reject the
        # two bull-market failure modes that squeeze a short: deep-crash dead-cat bounces and
        # strong-uptrend pullbacks. 2022 + 2021 both 100% WR / 0 loss after guards.
        if short_entry_condition_index == 545:
          # --- Global / base protections ---
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(roc_9_1d < 30.0)
          short_entry_logic.append(roc_9_4h < 22.0)
          short_entry_logic.append(rsi_14_4h < 65.0)
          # --- Regime guards (crash / trend squeeze avoidance) ---
          short_entry_logic.append(
            rsi_14_4h > 22.0
          )  # oversold floor: no short into a washed-out 4h (dead-cat-bounce top)
          short_entry_logic.append(roc_9_1d > -22.0)  # deep-crash floor: -22%+ 1d crash = V-recovery squeeze
          short_entry_logic.append(
            (aroonu_14_1d > 15.0) | (stochrsi_k_4h < 45.0)
          )  # no 1d-trend + 4h-overbought bounce = bull squeeze
          short_entry_logic.append(
            (aroonu_14_1d < 95.0) | (roc_9_4h > -3.0)
          )  # very-strong 1d trend + 4h pullback = short into uptrend = squeeze
          # --- Momentum / overbought squeeze guards ---
          short_entry_logic.append(
            (rsi_3_4h < 75.0) | (stochrsi_k_4h < 78.0)
          )  # 4h double-overbought = too tight = pops
          short_entry_logic.append(
            (roc_9_4h < 4.0) | (rsi_14_4h < 52.0)
          )  # premature: 4h still climbing = top unconfirmed
          short_entry_logic.append(
            (roc_9_1h < 6.0) | (rsi_14_1h < 63.0)
          )  # 1h dead-cat-pump, 4h unconfirmed = squeeze continues
          # --- Per-loss fine-tune (residual 2021 bull-market tops) ---
          short_entry_logic.append((roc_9_1d > -12.0) | (roc_9_4h < 8.0) | (roc_9_1h > 6.0))
          short_entry_logic.append((roc_9_1d > -18.0) | (roc_9_4h > -3.0) | (aroonu_14_1d > 8.0))
          short_entry_logic.append((roc_9_1d > -20.0) | (roc_9_4h > -13.0) | (roc_9_1h < 8.0))
          short_entry_logic.append((roc_9_1d < 6.0) | (roc_9_4h > -16.0) | (rsi_14_1h > 57.0))
          short_entry_logic.append((roc_9_1d > -4.0) | (roc_9_4h < -2.0) | (rsi_3_4h < 75.0))
          # --- Logic (entry trigger) ---
          short_entry_logic.append(bbb_20_2_0 > 4.0)
          short_entry_logic.append(stochrsi_k_1h > 30.0)
          short_entry_logic.append(close > (bbu_20_2_0 * 1.002))
          short_entry_logic.append(rsi_14 > 65.0)
          short_entry_logic.append(rsi_14_4h < 60.0)
          short_entry_logic.append(willr_14_1h > -20.0)
          short_entry_logic.append(aroonu_14_1h > 70.0)
          short_entry_logic.append(bbb_20_2_0_1h > 8.0)
          short_entry_logic.append(obv_change_pct < 0.0)
          short_entry_logic.append(cci_20_4h < 120.0)

        # Condition #546 - BB Upper Rejection + Multi-TF Overbought Stack (Short).
        # Shorts a hard rejection off BB-upper (bbp > 0.92, roc_2 < 0) with a multi-TF overbought
        # stack. The doc overbought-stack guard plus per-loss CCI/momentum guards reject blow-off
        # tops that keep ripping (high-CCI squeeze). 2022 + 2021: 100% WR / 0 loss.
        if short_entry_condition_index == 546:
          # --- Global / base protections ---
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(roc_9_1d < 30.0)
          short_entry_logic.append(roc_9_4h < 18.0)
          short_entry_logic.append(rsi_14_4h < 70.0)
          # --- Overbought-stack guard (multi-TF, buffered) ---
          short_entry_logic.append(
            ((rsi_3 < 93.0) | (rsi_3_15m < 88.0) | (aroonu_14_4h < 75.0))
            & ((rsi_3_15m < 90.0) | (rsi_3_1h < 85.0) | (stochrsi_k_4h > 40.0))
            & ((rsi_3_1h < 88.0) | (rsi_3_4h < 80.0) | (roc_9_1d < 20.0))
          )
          # --- Per-loss fine-tune (blow-off tops / weak bounces) ---
          short_entry_logic.append((cci_20_1h < 250.0) | (roc_9_1h < 7.0))  # CCI-blow-off top
          short_entry_logic.append((cci_20_1h < 180.0) | (roc_9_4h < 5.0))  # high-CCI momentum top
          short_entry_logic.append((stochrsi_k_4h < 80.0) | (cci_20_1h < 130.0))  # 4h-overbought top
          short_entry_logic.append((rsi_3_4h < 85.0) | (cci_20_1h < 200.0))  # extreme RSI3 + CCI top
          short_entry_logic.append((roc_9_4h > -3.0) | (rsi_3_4h > 40.0))  # weak-momentum bounce (both low = squeeze)
          short_entry_logic.append((roc_9_4h < 12.0) | (rsi_3_4h < 90.0))  # parabolic blow-off top
          # --- Logic (entry trigger) ---
          short_entry_logic.append(bbp_20_2_0 > 0.92)
          short_entry_logic.append(roc_2 < 0.0)
          short_entry_logic.append(bbb_20_2_0 > 4.0)
          short_entry_logic.append(stochrsi_k > 85.0)
          short_entry_logic.append(stochrsi_k_1h > 70.0)
          short_entry_logic.append(willr_14_1h > -15.0)
          short_entry_logic.append(rsi_14 > 68.0)
          short_entry_logic.append((rsi_14_15m > 60.0) | (rsi_14_1h > 58.0))
          short_entry_logic.append(obv_change_pct < 0.0)
          short_entry_logic.append(close > (close_max_48 * 0.98))

        # Condition #561 - Downtrend Pullback / Continuation mode (Short). Mirror of code-64.
        if short_entry_condition_index == 561:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          short_entry_logic.append(
            # Trend confirmation (higher TF must be bearish)
            (ema_12_4h < ema_200_4h)
            # --- 5m / base bounce over-recovered or near top (rsi_3, rsi_14, willr) ---
            # shallow daily + very strong 5m bounce + steep 4h drop (violent dead-cat)
            & ((rsi_3 < 65.0) | (roc_9_1d < -25.0) | (roc_9_4h > -20.0))
            # very strong 5m bounce (80+) reaching near top (willr high)
            & ((rsi_3 < 80.0) | (willr_14 < -20.0))
            # base RSI over-recovered (60+) + near-top bounce (willr high)
            & ((rsi_14 < 60.0) | (willr_14 < -22.0))
            # strong bounce (rsi_3 55+) + mild 4h drop + moderate daily = squeeze trap
            & ((rsi_3 < 55.0) | (roc_9_4h < -12.0) | (roc_9_1d > -15.0))
            # --- 4h momentum still up / not dropping (rsi_3_4h, roc_9_4h) ---
            # 4h up move, 15m still maxed
            & ((rsi_3_4h > 10.0) | (stochrsi_k_15m < 90.0))
            # bounce with 4h not dropping on any 4h momentum (short into strength)
            & ((rsi_3_4h < 25.0) | (roc_9_4h < -12.0) | (rsi_14_4h < 26.0))
            # exhausted crash (daily deep-down) + 4h bouncing
            & ((rsi_3_4h < 30.0) | (roc_9_4h < -15.0) | (roc_9_1d > -30.0))
            # deep daily crash + 4h flat / not dropping (exhausted crash bounce)
            & ((roc_9_4h < -10.0) | (roc_9_1d > -25.0))
            # weak 4h down, 15m maxed (CPI squeeze)
            & ((roc_9_4h < -5.0) | (stochrsi_k_15m < 95.0))
            # --- 1h & 4h RSI both bounced (mirror of 64) ---
            # 1h & 4h both bounced (LINK)
            & ((rsi_14_1h < 41.0) | (rsi_14_4h < 38.0))
            # 1h & 4h both bounced (SOL)
            & ((rsi_14_1h < 45.0) | (rsi_14_4h < 38.0))
            # --- 4h RSI elevated (not oversold) across daily contexts (rsi_14_4h) ---
            # deep-daily bounce, 4h not oversold, willr mid-band (-22..-20) = squeeze trap (narrow window)
            & ((rsi_14_4h < 28.0) | (willr_14 < -22.0) | (willr_14 > -20.0) | (roc_9_1d > -20.0))
            # deep-daily dead-cat, 4h mid (rsi_3_4h~30, roc_9_4h~-16, rsi_14_4h~30) — walks willr band on re-entry (multi-TF net)
            & ((rsi_3_4h < 25.0) | (rsi_3_4h > 35.0) | (roc_9_4h < -20.0) | (roc_9_1d > -20.0) | (rsi_14_4h < 30.0))
            # shallow daily + 4h not oversold + weak 5m bounce
            & ((rsi_14_4h < 28.0) | (roc_9_1d < -15.0) | (rsi_3 > 60.0))
            # flat daily (no daily downtrend) + 4h RSI still elevated
            & ((rsi_14_4h < 30.0) | (roc_9_1d < -10.0))
            # deep daily crash + 4h RSI elevated (33+)
            & ((rsi_14_4h < 33.0) | (roc_9_1d > -25.0))
            # deep daily crash + 4h RSI elevated (35+)
            & ((rsi_14_4h < 35.0) | (roc_9_1d > -25.0))
            # --- 5m / 15m stoch maxed (stochrsi) ---
            # 5m stoch high, 4h only mild down
            & ((stochrsi_k < 80.0) | (roc_9_4h < -15.0))
            # 15m maxed, 1h weak (escape strong downtrends)
            & ((stochrsi_k_15m < 96.0) | (rsi_14_1h > 40.0) | (roc_9_1d < -25.0))
            # 15m maxed, 4h weak (escape strong downtrends)
            & ((stochrsi_k_15m < 96.0) | (rsi_14_4h > 38.0) | (roc_9_1d < -25.0))
            # --- multi-TF net (moderate bounce indistinguishable from wins on any single TF) ---
            & (
              (stochrsi_k_15m > 90.0)
              | (rsi_3 > 60.0)
              | (rsi_3_4h > 35.0)
              | (rsi_14_4h < 25.0)
              | (roc_9_1d > -25.0)
              | (roc_9_4h < -20.0)
            )
            # --- structural regime bounds ---
            # 4h downtrend active
            & (aroond_14_4h > 50.0)
            # 4h not capitulated
            & (rsi_3_4h > 14.0)
            # Daily not pumping
            & (roc_9_1d < 5.0)
            # Daily not a capitulation-crash bottom
            & (roc_9_1d > -35.0)
          )

          # Logic — Bounce in downtrend
          short_entry_logic.append(
            (rsi_3 < 90.0)
            & (rsi_3_15m_lt_80)
            # & (rsi_3_1h < 80.0)
            & (rsi_14 > 55.0)
            & (willr_14 > -30.0)
            & (willr_14 < -15.0)
            & (stochrsi_k > 70.0)
            & (aroond_14_15m < 90.0)
            & (stochrsi_k_15m_gt_20)
            & (close > ema_12)
            & (close < ema_200)
            & (close < (bbu_20_2_0 * 0.99))
          )

        # Condition #562 - Trend Breakdown mode (Short).
        if short_entry_condition_index == 562:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(roc_9_1d < 5.0)
          short_entry_logic.append(rsi_14_4h < 48.0)
          short_entry_logic.append(rsi_14_1d < 50.0)
          short_entry_logic.append(rsi_14_1d > 25.0)

          short_entry_logic.append(
            # Downtrend confirmation (higher TF)
            (ema_12_4h < ema_200_4h)
            & (rsi_14_4h < 50.0)
            & (aroonu_14_4h < 60.0)
            & (roc_9_4h < 2.0)
            # 1h also bearish
            & (rsi_14_1h < 42.0)
            & (aroonu_14_1h < 40.0)
            # Daily momentum negative
            & (roc_9_1d < 0.0)
            # 1h + 4h capitulation oversold = double-exhaustion bottom
            & ((rsi_3_4h_gt_5) | (rsi_3_1h_gt_5) | (stochrsi_k_1h_gt_10))
            # 4h still in oversold zone post first leg + 1d sustained drop = continuation V-trap
            & ((rsi_3_4h_gt_20) | (stochrsi_k_4h > 10.0) | (rsi_3_1d_gt_40))
            # 1d capitulation but 4h mid = bottom formation, skip shorts
            & ((rsi_3_1d_gt_20) | (stochrsi_k_4h_lt_50) | (rsi_3_4h_gt_60))
            # 4h crash already extreme (>50% drop) = oversold bottom, dead cat
            & ((roc_9_4h_gt_neg_50) | (rsi_3_4h_gt_15) | (stochrsi_k_4h_gt_10))
            # 1d ultra-capitulation (STOCHRSIk = 0, RSI_3 < 10) = absolute bottom
            & ((rsi_3_1d_gt_10) | (stochrsi_k_1d > 5.0) | (rsi_3_4h_gt_40))
            # 4h drop ended (STOCHRSIk recovered) + 1h rallied = bull pullback over
            & ((stochrsi_k_4h_lt_50) | (stochrsi_k_1h < 60.0))
            # 1d AROONU high = recent 1d high made = bull pullback, not bear
            & ((aroonu_14_1d_lt_60) | (rsi_3_4h_gt_25))
            # 15m + 1h ultra-cap + 4h CMF positive = institutional buying, V-bottom
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (cmf_20_4h < -0.05))
            # 4h CMF nearly neutral + 1h rallied = money outflow stopping, bounce starting
            & ((cmf_20_4h < -0.05) | (stochrsi_k_1h < 70.0))
            # 1d massive crash already + 1h rallied = capitulation done, bounce starting
            & ((roc_9_1d > -25.0) | (stochrsi_k_1h < 60.0))
            # 15m + 1h ultra-capitulation = V-bottom forming regardless of CMF
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_15))
            # 1h overbought + 1d CMF positive = bull pullback bouncing on inflow
            & ((stochrsi_k_1h < 70.0) | (cmf_20_1d < 0.0))
            # 4h STOCHRSIk still extreme + 1h moderate = second leg waiting bounce
            & ((stochrsi_k_4h > 10.0) | (rsi_3_1h_gt_30))
            # 1d STOCHRSIk floor + 1d CMF positive = institutional buying after crash
            & ((stochrsi_k_1d > 5.0) | (cmf_20_1d < 0.0) | (rsi_3_4h_gt_45))
            # 1d big crash + 1h moderate overbought = bull pullback after sell-off
            & ((roc_9_1d > -22.0) | (stochrsi_k_1h < 70.0))
            ##########################################################################################################
            # 15m & 1h down move, 1h low, 15m low
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_25) | (aroonu_14_1h_gt_0) | (stochrsi_k_15m_gt_10))
            # 15m & 1h & 4h down move, 15m low
            & ((rsi_3_15m_gt_5) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_15m_gt_10))
            # 15m & 4h & 1d down move, 1d low
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1d_gt_20))
            # 15m & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_5) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_30))
            # 15m & 1d down move, 15m & 1d low
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_15) | (stochrsi_k_15m_gt_10) | (stochrsi_k_1d_gt_30))
            # 15m & 1d down move, 1d low
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_20) | (aroonu_14_1d_gt_0))
            # 15m & 1d down move, 15m & 4h low
            & ((rsi_3_15m_gt_5) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_gt_30) | (stochrsi_k_4h_gt_30))
            # 15m & 1h & 4h down move, 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_gt_10))
            # 15m & 1h & 4h down move, 15m low, 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_1h_gt_10) | (stochrsi_k_15m_gt_10))
            # 15m & 1h & 4h down move, 4h low, 15m low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_4h_gt_0) | (stochrsi_k_15m_gt_10))
            # 15m & 1h & 1d down move, 15m low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_gt_20))
            # 15m & 1h & 1d down move, 15m low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_gt_10))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_20) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_20))
            # 15m & 1h & 1d down move, 1h low, 1d oversold
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_gt_10) | (roc_9_1d_gt_neg_10))
            # 15m & 1h & 1d down move, 15m low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_30) | (stochrsi_k_15m_gt_10))
            # 15m & 1h & 4h down move, 15m low, 1d oversold
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_0) | (roc_9_1d_gt_neg_20))
            # 15m & 1 & 4h down move, 1h low, 15m low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_1h_gt_10) | (stochrsi_k_15m_gt_10))
            # 15m & 1h down move, 1h & 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_10))
            # 15m & 1h down move, 1h & 1d low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 15m & 1h down move, 15m & 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_30) | (stochrsi_k_15m_gt_10) | (stochrsi_k_4h_gt_20))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_30))
            # 15m & 1h down move, 1h & 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20))
            # 15m & 1h down move, 1h & 1d low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_10))
            # 15m & 1h down move, 1h low, 15m low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_gt_10) | (stochrsi_k_15m_gt_10))
            # 15m & 1h down move, 1h low, 1d oversold
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_1h_gt_20) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 4h low, 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1h_gt_35) | (aroonu_14_4h_gt_0) | (stochrsi_k_1h_gt_30))
            # 15m & 4h down move, 15m & 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_20))
            # 15m & 4h & 1d down move, 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_gt_20))
            # 15m & 4h & 1d down move, 1d low, 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (stochrsi_k_1d_gt_20) | (stochrsi_k_1h_gt_30))
            # 15m & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_50) | (aroonu_14_1h_gt_30) | (aroonu_14_1d_gt_30))
            # 15m & 4h & 1d down move, 1d low, 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1d_gt_10) | (stochrsi_k_4h_gt_30))
            # 15m & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_30))
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_0))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_30) | (aroonu_14_4h_gt_30))
            # 15m & 4h down move, 15m low, 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_4h_gt_45) | (stochrsi_k_15m_gt_10) | (stochrsi_k_4h_gt_20))
            # 15m & 1d down move, 4h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (aroonu_14_4h_gt_0) | (stochrsi_k_4h_gt_10))
            # 15m & 1d down move, 1d low
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_20) | (stochrsi_k_1d_gt_10))
            # 15m & 1d down move, 15m & 1h low
            & ((rsi_3_15m_gt_10) | (rsi_3_1d_gt_25) | (stochrsi_k_15m_gt_20) | (stochrsi_k_4h_gt_30))
            # 15m & 1h & 1d down move, 15m low
            & (
              (rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_15m_gt_10) | (stochrsi_k_15m_gt_10)
            )
            # 15m & 1h & 1d down move, 15m & 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_30) | (aroonu_14_4h_gt_30))
            # 15m & 1h down move, 1h low, 15m low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_1h_gt_30) | (stochrsi_k_15m_gt_10))
            # 15m & 1h down move, 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (aroonu_14_4h_gt_10))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_15) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_20))
            # 15m & 1h & 4h down move, 1h love
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1h_gt_0))
            # 15m & 1h down move, 15m & 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_20) | (stochrsi_k_15m_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 1h & 1d down move, 15m & 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_15m_gt_20) | (aroonu_14_1d_gt_20))
            # 15m & 1h & 4h down move, 4h low, 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_4h_gt_10) | (stochrsi_k_1d_gt_10))
            # 15m & 1h & 4h down move, 1h low, 15m low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1h_gt_30) | (stochrsi_k_15m_gt_30))
            # 15m & 1h & 1d down move, 15m & 1h low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20))
            # 15m & 1h down move, 1d low, 1d oversold
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_30) | (stochrsi_k_1d_gt_20) | (roc_9_1d_gt_neg_10))
            # 15m & 1h & 4h down move, 1h low, 4h downtrend not confirmed
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_40) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_lt_50))
            # 15m & 1h & 1d down move, 1h low, 4h downtrend not confirmed
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_30) | (aroonu_14_4h_lt_40))
            # 15m  & 1h down move, 1h & 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_35) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_30))
            # 15m & 1h down move, 1h low, 1d oversold
            & ((rsi_3_15m_gt_15) | (rsi_3_1h_gt_40) | (aroonu_14_1h_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_15) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_30))
            # 15m & 4h & 1d down move, 4h low, 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_40) | (aroonu_14_4h_gt_20) | (stochrsi_k_1d_gt_20))
            # 15m & 4h down move, 15m & 1h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_15m_gt_10) | (aroonu_14_1h_gt_10))
            # 15m & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_20))
            # 15m & 4h down move, 1h low, 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_1h_gt_0) | (stochrsi_k_4h_gt_30))
            # 15m & 4h down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_20) | (aroonu_14_4h_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_gt_10) | (stochrsi_k_4h_gt_20))
            # 15m & 4h & 1d down move, 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (aroonu_14_1d_gt_0) | (stochrsi_k_1d_gt_10))
            # 15m & 4h down move, 15m & 1h & 4h low
            & (
              (rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20)
            )
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_10))
            # 15m & 4h down move, 1h downtrend not confirmed, 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_lt_40) | (stochrsi_k_1d_gt_20))
            # 15m & 4h & 1d down move, 1h low, 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_gt_0) | (stochrsi_k_1d_gt_10))
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_30))
            # 15m & 1h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_30))
            # 15m & 4h down move, 1h low, 4h oversold
            & ((rsi_3_15m_gt_15) | (rsi_3_4h_gt_35) | (aroonu_14_1h_gt_0) | (roc_9_4h_gt_neg_20))
            # 15m & 1d down move, 15m & 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_15m_gt_10) | (aroonu_14_1d_gt_20))
            # 15m & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_15) | (aroonu_14_1h_gt_20) | (aroonu_14_1d_gt_30))
            # 15m & 1d down move, 1d downtrend not confirmed, 1h low
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_25) | (rsi_14_1d_lt_40) | (aroonu_14_1h_gt_0))
            # 15m & 1d down move, 15m low, 1d oversold
            & ((rsi_3_15m_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_15m_gt_30) | (roc_9_1d_gt_neg_15))
            # 15m down move, 4h downtrend not confirmed, 15m & 1h low
            & ((rsi_3_15m_gt_15) | (rsi_14_1h_lt_40) | (stochrsi_k_15m_gt_10) | (stochrsi_k_1h_gt_30))
            # 15m & 1h & 4h down move, 15m & 1h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20))
            # 15m & 1h & 4h down move, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (aroonu_14_4h_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 1h & 4h down move, 15m low, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_4h_gt_45) | (aroonu_14_15m_gt_10) | (stochrsi_k_4h_gt_20))
            # 15m & 1h & 1d down move, 15m low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_15m_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_0))
            # 15m & 1h down move, 5h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0))
            # 15m & 1h down move, 1h uptrend
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_20) | (cmf_20_1h_lt_0_10))
            # 15m & 1h & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_20))
            # 15m & 1h & 4h down move, 1h low, 15m low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1h_gt_0) | (stochrsi_k_15m_gt_10))
            # 15m & 1h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 1h down move, 15m & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 1h & 4h down move, 4h downtrend not confirmed, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40) | (aroonu_14_4h_gt_0))
            # 15m & 1h & 4h down move, 15m & 1h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_30) | (aroonu_14_1h_gt_30))
            # 15m & 1h & 4h down move, 4h downtrend not confirmed, 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40) | (aroonu_14_1d_gt_10))
            # 15m & 1h & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 15m & 1h & 4h & 1d down move, 1h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_0))
            # 15m & 1h & 1d down move, 1h low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0))
            # 15m & 1h & 4h down move, 15m & 1h high
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_20))
            # 15m & 1h & 4h down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (aroonu_14_4h_gt_10) | (roc_9_1d_gt_neg_10))
            # 15m & 1h down move, 1h low, 4h downtrend not confirmed
            & ((rsi_3_15m_gt_20) | (rsi_3_1h_gt_35) | (aroonu_14_1h_gt_0) | (stochrsi_k_4h_lt_60))
            # 15m & 4h & 1d down move, 1h low, 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_20) | (stochrsi_k_1d_gt_10))
            # 15m & 4h down move, 1h downtrend not confirmed, 4h downtrend not confirmed
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (rsi_14_1h_lt_40) | (aroonu_14_4h_lt_50))
            # 15m & 4h down move, 1h low, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_gt_0) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_30))
            # 15m & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_30))
            # 15m & 1h & 1d down move, 15m low, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (aroonu_14_15m_gt_0) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 15m & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_60) | (aroonu_14_15m_gt_10) | (aroonu_14_4h_gt_30))
            # 15m & 4h down move, 4h downtrend not confirmed, 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_4h_lt_50) | (stochrsi_k_1d_gt_20))
            # 15m & 4h & 1d down move, 4h downtrend not confirmed, 15m low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (rsi_14_4h_lt_40) | (stochrsi_k_15m_gt_20))
            # 15m & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_4h_gt_30) | (aroonu_14_1d_gt_30))
            # 15m & 4h & 1d down move, 1d low, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1d_gt_10) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (stochrsi_k_4h_gt_20) | (roc_9_1d_gt_neg_10))
            # 15m & 4h & 1d down move, 1d low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_1d_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_30))
            # 15m & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 15m & 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_30) | (stochrsi_k_4h_gt_10))
            # 15m & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_35) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_20))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20))
            # 15m & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_10))
            # 15m & 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10) | (stochrsi_k_4h_gt_10))
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_20) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 1d down move, 15m & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_15m_gt_30) | (aroonu_14_4h_gt_30))
            # 15m & 1d down move, 4h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_4h_gt_30) | (aroonu_14_1d_gt_30))
            # 15m & 1d down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_4h_gt_30) | (roc_9_1d_gt_neg_20))
            # 15m & 1d down move, 15m & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1d_gt_20))
            # 15m & 1d down move, 15m & 1h & 1d low
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 15m & 1d down move, 1d low, 1d oversold
            & ((rsi_3_15m_gt_20) | (rsi_3_1d_gt_30) | (aroonu_14_1d_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m down move, 1h & 1d low
            & ((rsi_3_15m_gt_20) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 15m & 1h & 4h down move, 1d low, 1d oversold
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1d_gt_10) | (roc_9_1d_gt_neg_20))
            # 15m & 1h & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_1h_gt_30) | (aroonu_14_4h_gt_30))
            # 15m & 1h & 4h down move, 15m & 4h low
            & (
              (rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_15m_gt_20) | (stochrsi_k_4h_gt_20)
            )
            # 15m & 1h & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_35) | (stochrsi_k_1h_gt_10) | (stochrsi_k_4h_gt_20))
            # 15m & 1h & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (stochrsi_k_1h_gt_10) | (stochrsi_k_4h_gt_30))
            # 15m & 1h & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_4h_gt_45) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_30))
            # 15m & 1h & 1d down move, 15m & 1h low
            & (
              (rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_3_1d_gt_45) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_30)
            )
            # 15m & 1h down move, 4h & 1d downtrend not confirmed, 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (rsi_14_4h_lt_40) | (rsi_14_1d_lt_40) | (aroonu_14_4h_gt_30))
            # 15m & 1h down move, 1h & 1d low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 15m & 1h down move, 1d low, 15m low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (aroonu_14_1d_gt_0) | (stochrsi_k_15m_gt_10))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_25) | (stochrsi_k_15m_gt_10) | (stochrsi_k_1h_gt_20))
            # 15m & 1h & 4h down move, 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_40) | (aroonu_14_4h_gt_0))
            # 15m & 1h & 4h & 1d down move, 15m low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_15m_gt_0))
            # 15m & 1h down move, 15m & 1h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_35) | (aroonu_14_15m_gt_10) | (aroonu_14_1h_gt_10))
            # 15m & 1h & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_1h_gt_30) | (aroonu_14_1d_gt_30))
            # 15m & 1h & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_25) | (rsi_3_1h_gt_45) | (rsi_3_4h_gt_45) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_10))
            # 15m & 4h & 1d down move, 4h downtrend not confirmed, 1d low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_35) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_gt_20))
            # 15m & 4h down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (aroonu_14_4h_gt_20) | (roc_9_1d_gt_neg_20))
            # 15m & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_25) | (stochrsi_k_1h_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 4h & 1d down move, 15m & 1h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20))
            # 15m & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_4h_gt_10) | (aroonu_14_1d_gt_10))
            # 15m & 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_20) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 1h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10))
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_35) | (stochrsi_k_15m_gt_10) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_0))
            # 15m & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_30))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_45) | (stochrsi_k_1h_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_10))
            # 15m & 1d down move, 15m & 1h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20))
            # 15m & 1d down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 1d down move, 15m & 4h low
            & ((rsi_3_15m_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_20) | (aroonu_14_4h_gt_20))
            # 15m down move, 1h low, 4h low, 15m low
            & ((rsi_3_15m_gt_25) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20) | (stochrsi_k_15m_gt_20))
            # 15m & 1h & 4h down move, 15m & 1d low
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_1d_gt_10))
            # 15m & 1h & 4h down move, 15m low, 1h low
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_0) | (stochrsi_k_1h_gt_20))
            # 15m & 1h down move, 4h low, 1h downtrend not confirmed
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_4h_gt_20) | (stochrsi_k_1h_lt_60))
            # 15m & 1h down move, 1h & 1d low, 15m low
            & (
              (rsi_3_15m_gt_30) | (rsi_3_1h_gt_30) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0) | (stochrsi_k_15m_gt_10)
            )
            # 15m & 1h & 4h down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (stochrsi_k_4h_gt_10) | (roc_9_1d_gt_neg_10))
            # 15m & 1h & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_30))
            # 15m & 1h & 4h down move, 1h & 4h low
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_20))
            # 15m & 1h & 4h down move, 4h downtrend not confirmed, 1h low
            & ((rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_14_4h_lt_40) | (aroonu_14_1h_gt_30))
            # 15m & 1h down move, 15m & 1h low, 1d oversold
            & (
              (rsi_3_15m_gt_30) | (rsi_3_1h_gt_40) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0) | (roc_9_1d_gt_neg_10)
            )
            # 15m & 4h & 1d down move, 15m low, 4h low
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_0) | (stochrsi_k_4h_gt_30))
            # 15m & 4h & 1d down move, 15m low, 4h low
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_10) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 15m & 4h low
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_10))
            # 15m & 4h down move, 1h & 1d low
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 15m & 4h down move, 1h low, 1d oversold
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_30) | (aroonu_14_1h_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (stochrsi_k_1h_gt_30) | (stochrsi_k_4h_gt_30))
            # 15m & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_15m_gt_30) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_4h_gt_10) | (aroonu_14_1d_gt_10))
            # 15m & 1h & 1d down move, 15m & 1h low
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0))
            # 15m & 1h & 1d down move, 1h & 4h low
            & ((rsi_3_15m_gt_35) | (rsi_3_1h_gt_40) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_10))
            # 15m & 4h down move, 4h downtrend not confirmed, 15m low
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40) | (aroonu_14_4h_lt_40) | (aroonu_14_15m_gt_10))
            # 15m & 4h & 1d down move, 15m & 1d low
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_15m_gt_0) | (aroonu_14_1d_gt_0))
            # 15m & 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_0) | (stochrsi_k_4h_gt_10))
            # 15m & 4h & 1d down move, 4h low, 1d oversold
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_4h_gt_0) | (roc_9_1d_gt_neg_10))
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_40) | (stochrsi_k_15m_gt_20) | (stochrsi_k_4h_gt_20))
            # 15m & 4h & 1d down move, 15m & 1h low
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20))
            # 15m & 4h & 1d down move, 1h low, 15m low
            & ((rsi_3_15m_gt_35) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_0) | (stochrsi_k_15m_gt_10))
            # 15m & 4h down move, 15m & 4h low
            & ((rsi_3_15m_gt_40) | (rsi_3_4h_gt_40) | (aroonu_14_15m_gt_10) | (aroonu_14_4h_gt_10))
            # 1h & 4h down move, 15m & 4h low
            & ((rsi_3_1h_gt_3) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_20) | (aroonu_14_4h_gt_30))
            # 1h & 1d down move, 15m & 4h low
            & ((rsi_3_1h_gt_5) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_10))
            # 1h down move, 1h & 4h low
            & ((rsi_3_1h_gt_5) | (stochrsi_k_1h_gt_10) | (stochrsi_k_4h_gt_30))
            # 1h & 4h & 1d down move, 4h & 1d oversold
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_20) | (roc_9_4h_gt_neg_30) | (roc_9_1d_gt_neg_40))
            # 1h & 4h down move, 1h low
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_gt_10))
            # 1h & 4h down move, 15m low, 4h downtrend not confirmed
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 15m & 1h low
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_35) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_20))
            # 1h & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_1h_gt_10) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_20))
            # 1h & 1d down move, 4h & 1d low
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_30) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_10))
            # 1h & 1d down move, 1d low, 1h low
            & ((rsi_3_1h_gt_10) | (rsi_3_1d_gt_30) | (aroonu_14_1d_gt_0) | (stochrsi_k_1h_gt_20))
            # 1h down move, 15m low, 4h oversold
            & ((rsi_3_1h_gt_10) | (aroonu_14_15m_gt_0) | (roc_9_4h_gt_neg_20))
            # 1h down move, 4h low
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_gt_0))
            # 1h down move, 1h low, 4h low
            & ((rsi_3_1h_gt_10) | (aroonu_14_4h_gt_10) | (stochrsi_k_1h_gt_10))
            # 1h down move, 15m & 4h low, 1d oversold
            & ((rsi_3_1h_gt_10) | (stochrsi_k_15m_gt_10) | (stochrsi_k_4h_gt_30) | (roc_9_1d_gt_neg_10))
            # 1h & 4h down move, 1h & 4h low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_15) | (stochrsi_k_1h_gt_30) | (stochrsi_k_4h_gt_30))
            # 1h & 4h down move, 1h & 4h low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_gt_10) | (stochrsi_k_4h_gt_20))
            # 1h & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (stochrsi_k_1h_gt_10) | (stochrsi_k_1d_gt_10))
            # 1h & 4h down move, 15m low, 1h low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_25) | (aroonu_14_15m_gt_10) | (stochrsi_k_1h_gt_10))
            # 1h & 4h & 1d down move, 15m & 4h low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_15m_gt_10) | (aroonu_14_4h_gt_20))
            # 1h & 4h & 1d down move, 1d low, 1d oversold
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1d_gt_0) | (roc_9_1d_gt_neg_10))
            # 1h & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_30) | (aroonu_14_4h_gt_30))
            # 1h & 4h & 1d down move, 15m low, 1h low
            & ((rsi_3_1h_gt_15) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_15m_gt_0) | (stochrsi_k_1h_gt_10))
            # 1h & 1d down move, 15m & 4h & 1d low
            & ((rsi_3_1h_gt_15) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0))
            # 1h down move, 15m & 4h low, 1h low
            & ((rsi_3_1h_gt_15) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_0) | (stochrsi_k_1h_gt_10))
            # 1h down move, 15m low, 1h low
            & ((rsi_3_1h_gt_15) | (aroonu_14_15m_gt_0) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_10))
            # 1h down move, 15m & 1h low
            & ((rsi_3_1h_gt_15) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20))
            # 1h down move, 15m & 1h low, 1d oversold
            & ((rsi_3_1h_gt_15) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_gt_30) | (roc_9_1d_gt_neg_10))
            # 1h & 4h & 1d down move, 1h low, 4h downtrend not confirmed
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_lt_50))
            # 1h & 4h down move, 1h & 4h low, 1d oversold
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_30) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 1h & 4h & 1d low
            & (
              (rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_20)
            )
            # 1h & 4h down move, 1h low, 1d oversold
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_20) | (stochrsi_k_1h_gt_10) | (roc_9_1d_gt_neg_30))
            # 1h & 4h down move, 1h & 4h low
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_25) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20))
            # 1h & 4h & 1d down move, 15m & 1h low
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_15m_gt_30) | (aroonu_14_1h_gt_30))
            # 1h & 3h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_20) | (aroonu_14_1d_gt_30))
            # 1h & 4h down move, 15m & 1h low
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0))
            # 1h & 4h down move, 15m & 4h low
            & ((rsi_3_1h_gt_20) | (rsi_3_4h_gt_40) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_0))
            # 1h & 1d down move, 15m & 1h low
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_15m_gt_10) | (aroonu_14_1h_gt_10))
            # 1h & 1d down move, 1d low, 4h low
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_30) | (aroonu_14_1d_gt_10) | (stochrsi_k_4h_gt_20))
            # 1h down move, 1d low, 4h downtrend not confirmed, 1h low
            & ((rsi_3_1h_gt_25) | (aroonu_14_1d_gt_0) | (aroonu_14_4h_lt_50) | (stochrsi_k_1h_gt_20))
            # 1h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 1h & 1d down move, 4h & 1d low
            & ((rsi_3_1h_gt_20) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_gt_20) | (stochrsi_k_1d_gt_30))
            # 1h down move, 1h low, 4h high
            & ((rsi_3_1h_gt_20) | (stochrsi_k_1h_gt_10) | (stochrsi_k_4h_lt_70))
            # 1h & 4h & 1d down move, 1h & 4h low
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_30))
            # 1h & 4h down move, 4h downtrend not confirmed, 4h low
            & ((rsi_3_1h_gt_25) | (rsi_3_4h_gt_30) | (rsi_14_4h_lt_40) | (aroonu_14_4h_gt_0))
            # 1h & 4h down move, 1h & 4h low, 15m low
            & (
              (rsi_3_1h_gt_25) | (rsi_3_4h_gt_40) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20) | (stochrsi_k_15m_gt_10)
            )
            # 1h & 1d down move, 1d uptrend, 4h & 1d low
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_30) | (cmf_20_1d_lt_0_10) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_30))
            # 1h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 1h down move, 15m low, 1h low, 1d downtrend not confirmed
            & ((rsi_3_1h_gt_25) | (aroonu_14_15m_gt_10) | (aroonu_14_1h_gt_20) | (stochrsi_k_1h_lt_50))
            # 1h down move, 1h low, 4h low, 15m low
            & ((rsi_3_1h_gt_25) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_20) | (stochrsi_k_15m_gt_10))
            # 1h & 4h & 1d down move, 4h low, 1d oversold
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_4h_gt_0) | (roc_9_1d_gt_neg_10))
            # 1 & 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_50) | (aroonu_14_1h_gt_0) | (stochrsi_k_4h_gt_30))
            # 1h & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_30) | (rsi_3_1d_gt_60) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0))
            # 1h & 4h & 1d down move, 4h & 1d low
            & ((rsi_3_1h_gt_30) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0))
            # 1h & 1d down move, 1h & 1d low, 1d oversold
            & (
              (rsi_3_1h_gt_30) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10) | (stochrsi_k_1d_gt_10) | (roc_9_1d_gt_neg_30)
            )
            # 1h down move, 1h low, 1d oversold
            & ((rsi_3_1h_gt_30) | (stochrsi_k_1h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h & 4h down move, 4h downtrend not confirmed, 1d low, 1d oversold
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (rsi_14_4h_lt_40) | (aroonu_14_1d_gt_10) | (roc_9_1d_gt_neg_10))
            # 1h & 4h down move, 1h & 1d low
            & ((rsi_3_1h_gt_35) | (rsi_3_4h_gt_35) | (aroonu_14_1h_gt_30) | (aroonu_14_1d_gt_30))
            # 1h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_35) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 1h down move, 15m low, 1h low
            & ((rsi_3_1h_gt_35) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0) | (stochrsi_k_1h_gt_10))
            # 1h down move, 1h & 4h low, 1d oversold
            & ((rsi_3_1h_gt_35) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_10) | (roc_9_1d_gt_neg_20))
            # 1h down move, 4h & 1d low, 1h downtrend not confirmed
            & ((rsi_3_1h_gt_35) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0) | (stochrsi_k_1h_lt_70))
            # 1h & 4h & 1d down move, 15m low, 1d oversold
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_15m_gt_0) | (roc_9_1d_gt_neg_10))
            # 1h & 4h & 1d down move, 1h low, 1d oversold
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_0) | (roc_9_1d_gt_neg_15))
            # 1h & 4h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_40) | (rsi_3_4h_gt_45) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_20))
            # 1h & 1d down move, 1h & 1d low
            & ((rsi_3_1h_gt_40) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 4h down move, 1h low, 4h low
            & ((rsi_3_4h_gt_5) | (aroonu_14_1h_gt_10) | (stochrsi_k_4h_gt_10))
            # 4h down move, 1d low, 4h low
            & ((rsi_3_4h_gt_5) | (aroonu_14_1d_gt_20) | (stochrsi_k_4h_gt_10))
            # 4h & 1d down move, 1h & 1d low
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 4h & 1d down move, 4h low, 1d oversold
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_45) | (stochrsi_k_4h_gt_10) | (roc_9_1d_gt_neg_10))
            # 4h down move, 15m & 1h low
            & ((rsi_3_4h_gt_10) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_0))
            # 4h down move, 15m low, 4h low
            & ((rsi_3_4h_gt_10) | (aroonu_14_15m_gt_0) | (stochrsi_k_4h_gt_20))
            # 4h & 1d down move, 4h low, 1d oversold
            & ((rsi_3_4h_gt_10) | (rsi_3_1d_gt_40) | (stochrsi_k_4h_gt_20) | (roc_9_1d_gt_neg_20))
            # 4h down move, 4h downtrend not confirmed, 1d low
            & ((rsi_3_4h_gt_10) | (rsi_14_4h_lt_40) | (aroonu_14_1d_gt_0))
            # 4h & 1d down move, 4h & 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_20) | (stochrsi_k_4h_gt_20) | (stochrsi_k_1d_gt_20))
            # 4h & 1d down move, 1h & 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (stochrsi_k_1h_gt_10) | (stochrsi_k_1d_gt_10))
            # 4h & 1d down move, 15m & 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_25) | (aroonu_14_15m_gt_10) | (aroonu_14_1d_gt_10))
            # 4h & 1d down move, 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_30) | (stochrsi_k_1d_gt_10))
            # 4h & 1d down move, 1h low, 4h low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1h_gt_20) | (stochrsi_k_4h_gt_30))
            # 4h & 1d down move, 1d low, 1d oversold
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_35) | (aroonu_14_1d_gt_0) | (roc_9_1d_gt_neg_10))
            # 4h & 1d down move, 1h & 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_40) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 4h & 1d down move, 4h downtrend not confirmed, 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_45) | (aroonu_14_4h_lt_50) | (aroonu_14_1d_gt_20))
            # 4h & 1d down move, 1d low, 1h low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_40) | (aroonu_14_1d_gt_0) | (stochrsi_k_1h_gt_20))
            # 4h & 1d down move, 4h & 1d low
            & ((rsi_3_4h_gt_15) | (rsi_3_1d_gt_60) | (stochrsi_k_4h_gt_10) | (stochrsi_k_1d_gt_30))
            # 4h down move, 15m & 4h low
            & ((rsi_3_4h_gt_15) | (aroonu_14_15m_gt_0) | (aroonu_14_4h_gt_10))
            # 4h down move, 1h & 1d low
            & ((rsi_3_4h_gt_15) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 4h down move, 4h low, 1d oversold
            & ((rsi_3_4h_gt_15) | (stochrsi_k_4h_gt_10) | (roc_9_1d_gt_neg_30))
            # 4h & 1d down move, 1h low, 1d low
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_25) | (aroonu_14_1h_gt_20) | (stochrsi_k_1d_gt_10))
            # 4h & 1d down move, 4h & 1d low
            & ((rsi_3_4h_gt_20) | (rsi_3_1d_gt_35) | (aroonu_14_4h_gt_10) | (aroonu_14_1d_gt_20))
            # 4h down move, 15m & 1h & 1d low
            & ((rsi_3_4h_gt_20) | (aroonu_14_15m_gt_10) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_10))
            # 4h down move, 1h & 4h & 1d low
            & ((rsi_3_4h_gt_20) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_30))
            # 4h down move, 1h low, 4h downtrend not confirmed
            & ((rsi_3_4h_gt_20) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_lt_50))
            # 4h down move, 1h low, 4h low, 1d downtrend not confirmed
            & ((rsi_3_4h_gt_20) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_10) | (aroonu_14_1d_lt_50))
            # 4h & 1d down move, 1h & 4h low
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_20))
            # 4h & 1d down move, 4h & 1d low
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_25) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0))
            # 4h & 1d down move, 1h low, 1d oversold
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_1h_gt_0) | (roc_9_1d_gt_neg_10))
            # 4h & 1d down move, 1d high, 4h high
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_30) | (aroonu_14_1d_gt_10) | (stochrsi_k_4h_gt_10))
            # 4h & 1d down move, 1d low, 4h low
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (aroonu_14_1d_gt_0) | (stochrsi_k_4h_gt_10))
            # 4h & 1d down move, 1h & 1d low
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_45) | (aroonu_14_1h_gt_20) | (aroonu_14_1d_gt_20))
            # 4h & 1d down move, 15m & 4h low
            & ((rsi_3_4h_gt_25) | (rsi_3_1d_gt_40) | (aroonu_14_15m_gt_20) | (aroonu_14_4h_gt_20))
            # 4h & 1d down move, 1h & 4h & 1d low
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_20))
            # 4h & 1d down move, 4h low
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_30) | (aroonu_14_4h_gt_0))
            # 4h & 1d down move, 4h & 1d low
            & ((rsi_3_4h_gt_30) | (rsi_3_1d_gt_35) | (aroonu_14_4h_gt_10) | (aroonu_14_1d_gt_10))
            # 4h down move, 15m & 1h low, 4h no downtrend confirmed
            & ((rsi_3_4h_gt_30) | (aroonu_14_15m_gt_20) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_lt_50))
            # 4h down move, 15m low, 1h downtrend not confirmed, 4h oversold
            & ((rsi_3_4h_gt_30) | (stochrsi_k_15m_gt_20) | (stochrsi_k_1h_lt_80) | (roc_9_4h_gt_neg_10))
            # 4h & 1d down move, 4h oversold, 4h low
            & ((rsi_3_4h_gt_35) | (rsi_3_1d_gt_35) | (roc_9_4h_gt_neg_10) | (aroonu_14_4h_gt_0))
            # 4h & 1d down move, 4h & 1d low
            & ((rsi_3_4h_gt_35) | (rsi_3_1d_gt_40) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_10))
            # 4h down move, 15m & 1h low, 4h no downtrend confirmed
            & ((rsi_3_4h_gt_35) | (aroonu_14_15m_gt_0) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_lt_50))
            # 4h down move, 4h low, 4h downtrend not confirmed, 1d oversold
            & ((rsi_3_4h_gt_35) | (aroonu_14_4h_gt_0) | (stochrsi_k_4h_lt_50) | (roc_9_1d_gt_neg_20))
            # 1d down move, 1d low, 1d oversold
            & ((rsi_3_1d_gt_10) | (stochrsi_k_1d_gt_20) | (roc_9_1d_gt_neg_20))
            # 1d down move, 15m & 1h uptrend, 1d low
            & ((rsi_3_1d_gt_15) | (cmf_20_15m_lt_0_20) | (cmf_20_1h_lt_0_20) | (stochrsi_k_1d_gt_20))
            # 1d down move, 4h & 1d low
            & ((rsi_3_1d_gt_15) | (aroonu_14_4h_gt_0) | (aroonu_14_1d_gt_0))
            # 1d down move, 4h low, 1d oversold
            & ((rsi_3_1d_gt_15) | (aroonu_14_4h_gt_0) | (roc_9_1d_gt_neg_20))
            # 1d down move, 4h low, 1d low
            & ((rsi_3_1d_gt_15) | (aroonu_14_4h_gt_10) | (stochrsi_k_1d_gt_10))
            # 15m down move, 4h high, 1d low
            & ((rsi_3_1d_gt_15) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_20) | (stochrsi_k_1d_gt_10))
            # 1d down move, 1h & 1d low
            & ((rsi_3_1d_gt_15) | (stochrsi_k_1h_gt_10) | (stochrsi_k_1d_gt_20))
            # 1d down move, 4h & 1d low
            & ((rsi_3_1d_gt_15) | (stochrsi_k_4h_gt_20) | (stochrsi_k_1d_gt_30))
            # 1d down move, 1h low, 4h downtrend not confirmed
            & ((rsi_3_1d_gt_20) | (aroonu_14_1h_gt_0) | (aroonu_14_4h_lt_40))
            # 1d down move, 1h & 4h low
            & ((rsi_3_1d_gt_20) | (aroonu_14_1h_gt_10) | (aroonu_14_4h_gt_10))
            # 1d down move, 4h low, 1d oversold
            & ((rsi_3_1d_gt_20) | (aroonu_14_4h_gt_0) | (roc_9_1d_gt_neg_10))
            # 1d down move, 4h low, 1d low
            & ((rsi_3_1d_gt_20) | (aroonu_14_4h_gt_20) | (aroonu_14_1d_gt_20) | (stochrsi_k_4h_gt_20))
            # 1d down move, 15m uptrend, 1d low
            & ((rsi_3_1d_gt_20) | (cmf_20_15m_lt_0_10) | (aroonu_14_1d_gt_0))
            # 1d down move, 1d low, 4h oversold
            & ((rsi_3_1d_gt_20) | (stochrsi_k_1d_gt_10) | (roc_9_4h_gt_neg_30))
            # 1d down move, 15m & 1h & 1d low
            & ((rsi_3_1d_gt_25) | (aroonu_14_15m_gt_10) | (aroonu_14_1h_gt_10) | (aroonu_14_1d_gt_20))
            # 1d down move, 1h low, 4h low
            & ((rsi_3_1d_gt_25) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_0) | (stochrsi_k_1h_gt_20))
            # 1d down move, 1h & 4h low, 1d oversold
            & ((rsi_3_1d_gt_25) | (aroonu_14_1h_gt_20) | (aroonu_14_4h_gt_20) | (roc_9_1d_gt_neg_10))
            # 1d down move, 15m & 4h low
            & ((rsi_3_1d_gt_25) | (stochrsi_k_15m_gt_10) | (stochrsi_k_4h_gt_10))
            # 1d down move, 15m & 1d low
            & ((rsi_3_1d_gt_25) | (stochrsi_k_15m_gt_10) | (stochrsi_k_1d_gt_20))
            # 1d down move, 15m & 1d low
            & ((rsi_3_1d_gt_30) | (stochrsi_k_15m_gt_10) | (stochrsi_k_1d_gt_10))
            # 1d down move, 1h high, 1d low
            & ((rsi_3_1d_gt_30) | (stochrsi_k_1h_lt_70) | (stochrsi_k_1d_gt_20))
            # 1d down move, 1h & 1d low
            & ((rsi_3_1d_gt_40) | (aroonu_14_1h_gt_0) | (aroonu_14_1d_gt_0))
            # 1h & 4h low
            & ((aroonu_14_1h_gt_0) | (aroonu_14_4h_gt_0))
            # 1h high, 4h low
            & ((stochrsi_k_1h_lt_80) | (stochrsi_k_4h_gt_10))
          )

          # Logic — Breakdown below BB lower in downtrend
          short_entry_logic.append(
            (rsi_3 < 20.0)
            & (rsi_3_15m < 35.0)
            & (rsi_14 > 15.0)
            & (rsi_14 < 32.0)
            & (cmf_20 < -0.08)
            & (obv_change_pct_15m < 0.0)
            & (ema_12 < ema_26)
            & (close < bbl_20_2_0)
          )

        # Condition #563 - Dead Cat Bounce mode (Short).
        if short_entry_condition_index == 563:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(roc_9_1d < 5.0)
          short_entry_logic.append(rsi_14_1d < 45.0)
          short_entry_logic.append(roc_9_1d < 0.0)

          short_entry_logic.append(
            # Context: recent large drop, 4h downtrend
            (roc_9_4h < -8.0)
            & (ema_12_4h < ema_200_4h)
            & (rsi_14_4h < 40.0)
            # 1h still bearish
            & (rsi_14_1h < 45.0)
            & (willr_14_1h < -50.0)
            & (aroonu_14_4h < 35.0)
            # 4h capitulation oversold + 15m strong rally start = V-reversal trap
            & ((rsi_3_4h_gt_5) | (stochrsi_k_15m < 90.0) | (aroonu_14_15m_lt_100))
            # 4h capitulation, 15m sustained overbought rally = V-reversal late stage
            & ((rsi_3_4h_gt_5) | (stochrsi_k_15m_lt_80) | (aroonu_14_15m_lt_80))
            # 4h oversold + 15m maxed out (STOCHRSIk = 100) = V-reversal already topped
            & ((rsi_3_4h_gt_15) | (stochrsi_k_15m < 90.0) | (aroonu_14_15m_lt_90))
            # 4h still oversold + 15m STOCHRSIk peaked = top distribution near recent levels
            & ((rsi_3_4h_gt_15) | (stochrsi_k_15m < 90.0))
            # 1d ultra-capitulation (STOCHRSIk = 0, RSI_3 < 10) = absolute bottom
            & ((rsi_3_1d_gt_10) | (stochrsi_k_1d > 5.0) | (rsi_3_4h_gt_40))
            # 1d already recovering (RSI_3 elevated + STOCHRSIk not low) = real recovery, not dead-cat
            & ((rsi_3_1d < 30.0) | (stochrsi_k_1d_lt_40))
            # 4h RSI still elevated (both 14 and 3-period) = 4h not bearish enough = real recovery
            & ((rsi_14_4h < 35.0) | (rsi_3_4h < 35.0))
            # SCENARIO: 1d not-yet-recovered gate OR 4h reclaiming = failed dead-cat vs real recovery
            & ((rsi_14_1d_lt_40) | (rsi_14_4h > 25.0))
            # SCENARIO: 1d ultra-capitulated (RSI_3 at absolute bottom) = due for a bounce that liquidates the short
            & (rsi_3_1d_gt_5)
            # SCENARIO: 4h reclaiming OR 4h money-flow leaving = bounce building, not a dead-cat
            & ((rsi_14_4h > 25.0) | (mfi_14_4h < 40.0))
            # SCENARIO: 4h money inflow at a 1d stoch-bottom = accumulation, bounce building
            & ((stochrsi_k_1d > 0.0) | (cci_20_change_pct_1h < -5.0))
            # SCENARIO: 1d downside stalling + short-term ultra-oversold = sellers exhausted, reversal
            & ((roc_9_1d < -5.0) | (rsi_3 > 30.0))
            # SCENARIO: 1d/4h ultra-capitulated but 1h already recovering = bottom in, bounce started
            & ((rsi_14_1h_lt_40) | (rsi_14_4h > 25.0))
            # SCENARIO: 4h crashed hard + 1h bouncing = V-reversal after capitulation, pump liquidates short
            & ((rsi_3_1d_gt_10) | (roc_9_4h > -20.0) | (rsi_14_1h_lt_40))
            # SCENARIO: 1d massive crash + 1h uptrend birth = capitulation bottom reversing
            & ((roc_9_1d > -40.0) | (aroonu_14_1h_lt_40))
            # SCENARIO: overbought entry + 4h momentum still up = shorting into a trend bounce
            & ((rsi_14 < 65.0) | (rsi_3_4h < 35.0))
            # SCENARIO: 1d stoch at absolute bottom + 1d RSI mid = mixed, due-for-bounce zone
            & ((stochrsi_k_1d > 0.0) | (rsi_14_1d_lt_40))
            # SCENARIO: 4h absolute-oversold selloff = capitulation exhaustion, sharp bounce
            & ((rsi_3_4h_gt_5) | (roc_9_4h > -25.0))
            # SCENARIO: 1d ultra-cap + 1h CCI recovering = capitulation bottom bouncing
            & ((rsi_3_1d_gt_10) | (cci_20_change_pct_1h > -35.0) | (rsi_3_4h_gt_20))
            # USELESS: multi-TF deep capitulation (1d crashed + 4h money-out + 4h stoch floor + 4h no-uptrend) = bounce liquidates short
            & ((roc_9_1d > -25.0) | (mfi_14_4h > 20.0) | (stochrsi_k_4h_gt_10) | (aroonu_14_4h_gt_10))
          )

          # Logic — Bounce that fails to reclaim resistance
          short_entry_logic.append(rsi_14 > 55.0)
          short_entry_logic.append(rsi_14 < 68.0)
          short_entry_logic.append(close < ema_200)
          short_entry_logic.append(close > ema_12)
          short_entry_logic.append(rsi_3 < 35.0)
          short_entry_logic.append(cci_20_change_pct_1h < 0.0)
          short_entry_logic.append(mfi_14_1h < 45.0)

        # Condition #592 - Quad-rotation stochastic pullback (Short, experimental).
        if short_entry_condition_index == 592:
          # --- Protections ---
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          # Round 1 (GRIFFAIN loss): block short while uptrend still has legs
          short_entry_logic.append(
            (roc_9_1d < 2.5)
            | (aroonu_14 < 100.0)
            | (aroonu_14_1h < 65.0)
            | (roc_9_1h < -5.5)
            | (cmf_20 < 0.0)
            | (rsi_14_1h > 40.0)
          )
          # Round 2 (XRP loss)
          short_entry_logic.append(
            (roc_9_1d < 2.0)
            | (rsi_14_1h > 42.0)
            | (rsi_3_15m > 65.0)
            | (cmf_20 > 0.15)
            | (aroonu_14_1h > 40.0)
            | (roc_9_1h < -5.0)
          )
          # Round 3 (API3/UNI loss)
          short_entry_logic.append((roc_9_1d < 0.0) | (roc_9_1h < -5.0) | (rsi_14_1h > 32.0) | (mfi_14_15m > 25.0))
          # Round 4 (EIGEN/DODOX loss)
          short_entry_logic.append((cmf_20 < 0.15) | (roc_9_1d < -3.0) | (roc_9_1d > 5.0) | (rsi_14_1h > 50.0))
          # Round 5 (CHZ loss): deep 1d downtrend + heavy money INFLOW at entry = squeeze fuel
          short_entry_logic.append((mfi_14 < 70.0) | (roc_9_1d > -10.0))
          # --- Logic: embedded down-regime + quad-overbought bounce + 5-candle shift kink ---
          short_entry_logic.append(stoch_60_10 < 20.0)
          short_entry_logic.append(stoch_9_3 > 80.0)
          short_entry_logic.append(stoch_14_3 > 80.0)
          short_entry_logic.append(stoch_4_4 > 80.0)
          short_entry_logic.append(close > np_shift(close, 5))
          short_entry_logic.append(stoch_9_3 < np_shift(stoch_9_3, 5))

        # Condition #593 - Quad-rotation TRUE pivot divergence (Short, experimental).
        if short_entry_condition_index == 593:
          # --- Protections ---
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          # Round 1 (UNI loss): 1h washed-out + 1d overbought & rising = bounce squeeze; need 1h strength
          # OR 1d not stretched OR 1d already down OR 4h stoch off the floor
          short_entry_logic.append(
            (rsi_14_1h > 30.0) | (stochrsi_k_1d < 80.0) | (roc_9_1d < 0.0) | (stochrsi_k_4h > 10.0)
          )
          # --- Logic: embedded down-regime + quad-overbought + two-pivot bearish divergence ---
          short_entry_logic.append(stoch_60_10 < 20.0)
          short_entry_logic.append(stoch_9_3 > 80.0)
          short_entry_logic.append(stoch_14_3 > 80.0)
          short_entry_logic.append(stoch_4_4 > 80.0)
          # price HIGHER-HIGH across swing windows while stoch makes a LOWER-HIGH (real divergence)
          short_entry_logic.append(quad_high_max_12 > np_shift(quad_high_max_12, 12))
          short_entry_logic.append(quad_s93_max_12 < np_shift(quad_s93_max_12, 12))

        # Condition #605 - Williams %R snapback (Short, experimental — mirror).
        if short_entry_condition_index == 605:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          # never fade the bounce of a fully-capitulated daily (violent squeeze habitat)
          short_entry_logic.append(rsi_3_1d > 12.0)
          # 1h close crosses INTO the overbought extreme
          short_entry_logic.append(willr_14_1h > -10.0)
          short_entry_logic.append(np_shift(willr_14_1h, 12) <= -10.0)
          # mean-revert WITH the daily trend: only short when the day is down
          short_entry_logic.append(change_pct_1d < 0.0)

        # # Condition #620 - Grind mode (Short).
        # if short_entry_condition_index == 620:
        #   # Protections
        #   short_entry_logic.append(num_open_short_grind_mode < self.grind_mode_max_slots)
        #   short_entry_logic.append(is_pair_short_grind_mode)
        #   short_entry_logic.append(df["RSI_3"] <= 40.0)
        #   short_entry_logic.append(rsi_3_15m >= 10.0)
        #   short_entry_logic.append(rsi_3_1h >= 5.0)
        #   short_entry_logic.append(rsi_3_4h >= 5.0)
        #   short_entry_logic.append(rsi_14_1h < 85.0)
        #   short_entry_logic.append(df["RSI_14_4h"] < 85.0)
        #   short_entry_logic.append(rsi_14_1d < 85.0)
        #   short_entry_logic.append(close_max_48 >= (df["close"] * 1.10))

        #   # Logic
        #   short_entry_logic.append(stochrsi_k_gt_80)
        #   short_entry_logic.append(willr_14 > -20.0)
        #   short_entry_logic.append(aroond_14_lt_25)

        # Condition #641 - Top Coins mode (Short).
        if short_entry_condition_index == 641:
          # Protections
          short_entry_logic.append(is_pair_short_top_coins_mode)

          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          short_entry_logic.append(rsi_3_1h >= 5.0)
          short_entry_logic.append(rsi_3_4h >= 20.0)
          short_entry_logic.append(rsi_3_1d >= 20.0)
          short_entry_logic.append(rsi_14_1h_gt_20)
          short_entry_logic.append(rsi_14_4h_gt_20)
          short_entry_logic.append(rsi_14_1d_gt_10)
          # 5m down move, 1h still not low enough, 4h high
          short_entry_logic.append((rsi_3_lt_90) | (stochrsi_k_1h_gt_90) | (stochrsi_k_4h_gt_30))
          # 5m down move, 1h high, 4h still not low enough
          short_entry_logic.append((rsi_3_lt_90) | (stochrsi_k_1h_gt_20) | (stochrsi_k_4h_gt_90))
          # 15m down move, 15m still not low enough, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_95) | (aroond_14_15m_lt_25) | (stochrsi_k_1h_gt_50))
          # 15m & 1h down move, 1d still not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (stochrsi_k_1d_gt_70))
          # 15m & 1h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_85) | (rsi_3_1h_lt_85) | (stochrsi_k_1h_gt_70))
          # 15m down move, 1h high, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_85) | (stochrsi_k_1h_gt_30) | (stochrsi_k_4h_gt_75))
          # 15m & 1h down move, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_80) | (rsi_3_1h_lt_70) | (stochrsi_k_4h_gt_50))
          # 15m down move, 1h still not low enough, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_75) | (stochrsi_k_1h_gt_80) | (stochrsi_k_4h_gt_60))
          # 1h & 4h & 1d down move
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_4h_lt_90) | (rsi_3_1d_lt_80))
          # 1h & 4h down move, 15m not low enough
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_15m > 75.0))
          # 1h down move, 1h still not low enough, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_90) | (stochrsi_k_1h_gt_90) | (stochrsi_k_4h_gt_50))
          # 1h & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_85) | (rsi_3_4h_lt_75) | (stochrsi_k_1h_gt_90))
          # 1h & 4h down move, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_85) | (rsi_3_4h_lt_75) | (stochrsi_k_4h_gt_50))
          # 1h & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_80) | (rsi_3_4h_lt_85) | (stochrsi_k_1h_gt_75))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_80) | (rsi_3_4h_lt_85) | (stochrsi_k_4h_gt_75))
          # 1h down move, 1h & 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_80) | (stochrsi_k_1h_gt_90) | (stochrsi_k_4h_gt_70))
          # 4h down move, 15m still high, 1h still not low enough
          short_entry_logic.append((rsi_3_4h_lt_85) | (stochrsi_k_15m_gt_50) | (stochrsi_k_1h_gt_75))
          # 4h down move, 15m & 4h still not low enough
          short_entry_logic.append((rsi_3_4h < 15.0) | (stochrsi_k_15m_gt_30) | (stochrsi_k_4h_gt_80))

          # Logic
          short_entry_logic.append(rsi_20 > rsi_20_shift_1)
          short_entry_logic.append(rsi_3 > 70.0)
          short_entry_logic.append(aroond_14_lt_25)
          short_entry_logic.append(close > sma_16 * 1.044)

        # Condition #642 - Top Coins mode (Short).
        if short_entry_condition_index == 642:
          # Protections
          short_entry_logic.append(is_pair_short_top_coins_mode)

          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          # 5m & 1h & 4h down move
          short_entry_logic.append((rsi_3_lt_90) | (rsi_3_1h_lt_95) | (rsi_3_4h_lt_90))
          # 5m down move, 15m & 4h still high
          short_entry_logic.append((rsi_3_lt_90) | (stochrsi_k_15m_gt_60) | (stochrsi_k_4h_gt_60))
          # 5m down move, 15m still high, 1h high
          short_entry_logic.append((rsi_3 < 85.0) | (aroond_14_15m_lt_50) | (stochrsi_k_1h_gt_20))
          # 15m & 1h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (stochrsi_k_1h_gt_90))
          # 15m & 1h down move, 1d still not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_95) | (stochrsi_k_1d_gt_70))
          # 15m strong down move, 4h high
          short_entry_logic.append((rsi_3_15m_lt_95) | (stochrsi_k_4h_gt_20))
          # 15m & 1h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_80) | (stochrsi_k_1h_gt_80))
          # 15m down move, 15m stil high, 1h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_90) | (stochrsi_k_15m_gt_50) | (stochrsi_k_1h_gt_80))
          # 15m down move, 1h & 4h still high
          short_entry_logic.append((rsi_3_15m_lt_90) | (stochrsi_k_1h_gt_60) | (stochrsi_k_4h_gt_60))
          # 15m & 1h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_95) | (rsi_3_1h_lt_70) | (stochrsi_k_4h_gt_50))
          # 15m down move, 15m still not low enough, 4h high
          short_entry_logic.append((rsi_3_15m_lt_85) | (stochrsi_k_15m_gt_80) | (stochrsi_k_4h_gt_20))
          # 15m down move, 4h still high, 1d high
          short_entry_logic.append((rsi_3_15m_lt_85) | (stochrsi_k_4h_gt_60) | (stochrsi_k_1d_gt_30))
          # 15m & 4h down move, 1d still high
          short_entry_logic.append((rsi_3_15m_lt_85) | (rsi_3_4h_lt_75) | (stochrsi_k_1d_gt_50))
          # 15m & 1h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_80) | (rsi_3_1h_lt_80) | (stochrsi_k_4h_gt_70))
          # 15m & 1h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_75) | (rsi_3_1h_lt_75) | (stochrsi_k_4h_gt_70))
          # 15m & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_75) | (rsi_3_4h_lt_75) | (stochrsi_k_4h_gt_80))
          # 15m down move, 1h still high, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_75) | (stochrsi_k_1h_gt_80) | (stochrsi_k_4h_gt_60))
          # 15m down move, 1h still not low enough, 4h high
          short_entry_logic.append((rsi_3_15m_lt_75) | (stochrsi_k_1h_gt_90) | (stochrsi_k_4h_gt_30))
          # 15m down move, 1h high, 4h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_75) | (stochrsi_k_1h_gt_20) | (stochrsi_k_4h_gt_90))
          # 15m down move, 4h high, 1d stil high
          short_entry_logic.append((rsi_3_15m_lt_75) | (stochrsi_k_4h_gt_20) | (stochrsi_k_1d_gt_50))
          # 15m & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_15m_lt_70) | (rsi_3_4h_lt_85) | (stochrsi_k_1h_gt_70))
          # 15m & 4h down move, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_70) | (rsi_3_4h_lt_80) | (stochrsi_k_1h_gt_50))
          # 15m down move, 15m still high 4h still high
          short_entry_logic.append((rsi_3_15m_lt_70) | (stochrsi_k_15m_gt_70) | (stochrsi_k_4h_gt_50))
          # 15m down move, 1h still high, 4h high
          short_entry_logic.append((rsi_3_15m_lt_70) | (stochrsi_k_1h_gt_50) | (stochrsi_k_4h_gt_10))
          # 1h & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_4h_lt_95) | (stochrsi_k_1h_gt_90))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_95) | (rsi_3_4h_lt_85) | (stochrsi_k_4h_gt_80))
          # 1h & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_1h_gt_90))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_90) | (stochrsi_k_4h_gt_80))
          # 1h & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_85) | (stochrsi_k_1h > 85.0))
          # 1h & 4h down move, 1d still high
          short_entry_logic.append((rsi_3_1h_lt_90) | (rsi_3_4h_lt_85) | (stochrsi_k_1d_gt_50))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_85) | (rsi_3_4h_lt_75) | (stochrsi_k_4h > 85.0))
          # 1h down move, 4h still high, 1d high
          short_entry_logic.append((rsi_3_1h_lt_80) | (stochrsi_k_4h_gt_60) | (stochrsi_k_1d_gt_30))
          # 1h & 4h down move, 1h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_80) | (rsi_3_4h_lt_85) | (stochrsi_k_1h_gt_75))
          # 1h & 4h down move, 15m still high
          short_entry_logic.append((rsi_3_1h_lt_80) | (rsi_3_4h_lt_80) | (stochrsi_k_15m_gt_50))
          # 1h & 4h down move, 4h still not low enough
          short_entry_logic.append((rsi_3_1h_lt_75) | (rsi_3_4h_lt_90) | (stochrsi_k_1h_gt_75))
          # 1h & 4h down move, 1h still high
          short_entry_logic.append((rsi_3_1h_lt_70) | (rsi_3_4h_lt_85) | (stochrsi_k_1h_gt_60))
          # 1h down move, 1h still not low enough, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_70) | (stochrsi_k_1h_gt_80) | (stochrsi_k_4h_gt_50))
          # 4h down move, 15m still high, 1h still not low enough
          short_entry_logic.append((rsi_3_4h_lt_85) | (stochrsi_k_15m_gt_60) | (stochrsi_k_1h_gt_80))
          # 4h down move, 15m still high, 4h still not low enough
          short_entry_logic.append((rsi_3_4h_lt_75) | (stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_75))
          # 4h down move, 1h still not low enough, 1d still high
          short_entry_logic.append((rsi_3_4h < 25.0) | (stochrsi_k_1h_gt_70) | (stochrsi_k_1d_gt_50))
          # 15m & 1h still high, 4h high
          short_entry_logic.append((stochrsi_k_15m_gt_70) | (stochrsi_k_1h_gt_70) | (stochrsi_k_4h_gt_10))
          # 15m still high, 1h & 1d high
          short_entry_logic.append((stochrsi_k_15m_gt_60) | (stochrsi_k_1h_gt_30) | (stochrsi_k_1d_gt_30))
          # 15m & 4h high
          short_entry_logic.append((stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_20))
          # 15m high, 1h & 4h still not low enough
          short_entry_logic.append((stochrsi_k_15m_gt_30) | (stochrsi_k_1h_gt_75) | (stochrsi_k_4h_gt_75))
          # 15m & 4h high
          short_entry_logic.append((stochrsi_k_15m_gt_30) | (stochrsi_k_4h_gt_30))
          # 1h & 4h still high, 1d high
          short_entry_logic.append((stochrsi_k_1h_gt_70) | (stochrsi_k_4h_gt_70) | (stochrsi_k_1d_gt_50))
          # 1h & 4h high
          short_entry_logic.append((stochrsi_k_1h_gt_30) | (stochrsi_k_4h_gt_10))
          # 1h & 4h high
          short_entry_logic.append((stochrsi_k_1h_gt_20) | (stochrsi_k_4h_gt_20))
          # 4h & 1d high
          short_entry_logic.append((stochrsi_k_4h_gt_20) | (stochrsi_k_1d_gt_20))
          # 1d red, 1d high
          short_entry_logic.append((change_pct_1d < 5.0) | (stochrsi_k_1d_gt_20))
          # 1d P&D, 1d high
          short_entry_logic.append((change_pct_1d_lt_10) | (change_pct_1d_shift_288 > -10.0) | (stochrsi_k_1d_gt_50))

          # Logic
          short_entry_logic.append(rsi_4 > 54.0)
          short_entry_logic.append(rsi_20 > rsi_20_shift_1)
          short_entry_logic.append(close > sma_16 * 1.042)

        # Condition #661 - Scalp mode (Short).
        if short_entry_condition_index == 661:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)

          # 15m down move, 15m high
          short_entry_logic.append((rsi_3_15m_lt_75) | (aroond_14_15m_lt_80))
          # 15m & 1h down move, 15m still high
          short_entry_logic.append((rsi_3_15m_lt_70) | (rsi_3_1h_lt_40) | (aroond_14_15m_lt_50))
          # 15m down move, 15m & 4h still high
          short_entry_logic.append((rsi_3_15m_lt_70) | (stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_50))
          # 15m & 1h down move, 1h high
          short_entry_logic.append((rsi_3_15m_lt_60) | (rsi_3_1h_lt_60) | (aroond_14_1h_lt_70))
          # 15m & 1h down move, 1h still high
          short_entry_logic.append((rsi_3_15m_lt_60) | (rsi_3_1h_lt_60) | (stochrsi_k_1h_gt_50))
          # 15m & 1h down move, 4h high
          short_entry_logic.append((rsi_3_15m_lt_60) | (rsi_3_1h_lt_40) | (aroond_14_4h_lt_80))
          # 15m & 4h down move, 15m high
          short_entry_logic.append((rsi_3_15m_lt_60) | (rsi_3_4h_lt_60) | (stochrsi_k_15m_gt_50))
          # 15m & 4h down move, 15m high
          short_entry_logic.append((rsi_3_15m_lt_60) | (rsi_3_4h_lt_40) | (stochrsi_k_15m_gt_30))
          # 15m down move, 15m & 1h still high
          short_entry_logic.append((rsi_3_15m_lt_60) | (aroond_14_15m_lt_50) | (stochrsi_k_1h_gt_50))
          # 15m down move, 15m & 1h still high
          short_entry_logic.append((rsi_3_15m_lt_60) | (stochrsi_k_15m_gt_50) | (stochrsi_k_1h_gt_50))
          # 15m down move, 4h still high, 1d overbought
          short_entry_logic.append((rsi_3_15m_lt_60) | (aroond_14_4h_lt_50) | (roc_9_1d_gt_neg_100))
          # 15m down move, 15m high, 4h still high
          short_entry_logic.append((rsi_3_15m_lt_55) | (aroond_14_15m > 30.0) | (stochrsi_k_4h_gt_50))
          # 15m down move, 15m & 1h still high
          short_entry_logic.append((rsi_3_15m_lt_55) | (stochrsi_k_15m > 55.0) | (stochrsi_k_1h_gt_60))
          # 15m down move, 15m still not low enough, 4h high
          short_entry_logic.append((rsi_3_15m_lt_50) | (stochrsi_k_15m_gt_70) | (stochrsi_k_4h_gt_10))
          # 1h down move, 4h still high, 1d high
          short_entry_logic.append((rsi_3_1h_lt_75) | (aroond_14_4h_lt_50) | (stochrsi_k_1d > 10.0))
          short_entry_logic.append((rsi_3_1h_lt_70) | (stochrsi_k_1h_gt_60) | (stochrsi_k_1d > 10.0))
          # 1h & 4h down move, 4h high
          short_entry_logic.append((rsi_3_1h_lt_65) | (rsi_3_4h_lt_40) | (stochrsi_k_4h_gt_20))
          # 1h down move, 15m & 1h still high
          short_entry_logic.append((rsi_3_1h_lt_60) | (stochrsi_k_15m_gt_50) | (stochrsi_k_1h_gt_50))
          # 1h down move, 1h still high, 4h high
          short_entry_logic.append((rsi_3_1h_lt_60) | (stochrsi_k_1h_gt_50) | (stochrsi_k_4h_gt_70))
          # 1h down move, 1h high
          short_entry_logic.append((rsi_3_1h_lt_60) | (stochrsi_k_1h_gt_40))
          # 1h down move, 4h & 1d high
          short_entry_logic.append((rsi_3_1h_lt_60) | (aroond_14_4h_lt_85) | (aroond_14_1d < 90.0))
          # 1h down move, 1h still high, 4h high
          short_entry_logic.append((rsi_3_1h_lt_55) | (aroond_14_1h_lt_50) | (aroond_14_4h < 90.0))
          # 1h down move, 1h high
          short_entry_logic.append((rsi_3_1h_lt_55) | (stochrsi_k_1h_gt_40))
          # 1h & 4h down move, 15m high
          short_entry_logic.append((rsi_3_1h_lt_50) | (rsi_3_4h_lt_40) | (aroond_14_15m_lt_70))
          # 1h down move, 15m still high, 4h high
          short_entry_logic.append((rsi_3_1h_lt_50) | (aroond_14_15m_lt_50) | (aroond_14_4h_lt_80))
          # 1h down move, 15m high, 1h still high
          short_entry_logic.append((rsi_3_1h_lt_50) | (aroond_14_15m_lt_70) | (stochrsi_k_1h_gt_60))
          # 1h down move, 15m still high, 4h high
          short_entry_logic.append((rsi_3_1h_lt_50) | (stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_20))
          # 1h down move, 15m & 1h high
          short_entry_logic.append((rsi_3_1h_lt_50) | (stochrsi_k_15m_gt_40) | (aroond_14_1h < 60.0))
          # 1h down move, 1h & 1d high
          short_entry_logic.append((rsi_3_1h_lt_50) | (aroond_14_1h_lt_70) | (stochrsi_k_1d_gt_20))
          # 1h down move, 4h still high, 1d high
          short_entry_logic.append((rsi_3_1h_lt_50) | (stochrsi_k_4h_gt_50) | (stochrsi_k_1d > 10.0))
          # 1h down move, 5m up move, 1h still high
          short_entry_logic.append((rsi_3_1h_lt_40) | (rsi_3 > 40.0) | (stochrsi_k_1h_gt_50))
          # 1h down move, 15m still not low enough, 1h high
          short_entry_logic.append((rsi_3_1h_lt_40) | (stochrsi_k_15m_gt_70) | (aroond_14_1h_lt_70))
          # 1h down move, 15m still not low enough, 1h high
          short_entry_logic.append((rsi_3_1h_lt_40) | (stochrsi_k_15m_gt_70) | (stochrsi_k_1h_gt_40))
          # 1h down move, 15m & 4h still high
          short_entry_logic.append((rsi_3_1h_lt_40) | (stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_50))
          # 1h down move, 15m & 1h high
          short_entry_logic.append((rsi_3_1h_lt_40) | (aroond_14_15m_lt_70) | (aroond_14_1h < 90.0))
          # 1h down move, 1h still high, 4h high
          short_entry_logic.append((rsi_3_1h_lt_40) | (aroond_14_1h_lt_50) | (stochrsi_k_4h_gt_10))
          # 1h down move, 1h high, 4h still high
          short_entry_logic.append((rsi_3_1h_lt_40) | (aroond_14_1h < 80.0) | (aroond_14_4h_lt_40))
          # 1h down move, 1h still high, 4h high
          short_entry_logic.append((rsi_3_1h_lt_40) | (stochrsi_k_1h_gt_60) | (aroond_14_4h_lt_70))
          # 1h down move, 1h & 1d high
          short_entry_logic.append((rsi_3_1h_lt_40) | (stochrsi_k_1h_gt_30) | (aroond_14_1d < 90.0))
          # 1h down move, 4h & 1d high
          short_entry_logic.append((rsi_3_1h_lt_40) | (rsi_14_4h_gt_30) | (rsi_14_1d > 20.0))
          # 4h down move, 15m high
          short_entry_logic.append((rsi_3_4h_lt_80) | (aroond_14_15m_lt_80))
          # 4h down move, 1h high
          short_entry_logic.append((rsi_3_4h_lt_75) | (stochrsi_k_1h_gt_20))
          # 4h down move, 1h & 4h still high
          short_entry_logic.append((rsi_3_4h < 65.0) | (stochrsi_k_1h_gt_50) | (aroond_14_4h_lt_50))
          # 4h down move, 15m & 1h high
          short_entry_logic.append((rsi_3_4h_lt_60) | (aroond_14_15m_lt_80) | (stochrsi_k_1h_gt_30))
          # 4h down move, 15m still high, 1h high
          short_entry_logic.append((rsi_3_4h_lt_60) | (stochrsi_k_15m_gt_60) | (stochrsi_k_1h_gt_20))
          # 4h down move, 1h still high, 4h still moving down
          short_entry_logic.append((rsi_3_4h_lt_60) | (stochrsi_k_1h_gt_50) | (cci_20_change_pct_4h_lt_0))
          # 4h down move, 1h high, 4h still high
          short_entry_logic.append((rsi_3_4h < 55.0) | (aroond_14_1h_lt_70) | (aroond_14_4h_lt_50))
          # 4h down move, 15m high, 4h still high
          short_entry_logic.append((rsi_3_4h_lt_50) | (aroond_14_15m_lt_70) | (stochrsi_k_4h_gt_60))
          # 4h down move, 15m still high, 1h high
          short_entry_logic.append((rsi_3_4h_lt_50) | (stochrsi_k_15m_gt_60) | (stochrsi_k_1h_gt_30))
          # 4h down move, 15m & 4h still high
          short_entry_logic.append((rsi_3_4h_lt_50) | (stochrsi_k_15m_gt_50) | (aroond_14_4h_lt_50))
          # 4h down move, 15m high, 4h still not low enough
          short_entry_logic.append((rsi_3_4h_lt_50) | (stochrsi_k_15m_gt_30) | (stochrsi_k_4h_gt_70))
          # 4h down move, 1h still high, 4h high
          short_entry_logic.append((rsi_3_4h_lt_50) | (stochrsi_k_1h_gt_50) | (aroond_14_4h_lt_70))
          # 4h down move, 15m & 4h high
          short_entry_logic.append((rsi_3_4h_lt_40) | (aroond_14_15m_lt_70) | (aroond_14_4h_lt_70))
          # 4h down move, 15m high, 4h still high
          short_entry_logic.append((rsi_3_4h_lt_40) | (aroond_14_15m_lt_80) | (aroond_14_4h_lt_40))
          # 4h down move, 15m still high, 4h high
          short_entry_logic.append((rsi_3_4h_lt_40) | (stochrsi_k_15m_gt_50) | (stochrsi_k_4h_gt_30))
          # 4h down move, 15m & 4h high
          short_entry_logic.append((rsi_3_4h_lt_40) | (stochrsi_k_15m_gt_30) | (stochrsi_k_4h_gt_40))
          # 4h down move, 1h & 4h high
          short_entry_logic.append((rsi_3_4h_lt_40) | (stochrsi_k_1h_gt_30) | (aroond_14_4h_lt_70))
          # 4h down move, 4h still high, 1d high
          short_entry_logic.append((rsi_3_4h_lt_40) | (stochrsi_k_4h_gt_50) | (stochrsi_k_1d_gt_20))
          # 15m high, 4h high
          short_entry_logic.append((aroond_14_15m_lt_70) | (aroond_14_4h_lt_85))
          # 15m high, 4h still high
          short_entry_logic.append((aroond_14_15m_lt_80) | (stochrsi_k_4h_gt_50))
          # 15m high, 1h still high
          short_entry_logic.append((stochrsi_k_15m_gt_30) | (stochrsi_k_1h_gt_60))
          # 15m & 4h high
          short_entry_logic.append((stochrsi_k_15m_gt_30) | (aroond_14_4h_lt_70))
          # 15m high, 1h still not low enough
          short_entry_logic.append((stochrsi_k_15m > 20.0) | (stochrsi_k_1h_gt_70))

          # Logic
          short_entry_logic.append(rsi_14 > 50.0)
          short_entry_logic.append(aroond_14_15m < 90.0)
          short_entry_logic.append(stochrsi_k_15m > 10.0)
          if not np.isnan(sma_200[-1]):
            short_entry_logic.append(sma_21_shift_1 > sma_200_shift_1)
            short_entry_logic.append(sma_21 < sma_200)
          else:
            short_entry_logic.append(np.full(len(df), False))
          if not np.isnan(ema_200_1h[-1]):
            short_entry_logic.append(close < ema_200_1h)
          else:
            short_entry_logic.append(np.full(len(df), False))
          if not np.isnan(ema_200_4h[-1]):
            short_entry_logic.append(close < ema_200_4h)
          else:
            short_entry_logic.append(np.full(len(df), False))
          short_entry_logic.append(bbb_20_2_0_1h > 4.0)

        ###############################################################################################

        # SHORT ENTRY CONDITIONS ENDS HERE

        ###############################################################################################

        # Condition #662 - 4h opening-range fakeout (Short, experimental).
        if short_entry_condition_index == 662:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          # don't fade an upside break out of a washed 4h with money outflow (that break is a real reversal rally)
          short_entry_logic.append((stochrsi_k_4h > 50.0) | (cmf_20_4h > -0.05))
          # prev 5m candle CLOSED above the day's first-4h range high; current closes back INSIDE
          short_entry_logic.append(np_shift(close, 1) > orange_h)
          short_entry_logic.append(close < orange_h)
          short_entry_logic.append(close > orange_l)

        # Condition #663 - Fib golden-pocket continuation (Short, experimental, protected).
        if short_entry_condition_index == 663:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          short_entry_logic.append(
            # Mar/May fast break in 4h trend: +DI4h >= 15, ROC2_4h >= -4, RSI change <= -12; need relief
            ((rsi_14_change_pct > -12) | (plus_di_14_4h < 15) | (roc_2_4h < -4))
            # Aug/Dec no-flow bounce: Aroon-up1h >= 30, CMF15m <= -0.05, WILLR15m <= -35; need one escape
            & ((cmf_20_15m > -0.05) | (willr_14_15m > -35) | aroonu_14_1h_lt_30)
            # Sep/Dec outflow bounce: 1h Aroon-up >= 20, CMF <= -0.15, RSI surge >= 20; need one escape
            & (aroonu_14_1h_lt_20 | (cmf_20_1h > -0.15) | (rsi_14_change_pct_1h < 20))
            # Dec-20 crash rebound: 4h ROC <= -14, 1h RSI acceleration >= 50; need either side softer
            & ((rsi_14_change_pct_1h < 50) | (roc_2_4h > -14))
          )

          # Logic
          short_entry_logic.append(ema_12_4h < ema_200_4h)
          # R1 (eyeball): only a clean active downtrend
          short_entry_logic.append(rsi_14_4h < 45.0)
          short_entry_logic.append(aroond_14_4h > 70.0)
          # R1: anti-capitulation mirror
          short_entry_logic.append(roc_9_1d > -30.0)
          _fib_high_wick_663 = ta.MAX(high_px, timeperiod=48)
          _fib_low_wick_663 = ta.MIN(low_px, timeperiod=48)
          _fib_high_index_663 = ta.MAXINDEX(high_px, timeperiod=48)
          _fib_low_index_663 = ta.MININDEX(low_px, timeperiod=48)
          _fib_ordered_663 = np.where(_fib_high_index_663 < _fib_low_index_663, 1.0, 0.0)
          _fib_rng_663 = _fib_high_wick_663 - _fib_low_wick_663
          _fib_retr_663 = (close - _fib_low_wick_663) / _fib_rng_663
          _fib_retr_prev_663 = np_shift(_fib_retr_663, 1)
          short_entry_logic.append(_fib_rng_663 > (_fib_low_wick_663 * 0.04))
          # The engulfing candle closes back through the wick-anchored pocket's 0.618 edge.
          short_entry_logic.append(_fib_ordered_663 > 0.5)
          short_entry_logic.append(_fib_retr_prev_663 >= 0.618)
          short_entry_logic.append(_fib_retr_prev_663 <= 0.786)
          short_entry_logic.append(_fib_retr_663 >= 0.5)
          short_entry_logic.append(_fib_retr_663 < 0.618)
          short_entry_logic.append(engulf_bear > 0.5)

        # Condition #664 - Squeeze Momentum release (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 664:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(np_shift(sqz_on, 1) > 0.5)
          short_entry_logic.append(sqz_on < 0.5)
          short_entry_logic.append(np_shift(sqz_cnt_24, 1) >= 12.0)
          # expansion direction: close breaks through the lower band
          short_entry_logic.append(close < bbl_20_2_0)

        # Condition #665 - Engulfing continuation (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 665:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          short_entry_logic.append(
            # daily money flowing in and 4h not oversold
            ((cmf_20_1d > 0.05) | (rsi_14_4h_lt_40))
            # 5m money flowing in and 1h money flowing in
            # 15m volume flow rising, 4h not extended and 5m stochastic high
            & ((stochrsi_k < 50) | (obv_change_pct_15m < 7) | (cci_20_4h < 105))
            # None
            & ((stoch_4_4 < 45) | (change_pct_1h < 0.5) | (rsi_3_change_pct_1d < -25))
            # 1h the two-day window off its floor, 5m stochastic high and daily stochastic high
            & ((stoch_9_3 < 30) | (willr_84_1h < -20) | (stochrsi_k_1d < 85))
            # the last 24h fell hard and the 4h cycle is turning up
            & ((roc_288 > -11.0) | (cci_20_change_pct_4h < -10.0))
            # money leaving on 5m and on 1h
            & ((mfi_14 < 30) | (mfi_14_1h < 40))
            # 15m high in its range, 5m money drained and daily a recent low
            & ((mfi_14 > 10) | (willr_14_15m < -65) | (aroond_14_1d < 10))
            # 15m falling, 5m money flowing in and 1h a recent low
            & ((mfi_14 < 50) | (roc_9_15m > -6) | (aroond_14_1h < 95))
            # 4h oscillator low, 5m money leaving and a recent low
            & ((cmf_20 > -0.4) | (aroond_14_4h < 90) | (uo_7_14_28_4h > 35))
            # None
            & ((cmf_20 > -0.4) | (mfi_14_1h < 30) | (uo_7_14_28_4h > 35))
            # daily momentum snapping up, 5m volume flow falling and 4h oversold
            & ((obv_change_pct > -0.5) | (rsi_14_4h > 35) | (rsi_3_change_pct_1d < 190))
            # below-average volume and 1h momentum alive
            & ((vol_rel > 1.25) | (rsi_3_1h < 20))
            # daily a long upper wick, 5m a volume spike and no recent low
            & ((vol_rel < 4.5) | (aroond_14_1d > 5) | (top_wick_pct_1d < 8))
            # 15m oscillator low, 5m a new high and 1h money drained
            & ((aroonu_14 < 45) | (uo_7_14_28_15m > 30) | (mfi_14_1h > 40))
            # 15m money flowing in, 5m a new high and 1h money drained
            & ((aroonu_14 < 65) | (mfi_14_15m < 55) | (mfi_14_1h > 30))
            # 5m money flowing in, a new high and daily stochastic at the floor
            & ((aroonu_14 < 65) | (cmf_20 < 0.1) | (stochrsi_k_1d > 50))
            # 5m no recent low, daily oversold and 15m stochastic at the floor
            & ((aroond_14 > 40) | (rsi_14_1d > 35) | (stochrsi_k_15m_gt_40))
            # 5m oversold, no recent low and 4h a trend established
            & ((aroond_14 > 85) | (rsi_4 > 10) | (adx_14_4h < 25))
            # 1h momentum rising, 5m fast stochastic high and high in its base
            & ((ph_base_pos < 1.5) | (stoch_4_4 < 50) | (rsi_14_change_pct_1h < 5))
            # 4h at an extreme low, 5m a tight pre-break coil and a new high
            & ((ph_pre_tight < 6) | (aroonu_14_4h < 15) | (cci_20_4h > -225))
            # None
            & ((ph_pre_tight < 5) | (obv_change_pct_15m < 8) | (rsi_3_1h > 10))
            # 5m not oversold, the coil's roof low and 1h stochastic at the floor
            & ((quad_s93_max_12 > 30) | (rsi_4 < 25) | (stochrsi_k_1h > 20))
            # 5m not oversold, the coil's roof low and 4h a recent low
            & ((quad_s93_max_12 > 30) | (rsi_4 < 30) | (aroond_14_4h < 55))
            # 15m momentum falling, daily momentum snapping up and 1h a recent low
            & ((rsi_14_change_pct_15m > -25) | (aroond_14_1h < 55) | (rsi_3_change_pct_1d < 190))
            # 15m stochastic high, 4h high in its range and no recent low
            & ((stochrsi_k_15m < 75) | (aroond_14_4h > 5) | (willr_14_4h < -50))
            # 15m stochastic high, oscillator falling and daily not oversold
            & ((stochrsi_k_15m < 75) | (uo_7_14_28_change_pct_15m > -15) | (rsi_14_1d < 45))
            # 15m at the floor of its range, stochastic high and daily money flowing in
            & ((stochrsi_k_15m < 55) | (willr_14_15m > -95) | (mfi_14_1d < 70))
            # 15m at an extreme low, 1h not extended and daily no recent low
            & ((cci_20_15m > -275) | (cci_20_1h < 20) | (aroond_14_1d > 30))
            # 15m money flowing in, 4h downtrend weak and oscillator lifting
            & ((cmf_20_15m_lt_0_10) | (minus_di_14_4h > 25) | (uo_7_14_28_change_pct_15m < 5))
            # 15m money leaving, a new high and 1h no recent low
            & ((aroonu_14_15m < 65) | (cmf_20_15m > -0.3) | (aroond_14_1h > 30))
            # 15m oversold, a new high and daily a recent low
            & ((aroonu_14_15m < 65) | (rsi_14_15m > 20) | (aroond_14_1d < 10))
            # 4h no trend established, not falling and 15m a new high
            & ((aroonu_14_15m < 25) | (adx_14_4h > 20) | (roc_9_4h < 6))
            # 1h high in its range, stochastic at the floor and daily a recent low
            & ((stochrsi_k_1h > 20) | (willr_14_1h < -45) | (aroond_14_1d < 45))
            # 1h stochastic at the floor, 4h momentum snapping up and daily not falling
            & ((stochrsi_k_1h > 20) | (rsi_3_change_pct_4h < 115) | (roc_9_1d < -10))
            # 1h at an extreme low and daily a long lower wick
            & ((cci_20_1h > -175.0) | (bot_wick_pct_1d < 3))
            # 1h not extended, 4h momentum dead and daily not falling
            & ((cci_20_1h < -5) | (rsi_3_4h_gt_30) | (roc_2_1d < -2.0))
            # None
            & ((cci_20_1h > -175) | (willr_84_1h < -20) | (adx_14_4h < 20))
            # 1h money drained, cycle falling and daily no new high
            & ((cci_20_change_pct_1h > -240) | (mfi_14_1h > 30) | (aroonu_14_1d > 40))
            # None
            & ((cci_20_change_pct_1h > -240) | (mfi_14_1h > 25) | (adx_14_4h < 20))
            # 1h money drained, stochastic high and daily no new high
            & ((mfi_14_1h > 25) | (stochrsi_k_1h < 80) | (aroonu_14_1d > 5))
            # 1h a new high, at an extreme low and daily a new high
            & ((aroonu_14_1h < 80) | (cci_20_1h > -300) | (aroonu_14_1d < 5))
            # 1h a recent low, falling and stochastic high
            & ((aroond_14_1h < 80) | (roc_9_1h > -7) | (stochrsi_k_1h_lt_30))
            # 1h no recent low, 4h money drained and daily no recent low
            & ((aroond_14_1h > 20) | (mfi_14_4h > 25) | (aroond_14_1d > 5))
            # the two-day window off its floor and tightly squeezed
            & ((willr_84_1h < -75) | (sqz_cnt_24 < 10))
            # 4h momentum alive and stochastic turning up
            & ((rsi_3_4h < 65) | (stochrsi_k_change_pct_4h < 5))
            # 4h momentum falling and daily no upper wick
            & ((rsi_14_change_pct_4h > -15.0) | (top_wick_pct_1d > 1.5))
            # 4h momentum rising, a long upper wick and daily money leaving
            & ((rsi_14_change_pct_4h < 10) | (top_wick_pct_4h < 2.5) | (cmf_20_1d > 0.05))
            # 4h falling, daily momentum alive and a recent low
            & ((roc_9_4h > -10) | (aroond_14_1d < 10) | (rsi_3_1d < 85))
            # 4h money flowing in and high in its range
            & ((mfi_14_4h < 55) | (willr_14_4h > -40))
            # 4h money leaving and 1h at the floor of its range
            & ((cmf_20_4h > -0.05) | (willr_14_1h < -75))
            # 4h oscillator low, daily stochastic high and money flowing in
            & ((cmf_20_4h < -0.05) | (uo_7_14_28_4h > 35) | (stochrsi_k_1d < 90))
            # 4h money flowing in, at the floor of its range and daily no recent low
            & ((cmf_20_4h < 0.2) | (willr_14_4h > -80) | (aroond_14_1d > 20))
            # 4h a trend established, money flowing in and 5m falling
            & ((adx_14_4h < 40) | (cmf_20_4h_lt_0_15) | (roc_9 > -2))
            # 4h no trend established and stochastic falling hard
            & ((adx_14_4h > 20) | (stochrsi_k_change_pct_4h > -70.0))
            # 4h stochastic at the floor, daily momentum alive and a trend established
            & ((adx_14_4h < 20) | (stochk_14_3_3_4h > 25) | (rsi_3_1d < 90))
            # 4h oscillator low, daily stochastic high and no new high
            & ((aroonu_14_4h > 10) | (uo_7_14_28_4h > 35) | (stochrsi_k_1d < 70))
            # 4h no recent low and money flowing in
            & ((aroond_14_4h > 5) | (cmf_20_4h < 0.05))
          )

          # Logic
          short_entry_logic.append(
            # a bearish engulfing inside a downtrend, in the lower half of the range
            (close < ema_200) & (rsi_14 < 50.0) & (willr_14 < -50.0) & (rsi_3_15m < 45.0) & (engulf_bear > 0.5)
          )

        # Condition #666 - Swing-failure pattern (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 666:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          # prior 48-candle high swept by the wick, candle closes back below it
          short_entry_logic.append(sfp_bear > 0.5)

        # Condition #667 - 1h inside-bar breakout (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 667:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(close < ema_200)
          # don't short a breakdown when the daily cycle already sits low (bounce zone)
          short_entry_logic.append(stochrsi_k_1d < 48.0)
          # last completed 1h candle was an inside bar; this 5m candle CROSSES below the mother low
          short_entry_logic.append(ib_ready > 0.5)
          short_entry_logic.append(np_shift(close, 1) >= ib_mother_l)
          short_entry_logic.append(close < ib_mother_l)
        # Condition #669 - Dump hunter (Short, experimental, RAW — crash ignition, mirror of 171).
        if short_entry_condition_index == 669:
          # Protections
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)

          short_entry_logic.append(
            # --- 5m: no room left below, and the break candle itself
            (rsi_3 > 0.4)
            # base momentum is not spent while the 4h has already given way: selling after the
            # move, not into it
            & ((rsi_3 < 20.0) | (rsi_4 > 25.0) | rsi_3_4h_gt_15)
            # the base RSI is not low, the 4-period RSI is not washed and the base stochastic is
            # off zero: the fast timeframe has nothing left to give (3 losses, free everywhere)
            & ((rsi_14 > 25.0) | (rsi_4 < 10.0) | (stochrsi_k > 0.0))
            # 4h strong with clearly positive 4h money flow: that is shorting a healthy uptrend
            # (ARPA -6,334 + 1 more; the only one of the late chains that also pays in 2022)
            & (rsi_14_4h_lt_50 | cmf_20_4h_lt_0_15)
            # 4h: just printed a high, or money flow still rich (DODOX -3314 at AROONU_14_4h 78.6)
            & aroonu_14_4h_lt_50
            # a fully washed 4h on a pair whose DAILY has just printed a high: that is a dip inside
            # a strong uptrend, not a breakdown. Blocked trades average -3.5% in the 2021 bull and
            # +1.4% in 2026 (well under the tag average), so it costs nothing and saves the bull
            & (stochrsi_k_4h_gt_10 | aroonu_14_1d_lt_85)
            # price is not pinned at the very floor of its 40h range — there has to be room left below
            & (willr_480 > -99.5)
            # the base has a position at all: a dead-flat base is not a breakdown
            & (ph_base_pos > 0.03)
            # something was coiled before the break; a break out of nothing has nothing behind it
            & (ph_pre_tight > 0.4)
            # a tight pre-break hour blown apart by a volume spike: the move is the spike itself
            & ((ph_pre_tight > 0.8) | (vol_rel < 10.0))
            # the base has not been squeezed for the whole day — that is a range, not a setup
            & (sqz_cnt_24 < 23.0)
            # a bearish engulfing while the DAILY is making highs and strong is a pullback inside
            # an uptrend, not a breakdown. In the 2021 bull the blocked group averages -7.2%
            # against a +0.2% population; in 2026/2022 it touches three trades in total
            & ((engulf_bear < 0.5) | aroonu_14_1d_lt_70 | rsi_14_1d_lt_60)
            # --- 15m: the fast timeframe has to confirm the break
            # a 15m stuck at its low that has not made a new low, entered from above the 24h base
            # (RUNE -29,002; 0W/1L | 2W/1L | 3W/2L)
            & (rsi_3_1h_lt_55 | (aroond_14_15m < 100.0) | (ph_base_pos < 0.5))
            & (rsi_14_15m > 17.0)
            # the 15m selling is spent while the 4h RSI is nowhere near washed (ADA -20,094)
            & (rsi_14_4h_gt_20 | (cci_20_change_pct_15m < 100.0) | rsi_3_15m_gt_20)
            # no fresh 15m low, base and 15m money flow both drained, and the 12-candle high sits
            # near the top of its range: sold out into a market that just topped (5 losses)
            & ((mfi_14 < 35.0) | (mfi_14_15m < 30.0) | (quad_s93_max_12 > 60.0))
            # 4h and 1h both printing highs while the 15m RSI is not falling (LINK -20,140;
            # 1W/0L | 1W/1L | 0W/2L)
            & (aroonu_14_4h_lt_40 | aroonu_14_1h_lt_70 | (rsi_14_change_pct_15m > -10.0))
            # the 15m stochastics are both on the floor after a long coil: the fast
            # timeframe is already spent when the break prints
            & ((stochrsi_k_15m > 0.0) | (sqz_cnt_24 < 18.0) | (stochk_14_3_3_15m > 10.0))
            # the 15m is already deep in its own range while its oscillator holds up: no leg left
            # to sell (INJ -1,844; 0W/1L | 0W/0L | 0W/1L)
            & ((quad_s93_min_12 < 15.0) | (uo_7_14_28_15m > 35.0) | (rsi_14_15m < 25.0))
            # the 15m has already been sold off hard and the base oscillator has not confirmed
            # (SAND 2021 -822,676; 0W/0L | 1W/1L | 0W/1L)
            & ((cci_20_change_pct_15m > -1200.0) | rsi_14_15m_lt_40 | (aroond_14_15m < 100.0))
            # the 15m momentum has already collapsed and volume is coming back in: the flush is
            # over (SOL -2,739; 0W/0L | 0W/0L | 1W/3L)
            & ((cci_20_change_pct_15m > -850.0) | (willr_14_15m > -95.0) | (obv_change_pct_15m > 1.0))
            # the base is pinned at its 14-bar low while the 15m stochastic is still high:
            # the low is already in and the fast timeframe has not confirmed it
            & ((willr_14 > -100.0) | (stochk_14_3_3_15m < 60.0))
            # a dead 15m oscillator under a huge volume spike = climax, not a leg down
            & ((uo_7_14_28_15m > 30.0) | (vol_rel < 10.0))
            # the 15m oscillator is not surging: the fast timeframe must not be turning up
            & (uo_7_14_28_change_pct_15m < 10.0)
            # volume leaving on the 15m while the hour has just printed a high (BERA -2,049;
            # 0W/1L | 0W/2L | 0W/1L)
            & ((obv_change_pct > -15.0) | aroonu_14_1h_gt_20 | (uo_7_14_28_change_pct_15m < -10.0))
            # volume leaving on the 15m while the day is dropping hard, the base RSI is low and
            # the 15m oscillator is off its floor: selling the end of a move (5 losses)
            & ((obv_change_pct_15m > 0.0) | (rsi_20 < 35.0) | stochrsi_k_15m_gt_20)
            # a long coil whose base stochastic has been high while the 15m collapses: the
            # break is the end of the coil, not the start of a move
            & ((sqz_cnt_24 < 20.0) | (quad_s93_max_12 > 50.0) | (rsi_3_15m < 10.0))
            # --- 1h: the hour must not already be turning back up
            # the 5m is not really selling and the hour is flat: nothing to ride
            & ((rsi_3 < 15.0) | (roc_9_1h < -0.25))
            # the hour is rising into the break — momentum high, the candle green and the hourly RSI mid-
            # range: selling a move that has not turned
            & ((rsi_3_1h < 65.0) | (change_pct_1h < 0.5) | (rsi_14_1h < 50.0))
            # the base ROC still falling while the 15m momentum holds up, the hourly oscillator
            # is mid-band and price sits high in the hour's range: no leg underneath (5 losses)
            & ((rsi_3_change_pct_15m > -50.0) | stochrsi_k_1h_lt_60 | (willr_14_1h > -75.0))
            # hourly RSI_3 snapping up on a falling candle with 15m money flow still neutral
            # (BTC -23,817; 0W/1L | 1W/1L | 0W/0L)
            & ((rsi_3_change_pct_1h < 740.0) | (roc_2 < -1.5) | (cmf_20_15m > -0.05))
            # the base is not oversold, the 15m stochastic is off its floor and the hour has
            # not rolled over: nothing is confirming the break
            & ((rsi_14 < 30.0) | (stochrsi_k_15m > 0.0) | (stochk_14_3_3_1h > 25.0))
            # the base RSI is on its floor while the base stochastic is mid-range and the hour is dead: a
            # stalled flush
            & ((rsi_14 > 20.0) | (stoch_9_3 < 35.0) | (rsi_3_1h > 5.0))
            # the base is not oversold, base money flow has not turned negative and the
            # hour is far from its low: selling with the move not yet under way
            & ((rsi_14 > 25.0) | (cmf_20 < -0.1) | (willr_14_1h < -70.0))
            # the 15m is not washed out, the hour is not oversold and hourly money flow is
            # still positive: selling before anything has given way
            & ((rsi_14_15m > 20.0) | (rsi_14_1h < 35.0) | (mfi_14_1h > 40.0))
            # hourly oversold while price is nowhere near its 40h low: the sell-off is paid for
            # and what is left is the bounce (EIGEN -6,312, BERA -6,235)
            & ((rsi_14_1h > 40.0) | (willr_480 < -85.0))
            # high-volume break into an hour that has already recovered = squeeze fuel
            # (NAORIS -5,028, ARB -4,918, SAND -4,261)
            & (rsi_14_1h_lt_40 | (vol_rel < 6.0) | (mfi_14_1h < 30.0))
            # the base momentum barely moved and the hour is not really rolling over:
            # a break with no acceleration behind it
            & ((rsi_14_change_pct < -20.0) | (aroonu_14 > 0.0) | (rsi_3_change_pct_1h < 40.0))
            # base money flow is not draining, the hourly momentum has not really given way
            # and the hour is off its floor: the sellers are not there yet
            & ((cmf_20 > -0.25) | (rsi_3_change_pct_1h < 60.0) | (willr_14_1h > -85.0))
            # hourly money flow still neutral while the hour is no longer falling and the 5m is
            # not washed: nothing is actually selling (3 losses, free in all three years)
            & ((cmf_20_1h > -0.05) | (roc_9_1h < 0.0) | rsi_3_gt_5)
            # money flow is intact on both the base and the hour while the hour is off its
            # low: selling into a market that is not under pressure
            & ((mfi_14 > 15.0) | (mfi_14_1h > 25.0) | (willr_14_1h < -70.0))
            # 15m money flow still rich while the hour is red and the 4h has already dropped:
            # buyers are underneath the break (6 losses, all in 2022)
            & ((mfi_14_15m > 35.0) | rsi_3_4h_gt_10 | (change_pct_1h < 0.0))
            # hourly money flow is not rich — buyers should not be in control of the hour
            & (mfi_14_1h < 50.0)
            # hourly money flow drained while price sits high in its own range = exhausted seller
            & ((mfi_14_1h > 20.0) | (willr_14_1h < -75.0))
            # the 15m stochastic pinned at zero with hourly money flow drained and the 15m no
            # longer falling: the flush already happened (6 losses, mostly 2021)
            & ((mfi_14_1h > 25.0) | (roc_9_15m > -3.0) | (stochrsi_k_15m > 0.0))
            # no fresh 15m low while the 4h low is recent, hourly CCI already recovering and the
            # 15m RSI not low: the 15m has finished its leg (4 losses, free in all three years)
            & (aroond_14_15m_lt_80 | (cci_20_1h > -175.0) | rsi_14_15m_lt_35)
            # 4h near its low, its oscillator back up, hourly off its own low
            # (NAORIS -5,539 on 2026-04-18: AROOND_14_4h 85.7, STOCHRSIk_4h 92.0, WILLR_14_1h -70.2)
            & (aroond_14_4h_lt_80 | stochrsi_k_4h_lt_40 | (willr_14_1h < -85.0))
            # 4h near its low while the 1h has just printed a high and its oscillator is above
            # mid-band: the leg down is finished (AVAX -16,736; thresholds picked on 2026+2022)
            & (aroond_14_4h_lt_80 | aroonu_14_1h_lt_40 | (uo_7_14_28_1h < 50.0))
            # the hourly CCI has collapsed while the 15m momentum is still alive and its oscillator rich
            & ((cci_20_1h > -300.0) | (rsi_3_15m < 35.0) | (uo_7_14_28_15m < 50.0))
            # the hourly CCI is exploding upward while OBV drains on both the base and the 15m
            & ((cci_20_change_pct_1h < 250.0) | (obv_change_pct > 0.0) | (obv_change_pct_15m > 0.0))
            # the hourly CCI has not exploded upward
            & (cci_20_change_pct_1h < 500.0)
            # the hourly oscillator is rich while every base RSI is elevated: nothing is oversold to sell
            & ((uo_7_14_28_1h < 55.0) | (rsi_14 < 35.0) | (rsi_3 < 15.0))
            # the hourly oscillator is rich, the 15m CCI has exploded and the base stochastic is on its
            # floor
            & ((uo_7_14_28_1h < 55.0) | (cci_20_change_pct_15m < 250.0) | (stoch_4_4 > 5.0))
            # the 15m oscillator is turning up, the base sits on its floor and the hourly CCI is washed out
            & ((uo_7_14_28_change_pct_15m < 5.0) | (ph_base_pos > 0.1) | (cci_20_1h > -250.0))
            # the hour itself is not rising into the break
            & (roc_2_1h < 0.5)
            # the 15m is not falling, the 4h stochastic is maxed and the hour is not pinned:
            # the break is a spike inside a market still holding up
            & ((roc_9_15m < -1.0) | (willr_14_1h > -90.0) | stochrsi_k_4h_lt_90)
            # the 15m has dropped but its RSI is not low, price is pinned at the 15m floor and
            # the hour is flat: the move already happened on the fast timeframe (5 losses)
            & ((roc_9_15m < -2.5) | (willr_14_15m < -75.0) | (change_pct_1h > -1.5))
            # shorting a small red candle while the 15m has not really broken down and the
            # hour is only mildly negative: no conviction behind the break
            & ((change_pct < -0.4) | (rsi_14_change_pct_15m > -30.0) | (roc_2_1h < -2.0))
            # --- 4h: the higher timeframe carries the move — it must not be washed out
            # the 4h has not been pushed to an extreme, its momentum is only mildly down and
            # its stochastic is mid-range: the higher timeframe has not committed
            & ((rsi_3_4h < 45.0) | (stochk_14_3_3_4h < 40.0) | (cci_20_4h > -75.0))
            # the 4h sits at its own high, stochastic and CCI both up there: there is no exhaustion above to
            # sell into
            & ((rsi_3_4h < 85.0) | (stochk_14_3_3_4h < 70.0) | (cci_20_4h < 50.0))
            # 4h momentum is dead, the pair has not fallen over the rolling day and the 15m
            # is still alive: selling a 4h low in a market that never dropped
            & ((rsi_3_4h > 5.0) | (roc_288 < -3.0) | (rsi_3_15m < 30.0))
            # shorting into a violent hourly bounce while the base is washed out and the 4h
            # has barely fallen: the break is being bought back
            & ((rsi_14 < 30.0) | (rsi_3_change_pct_1h < 250.0) | (change_pct_4h > -1.5))
            # hourly RSI mid-range while the 4h momentum has collapsed but the 15m has not
            # confirmed: the fast timeframe is not selling (UNI -10,291; 2W/0L | 2W/0L | 0W/1L)
            & (rsi_14_1h_lt_50 | (rsi_3_change_pct_4h > -30.0) | (rsi_3_change_pct_15m < -60.0))
            # the 15m RSI barely moved, the 4h momentum has not given way and the base has
            # been coiled for a while: a break out of a quiet base with nothing behind it
            & ((rsi_14_change_pct_15m > -30.0) | (rsi_3_change_pct_4h > -60.0) | (sqz_cnt_24 < 12.0))
            # the hourly turning up hard while price sits high in its 84-candle range: the 4h RSI
            # is rising as we sell (APR -14,372, our largest 2026 loss; 2W/1L | 1W/2L | 0W/1L)
            & ((rsi_14_change_pct_4h < 6.0) | stochrsi_k_1h_lt_60 | (willr_84_1h < -70.0))
            # the 4h RSI is not jumping: the higher timeframe must not be recovering
            & (rsi_14_change_pct_4h < 8.0)
            # the pair has not fallen over the rolling day, the base is not oversold and the
            # 4h oscillator is still rich: a break with the trend untouched
            & ((rsi_20 < 30.0) | (roc_288 > -5.0) | (uo_7_14_28_4h < 55.0))
            # money is flowing into the base, OBV is rising and the 4h sits high: nothing is breaking down
            & ((cmf_20 < 0.05) | (obv_change_pct < 5.0) | (stochk_14_3_3_4h < 65.0))
            # money is entering the base, the 4h candle is green and the base stochastic is mid-range
            & ((cmf_20 < 0.05) | (change_pct_4h < 0.0) | (stoch_9_3 < 25.0))
            # base money has already left, the 4h stochrsi is on its floor and the 4h oscillator is low
            & ((cmf_20 > -0.3) | (stochrsi_k_4h > 5.0) | (uo_7_14_28_4h > 40.0))
            # 5m selling stalled and the 15m oscillator snapping back up under the break (XMR
            # -2,340; 0W/1L | 0W/1L | 0W/1L)
            & ((cmf_20_1h > -0.25) | (rsi_3_change_pct_15m > -70.0) | (stochrsi_k_change_pct_4h > -40.0))
            # money is flowing into the 4h and the base stochastic has just been at its ceiling
            & ((cmf_20_4h < 0.15) | (quad_s93_max_12 < 95.0) | (stochk_14_3_3_4h > 15.0))
            # 4h money flow clearly positive while the 4h is pinned at its low = accumulation at
            # the bottom, not a breakdown (AVAX -6,879; 1W/1L | 0W/2L | 1W/1L)
            & (cmf_20_4h_lt_0_15 | (willr_14_4h > -90.0) | (rsi_3_change_pct_4h > -40.0))
            # 15m money flow is not exhausted, the 15m RSI has barely dropped and the 4h
            # stochastic is turning back up: the flush is already being bought
            & ((mfi_14_15m > 10.0) | (rsi_14_change_pct_15m > -15.0) | (stochrsi_k_change_pct_4h < 10.0))
            # hourly money flow drained, 4h already down hard, and the base timeframe printing a
            # high (SOON -2,118; 2W/1L | 2W/3L | 3W/3L)
            & ((mfi_14_1h > 10.0) | (roc_9_4h > -4.0) | (aroonu_14 > 30.0))
            # 4h money flow is rich, the 15m stochastic is mid-range and its CCI has jumped: no capitulation
            # here
            & ((mfi_14_4h < 50.0) | (stochk_14_3_3_15m < 50.0) | (cci_20_change_pct_15m < 300.0))
            # 4h money flow is not rich either
            & (mfi_14_4h < 55.0)
            # 4h money is drained and the bands are flat, yet the base never printed a low: nothing has
            # broken
            & ((mfi_14_4h > 20.0) | (quad_s93_min_12 < 10.0) | (willr_84_1h > -95.0))
            # the 15m has not turned down, 15m money flow is still healthy and the 4h is
            # not draining: a break with nothing behind it on the fast timeframes
            & (aroonu_14_15m_lt_70 | (mfi_14_15m > 35.0) | (cmf_20_4h > -0.2))
            # 4h already recovering off a pair that has fallen hard over the day, while the 4h
            # itself is no longer in a live down-leg
            & (aroonu_14_4h_lt_30 | (roc_288 > -7.0) | (cci_20_4h < -125.0))
            # 4h at its 14-period low and the 5m selling already stopped
            # (PLAY -16,653 on 2026-07-04: AROOND_14_4h 100 with RSI_3 20.8)
            & ((aroond_14_4h < 100.0) | (rsi_3 < 15.0))
            # the low printed on BOTH 4h and 15m right now, money flow above neutral
            # (CLANKER -4,785 on 2026-04-29)
            & ((aroond_14_4h < 100.0) | (aroond_14_15m < 100.0) | (mfi_14_1h < 40.0))
            # the 4h is high on stochrsi while the hourly CCI has collapsed underneath it
            & ((stochrsi_k_4h < 80.0) | (cci_20_change_pct_1h > -400.0) | (roc_2 < -0.5))
            # the 4h stochrsi is near its ceiling, hourly money is coming in and the 4h has no downward
            # direction
            & ((stochrsi_k_4h < 85.0) | (cmf_20_1h < 0.05) | (plus_di_14_4h > 10.0))
            # the 4h stochrsi sits at zero while 15m money flow and the 15m oscillator both turn up
            & ((stochrsi_k_4h > 5.0) | (cmf_20_15m < 0.05) | (uo_7_14_28_change_pct_15m < 0.0))
            # the 4h oscillator has stopped falling, the 4h low is not fresh, and the hourly
            # oscillator is already at the floor (SOL 2021 -815,130; 1W/0L | 3W/0L | 0W/4L)
            & ((stochrsi_k_change_pct_4h < 10.0) | (aroond_14_4h > 20.0) | stochrsi_k_1h_lt_30)
            # 4h: turning back up under the break (KOMA -2725, DODOX -2051, CLANKER -1850)
            & (stochrsi_k_change_pct_4h < 25.0)
            # the 4h is at its ceiling on every measure — stochastic, money flow and williams
            & ((stochk_14_3_3_4h < 75.0) | (mfi_14_4h < 50.0) | (willr_14_4h < -30.0))
            # recovering. Floor already washed out (PLAY -1785 at 7.11, ALCH -1159 at 5.19)
            & (stochk_14_3_3_4h > 12.0)
            # the 4h is on its own floor — stochastic at the low, money flow drained and williams pinned:
            # the break has nothing left underneath it
            & ((stochk_14_3_3_4h > 15.0) | (mfi_14_4h > 25.0) | (willr_14_4h > -95.0))
            # the 4h stochastic is on its floor and the hour's momentum has already collapsed: the break is
            # late
            & ((stochk_14_3_3_4h > 15.0) | (rsi_14_change_pct_1h > -20.0) | (roc_2 < -0.5))
            # the 4h stochastic is on its floor with no trend strength while the 4h itself ticks up
            & ((stochk_14_3_3_4h > 15.0) | (adx_14_4h > 15.0) | (roc_2_4h < 0.0))
            # base stochastic high, 4h RSI rising and the 15m oversold: selling into a
            # market that has already turned back up
            & ((stoch_4_4 < 40.0) | (rsi_14_change_pct_4h < 4.0) | (rsi_14_15m > 30.0))
            # the hourly CCI has exploded, money is entering the base and the 4h stochrsi is near its
            # ceiling
            & ((cci_20_change_pct_1h < 350.0) | (cmf_20 < 0.05) | (stochrsi_k_4h < 85.0))
            # hourly CCI collapsing into a base oscillator that is already low, on a 4h that has
            # not made a recent low (DOT -26,460; 0W/0L | 0W/1L | 0W/0L)
            & ((cci_20_change_pct_1h > -475.0) | (stochrsi_k < 40.0) | (aroond_14_4h < 60.0))
            # no 4h high behind it, 4h CCI still climbing, directional strength weak and the base
            # RSI already low: selling a market with no down-leg to give
            & ((cci_20_change_pct_4h < 200.0) | (plus_di_14_4h < 20.0) | (rsi_20 < 35.0))
            # 4h momentum has not turned over on any reading — CCI still rising, neither the 15m
            # nor the 4h RSI falling, and the 4h oscillator above mid-band
            & ((cci_20_change_pct_4h < 200.0) | (rsi_14_change_pct_4h > -18.0) | stochrsi_k_4h_lt_60)
            # 4h CCI collapsing into a washed 4h RSI_3 with the 4h stochastic still elevated:
            # the down-leg is spent (APR -2,531; 0W/1L | 0W/1L | 0W/1L)
            & ((cci_20_change_pct_4h > -600.0) | rsi_3_4h_gt_10 | (stochk_14_3_3_4h < 35.0))
            # the 15m williams is at the absolute floor while 4h money is drained and the 4h has no
            # direction
            & ((willr_14_15m > -100.0) | (mfi_14_4h > 20.0) | (plus_di_14_4h > 10.0))
            # price is on its 40h floor while the 4h stochastic collapses and the 15m barely moved: the
            # flush already happened
            & ((willr_480 > -95.0) | (stochrsi_k_change_pct_4h > -90.0) | (rsi_14_change_pct_15m > -30.0))
            # price sits on its 40h floor, the base stochastic never got high all session, and the 4h shows
            # a rejection wick above
            & ((willr_480 > -95.0) | (quad_s93_max_12 > 25.0) | (top_wick_pct_4h < 2.0))
            # the hourly williams is near its top and the 4h CCI is positive with no coil behind the break
            & ((willr_84_1h < -40.0) | (cci_20_4h < 20.0) | (sqz_cnt_24 > 0.0))
            # the 4h stochastic is high and still turning up while the hour is not washed:
            # selling into a higher timeframe that has not rolled over yet
            & ((willr_84_1h < -70.0) | stochrsi_k_4h_lt_80 | (stochrsi_k_change_pct_4h > -10.0))
            # the hourly oscillator is rich while the 4h has no directional strength and no momentum left
            & ((uo_7_14_28_1h < 55.0) | (plus_di_14_4h > 10.0) | (rsi_3_4h > 10.0))
            # but the 4h oscillator is not on its floor — the move must not already be finished
            & (uo_7_14_28_4h > 35.0)
            # the 4h oscillator is low while the base RSI is high and the hour is on its floor
            & ((uo_7_14_28_4h > 40.0) | (rsi_14 < 35.0) | (stochrsi_k_1h > 5.0))
            # the pair has already fallen hard over the day and the 4h, yet the base never printed a low:
            # the sellers are late
            & ((roc_288 > -8.0) | (roc_9_4h > -10.0) | (quad_s93_min_12 < 15.0))
            # both the 4h and the hour are rising into the break, with the 4h stochastic turning up
            & ((roc_2_4h < 1.0) | (roc_9_1h < 0.0) | (stochrsi_k_change_pct_4h < 15.0))
            # the 4h has already fallen more than 6%, its RSI is not washed, the hour is pinned
            # at its low and flat: the drop is finished (4 losses, all in 2022)
            & ((roc_9_4h < -6.0) | (rsi_14_4h > 25.0) | (willr_14_1h < -80.0))
            # every fast timeframe is pinned at its floor while the 4h is actually rising: the flush is done
            # and the higher timeframe never joined
            & ((roc_9_4h < 1.0) | (willr_14_1h > -95.0) | (uo_7_14_28_1h > 35.0))
            # the 15m candle is barely red, the hour is not accelerating down and the 4h
            # has no downward strength: a break nobody is following
            & ((change_pct_15m < -0.75) | (rsi_14_change_pct_1h > -25.0) | (minus_di_14_4h < 35.0))
            # selling into a 4h that has already dropped hard while the base stochastic is not
            # washed (APR -4,592; 0W/0L | 1W/3L | 1W/0L)
            & ((change_pct_4h > -7.0) | (stoch_9_3 < 15.0) | (rsi_3_change_pct_15m < -60.0))
            # the base is off its floor, the 15m has not capitulated and the 4h shows a
            # rejection wick: the move down is not the one being sold
            & ((ph_base_pos > 0.25) | (rsi_3_change_pct_15m > -80.0) | (top_wick_pct_4h > 0.25))
            # a wide, choppy pre-break hour on a pair that has not really fallen over the day and
            # whose 15m is already pinned at its floor: the "break" is just another swing inside
            # the range with no room left under it (SAND -5,934 + others)
            & ((ph_pre_tight < 5.0) | (roc_9_4h > -3.0) | (willr_14_15m > -95.0))
            # a long coil has ended with every williams pinned at the floor and the 4h stochastic down there
            # too
            & ((sqz_cnt_24 < 15.0) | (willr_14_4h > -95.0) | (stochk_14_3_3_4h > 15.0))
            # a high already printed on the base timeframe, 4h directional strength positive, the
            # pair not far down over the day and the daily oscillator elevated: shorting into a
            # market that is holding up on every reading (4 losses, free in all three years)
            & ((plus_di_14_4h > 12.0) | (roc_288 > -7.0) | stochrsi_k_1d_lt_60)
            # the daily low is fresh, 4h directional strength is positive, the hour is falling and
            # price is far off its 40h low: a live daily down-leg we are late to (4 losses, and it
            # costs nothing in any of the three years)
            & ((plus_di_14_4h > 12.0) | (roc_9_1h < 0.0) | (willr_480 > -85.0))
            # the 4h has no downward direction, its money flow is rich and the hour is rising
            & ((minus_di_14_4h > 15.0) | (mfi_14_4h < 50.0) | (roc_9_1h < 0.0))
            # the 4h trend is already strong, 15m money is coming in and the hour is not weak: the move is
            # running, not breaking
            & ((adx_14_4h < 45.0) | (cmf_20_15m < 0.05) | (uo_7_14_28_1h < 50.0))
            # the 4h shows no rejection wick at all, the base stochastic is mid-range and 4h momentum is
            # dead
            & ((top_wick_pct_4h > 0.25) | (stoch_4_4 < 35.0) | (rsi_3_4h > 10.0))
            # a heavy volume flush while hourly money still comes in and the 4h has no trend behind it
            & ((vol_rel < 6.0) | (cmf_20_1h < 0.10) | (adx_14_4h > 15.0))
            # --- 1d: the day must not be strong underneath the break
            # same hourly bounce, this time with no 4h rejection wick under a day that is
            # holding up: nothing is confirming the break
            & ((rsi_3_change_pct_1h < 250.0) | (top_wick_pct_4h > 0.25) | (change_pct_1d > -2.0))
            # the hour is accelerating upward, the 4h has no trend and the daily stochastic is high
            & ((rsi_3_change_pct_1h < 300.0) | (adx_14_4h > 15.0) | (stochk_14_3_3_1d < 80.0))
            # 15m money flow already negative, the day flat and the 15m RSI_3 collapsing on a
            # day that has not fallen: a spike being sold into a stable market (3 losses)
            & ((cmf_20_15m > -0.2) | (roc_2_1d < 2.0) | (change_pct_1d > -2.0))
            # 15m money flow is not draining, the hour is not oversold and the day has not
            # fallen: selling a break into a market that is still intact
            & ((cmf_20_15m > -0.35) | (rsi_14_1h > 25.0) | (roc_9_1d > -10.0))
            # a bounce day on weak daily money flow with the 4h momentum not confirming — unless
            # the hour itself is genuinely falling right now. The fifth clause is what makes this
            # free: with four it cut $16,530 of 2026 winners, with five it blocks 8 losses across
            # the three years and not one protected winner (blocked group averages -24% / -18% /
            # -34% against positive populations)
            & ((cmf_20_1d > -0.05) | (roc_9_1d < 5.0) | rsi_14_1d_gt_50)
            # hourly money is still flowing in, 4h money flow is rich and the day is up: a capitulation
            # candle, not a breakdown
            & ((cmf_20_1h < 0.10) | (mfi_14_4h < 50.0) | (roc_2_1d < 1.0))
            # 4h money flow negative with the base money flow at zero, a squeeze behind it and a
            # daily candle with no upper wick: the down-move is spent (3 losses, free everywhere)
            & ((mfi_14 > 5.0) | (sqz_cnt_24 > 4.0) | (top_wick_pct_1d < 1.5))
            # daily money flow washed out on a pair that has actually fallen over the day, while
            # the 15m has still printed a recent high = capitulation, and shorting there is
            # shorting into the bounce
            & ((mfi_14_1d > 20.0) | (roc_288 > -4.5) | (aroonu_14_15m < 5.0))
            # daily money flow washed on a 4h that has already dropped, with the hourly RSI
            # turning back up (OP -1,943; 2W/2L | 0W/2L | 0W/0L)
            & ((mfi_14_1d > 20.0) | (change_pct_4h > -2.5) | (rsi_14_change_pct_1h < -15.0))
            # 4h money is plentiful, the 15m momentum has just exploded and the daily stochrsi is at its
            # ceiling
            & ((mfi_14_4h < 50.0) | (rsi_3_change_pct_15m < 150.0) | (stochrsi_k_1d < 90.0))
            # the daily has fallen and its 2-period ROC is bouncing while 4h money flow holds up
            # (BTC 2021 -873,230; 1W/0L | 1W/0L | 1W/2L)
            & ((mfi_14_4h > 15.0) | (change_pct_1d < -2.0) | (roc_2_1d > -4.0))
            # no high anywhere on the base or 15m, the day is falling and not overbought: the
            # market is already down and there is nothing left to break (5 losses)
            & ((aroonu_14 > 0.0) | (roc_9_1d > 0.0) | (rsi_14_1d < 55.0))
            # the day is at a fresh high and has already run: no exhaustion to sell
            & (aroonu_14_1d_lt_100 | (change_pct_1d < 6.0))
            # the daily low is not fresh, the daily 5m proxy is snapping up, a long squeeze sits
            # behind it and the 4h candle has no upper wick: a coiled market about to expand up
            & ((aroond_14_1d > 25.0) | (rsi_3_change_pct_1d < 50.0) | (top_wick_pct_4h < 0.25))
            # the hour is already at its floor and the 4h is green under a day that has not
            # fallen: nothing below to sell into
            & (stochrsi_k_1h_lt_30 | (change_pct_4h < 0.0) | (roc_9_1d > -20.0))
            # the hourly oscillator is high, the hour has barely fallen and the daily
            # stochastic is mid-range: no exhaustion anywhere to sell into
            & (stochrsi_k_1h_lt_60 | (change_pct_1h > -1.5) | (stochk_14_3_3_1d < 60.0))
            # the 4h stochastic has collapsed to zero under a long 4h upper wick while the day is up: the
            # rejection already happened
            & ((stochrsi_k_4h > 5.0) | (top_wick_pct_4h < 2.0) | (roc_2_1d < 5.0))
            # the base stochastic is still high, the 4h momentum has not collapsed and the
            # day is far from its own low: selling into a market with room above
            & ((stoch_4_4 < 40.0) | (rsi_3_change_pct_4h > -40.0) | (willr_14_1d < -50.0))
            # the 15m CCI is on its floor while the 4h CCI explodes upward and the day shows no lower wick
            & ((cci_20_15m > -250.0) | (cci_20_change_pct_4h < 400.0) | (bot_wick_pct_1d > 1.0))
            # hourly CCI collapsing while volume comes back in and the daily sits high in its own
            # range: squeeze fuel on a strong day (6 losses across all three years)
            & ((cci_20_1h > -200.0) | (obv_change_pct > 0.0) | (willr_14_1d > -60.0))
            # the 15m CCI has not really turned down, the 4h oscillator is rich and the day
            # has barely moved: nothing has broken yet
            & ((cci_20_change_pct_15m < 175.0) | (uo_7_14_28_4h < 55.0) | (rsi_3_change_pct_1d > -25.0))
            # 15m CCI already turning up while the hourly is still falling, hourly RSI low and
            # the day barely down: a bounce forming under a tired hour (5 losses)
            & ((cci_20_change_pct_1h < 50.0) | (rsi_14_1h < 45.0) | (change_pct_1d > -2.0))
            # hourly CCI snapping up, daily money flow rich, the 15m oscillator above mid-band
            # and price at the 15m floor: buyers already stepped in (5 losses)
            & ((cci_20_change_pct_1h < 75.0) | (mfi_14_1d < 60.0) | (willr_14_15m < -75.0))
            # hourly CCI already recovering, the daily RSI_3 snapping up and price nowhere near
            # its 40h low: the hour has turned and there is room above, not below (3 losses)
            & ((cci_20_change_pct_1h > -25.0) | (rsi_3_change_pct_1d < 75.0) | (willr_480 > -90.0))
            # a bounce day on weak daily money flow, 4h CCI already falling, and the 5m fully
            # spent: nothing left to sell (7 losses in 2026|2022|2021, 1 protected winner)
            & ((cci_20_change_pct_4h > 0.0) | (mfi_14_1d > 40.0) | (roc_9_1d < 5.0))
            # the 4h oscillator is not elevated and daily momentum is already dead: nothing
            # left underneath to sell into
            & ((uo_7_14_28_4h < 60.0) | (rsi_3_1d > 10.0))
            # the 4h oscillator is at its low while the 15m CCI explodes upward under a long daily upper
            # wick
            & ((uo_7_14_28_4h > 40.0) | (cci_20_change_pct_15m < 250.0) | (top_wick_pct_1d < 4.0))
            # the 4h oscillator is on its floor under a long daily lower wick with base money already gone
            & ((uo_7_14_28_4h > 40.0) | (bot_wick_pct_1d < 5.0) | (cmf_20 > -0.3))
            # the 15m oscillator is turning up under a strong day while the hour is pinned at its low
            & ((uo_7_14_28_change_pct_15m < 5.0) | (rsi_14_1d < 55.0) | (willr_14_1h > -95.0))
            # daily still rising, no long squeeze behind it, 4h money flow not negative
            # (AVAX 2021 -846,246; 0W/0L | 1W/2L | 0W/0L)
            & ((roc_2_1d < 8.0) | (sqz_cnt_24 < 10.0) | (cmf_20_4h > -0.05))
            # the day has not really fallen while both the 5m and the hourly RSI_3 are washed and
            # the 4h sits at its low: everything is oversold except the day (5 losses)
            & ((roc_2_1d > -10.0) | (rsi_3 < 10.0) | (willr_14_4h < -80.0))
            # the day has already fallen hard and printed a long upper wick, with the 4h stochastic on its
            # floor
            & ((roc_2_1d > -10.0) | (top_wick_pct_1d < 5.0) | (stochk_14_3_3_4h > 15.0))
            # the base has not really dropped and neither the day nor the base oscillator is
            # weak: a break with the whole structure still intact
            & ((roc_9 > -3.0) | (rsi_20 > 20.0) | (rsi_14_1d > 35.0))
            # 15m has not really dropped, the hour is not accelerating down and the day shows
            # a long upper wick: the sellers already showed up and left
            & ((roc_9_15m > -3.5) | (mfi_14_1h < 45.0) | (top_wick_pct_1d < 3.0))
            # the day is up hard with 15m money flow drained: shorting into a squeeze
            & ((roc_9_1d < 80.0) | (mfi_14_15m > 20.0))
            # the day has collapsed yet 4h money flow and the base RSI are both high: the drop is already
            # paid for
            & ((roc_9_1d > -25.0) | (mfi_14_4h < 50.0) | (rsi_14 < 30.0))
            # daily down hard, 4h pinned at its low, price above the 24h base: the low is in
            # (AVAX -20,591; 0W/0L | 1W/1L | 0W/2L)
            & ((roc_9_1d > -30.0) | (willr_14_4h > -90.0) | (ph_base_pos > 0.5))
            # the hour is not falling, its RSI is mid-range, the daily candle has a long lower
            # wick and the 4h is flat: a market being bought on every dip (5 losses)
            & ((roc_9_1h < -1.0) | (bot_wick_pct_1d < 4.0) | (change_pct_4h > -1.5))
            # the 4h has already fallen hard, the day shows no lower wick and the base RSIs are mid-range
            & ((roc_9_4h > -8.0) | (bot_wick_pct_1d > 0.3) | (rsi_20 < 35.0))
            # the day is deep in the red, the daily RSI is washed and the 15m candle is enormous: the drop
            # is over
            & ((change_pct_15m > -2.0) | (rsi_14_1d > 30.0) | (roc_9_1d > -20.0))
            # the 4h is not stretched down, the base was never tight and the day printed a
            # long lower wick: the flush was already bought once
            & ((ph_pre_tight < 4.5) | (cci_20_4h < -25.0) | (bot_wick_pct_1d > 2.5))
            # volume has drained on the 15m while the 4h CCI explodes upward under a day taking money in
            & ((obv_change_pct_15m > -20.0) | (cci_20_change_pct_4h < 300.0) | (cmf_20_1d < 0.15))
            # volatility has already expanded, the day is strong and the 4h is weak: the
            # move being sold is the one that already happened
            & ((bbt_40_2_0 < 15.0) | (rsi_14_4h > 35.0) | (rsi_14_1d < 60.0))
            # volatility has already expanded, OBV is draining and the day is up: the move is behind us
            & ((bbt_40_2_0 < 400.0) | (obv_change_pct > 0.0) | (roc_2_1d < 4.0))
            # a trending 4h under a daily that is neither weak nor washed, out of a long squeeze:
            # shorting strength (6 losses in 2026 and 2022)
            & ((adx_14_4h > 15.0) | rsi_14_1d_gt_40 | (stochk_14_3_3_1d > 20.0))
            # a long upper wick on a day still taking money in, with the hour turning up underneath it
            & ((top_wick_pct_1d < 5.0) | (roc_2_1h < 0.0) | (mfi_14_1d < 65.0))
            # the day printed a long lower wick — buyers already stepped in — while the hour sits on its
            # floor with no money left
            & ((bot_wick_pct_1d < 5.0) | (willr_84_1h > -95.0) | (mfi_14_1h > 15.0))
            # no lower wick on the day, the 4h oscillator is low and the 15m CCI is on its floor
            & ((bot_wick_pct_1d > 0.25) | (uo_7_14_28_4h > 40.0) | (cci_20_15m > -250.0))
            # a volume explosion while the daily stochastic is high and 15m money is flowing in: a spike
            # inside strength
            & ((vol_rel < 10.0) | (stochk_14_3_3_1d < 70.0) | (cmf_20_15m < 0.15))
            # an enormous volume spike under a long daily lower wick while the 4h is rising: the
            # capitulation candle is already being bought
            & ((vol_rel < 25.0) | (bot_wick_pct_1d < 5.0) | (roc_9_4h < 1.0))
          )

          # Logic
          short_entry_logic.append(
            # calm base: not already crashed over the rolling 24h (ride the ignition, don't chase)
            (roc_288 > -10.0)
            # ...on explosive volume. 3.0 is load-bearing: at 2.0 the tag takes 95 more trades and
            # loses ~92% of its profit (measured 2026-08-13)
            & (vol_rel > 3.0)
            # ignition: red candle with a real body (a doji-sized "breakdown" has no follow-through:
            # bodies under 0.3% are net negative) CROSSING below the prior 48-candle low...
            & (close < (open_rate * 0.997))
            & (close < dh_prev_min)
            & (np_shift(close, 1) >= dh_prev_min)
          )

        # Condition #670 - Marubozu momentum (Short, experimental, RAW — mirror).
        if short_entry_condition_index == 670:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          short_entry_logic.append(close < ema_200)
          short_entry_logic.append(rsi_14 < 50.0)
          short_entry_logic.append(mrb_bear > 0.5)

        # Condition #671 - Shooting-star pin-bar (Short, experimental, RAW — mirror at a top).
        if short_entry_condition_index == 671:
          short_entry_logic.append(num_empty_288 <= allowed_empty_candles_288)
          short_entry_logic.append(protections_short_global == True)
          # top context: near the 4h high, 5m hot
          short_entry_logic.append(close > (close_max_48 * 0.97))
          short_entry_logic.append(rsi_3 > 60.0)
          # the fact: long upper rejection wick, tiny lower wick
          short_entry_logic.append(pb_star > 0.5)

        short_entry_logic.append(df["volume"] > 0)
        item_short_entry = _and_entry_conditions(short_entry_logic)
        _append_entry_tag(entry_tags, item_short_entry, f"{short_entry_condition_index} ")
        short_entry_conditions.append(item_short_entry)
        df.loc[:, "enter_short"] = item_short_entry.astype(int)

    if short_entry_conditions:
      df.loc[:, "enter_short"] = _or_entry_conditions(short_entry_conditions).astype(int)

    df.loc[:, "enter_tag"] = pd.array(entry_tags, dtype="string")
    if debug:
      tok = time.perf_counter()
      log.debug("populate_entry_trend took a total of: %.4f seconds.", tok - tik)
    return df

  ###############################################################################################

  # COMMON FUNCTIONS FOR BOTH LONG AND SHORT SIDE ENDS HERE

  ###############################################################################################

  #  /$$        /$$$$$$  /$$   /$$  /$$$$$$         /$$$$$$  /$$$$$$ /$$$$$$$  /$$$$$$$$
  # | $$       /$$__  $$| $$$ | $$ /$$__  $$       /$$__  $$|_  $$_/| $$__  $$| $$_____/
  # | $$      | $$  \ $$| $$$$| $$| $$  \__/      | $$  \__/  | $$  | $$  \ $$| $$
  # | $$      | $$  | $$| $$ $$ $$| $$ /$$$$      |  $$$$$$   | $$  | $$  | $$| $$$$$
  # | $$      | $$  | $$| $$  $$$$| $$|_  $$       \____  $$  | $$  | $$  | $$| $$__/
  # | $$      | $$  | $$| $$\  $$$| $$  \ $$       /$$  \ $$  | $$  | $$  | $$| $$
  # | $$$$$$$$|  $$$$$$/| $$ \  $$|  $$$$$$/      |  $$$$$$/ /$$$$$$| $$$$$$$/| $$$$$$$$
  # |________/ \______/ |__/  \__/ \______/        \______/ |______/|_______/ |________/

  # Long Side Functions for handling long orders
  # ---------------------------------------------------------------------------------------------

  ###############################################################################################

  # LONG EXIT FUNCTIONS STARTS HERE

  ###############################################################################################

  #
  #  /$$        /$$$$$$  /$$   /$$  /$$$$$$        /$$$$$$$$ /$$   /$$ /$$$$$$ /$$$$$$$$
  # | $$       /$$__  $$| $$$ | $$ /$$__  $$      | $$_____/| $$  / $$|_  $$_/|__  $$__/
  # | $$      | $$  \ $$| $$$$| $$| $$  \__/      | $$      |  $$/ $$/  | $$     | $$
  # | $$      | $$  | $$| $$ $$ $$| $$ /$$$$      | $$$$$    \  $$$$/   | $$     | $$
  # | $$      | $$  | $$| $$  $$$$| $$|_  $$      | $$__/     >$$  $$   | $$     | $$
  # | $$      | $$  | $$| $$\  $$$| $$  \ $$      | $$       /$$/\  $$  | $$     | $$
  # | $$$$$$$$|  $$$$$$/| $$ \  $$|  $$$$$$/      | $$$$$$$$| $$  \ $$ /$$$$$$   | $$
  # |________/ \______/ |__/  \__/ \______/       |________/|__/  |__/|______/   |__/
  #

  # Long Exit Normal
  # ---------------------------------------------------------------------------------------------
  def long_exit_normal(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.long_normal_mode_name

    sell = False

    # if the profit is negative skip checking these
    if profit_init_ratio > 0.0:
      # Original sell signals
      sell, signal_name = self.long_exit_signals(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

      # Main sell signals
      if not sell:
        sell, signal_name = self.long_exit_main(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Williams %R based sells
      if not sell:
        sell, signal_name = self.long_exit_williams_r(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Downtrend/descending based sells
      if not sell:
        sell, signal_name = self.long_exit_dec(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

    # Stoplosses
    if not sell:
      sell, signal_name = self.long_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      previous_sell_reason = ""
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
        previous_sell_reason = target_data["sell_reason"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ] and (
        previous_sell_reason
        not in [
          f"exit_{mode_name}_stoploss_doom",
          f"exit_{mode_name}_stoploss_u_e",
        ]
      ):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for long_exit_normal

    return False, None

  # Long Exit Pump
  # ---------------------------------------------------------------------------------------------
  def long_exit_pump(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.long_pump_mode_name

    sell = False
    signal_name = None

    stoploss_doom = f"exit_{mode_name}_stoploss_doom"
    stoploss_ue = f"exit_{mode_name}_stoploss_u_e"
    max_signal = f"exit_profit_{mode_name}_max"

    candle_args = (
      last_candle,
      previous_candle_1,
    )

    common_args = (
      mode_name,
      profit_init_ratio,
      max_profit,
      max_loss,
      *candle_args,
      trade,
      current_time,
      enter_tags,
    )

    # Profit-based exits
    if profit_init_ratio > 0.0:
      exit_checks = (
        self.long_exit_signals,
        self.long_exit_main,
        self.long_exit_williams_r,
        self.long_exit_dec,
      )

      for exit_check in exit_checks:
        sell, signal_name = exit_check(*common_args)

        if sell:
          break

    # Stoploss exits
    if not sell:
      sell, signal_name = self.long_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        *candle_args,
        trade,
        current_time,
        enter_tags,
      )

    # Cached target profit data
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = target_data["profit"] if target_data else None
    previous_sell_reason = target_data["sell_reason"] if target_data else ""

    # Profit target logic
    if target_data:
      previous_rate = target_data["rate"]

      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == stoploss_ue:
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(
              pair,
              mark_signal,
              current_rate,
              profit_ratio,
              current_time,
            )

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != stoploss_doom:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    # Sell triggered
    if sell and signal_name is not None:
      if signal_name in (stoploss_doom, stoploss_ue):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_ratio,
            current_time,
          )

        else:
          return True, signal_name

      elif previous_profit is None or previous_profit < profit_init_ratio:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

        else:
          return True, signal_name

    # Update cached max profit
    elif profit_init_ratio >= 0.005:
      if previous_profit is None or previous_profit < profit_init_ratio:
        set_profit_target(
          pair,
          max_signal,
          current_rate,
          profit_init_ratio,
          current_time,
        )

    # Final sell validation
    if sell and signal_name is not None and signal_name not in (max_signal, stoploss_doom, stoploss_ue):
      return True, signal_name

    return False, None

  # Long Exit Quick
  # ---------------------------------------------------------------------------------------------
  def long_exit_quick(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.long_quick_mode_name

    sell = False
    signal_name = None

    stoploss_doom = f"exit_{mode_name}_stoploss_doom"
    stoploss_ue = f"exit_{mode_name}_stoploss_u_e"
    profit_max_signal = f"exit_profit_{mode_name}_max"

    candle_args = (
      last_candle,
      previous_candle_1,
    )

    common_args = (
      mode_name,
      profit_init_ratio,
      max_profit,
      max_loss,
      *candle_args,
      trade,
      current_time,
      enter_tags,
    )

    # -------------------------------------------------------------------------
    # Profit-based exit signals
    # -------------------------------------------------------------------------
    if profit_init_ratio > 0.0:
      exit_checks = (
        self.long_exit_signals,
        self.long_exit_main,
        self.long_exit_williams_r,
        self.long_exit_dec,
      )

      for exit_check in exit_checks:
        sell, signal_name = exit_check(*common_args)

        if sell:
          break

    # -------------------------------------------------------------------------
    # Stoploss
    # -------------------------------------------------------------------------
    if not sell:
      sell, signal_name = self.long_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        *candle_args,
        trade,
        current_time,
        enter_tags,
      )

    # -------------------------------------------------------------------------
    # Extra quick exit logic
    # -------------------------------------------------------------------------
    if not sell and 0.02 < profit_init_ratio <= 0.09:
      rsi_14 = last_candle["RSI_14"]
      mfi_14 = last_candle["MFI_14"]
      willr_14 = last_candle["WILLR_14"]
      rsi_3 = last_candle["RSI_3"]
      rsi_3_15m = last_candle["RSI_3_15m"]

      quick_conditions = (
        (rsi_14 > 78.0, "q_1"),
        (mfi_14 > 84.0, "q_2"),
        (willr_14 >= -0.1, "q_3"),
        (
          rsi_14 >= 72.0 and rsi_3 > 90.0 and rsi_3_15m > 90.0,
          "q_4",
        ),
        (rsi_3_15m > 96.0, "q_5"),
        (rsi_3 > 85.0 and rsi_3_15m > 85.0, "q_6"),
        (rsi_3 > 90.0 and rsi_3_15m > 80.0, "q_7"),
        (rsi_3 > 92.0 and rsi_3_15m > 75.0, "q_8"),
        (rsi_3 > 94.0 and rsi_3_15m > 70.0, "q_9"),
        (rsi_3 > 99.0, "q_10"),
      )

      for condition, suffix in quick_conditions:
        if condition:
          sell = True
          signal_name = f"exit_{mode_name}_{suffix}"
          break

    # -------------------------------------------------------------------------
    # Cached target data
    # -------------------------------------------------------------------------
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = target_data["profit"] if target_data else None
    previous_sell_reason = target_data["sell_reason"] if target_data else ""

    # -------------------------------------------------------------------------
    # Profit target logic
    # -------------------------------------------------------------------------
    if target_data:
      previous_rate = target_data["rate"]

      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == stoploss_ue:
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(
              pair,
              mark_signal,
              current_rate,
              profit_ratio,
              current_time,
            )

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != stoploss_doom:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    # -------------------------------------------------------------------------
    # Sell triggered logic
    # -------------------------------------------------------------------------
    if sell and signal_name is not None:
      if signal_name in (stoploss_doom, stoploss_ue) and previous_sell_reason not in (
        stoploss_doom,
        f"exit_{mode_name}_stoploss_u_e",
      ):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_ratio,
            current_time,
          )

        else:
          return True, signal_name

      elif previous_profit is None or previous_profit < profit_init_ratio:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

        else:
          return True, signal_name

    # -------------------------------------------------------------------------
    # Update max cached profit
    # -------------------------------------------------------------------------
    elif profit_init_ratio >= 0.005:
      if previous_profit is None or previous_profit < profit_init_ratio:
        set_profit_target(
          pair,
          profit_max_signal,
          current_rate,
          profit_init_ratio,
          current_time,
        )

    # -------------------------------------------------------------------------
    # Final sell validation
    # -------------------------------------------------------------------------
    if (
      sell
      and signal_name is not None
      and signal_name
      not in (
        profit_max_signal,
        stoploss_doom,
        stoploss_ue,
      )
    ):
      return True, signal_name

    return False, None

  # Long Exit Rebuy
  # ---------------------------------------------------------------------------------------------
  def long_exit_rebuy(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode

    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.long_rebuy_mode_name
    stoploss_doom = f"exit_{mode_name}_stoploss_doom"
    stoploss_u_e = f"exit_{mode_name}_stoploss_u_e"
    profit_max = f"exit_profit_{mode_name}_max"

    sell = False
    signal_name = None

    signal_args = (
      mode_name,
      profit_current_stake_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Original sell signals
    for exit_func in (
      self.long_exit_signals,
      self.long_exit_main,
      self.long_exit_williams_r,
      self.long_exit_dec,
    ):
      sell, signal_name = exit_func(*signal_args)

      if sell:
        break

    # Stoplosses
    if not sell:
      leverage = trade.leverage
      entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price

      is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)

      if is_system_v3_2:
        threshold = (
          self.system_v3_2_stop_threshold_futures_rebuy
          if is_futures_mode
          else self.system_v3_2_stop_threshold_spot_rebuy
        )

        if self.system_v3_2_stops_enable and profit_stake < -(entry_cost * threshold / leverage):
          sell, signal_name = True, stoploss_doom

      elif is_system_v3_1:
        threshold = (
          self.system_v3_1_stop_threshold_futures_rebuy
          if is_futures_mode
          else self.system_v3_1_stop_threshold_spot_rebuy
        )

        if profit_stake < -(entry_cost * threshold / leverage):
          sell, signal_name = True, stoploss_doom

      elif is_system_v3:
        threshold = (
          self.system_v3_stop_threshold_futures_rebuy if is_futures_mode else self.system_v3_stop_threshold_spot_rebuy
        )

        if profit_stake < -(entry_cost * threshold / leverage):
          sell, signal_name = True, stoploss_doom

      else:
        threshold = self.stop_threshold_futures_rebuy if is_futures_mode else self.stop_threshold_spot_rebuy

        if profit_stake < -(entry_cost * threshold / leverage) and (
          trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 9, 13) or self.is_backtest_mode()
        ):
          sell, signal_name = True, stoploss_doom

    # Profit Target Signal
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = target_data["profit"] if target_data else None
    previous_sell_reason = target_data["sell_reason"] if target_data else ""

    if target_data:
      previous_rate = target_data["rate"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == stoploss_u_e:
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(
              pair,
              mark_signal,
              current_rate,
              profit_ratio,
              current_time,
            )

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != stoploss_doom:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      if signal_name in (stoploss_doom, stoploss_u_e):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_ratio,
            current_time,
          )
        else:
          return True, signal_name

      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )
        else:
          return True, signal_name

    else:
      if profit_init_ratio >= 0.005:
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          set_profit_target(
            pair,
            profit_max,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    if signal_name not in (
      profit_max,
      stoploss_doom,
      stoploss_u_e,
    ):
      if sell and signal_name is not None:
        return True, signal_name

    if (
      enter_tags == ["65"]
      and (current_time - trade.open_date_utc).total_seconds() >= 90 * 60
      and profit_init_ratio >= 0.0125
    ):
      return True, "exit_long_rebuy_e_r"

    # Here ends exit signal conditions for long_exit_rebuy
    return False, None

  # Long Exit High Profit
  # ---------------------------------------------------------------------------------------------
  def long_exit_high_profit(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.long_high_profit_mode_name

    stoploss_doom = f"exit_{mode_name}_stoploss_doom"
    stoploss_u_e = f"exit_{mode_name}_stoploss_u_e"
    profit_max = f"exit_profit_{mode_name}_max"

    sell = False
    signal_name = None

    signal_args = (
      mode_name,
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Original/Main/Williams sells
    for exit_func in (
      self.long_exit_signals,
      self.long_exit_main,
      self.long_exit_williams_r,
    ):
      sell, signal_name = exit_func(*signal_args)

      if sell:
        break

    # Stoplosses
    if not sell:
      sell, signal_name = self.long_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Profit Target Signal
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = target_data["profit"] if target_data else None
    previous_sell_reason = target_data["sell_reason"] if target_data else ""

    if target_data:
      previous_rate = target_data["rate"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == stoploss_u_e:
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(
              pair,
              mark_signal,
              current_rate,
              profit_ratio,
              current_time,
            )

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != stoploss_doom:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      if signal_name in (stoploss_doom, stoploss_u_e):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_ratio,
            current_time,
          )
        else:
          return True, signal_name

      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )
        else:
          return True, signal_name

    else:
      if profit_init_ratio >= 0.03:
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          set_profit_target(
            pair,
            profit_max,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    if signal_name not in [
      profit_max,
      # stoploss_doom,
      # stoploss_u_e,
    ]:
      if sell and signal_name is not None:
        return True, signal_name

    # Here ends exit signal conditions for long_exit_high_profit
    return False, None

  # Long Exit Rapid
  # ---------------------------------------------------------------------------------------------
  def long_exit_rapid(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode
    stops_enable = self.stops_enable

    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    is_backtest = self.is_backtest_mode()
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)

    mode = self.long_rapid_mode_name
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    pair_cache = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = pair_cache["profit"] if pair_cache else None
    previous_sell_reason = pair_cache["sell_reason"] if pair_cache else ""

    sell = False
    signal_name = None

    common_args = (
      mode,
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # if the profit is negative skip checking these
    if profit_init_ratio > 0.0:
      for exit_func in (
        self.long_exit_signals,
        self.long_exit_main,
        self.long_exit_williams_r,
        self.long_exit_dec,
      ):
        sell, signal_name = exit_func(*common_args)
        if sell:
          break

    # Extra exit logic
    if not sell:
      in_range = 0.09 >= profit_init_ratio > 0.005

      if in_range:
        rsi14 = last_candle["RSI_14"]
        mfi14 = last_candle["MFI_14"]
        willr14 = last_candle["WILLR_14"]
        rsi3 = last_candle["RSI_3"]
        rsi3_15m = last_candle["RSI_3_15m"]

        rapid_conditions = (
          (rsi14 > 78.0, f"exit_{mode}_rpd_1"),
          (mfi14 > 84.0, f"exit_{mode}_rpd_2"),
          (willr14 >= -0.1, f"exit_{mode}_rpd_3"),
          (
            rsi14 >= 72.0 and rsi3 > 90.0 and rsi3_15m > 90.0,
            f"exit_{mode}_rpd_4",
          ),
          (rsi3_15m > 96.0, f"exit_{mode}_rpd_5"),
          (rsi3 > 85.0 and rsi3_15m > 85.0, f"exit_{mode}_rpd_6"),
          (rsi3 > 90.0 and rsi3_15m > 80.0, f"exit_{mode}_rpd_7"),
          (rsi3 > 92.0 and rsi3_15m > 75.0, f"exit_{mode}_rpd_8"),
          (rsi3 > 94.0 and rsi3_15m > 70.0, f"exit_{mode}_rpd_9"),
          (rsi3 > 99.0, f"exit_{mode}_rpd_10"),
        )

        for condition, signal in rapid_conditions:
          if condition:
            sell, signal_name = True, signal
            break

      if not sell:
        entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
        leverage = trade.leverage
        stop_threshold = None
        stop_enabled = False

        if is_system_v3_2:
          stop_enabled = self.system_v3_2_stops_enable
          stop_threshold = (
            self.system_v3_2_stop_threshold_rapid_futures
            if is_futures_mode
            else self.system_v3_2_stop_threshold_rapid_spot
          )
        elif is_system_v3_1:
          stop_enabled = stops_enable
          stop_threshold = (
            self.system_v3_1_stop_threshold_rapid_futures
            if is_futures_mode
            else self.system_v3_1_stop_threshold_rapid_spot
          )
        elif is_system_v3:
          stop_enabled = stops_enable
          stop_threshold = (
            self.system_v3_stop_threshold_rapid_futures
            if is_futures_mode
            else self.system_v3_stop_threshold_rapid_spot
          )
        else:
          stop_enabled = stops_enable
          stop_threshold = self.stop_threshold_rapid_futures if is_futures_mode else self.stop_threshold_rapid_spot

        if stop_enabled:
          stoploss_value = -(entry_cost * stop_threshold / leverage)

          if is_system_v3 or is_system_v3_1 or is_system_v3_2:
            if profit_stake < stoploss_value:
              sell, signal_name = True, f"exit_{mode}_stoploss_doom"
          elif profit_stake < stoploss_value and (
            is_backtest or trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 9, 13)
          ):
            sell, signal_name = True, f"exit_{mode}_stoploss_doom"

    # Profit Target Signal
    if pair_cache:
      previous_rate = pair_cache["rate"]
      previous_time_profit_reached = datetime.fromisoformat(pair_cache["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == f"exit_{mode}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(
              pair,
              mark_signal,
              current_rate,
              profit_ratio,
              current_time,
            )

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != f"exit_{mode}_stoploss_doom":
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      protected_signals = {
        f"exit_{mode}_stoploss_doom",
        f"exit_{mode}_stoploss_u_e",
      }

      blocked_previous_signals = {
        f"exit_{mode}_stoploss_doom",
        f"exit_{mode}_stoploss_u_e",
      }

      if signal_name in protected_signals and previous_sell_reason not in blocked_previous_signals:
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_ratio,
            current_time,
          )
        else:
          return True, signal_name

      elif previous_profit is None or previous_profit < profit_init_ratio:
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )
        else:
          return True, signal_name

    elif profit_init_ratio >= 0.005:
      if previous_profit is None or previous_profit < profit_init_ratio:
        set_profit_target(
          pair,
          f"exit_profit_{mode}_max",
          current_rate,
          profit_init_ratio,
          current_time,
        )

    ignored_signals = {
      f"exit_profit_{mode}_max",
      f"exit_{mode}_stoploss_doom",
      f"exit_{mode}_stoploss_u_e",
    }

    if sell and signal_name is not None and signal_name not in ignored_signals:
      return True, signal_name

    # Here ends exit signal conditions for long_exit_rapid
    return False, None

  # Long Exit Grind
  # ---------------------------------------------------------------------------------------------
  def long_exit_grind(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    if profit_init_ratio > 0.25:
      return True, f"exit_{self.long_grind_mode_name}_g"

    # Here ends exit signal conditions for long_exit_grind
    return False, None

  # Long Exit Btc
  # ---------------------------------------------------------------------------------------------
  def long_exit_btc(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    if profit_init_ratio > 0.25:
      return True, f"exit_{self.long_btc_mode_name}_g"

    # Here ends exit signal conditions for long_exit_btc
    return False, None

  # Long Exit Top Coins
  # ---------------------------------------------------------------------------------------------
  def long_exit_top_coins(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode = self.long_top_coins_mode_name

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    pair_cache = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = pair_cache["profit"] if pair_cache else None
    previous_sell_reason = pair_cache["sell_reason"] if pair_cache else ""

    sell = False
    signal_name = None

    common_args = (
      mode,
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Original/Main/Williams/DEC sell signals
    for exit_func in (
      self.long_exit_signals,
      self.long_exit_main,
      self.long_exit_williams_r,
      self.long_exit_dec,
    ):
      sell, signal_name = exit_func(*common_args)

      if sell:
        break

    # Stoplosses
    if not sell:
      sell, signal_name = self.long_exit_stoploss(
        mode,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Profit Target Signal
    if pair_cache:
      previous_rate = pair_cache["rate"]
      previous_time_profit_reached = datetime.fromisoformat(pair_cache["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == f"exit_{mode}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(
              pair,
              mark_signal,
              current_rate,
              profit_ratio,
              current_time,
            )

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != f"exit_{mode}_stoploss_doom":
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            profit_init_ratio,
            current_time,
          )

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      protected_signals = {
        f"exit_{mode}_stoploss_doom",
        f"exit_{mode}_stoploss_u_e",
      }

      blocked_previous_signals = {
        f"exit_{mode}_stoploss_doom",
        f"exit_{mode}_stoploss_u_e",
      }

      target_profit = profit_ratio if signal_name in protected_signals else profit_init_ratio

      should_mark = (signal_name in protected_signals and previous_sell_reason not in blocked_previous_signals) or (
        signal_name not in protected_signals and (previous_profit is None or previous_profit < profit_init_ratio)
      )

      if should_mark:
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          target_profit,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(
            pair,
            mark_signal,
            current_rate,
            target_profit,
            current_time,
          )
        else:
          return True, signal_name

    elif profit_init_ratio >= 0.005:
      if previous_profit is None or previous_profit < profit_init_ratio:
        set_profit_target(
          pair,
          f"exit_profit_{mode}_max",
          current_rate,
          profit_init_ratio,
          current_time,
        )

    ignored_signals = {
      f"exit_profit_{mode}_max",
      f"exit_{mode}_stoploss_doom",
      f"exit_{mode}_stoploss_u_e",
    }

    if sell and signal_name is not None and signal_name not in ignored_signals:
      return True, signal_name

    # Here ends exit signal conditions for long_exit_top_coins
    return False, None

  # Long Exit Scalp
  # ---------------------------------------------------------------------------------------------
  def long_exit_scalp(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode

    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode = self.long_scalp_mode_name

    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)

    sell = False
    signal_name = None

    signal_args = (
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Original sell signals
    sell, signal_name = self.long_exit_signals(mode, *signal_args)

    # Main sell signals
    if not sell:
      sell, signal_name = self.long_exit_main(mode, *signal_args)

    # Williams %R based sells
    if not sell:
      sell, signal_name = self.long_exit_williams_r(mode, *signal_args)

    # Downtrend/descending based sells
    if not sell:
      sell, signal_name = self.long_exit_dec(mode, *signal_args)

    # Extra exit logic
    if not sell:
      entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
      leverage = trade.leverage

      if is_system_v3_2:
        threshold = (
          self.system_v3_2_stop_threshold_scalp_futures
          if is_futures_mode
          else self.system_v3_2_stop_threshold_scalp_spot
        )

        stoploss_hit = self.system_v3_2_stops_enable and profit_stake < -(entry_cost * threshold / leverage)

      elif is_system_v3_1:
        threshold = (
          self.system_v3_1_stop_threshold_scalp_futures
          if is_futures_mode
          else self.system_v3_1_stop_threshold_scalp_spot
        )

        stoploss_hit = profit_stake < -(entry_cost * threshold / leverage)

      elif is_system_v3:
        threshold = (
          self.system_v3_stop_threshold_scalp_futures if is_futures_mode else self.system_v3_stop_threshold_scalp_spot
        )

        stoploss_hit = profit_stake < -(entry_cost * threshold / leverage)

      else:
        threshold = self.stop_threshold_scalp_futures if is_futures_mode else self.stop_threshold_scalp_spot

        stoploss_hit = profit_stake < -(entry_cost * threshold)

      if stoploss_hit:
        sell, signal_name = True, f"exit_{mode}_stoploss_doom"

    # Profit Target Signal
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None
    pair_data = profit_target_get(pair) if profit_target_get is not None else None
    previous_profit = pair_data["profit"] if pair_data else None
    previous_sell_reason = pair_data["sell_reason"] if pair_data else ""

    if pair_data:
      previous_rate = pair_data["rate"]
      previous_time_profit_reached = datetime.fromisoformat(pair_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )

      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"

      if previous_sell_reason == f"exit_{mode}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )

          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)

      elif profit_init_ratio > (previous_profit + 0.001) and previous_sell_reason != f"exit_{mode}_stoploss_doom":
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      if signal_name in {
        f"exit_{mode}_stoploss_doom",
        f"exit_{mode}_stoploss_u_e",
      }:
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"

      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )

        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"

    else:
      if profit_init_ratio >= 0.005:
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in {
      f"exit_profit_{mode}_max",
      f"exit_{mode}_stoploss_doom",
      f"exit_{mode}_stoploss_u_e",
    }:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    # Here ends exit signal conditions for long_exit_scalp

    return False, None

  # Long Exit Signals
  # ---------------------------------------------------------------------------------------------
  def long_exit_signals(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_rsi_14 = last_candle["RSI_14"]
    last_close = last_candle["close"]
    last_ema_200 = last_candle["EMA_200"]
    last_ema_50 = last_candle["EMA_50"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_bbu_20 = last_candle["BBU_20_2.0"]
    last_bbu_20_1h = last_candle["BBU_20_2.0_1h"]
    bb_above_count = last_candle["BB_ABOVE_COUNT"]
    current_profit_gt_0_01 = current_profit > 0.01

    # Sell signal 1
    if (last_rsi_14 > 84.0) and (last_close > last_bbu_20) and (bb_above_count >= 5):
      if last_close > last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_1_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_1_2_1"

    # Sell signal 2
    elif (last_rsi_14 > 86.0) and (last_close > last_bbu_20) and (bb_above_count >= 3):
      if last_close > last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_2_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_2_2_1"

    # Sell signal 3
    elif last_rsi_14 > 88.0:
      if last_close > last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_3_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_3_2_1"

    # Sell signal 4
    elif (last_rsi_14 > 84.0) and (last_rsi_14_1h > 80.0):
      if last_close > last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_4_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_4_2_1"

    # Sell signal 6
    elif (last_close < last_ema_200) and (last_close > last_ema_50) and (last_rsi_14 > 79.0):
      if current_profit_gt_0_01:
        return True, f"exit_{mode_name}_6_1"

    # # Sell signal 7
    # elif (last_candle["RSI_14_1h"] > 79.0) and (last_candle["crossed_below_EMA_12_26"]):
    #   if last_candle["close"] > last_candle["EMA_200"]:
    #     if current_profit_gt_0_01:
    #       return True, f"exit_{mode_name}_7_1_1"
    #   else:
    #     if current_profit_gt_0_01:
    #       return True, f"exit_{mode_name}_7_2_1"

    # Sell signal 8
    elif last_close > last_bbu_20_1h * 1.14:
      if last_close > last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_8_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_8_2_1"

    #  Here ends exit signal conditions for long_exit_signals

    return False, None

  # Long Exit Main
  # ---------------------------------------------------------------------------------------------
  def long_exit_main(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_rsi_14 = last_candle["RSI_14"]
    last_close = last_candle["close"]
    last_ema_200 = last_candle["EMA_200"]

    if last_close > last_ema_200:
      if 0.01 > current_profit >= 0.001:
        if last_rsi_14 < 10.0:
          return True, f"exit_{mode_name}_o_0"
      elif 0.02 > current_profit >= 0.01:
        if last_rsi_14 < 28.0:
          return True, f"exit_{mode_name}_o_1"
      elif 0.03 > current_profit >= 0.02:
        if last_rsi_14 < 30.0:
          return True, f"exit_{mode_name}_o_2"
      elif 0.04 > current_profit >= 0.03:
        if last_rsi_14 < 32.0:
          return True, f"exit_{mode_name}_o_3"
      elif 0.05 > current_profit >= 0.04:
        if last_rsi_14 < 34.0:
          return True, f"exit_{mode_name}_o_4"
      elif 0.06 > current_profit >= 0.05:
        if last_rsi_14 < 36.0:
          return True, f"exit_{mode_name}_o_5"
      elif 0.07 > current_profit >= 0.06:
        if last_rsi_14 < 38.0:
          return True, f"exit_{mode_name}_o_6"
      elif 0.08 > current_profit >= 0.07:
        if last_rsi_14 < 40.0:
          return True, f"exit_{mode_name}_o_7"
      elif 0.09 > current_profit >= 0.08:
        if last_rsi_14 < 42.0:
          return True, f"exit_{mode_name}_o_8"
      elif 0.1 > current_profit >= 0.09:
        if last_rsi_14 < 44.0:
          return True, f"exit_{mode_name}_o_9"
      elif 0.12 > current_profit >= 0.1:
        if last_rsi_14 < 46.0:
          return True, f"exit_{mode_name}_o_10"
      elif 0.2 > current_profit >= 0.12:
        if last_rsi_14 < 44.0:
          return True, f"exit_{mode_name}_o_11"
      elif current_profit >= 0.2:
        if last_rsi_14 < 42.0:
          return True, f"exit_{mode_name}_o_12"
    elif last_close < last_ema_200:
      if 0.01 > current_profit >= 0.001:
        if last_rsi_14 < 12.0:
          return True, f"exit_{mode_name}_u_0"
      elif 0.02 > current_profit >= 0.01:
        if last_rsi_14 < 30.0:
          return True, f"exit_{mode_name}_u_1"
      elif 0.03 > current_profit >= 0.02:
        if last_rsi_14 < 32.0:
          return True, f"exit_{mode_name}_u_2"
      elif 0.04 > current_profit >= 0.03:
        if last_rsi_14 < 34.0:
          return True, f"exit_{mode_name}_u_3"
      elif 0.05 > current_profit >= 0.04:
        if last_rsi_14 < 36.0:
          return True, f"exit_{mode_name}_u_4"
      elif 0.06 > current_profit >= 0.05:
        if last_rsi_14 < 38.0:
          return True, f"exit_{mode_name}_u_5"
      elif 0.07 > current_profit >= 0.06:
        if last_rsi_14 < 40.0:
          return True, f"exit_{mode_name}_u_6"
      elif 0.08 > current_profit >= 0.07:
        if last_rsi_14 < 42.0:
          return True, f"exit_{mode_name}_u_7"
      elif 0.09 > current_profit >= 0.08:
        if last_rsi_14 < 44.0:
          return True, f"exit_{mode_name}_u_8"
      elif 0.1 > current_profit >= 0.09:
        if last_rsi_14 < 46.0:
          return True, f"exit_{mode_name}_u_9"
      elif 0.12 > current_profit >= 0.1:
        if last_rsi_14 < 48.0:
          return True, f"exit_{mode_name}_u_10"
      elif 0.2 > current_profit >= 0.12:
        if last_rsi_14 < 46.0:
          return True, f"exit_{mode_name}_u_11"
      elif current_profit >= 0.2:
        if last_rsi_14 < 44.0:
          return True, f"exit_{mode_name}_u_12"

    #  Here ends exit signal conditions for long_exit_main

    return False, None

  # Long Exit Williams R
  # ---------------------------------------------------------------------------------------------
  def long_exit_williams_r(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_willr_14 = last_candle["WILLR_14"]
    last_rsi_3 = last_candle["RSI_3"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_aroonu_14_4h = last_candle["AROONU_14_4h"]
    last_rsi_14 = last_candle["RSI_14"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_stochrsi_k_1d = last_candle["STOCHRSIk_14_14_3_3_1d"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_willr_480 = last_candle["WILLR_480"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    last_cmf_20_1h = last_candle["CMF_20_1h"]
    last_cmf_20_4h = last_candle["CMF_20_4h"]
    last_cci_20_change_pct_4h = last_candle["CCI_20_change_pct_4h"]
    last_top_wick_pct_1d = last_candle["top_wick_pct_1d"]
    # Reused long Williams-R exit thresholds
    last_willr_14_gt_neg_2 = last_willr_14 > -2.0
    last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
    last_willr_14_gt_neg_1 = last_willr_14 > -1.0
    last_stochrsi_k_4h_gt_70 = last_stochrsi_k_4h > 70.0
    last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
    last_rsi_3_gt_90 = last_rsi_3 > 90.0
    last_willr_14_gt_neg_8 = last_willr_14 > -8.0
    last_willr_14_gt_neg_6 = last_willr_14 > -6.0
    last_willr_14_gt_neg_4 = last_willr_14 > -4.0
    last_rsi_3_gt_92 = last_rsi_3 > 92.0
    last_rsi_3_gt_88 = last_rsi_3 > 88.0
    last_willr_14_gte_neg_1 = last_willr_14 >= -1.0
    last_rsi_3_gt_94 = last_rsi_3 > 94.0
    last_rsi_3_gt_98 = last_rsi_3 > 98.0
    last_willr_14_gt_neg_20 = last_willr_14 > -20.0
    last_rsi_3_gt_99 = last_rsi_3 > 99.0
    last_rsi_3_gt_86 = last_rsi_3 > 86.0
    last_rsi_3_gt_84 = last_rsi_3 > 84.0
    last_willr_480_gt_neg_25 = last_willr_480 > -25.0
    last_willr_14_gte_neg_2 = last_willr_14 >= -2.0
    last_willr_14_gt_neg_10 = last_willr_14 > -10.0
    last_stochrsi_k_4h_gt_80 = last_stochrsi_k_4h > 80.0
    last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
    last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
    last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
    last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
    last_stochrsi_k_1h_gt_20 = last_stochrsi_k_1h > 20.0
    last_rsi_3_4h_lt_50 = last_rsi_3_4h < 50.0
    last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
    last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
    last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
    last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
    last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
    last_rsi_3_1h_lt_30 = last_rsi_3_1h < 30.0
    last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
    last_rsi_3_gt_96 = last_rsi_3 > 96.0
    last_rsi_3_gt_82 = last_rsi_3 > 82.0
    last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
    last_rsi_14_4h_gt_60 = last_rsi_14_4h > 60.0
    last_roc_9_1h_lt_neg_5 = last_roc_9_1h < -5.0

    # Reused long Williams-R exit thresholds
    last_top_wick_pct_1d_gt_20 = last_top_wick_pct_1d > 20.0
    last_roc_9_4h_gt_20 = last_roc_9_4h > 20.0
    last_roc_9_4h_gt_10 = last_roc_9_4h > 10.0
    last_roc_9_1h_lt_0 = last_roc_9_1h < -0.0
    last_cmf_20_4h_lt_0 = last_cmf_20_4h < -0.0
    last_cmf_20_1h_lt_0 = last_cmf_20_1h < -0.0
    last_cci_20_change_pct_4h_lt_0 = last_cci_20_change_pct_4h < -0.0
    last_rsi_3_gt_80 = last_rsi_3 > 80.0
    last_willr_14_gt_neg_12 = last_willr_14 > -12.0
    last_rsi_14_gt_70 = last_rsi_14 > 70.0
    last_willr_14_gte_neg_15 = last_willr_14 >= -15.0
    last_rsi_14_gt_75 = last_rsi_14 > 75.0
    last_rsi_14_lt_52 = last_rsi_14 < 52.0
    last_rsi_14_lt_50 = last_rsi_14 < 50.0
    last_rsi_14_lt_48 = last_rsi_14 < 48.0
    last_willr_14_gte_neg_5 = last_willr_14 >= -5.0
    last_willr_14_gt_neg_14 = last_willr_14 > -14.0
    last_rsi_14_gt_80 = last_rsi_14 > 80.0
    last_rsi_14_gt_78 = last_rsi_14 > 78.0
    last_rsi_14_lt_54 = last_rsi_14 < 54.0
    last_rsi_14_lt_46 = last_rsi_14 < 46.0
    last_willr_14_gt_neg_24 = last_willr_14 > -24.0
    last_willr_14_gt_neg_22 = last_willr_14 > -22.0
    last_willr_14_gt_neg_18 = last_willr_14 > -18.0
    last_willr_14_gt_neg_16 = last_willr_14 > -16.0
    last_rsi_3_gt_95 = last_rsi_3 > 95.0
    last_rsi_3_gt_78 = last_rsi_3 > 78.0
    last_rsi_3_gt_50 = last_rsi_3 > 50.0
    last_rsi_3_gt_48 = last_rsi_3 > 48.0
    last_rsi_3_gt_46 = last_rsi_3 > 46.0
    last_rsi_3_gt_44 = last_rsi_3 > 44.0
    last_rsi_14_gt_77 = last_rsi_14 > 77.0
    last_rsi_14_gt_76 = last_rsi_14 > 76.0
    last_rsi_14_lt_56 = last_rsi_14 < 56.0
    last_rsi_14_lt_44 = last_rsi_14 < 44.0
    last_rsi_14_lt_40 = last_rsi_14 < 40.0

    if 0.01 > current_profit >= 0.001:
      if (last_willr_480 > -0.1) and (last_willr_14_gte_neg_1) and (last_rsi_14_gt_75):
        return True, f"exit_{mode_name}_w_0_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14 > 84.0):
        return True, f"exit_{mode_name}_w_0_2"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_lt_40):
        return True, f"exit_{mode_name}_w_0_3"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_80) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_0_4"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_4)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_0_5"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_1)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_0_6"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_0_7"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_0_8"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_1)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_0_9"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_16)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_0_10"
      elif (last_rsi_3_gt_98) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_0_11"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_0_12"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_0_13"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_0_14"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_48)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_0_15"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_0_16"
      elif (
        (last_rsi_3_gt_98) and (last_willr_14_gt_neg_4) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_0_17"
      elif (
        (last_rsi_3_gt_90) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_0_18"
    elif 0.02 > current_profit >= 0.01:
      if last_willr_480 > -0.2:
        return True, f"exit_{mode_name}_w_1_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_78):
        return True, f"exit_{mode_name}_w_1_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_46):
        return True, f"exit_{mode_name}_w_1_3"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_gt_78) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_1_4"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_6)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_1_5"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_2)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_1_6"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_1_7"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_1_8"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_2)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_1_9"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_18)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_1_10"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_1_11"
      elif (last_rsi_3_gt_98) and (last_willr_14_gt_neg_2) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_1_12"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_1_13"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_1_14"
      elif (
        (last_rsi_3_gt_50)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_1_15"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_1_16"
      elif (
        (last_rsi_3_gt_96) and (last_willr_14_gt_neg_6) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_1_17"
      elif (
        (last_rsi_3_gt_88) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_d_1_18"
    elif 0.03 > current_profit >= 0.02:
      if last_willr_480 > -0.3:
        return True, f"exit_{mode_name}_w_2_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_77):
        return True, f"exit_{mode_name}_w_2_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_48):
        return True, f"exit_{mode_name}_w_2_3"
      elif (last_willr_14_gte_neg_5) and (last_rsi_14_gt_75) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_2_4"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_8)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_2_5"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_4)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_2_6"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_2_7"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_2_8"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_4)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_2_9"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_20)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_2_10"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_2_11"
      elif (last_rsi_3_gt_96) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_2_12"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_2_13"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_2_14"
      elif (
        (last_rsi_3_gt_48)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_52)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_2_15"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_2_16"
      elif (
        (last_rsi_3_gt_94) and (last_willr_14_gt_neg_8) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_2_17"
      elif (
        (last_rsi_3_gt_86) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_2_18"
    elif 0.04 > current_profit >= 0.03:
      if last_willr_480 > -0.4:
        return True, f"exit_{mode_name}_w_3_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_76):
        return True, f"exit_{mode_name}_w_3_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_50):
        return True, f"exit_{mode_name}_w_3_3"
      elif (last_willr_14_gte_neg_5) and (last_rsi_14_gt_75) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_3_4"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_3_5"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_6)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_3_6"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_3_7"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_3_8"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_6)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_3_9"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_22)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_3_10"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_3_11"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_3_12"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_3_13"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_3_14"
      elif (
        (last_rsi_3_gt_46)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_54)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_3_15"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_3_16"
      elif (
        (last_rsi_3_gt_92) and (last_willr_14_gt_neg_10) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_3_17"
      elif (
        (last_rsi_3_gt_84) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_3_18"
    elif 0.05 > current_profit >= 0.04:
      if last_willr_480 > -0.5:
        return True, f"exit_{mode_name}_w_4_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_75):
        return True, f"exit_{mode_name}_w_4_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_52):
        return True, f"exit_{mode_name}_w_4_3"
      elif (last_willr_14_gte_neg_5) and (last_rsi_14_gt_75) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_4_4"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_12)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_4_5"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_8)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_4_6"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_4_7"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_4_8"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_4_9"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_24)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_4_10"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_4_11"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_4_12"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_4_13"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_4_14"
      elif (
        (last_rsi_3_gt_44)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_56)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_4_15"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_4_16"
      elif (
        (last_rsi_3_gt_90) and (last_willr_14_gt_neg_12) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_4_17"
      elif (
        (last_rsi_3_gt_82) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_4_18"
    elif 0.06 > current_profit >= 0.05:
      if last_willr_480 > -0.6:
        return True, f"exit_{mode_name}_w_5_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14 > 74.0):
        return True, f"exit_{mode_name}_w_5_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_54):
        return True, f"exit_{mode_name}_w_5_3"
      elif (last_willr_14 >= -10.0) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_5_4"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_14)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_5_5"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_5_6"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_5_7"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_5_8"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_10)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_5_9"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14 > -26.0)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_5_10"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_5_11"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_5_12"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_5_13"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_5_14"
      elif (
        (last_rsi_3 > 42.0)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14 < 58.0)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_5_15"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_5_16"
      elif (
        (last_rsi_3_gt_88) and (last_willr_14_gt_neg_14) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_5_17"
      elif (
        (last_rsi_3_gt_80) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_5_18"
    elif 0.07 > current_profit >= 0.06:
      if last_willr_480 > -0.7:
        return True, f"exit_{mode_name}_w_6_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_75):
        return True, f"exit_{mode_name}_w_6_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_52):
        return True, f"exit_{mode_name}_w_6_3"
      elif (last_willr_14_gte_neg_15) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_6_4"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_12)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_6_5"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_8)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_6_6"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_6_7"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_6_8"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_6_9"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_24)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_6_10"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_6_11"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_6_12"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_6_13"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_6_14"
      elif (
        (last_rsi_3_gt_44)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_56)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_6_15"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_6_16"
      elif (
        (last_rsi_3_gt_90) and (last_willr_14_gt_neg_12) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_6_17"
      elif (
        (last_rsi_3_gt_82) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_6_18"
    elif 0.08 > current_profit >= 0.07:
      if last_willr_480 > -0.8:
        return True, f"exit_{mode_name}_w_7_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_76):
        return True, f"exit_{mode_name}_w_7_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_50):
        return True, f"exit_{mode_name}_w_7_3"
      elif (last_willr_14_gte_neg_15) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_7_4"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_7_5"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_6)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_7_6"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_7_7"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_7_8"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_6)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_7_9"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_22)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_7_10"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_7_11"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_7_12"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_7_13"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_7_14"
      elif (
        (last_rsi_3_gt_46)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_54)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_7_15"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_7_16"
      elif (
        (last_rsi_3_gt_92) and (last_willr_14_gt_neg_10) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_7_17"
      elif (
        (last_rsi_3_gt_84) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_7_18"
    elif 0.09 > current_profit >= 0.08:
      if last_willr_480 > -0.9:
        return True, f"exit_{mode_name}_w_8_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_77):
        return True, f"exit_{mode_name}_w_8_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_48):
        return True, f"exit_{mode_name}_w_8_3"
      elif (last_willr_14_gte_neg_15) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_8_4"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_8)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_8_5"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_4)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_8_6"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_8_7"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_8_8"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_4)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_8_9"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_20)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_8_10"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_8_11"
      elif (last_rsi_3_gt_96) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_8_12"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_8_13"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_8_14"
      elif (
        (last_rsi_3_gt_48)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_52)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_8_15"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_8_16"
      elif (
        (last_rsi_3_gt_94) and (last_willr_14_gt_neg_8) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_8_17"
      elif (
        (last_rsi_3_gt_86) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_8_18"
    elif 0.1 > current_profit >= 0.09:
      if last_willr_480 > -1.0:
        return True, f"exit_{mode_name}_w_9_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_78):
        return True, f"exit_{mode_name}_w_9_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_46):
        return True, f"exit_{mode_name}_w_9_3"
      elif (last_willr_14_gte_neg_15) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_9_4"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_6)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_9_5"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_2)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_9_6"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_9_7"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_9_8"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_2)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_9_9"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_18)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_9_10"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_9_11"
      elif (last_rsi_3_gt_98) and (last_willr_14_gt_neg_2) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_9_12"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_9_13"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_9_14"
      elif (
        (last_rsi_3_gt_50)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_9_15"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_9_16"
      elif (
        (last_rsi_3_gt_96) and (last_willr_14_gt_neg_6) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_9_17"
      elif (
        (last_rsi_3_gt_88) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_9_18"
    elif 0.12 > current_profit >= 0.1:
      if last_willr_480 > -1.1:
        return True, f"exit_{mode_name}_w_10_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14 > 79.0):
        return True, f"exit_{mode_name}_w_10_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_44):
        return True, f"exit_{mode_name}_w_10_3"
      elif (last_willr_14_gte_neg_15) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_10_4"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_4)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_10_5"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_1)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_10_6"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_10_7"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_10_8"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_1)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_10_9"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_16)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_10_10"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_10_11"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_10_12"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_10_13"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_10_14"
      elif (
        (last_rsi_3 > 52.0)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_48)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_10_15"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_10_16"
      elif (
        (last_rsi_3_gt_98) and (last_willr_14_gt_neg_4) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_10_17"
      elif (
        (last_rsi_3_gt_90) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_10_18"
    elif 0.2 > current_profit >= 0.12:
      if last_willr_480 > -0.4:
        return True, f"exit_{mode_name}_w_11_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_80):
        return True, f"exit_{mode_name}_w_11_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14 < 42.0):
        return True, f"exit_{mode_name}_w_11_3"
      elif (last_willr_14_gte_neg_15) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_11_4"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_2)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_11_5"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_11_6"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_11_7"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_11_8"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_1)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_11_9"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_14)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_11_10"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_11_11"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_11_12"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_11_13"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_11_14"
      elif (
        (last_rsi_3 > 54.0)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_46)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_11_15"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_11_16"
      elif (
        (last_rsi_3_gt_99) and (last_willr_14_gt_neg_2) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_11_17"
      elif (
        (last_rsi_3_gt_92) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_11_18"
    elif current_profit >= 0.2:
      if last_willr_480 > -0.2:
        return True, f"exit_{mode_name}_w_12_1"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14 > 81.0):
        return True, f"exit_{mode_name}_w_12_2"
      elif (last_willr_14_gte_neg_2) and (last_rsi_14_lt_40):
        return True, f"exit_{mode_name}_w_12_3"
      elif (last_willr_14_gte_neg_1) and (last_rsi_14_gt_80) and (last_roc_9_1h_lt_0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_w_12_4"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_12_5"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
        and (last_stochrsi_k_1h_gt_80)
      ):
        return True, f"exit_{mode_name}_w_12_6"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_14_4h_gt_60)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
      ):
        return True, f"exit_{mode_name}_w_12_7"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_w_12_8"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_1)
        and (last_roc_9_1h_lt_neg_5)
        and (last_roc_9_4h_gt_10)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_w_12_9"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_12)
        and (last_aroonu_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_lt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_w_12_10"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_25):
        return True, f"exit_{mode_name}_w_12_11"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_w_12_12"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_w_12_13"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_w_12_14"
      elif (
        (last_rsi_3 > 56.0)
        and (last_willr_480_gt_neg_25)
        and (last_rsi_14_lt_44)
        and (last_rsi_14_4h_gt_70)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 100.0))
      ):
        return True, f"exit_{mode_name}_w_12_15"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_40)
        and (last_aroonu_14_4h_gt_75)
        and (last_stochrsi_k_1h_gt_30)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_w_12_16"
      elif (
        (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_aroonu_14_4h_gt_75) and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_w_12_17"
      elif (
        (last_rsi_3_gt_94) and (last_willr_14_gt_neg_20) and (last_aroonu_14_4h_gt_50) and (last_top_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_12_18"

    #  Here ends exit signal conditions for long_exit_williams_r

    return False, None

  # Long Exit Dec
  # ---------------------------------------------------------------------------------------------
  def long_exit_dec(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_rsi_3 = last_candle["RSI_3"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_aroonu_14_4h = last_candle["AROONU_14_4h"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_aroonu_14_1h = last_candle["AROONU_14_1h"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    last_ema_200_1h = last_candle["EMA_200_1h"]
    last_ema_200_4h = last_candle["EMA_200_4h"]
    last_change_pct_1d = last_candle["change_pct_1d"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_1d = last_candle["STOCHRSIk_14_14_3_3_1d"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_aroonu_14_1d = last_candle["AROONU_14_1d"]
    last_cmf_20_1h = last_candle["CMF_20_1h"]
    last_cmf_20_4h = last_candle["CMF_20_4h"]
    last_ema_12_1h = last_candle["EMA_12_1h"]
    last_ema_12_4h = last_candle["EMA_12_4h"]
    last_change_pct_4h = last_candle["change_pct_4h"]
    last_roc_2_1d = last_candle["ROC_2_1d"]
    last_roc_2_1h = last_candle["ROC_2_1h"]
    last_roc_2_4h = last_candle["ROC_2_4h"]
    last_rsi_14_1d = last_candle["RSI_14_1d"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    last_cci_20_change_pct_1h = last_candle["CCI_20_change_pct_1h"]
    last_kst_1h = last_candle["KST_10_15_20_30_10_10_10_15_1h"]
    last_kst_4h = last_candle["KST_10_15_20_30_10_10_10_15_4h"]
    last_ksts_9_1h = last_candle["KSTs_9_1h"]
    last_ksts_9_4h = last_candle["KSTs_9_4h"]
    last_roc_9_15m = last_candle["ROC_9_15m"]
    last_stochrsi_k_change_pct_4h = last_candle["STOCHRSIk_14_14_3_3_change_pct_4h"]
    last_stoch_k_4h = last_candle["STOCHk_14_3_3_4h"]
    last_change_pct_1h = last_candle["change_pct_1h"]
    last_close = last_candle["close"]
    last_high_max_30_1d = last_candle["high_max_30_1d"]
    # Reused long exit decision thresholds
    last_stochrsi_k_4h_gt_50 = last_stochrsi_k_4h > 50.0
    last_rsi_14_lt_50 = last_rsi_14 < 50.0
    last_stochrsi_k_1h_gt_50 = last_stochrsi_k_1h > 50.0
    last_rsi_3_1h_lt_30 = last_rsi_3_1h < 30.0
    last_rsi_3_4h_lt_30 = last_rsi_3_4h < 30.0

    # Reused long DEC exit thresholds
    last_willr_14_gt_neg_10 = last_willr_14 > -10.0
    last_willr_14_gt_neg_1 = last_willr_14 > -1.0
    last_willr_14_gt_neg_2 = last_willr_14 > -2.0
    last_willr_14_gt_neg_25 = last_willr_14 > -25.0
    last_willr_14_gt_neg_8 = last_willr_14 > -8.0
    last_willr_14_gt_neg_20 = last_willr_14 > -20.0
    last_change_pct_1d_lt_neg_5 = last_change_pct_1d < -5.0
    last_willr_14_gt_neg_6 = last_willr_14 > -6.0
    last_willr_14_gt_neg_4 = last_willr_14 > -4.0
    last_roc_9_4h_lt_neg_25 = last_roc_9_4h < -25.0
    last_roc_9_4h_lt_neg_20 = last_roc_9_4h < -20.0
    last_roc_9_1h_lt_neg_10 = last_roc_9_1h < -10.0
    last_change_pct_4h_lt_neg_5 = last_change_pct_4h < -5.0
    last_stochrsi_k_4h_gt_80 = last_stochrsi_k_4h > 80.0
    last_stochrsi_k_4h_gt_70 = last_stochrsi_k_4h > 70.0
    last_stochrsi_k_4h_gt_10 = last_stochrsi_k_4h > 10.0
    last_stochrsi_k_1h_gt_25 = last_stochrsi_k_1h > 25.0
    last_stochrsi_k_1h_gt_20 = last_stochrsi_k_1h > 20.0
    last_rsi_3_4h_lt_5 = last_rsi_3_4h < 5.0
    last_rsi_3_4h_lt_35 = last_rsi_3_4h < 35.0
    last_rsi_3_1d_lt_40 = last_rsi_3_1d < 40.0
    last_rsi_3_15m_lt_30 = last_rsi_3_15m < 30.0
    last_roc_9_4h_gt_40 = last_roc_9_4h > 40.0
    last_roc_9_4h_gt_25 = last_roc_9_4h > 25.0
    last_roc_9_4h_lt_neg_5 = last_roc_9_4h < -5.0
    last_roc_9_4h_lt_neg_10 = last_roc_9_4h < -10.0
    last_roc_9_1h_lt_neg_5 = last_roc_9_1h < -5.0
    last_roc_2_4h_lt_neg_30 = last_roc_2_4h < -30.0
    last_cmf_20_4h_lt_0 = last_cmf_20_4h < -0.0
    last_cmf_20_1h_lt_0 = last_cmf_20_1h < -0.0
    last_willr_14_gt_neg_12 = last_willr_14 > -12.0
    last_stochrsi_k_gt_70 = last_stochrsi_k > 70.0
    last_willr_14_gt_neg_30 = last_willr_14 > -30.0
    last_willr_14_gt_neg_15 = last_willr_14 > -15.0
    last_willr_14_gt_neg_14 = last_willr_14 > -14.0
    last_willr_14_gt_neg_5 = last_willr_14 > -5.0
    last_willr_14_gt_neg_16 = last_willr_14 > -16.0
    last_rsi_3_15m_gt_70 = last_rsi_3_15m > 70.0
    last_rsi_3_gt_56 = last_rsi_3 > 56.0
    last_willr_14_gt_neg_18 = last_willr_14 > -18.0
    last_stochrsi_k_change_pct_4h_lt_neg_10 = last_stochrsi_k_change_pct_4h < -10.0
    last_stochrsi_k_1h_gt_90 = last_stochrsi_k_1h > 90.0
    last_stochrsi_k_1h_gt_75 = last_stochrsi_k_1h > 75.0
    last_stochrsi_k_1d_gt_50 = last_stochrsi_k_1d > 50.0
    last_stoch_k_4h_gt_40 = last_stoch_k_4h > 40.0

    if 0.01 > current_profit >= 0.001:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_95 = last_rsi_3 > 95.0
      last_rsi_3_gt_99 = last_rsi_3 > 99.0
      last_rsi_3_gt_98 = last_rsi_3 > 98.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_rsi_14_gt_78 = last_rsi_14 > 78.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_14_lt_40 = last_rsi_14 < 40.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_42 = last_rsi_14 < 42.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_gt_96 = last_rsi_3 > 96.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_stochrsi_k_gt_95 = last_stochrsi_k > 95.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_14_lt_38 = last_rsi_14 < 38.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14_gt_78)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_0_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14_gt_78)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_0_2"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_0_3"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14_gt_78)
        and (last_stochrsi_k_gt_95)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_0_4"
      elif (last_willr_14_gt_neg_1) and (last_rsi_14_gt_78) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_0_5"
      elif (
        (last_rsi_3_gt_95)
        and (last_stochrsi_k_gt_95)
        and (last_rsi_14_lt_40)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_95)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_0_7"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_0_8"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_3_gt_99)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_9"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_0_10"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_0_11"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_0_12"
      elif (last_rsi_3_gt_99) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_0_13"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_0_14"
      elif (last_rsi_3_gt_99) and (last_rsi_14_gt_78) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_0_15"
      elif (
        (last_rsi_3_gt_99)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_0_16"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_0_17"
      elif (last_rsi_3_gt_95) and (last_rsi_14 > 75.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_0_18"
      elif (
        (last_rsi_3_gt_99)
        and (last_rsi_14_gt_78)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_0_19"
      elif (last_rsi_3_gt_90) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_0_20"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_0_21"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_0_22"
      elif (last_rsi_3_gt_98) and (last_willr_14_gt_neg_5) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_0_23"
      elif (
        (last_rsi_3_gt_99)
        and (last_rsi_14_gt_78)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_0_24"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_25"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_0_26"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_0_27"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_0_28"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_0_29"
      elif (last_rsi_3_gt_99) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_0_30"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_0_31"
      elif (last_rsi_3_gt_95) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_0_32"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_1)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_0_34"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_5) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_0_35"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_1)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_36"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_37"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_0_38"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_0_39"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_0_40"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_41"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_0_42"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_0_43"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_0_44"
      elif (last_rsi_3_gt_96) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_0_45"
      elif (last_rsi_3_gt_98) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_0_46"
      elif (
        (last_rsi_3_gt_98)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_0_47"
      elif (
        (last_rsi_3 > 70.0)
        and (last_rsi_14_lt_42)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_48"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_49"
      elif (last_rsi_3 > 80.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_0_50"
      elif (last_rsi_3 > 68.0) and (last_rsi_14_lt_44) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_0_51"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14 > 62.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_0_52"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_53"
      elif (
        (last_rsi_3 > 80.0)
        and (last_rsi_14_lt_44)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_0_54"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_12)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_55"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_0_56"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 34.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_0_57"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_58"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_59"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_38)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_60"
      elif (last_rsi_3_gt_98) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_0_61"
      elif (
        (last_rsi_3 > 88.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_0_62"
      elif (last_rsi_3_gt_98) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_0_63"
      elif (
        (last_rsi_3_gt_98)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_64"
      elif (last_rsi_3_gt_90) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_0_65"
      elif (last_rsi_3_gt_84) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_0_66"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14_lt_40)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_0_67"
      elif (
        (last_rsi_3 > 86.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_0_68"
      elif (
        (last_rsi_3 > 97.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_0_69"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_38) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_0_70"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_42) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_0_71"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_0_72"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_0_73"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_74"
      elif (
        (last_rsi_3_gt_98)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_75"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_48) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_0_76"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_77"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_0_78"
      elif (last_rsi_3 > 94.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_0_79"
      elif (
        (last_rsi_3 > 74.0)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_0_80"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_81"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_82"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_83"
      elif (last_rsi_3_gt_99) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_0_84"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_85"
      elif (
        (last_rsi_3_gt_96)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_86"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_42)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_87"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_0_88"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_38)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_0_89"
      elif (
        (last_rsi_3 > 94.0)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_0_90"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_91"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_0_92"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_93"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_0_94"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_0_95"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_96"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_0_97"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_3_15m > 74.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_98"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_0_99"
      elif (last_rsi_3_gt_99) and (last_rsi_14_gt_78) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_0_100"
      elif (
        (last_rsi_3 > 86.0)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_0_101"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_0_102"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14 < 54.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_0_103"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_104"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_0_105"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_106"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_0_107"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_0_108"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_109"
      elif (last_rsi_3_gt_95) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_0_110"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_42)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_0_111"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_112"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_0_113"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_0_114"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_115"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_0_116"
      elif (last_rsi_3_gt_95) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_0_117"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_0_118"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_119"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_0_120"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_0_121"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_42) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_0_122"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_0_123"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_0_124"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_0_125"
      elif (last_rsi_3_gt_95) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_0_126"
      elif (last_rsi_3_gt_95) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_0_127"
      elif (last_rsi_3_gt_96) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_0_128"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_0_129"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_0_130"
      elif (last_rsi_14 < 36.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_0_131"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_0_132"
      elif (
        (last_rsi_3_gt_95)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_0_133"
    elif 0.02 > current_profit >= 0.01:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_gt_95 = last_rsi_3 > 95.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_14_lt_40 = last_rsi_14 < 40.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_rsi_3_gt_65 = last_rsi_3 > 65.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_rsi_3_gt_94 = last_rsi_3 > 94.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_68 = last_rsi_3 > 68.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_98 = last_rsi_3 > 98.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_66 = last_rsi_3 > 66.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_rsi_14_lt_42 = last_rsi_14 < 42.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_1_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 68.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_1_2"
      elif (
        (last_willr_14_gt_neg_8)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_1_3"
      elif (
        (last_willr_14_gt_neg_30)
        and (last_rsi_14 > 65.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_1_4"
      elif (last_willr_14_gt_neg_2) and (last_rsi_14 > 72.0) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_1_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14_lt_40)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_1_7"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_1_8"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_rsi_3_gt_95)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_9"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_1_10"
      elif (
        (last_rsi_3 > 75.0)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_1_11"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_1_12"
      elif (last_rsi_3_gt_80) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_1_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_1_14"
      elif (last_rsi_3_gt_95) and (last_rsi_14 > 75.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_1_15"
      elif (
        (last_rsi_3_gt_95)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_1_16"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_1_17"
      elif (last_rsi_3 > 75.0) and (last_rsi_14 > 60.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_1_18"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14 > 72.0)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_1_19"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_1_20"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_1_21"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_2)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_1_22"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_1_23"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14 > 75.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_1_24"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_25"
      elif (last_rsi_3_gt_85) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_1_26"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_1_27"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_1_28"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_1_29"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_1_30"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_1_31"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_1_32"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_2)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_33"
      elif (last_rsi_3_gt_65) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_1_34"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_6) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_1_35"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_15)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_36"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_37"
      elif (last_rsi_3_gt_85) and (last_willr_14_gt_neg_15) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_1_38"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_5) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_1_39"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_1_40"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_41"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_25)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_1_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_1_43"
      elif (
        (last_rsi_3_gt_65)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_1_44"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_1_45"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_1_46"
      elif (
        (last_rsi_3_gt_86)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_1_47"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_48"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_4) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_1_50"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_46) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_1_51"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14 > 60.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_1_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_53"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_46)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_1_54"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_14)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_55"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_1_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 36.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_1_57"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_59"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_40)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_1_61"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_1_62"
      elif (last_rsi_3_gt_68) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_1_63"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_64"
      elif (last_rsi_3_gt_68) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_1_65"
      elif (last_rsi_3_gt_82) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_1_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_42)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_1_67"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_1_68"
      elif (
        (last_rsi_3 > 96.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_1_69"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_1_70"
      elif (last_rsi_3 > 64.0) and (last_rsi_14_lt_44) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_1_71"
      elif (last_rsi_3_gt_78) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_1_72"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_1_73"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_74"
      elif (
        (last_rsi_3 > 96.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_75"
      elif (last_rsi_3_gt_68) and (last_rsi_14_lt_50) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_1_76"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_77"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_1_78"
      elif (last_rsi_3 > 92.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_1_79"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_1_80"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_81"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_82"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_83"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_1_84"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_85"
      elif (
        (last_rsi_3_gt_94)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_86"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_87"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_20)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_1_88"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_40)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_1_89"
      elif (
        (last_rsi_3 > 92.0)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_1_90"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_91"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_1_92"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_93"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_1_94"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_1_95"
      elif (
        (last_rsi_3 > 62.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_96"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_1_97"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_15m > 72.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_98"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14 < 52.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_1_99"
      elif (last_rsi_3_gt_98) and (last_rsi_14 > 76.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_1_100"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_1_101"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_1_102"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14 < 56.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_1_103"
      elif (
        (last_rsi_3 > 64.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_104"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_1_105"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_106"
      elif (
        (last_rsi_3 > 74.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_1_107"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_1_108"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_109"
      elif (last_rsi_3_gt_72) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_1_110"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_1_111"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_14 < 52.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_112"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_1_113"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_1_114"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_115"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_1_116"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_1_117"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_1_118"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_119"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_1_120"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_1_121"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_44) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_1_122"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_1_123"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_1_124"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_1_125"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_1_126"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_1_127"
      elif (last_rsi_3_gt_94) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_1_128"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_1_129"
      elif (
        (last_rsi_3 > 74.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_1_130"
      elif (last_rsi_14 < 38.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_1_131"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_1_132"
      elif (
        (last_rsi_3_gt_80)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_1_133"
    elif 0.03 > current_profit >= 0.02:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_rsi_14_gt_70 = last_rsi_14 > 70.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_14_lt_42 = last_rsi_14 < 42.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_66 = last_rsi_3 > 66.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_rsi_3_gt_65 = last_rsi_3 > 65.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_64 = last_rsi_3 > 64.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_2_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 66.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_2_2"
      elif (
        (last_willr_14_gt_neg_10)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_2_3"
      elif (
        (last_willr_14_gt_neg_30)
        and (last_rsi_14 > 65.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_2_4"
      elif (last_willr_14_gt_neg_4) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_2_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_2_7"
      elif (
        (last_willr_14_gt_neg_4)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_2_8"
      elif (
        (last_willr_14_gt_neg_4)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_9"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_2_10"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_2_11"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_2_12"
      elif (last_rsi_3_gt_80) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_2_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_2_14"
      elif (last_rsi_3_gt_92) and (last_rsi_14_gt_70) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_2_15"
      elif (
        (last_rsi_3_gt_70)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_2_16"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_2_17"
      elif (last_rsi_3_gt_75) and (last_rsi_14 > 60.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_2_18"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_gt_70)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_2_19"
      elif (last_rsi_3 > 48.0) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_2_20"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_2_21"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_4)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_2_22"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_15) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_2_23"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_gt_70)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_2_24"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_25"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_2_26"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_2_27"
      elif (last_rsi_3_gt_75) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_2_28"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_2_29"
      elif (last_rsi_3_gt_85) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_2_30"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_2_31"
      elif (last_rsi_3_gt_85) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_2_32"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_4)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_33"
      elif (last_rsi_3_gt_65) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_2_34"
      elif (last_rsi_3_gt_86) and (last_willr_14 > -7.0) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_2_35"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_36"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_37"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_20) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_2_38"
      elif (last_rsi_3 > 94.0) and (last_willr_14_gt_neg_6) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_2_39"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_2_40"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_41"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_30)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_2_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_2_43"
      elif (
        (last_rsi_3_gt_60)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_2_44"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_2_45"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_2_46"
      elif (
        (last_rsi_3_gt_84)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_2_47"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_48"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_6) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_2_50"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_48) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_2_51"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14 > 58.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_2_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_53"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_48)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_2_54"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_16)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_55"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_2_56"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 38.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_2_57"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_59"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_42)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_2_61"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_2_62"
      elif (last_rsi_3_gt_66) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_2_63"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_64"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_2_65"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_2_66"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14_lt_44)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_2_67"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_2_68"
      elif (
        (last_rsi_3 > 95.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_2_69"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_2_70"
      elif (last_rsi_3 > 62.0) and (last_rsi_14_lt_46) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_2_71"
      elif (last_rsi_3_gt_76) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_2_72"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_2_73"
      elif (
        (last_rsi_3 > 97.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_74"
      elif (
        (last_rsi_3 > 94.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_75"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_52) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_2_76"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_77"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_2_78"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_2_79"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_2_80"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_81"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_82"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_83"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_2_84"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_85"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_86"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_87"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14 > -22.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_2_88"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_42)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_2_89"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_2_90"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_91"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_2_92"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_93"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_2_94"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_2_95"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_96"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_2_97"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_15m_gt_70)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_98"
      elif (
        (last_rsi_3 > 58.0)
        and (last_rsi_14 < 54.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_2_99"
      elif (last_rsi_3 > 96.0) and (last_rsi_14 > 74.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_2_100"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_2_101"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_2_102"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14 < 58.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_2_103"
      elif (
        (last_rsi_3 > 62.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_104"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_2_105"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_106"
      elif (
        (last_rsi_3 > 72.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_2_107"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_2_108"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_109"
      elif (last_rsi_3_gt_70) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_2_110"
      elif (
        (last_rsi_3 > 48.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_2_111"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_14 < 54.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_112"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_2_113"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_2_114"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_115"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_2_116"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_2_117"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_2_118"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_119"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_2_120"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_2_121"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_46) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_2_122"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_2_123"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_2_124"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_2_125"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_2_126"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_2_127"
      elif (last_rsi_3_gt_92) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_2_128"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_2_129"
      elif (
        (last_rsi_3 > 72.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_2_130"
      elif (last_rsi_14 < 40.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_2_131"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_2_132"
      elif (
        (last_rsi_3_gt_78)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_2_133"
    elif 0.04 > current_profit >= 0.03:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_gt_68 = last_rsi_3 > 68.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_64 = last_rsi_3 > 64.0
      last_rsi_14_lt_54 = last_rsi_14 < 54.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_stochrsi_k_gt_95 = last_stochrsi_k > 95.0
      last_rsi_14_gt_68 = last_rsi_14 > 68.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_94 = last_rsi_3 > 94.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_rsi_3_gt_65 = last_rsi_3 > 65.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_62 = last_rsi_3 > 62.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_3_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 64.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_3_2"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_stochrsi_k_gt_95)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_3_3"
      elif (
        (last_willr_14_gt_neg_30)
        and (last_rsi_14 > 65.0)
        and (last_stochrsi_k_gt_95)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_3_4"
      elif (last_willr_14_gt_neg_6) and (last_rsi_14_gt_68) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_3_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_3_7"
      elif (
        (last_willr_14_gt_neg_6)
        and (last_stochrsi_k_gt_95)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_3_8"
      elif (
        (last_willr_14_gt_neg_6)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_9"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_3_10"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_3_11"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_3_12"
      elif (last_rsi_3_gt_80) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_3_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_3_14"
      elif (last_rsi_3_gt_90) and (last_rsi_14 > 65.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_3_15"
      elif (
        (last_rsi_3_gt_70)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_3_16"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_3_17"
      elif (last_rsi_3_gt_75) and (last_rsi_14 > 60.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_3_18"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_14_gt_68)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_3_19"
      elif (last_rsi_3 > 46.0) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_3_20"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_3_21"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_6)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_3_22"
      elif (last_rsi_3_gt_85) and (last_willr_14_gt_neg_20) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_3_23"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_14_gt_68)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_3_24"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_25"
      elif (last_rsi_3_gt_75) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_3_26"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_3_27"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_3_28"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_3_29"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_3_30"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_3_31"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_3_32"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_6)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_33"
      elif (last_rsi_3_gt_65) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_3_34"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_8) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_3_35"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_36"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_37"
      elif (last_rsi_3_gt_75) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_3_38"
      elif (last_rsi_3 > 93.0) and (last_willr_14 > -7.0) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_3_39"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_3_40"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_41"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14 > -35.0)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_3_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_3_43"
      elif (
        (last_rsi_3 > 55.0)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_3_44"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_3_45"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_3_46"
      elif (
        (last_rsi_3_gt_82)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_3_47"
      elif (
        (last_rsi_3 > 55.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_48"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_8) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_3_50"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_50) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_3_51"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14 > 56.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_3_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_53"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_3_54"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_18)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_55"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_3_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_3_57"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_59"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_44)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_3_61"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_3_62"
      elif (last_rsi_3_gt_64) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_3_63"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_64"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_3_65"
      elif (last_rsi_3_gt_78) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_3_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_46)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_3_67"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_3_68"
      elif (
        (last_rsi_3_gt_94) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_3_69"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_3_70"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_48) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_3_71"
      elif (last_rsi_3_gt_74) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_3_72"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_3_73"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_74"
      elif (
        (last_rsi_3 > 92.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_75"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_54) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_3_76"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_77"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_3_78"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_3_79"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_3_80"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_81"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_82"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_83"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_3_84"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_85"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_86"
      elif (
        (last_rsi_3_gt_62)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_87"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14 > -24.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_3_88"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_44)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_3_89"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_3_90"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_91"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_3_92"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_93"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_3_94"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_3_95"
      elif (
        (last_rsi_3 > 58.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_96"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_3_97"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_15m > 68.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_98"
      elif (
        (last_rsi_3_gt_56)
        and (last_rsi_14 < 56.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_3_99"
      elif (last_rsi_3_gt_94) and (last_rsi_14 > 72.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_3_100"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_3_101"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_3_102"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14 < 60.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_3_103"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_104"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_3_105"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_106"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_3_107"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_3_108"
      elif (
        (last_rsi_3_gt_72)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_109"
      elif (last_rsi_3_gt_68) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_3_110"
      elif (
        (last_rsi_3 > 46.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_3_111"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14 > -35.0)
        and (last_rsi_14 < 56.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_112"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_3_113"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_3_114"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_115"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_3_116"
      elif (last_rsi_3_gt_82) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_3_117"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_3_118"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_119"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_3_120"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_3_121"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_48) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_3_122"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_3_123"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_3_124"
      elif (
        (last_rsi_3_gt_72)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_3_125"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_3_126"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_3_127"
      elif (last_rsi_3_gt_90) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_3_128"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_3_129"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_3_130"
      elif (last_rsi_14 < 42.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_3_131"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_3_132"
      elif (
        (last_rsi_3_gt_76)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_3_133"
    elif 0.05 > current_profit >= 0.04:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_54 = last_rsi_14 < 54.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_rsi_3_gt_66 = last_rsi_3 > 66.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_3_gt_65 = last_rsi_3 > 65.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_rsi_3_gt_62 = last_rsi_3 > 62.0
      last_rsi_14_lt_56 = last_rsi_14 < 56.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_stochrsi_k_gt_95 = last_stochrsi_k > 95.0
      last_rsi_14_gt_66 = last_rsi_14 > 66.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_4_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 62.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_4_2"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_stochrsi_k_gt_95)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_4_3"
      elif (
        (last_willr_14_gt_neg_30)
        and (last_rsi_14 > 65.0)
        and (last_stochrsi_k_gt_95)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_4_4"
      elif (last_willr_14_gt_neg_8) and (last_rsi_14_gt_66) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_4_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_4_7"
      elif (
        (last_willr_14_gt_neg_8)
        and (last_stochrsi_k_gt_95)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_4_8"
      elif (
        (last_willr_14 > -7.0)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_9"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_4_10"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_4_11"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_4_12"
      elif (last_rsi_3_gt_80) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_4_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_4_14"
      elif (last_rsi_3_gt_88) and (last_rsi_14 > 60.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_4_15"
      elif (
        (last_rsi_3_gt_70)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_4_16"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_4_17"
      elif (last_rsi_3_gt_75) and (last_rsi_14 > 60.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_4_18"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_gt_66)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_4_19"
      elif (last_rsi_3 > 44.0) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_4_20"
      elif (last_rsi_3 > 55.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_4_21"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_8)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_4_22"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_25) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_4_23"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_gt_66)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_4_24"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_25"
      elif (last_rsi_3_gt_70) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_4_26"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_4_27"
      elif (last_rsi_3_gt_65) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_4_28"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_4_29"
      elif (last_rsi_3_gt_75) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_4_30"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_4_31"
      elif (last_rsi_3_gt_75) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_4_32"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_8)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_33"
      elif (last_rsi_3_gt_65) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_4_34"
      elif (last_rsi_3_gt_82) and (last_willr_14 > -9.0) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_4_35"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_30)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_36"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_37"
      elif (last_rsi_3_gt_70) and (last_willr_14_gt_neg_30) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_4_38"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_8) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_4_39"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_4_40"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_41"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14 > -40.0)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_4_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_4_43"
      elif (
        (last_rsi_3_gt_50)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_4_44"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_12) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_4_45"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_4_46"
      elif (
        (last_rsi_3_gt_80)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_4_47"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_48"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_10) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_4_50"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_52) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_4_51"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14 > 54.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_4_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_53"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_52)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_4_54"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_20)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_55"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_4_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 42.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_4_57"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_58"
      elif (
        (last_rsi_3 > 85.0)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_59"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_46)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_4_61"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_4_62"
      elif (last_rsi_3_gt_62) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_4_63"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_64"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_4_65"
      elif (last_rsi_3_gt_76) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_4_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_48)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_4_67"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_4_68"
      elif (
        (last_rsi_3 > 93.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_4_69"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_4_70"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_50) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_4_71"
      elif (last_rsi_3_gt_72) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_4_72"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_4_73"
      elif (
        (last_rsi_3 > 95.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_74"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_75"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_56) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_4_76"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_77"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14 > -22.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_4_78"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_4_79"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_4_80"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_81"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_82"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_83"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_4_84"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_85"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_86"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_87"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14 > -26.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_4_88"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_4_89"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_4_90"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_91"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_4_92"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_93"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_4_94"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_4_95"
      elif (
        (last_rsi_3_gt_56)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_96"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_4_97"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_15m > 66.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_98"
      elif (
        (last_rsi_3 > 54.0)
        and (last_rsi_14 < 58.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_4_99"
      elif (last_rsi_3_gt_92) and (last_rsi_14 > 70.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_4_100"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14 > -22.0)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_4_101"
      elif (
        (last_rsi_3_gt_62)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_4_102"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14 < 62.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_4_103"
      elif (
        (last_rsi_3 > 58.0)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_104"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_4_105"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_106"
      elif (
        (last_rsi_3 > 68.0)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_4_107"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_4_108"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_109"
      elif (last_rsi_3_gt_66) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_4_110"
      elif (
        (last_rsi_3 > 44.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_4_111"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14 > -40.0)
        and (last_rsi_14 < 58.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_112"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_4_113"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_4_114"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_115"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_4_116"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_4_117"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_4_118"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_119"
      elif (last_rsi_3 > 48.0) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_4_120"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_4_121"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_50) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_4_122"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_4_123"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_4_124"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_4_125"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_4_126"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_4_127"
      elif (last_rsi_3_gt_88) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_4_128"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_4_129"
      elif (
        (last_rsi_3 > 68.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_4_130"
      elif (last_rsi_14 < 44.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_4_131"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_4_132"
      elif (
        (last_rsi_3_gt_74)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_4_133"
    elif 0.06 > current_profit >= 0.05:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_14_lt_56 = last_rsi_14 < 56.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_54 = last_rsi_14 < 54.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_gt_65 = last_rsi_3 > 65.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_rsi_3_gt_64 = last_rsi_3 > 64.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_14_lt_58 = last_rsi_14 < 58.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_stochrsi_k_gt_95 = last_stochrsi_k > 95.0
      last_rsi_14_gt_64 = last_rsi_14 > 64.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_58 = last_rsi_3 > 58.0
      last_rsi_3_gt_68 = last_rsi_3 > 68.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_5_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 60.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_5_2"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_stochrsi_k_gt_95)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_5_3"
      elif (
        (last_willr_14_gt_neg_30)
        and (last_rsi_14 > 65.0)
        and (last_stochrsi_k_gt_95)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_5_4"
      elif (last_willr_14_gt_neg_10) and (last_rsi_14_gt_64) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_5_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_5_7"
      elif (
        (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_gt_95)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_5_8"
      elif (
        (last_willr_14_gt_neg_8)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_9"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_5_10"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_5_11"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_5_12"
      elif (last_rsi_3_gt_80) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_5_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_12) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_5_14"
      elif (last_rsi_3_gt_86) and (last_rsi_14 > 58.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_5_15"
      elif (
        (last_rsi_3_gt_70)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_5_16"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14 > -35.0)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_5_17"
      elif (last_rsi_3_gt_75) and (last_rsi_14 > 60.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_5_18"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_gt_64)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_5_19"
      elif (last_rsi_3 > 42.0) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_5_20"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_5_21"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_10)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_5_22"
      elif (last_rsi_3_gt_75) and (last_willr_14_gt_neg_30) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_5_23"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_gt_64)
        and (last_willr_14 > -35.0)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_5_24"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_25"
      elif (last_rsi_3_gt_65) and (last_willr_14_gt_neg_12) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_5_26"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_5_27"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_5_28"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_5_29"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_5_30"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_5_31"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_5_32"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_10)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_33"
      elif (last_rsi_3_gt_65) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_5_34"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_10) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_5_35"
      elif (
        (last_rsi_3_gt_65)
        and (last_willr_14 > -35.0)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_36"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_37"
      elif (last_rsi_3_gt_65) and (last_willr_14 > -35.0) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_5_38"
      elif (last_rsi_3 > 91.0) and (last_willr_14 > -9.0) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_5_39"
      elif (
        (last_rsi_3_gt_65)
        and (last_willr_14 > -35.0)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_5_40"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_41"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14 > -45.0)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_5_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_5_43"
      elif (
        (last_rsi_3_gt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_5_44"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_14) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_5_45"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_5_46"
      elif (
        (last_rsi_3_gt_78)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_5_47"
      elif (
        (last_rsi_3 > 45.0)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_48"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_12) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_5_50"
      elif (last_rsi_3_gt_58) and (last_rsi_14_lt_54) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_5_51"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14 > 52.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_5_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_53"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_54)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_5_54"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14 > -22.0)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_55"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_5_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 44.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_5_57"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_58"
      elif (
        (last_rsi_3 > 85.0)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_59"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_48)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_5_61"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_5_62"
      elif (last_rsi_3_gt_60) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_5_63"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_64"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_5_65"
      elif (last_rsi_3_gt_74) and (last_rsi_14_lt_56) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_5_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_50)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_5_67"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_5_68"
      elif (
        (last_rsi_3 > 92.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_5_69"
      elif (last_rsi_3_gt_58) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_5_70"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_52) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_5_71"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_5_72"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_5_73"
      elif (
        (last_rsi_3 > 94.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_74"
      elif (
        (last_rsi_3 > 88.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_75"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_58) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_5_76"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_77"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14 > -24.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_5_78"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_5_79"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_5_80"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_81"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_82"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_83"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_5_84"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_85"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_86"
      elif (
        (last_rsi_3_gt_58)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_87"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14 > -28.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_5_88"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_5_89"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_5_90"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_91"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_5_92"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_58)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_93"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_58)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_5_94"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_5_95"
      elif (
        (last_rsi_3 > 54.0)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_96"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_5_97"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_15m > 64.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_98"
      elif (
        (last_rsi_3 > 52.0)
        and (last_rsi_14 < 60.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_5_99"
      elif (last_rsi_3_gt_90) and (last_rsi_14 > 68.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_5_100"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14 > -24.0)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_5_101"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_5_102"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14 < 64.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_5_103"
      elif (
        (last_rsi_3_gt_56)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_104"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_5_105"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_106"
      elif (
        (last_rsi_3 > 66.0)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_5_107"
      elif (last_rsi_3 > 48.0) and (last_rsi_14_lt_56) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_5_108"
      elif (
        (last_rsi_3_gt_68)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_109"
      elif (last_rsi_3_gt_64) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_5_110"
      elif (
        (last_rsi_3 > 42.0)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_5_111"
      elif (
        (last_rsi_3_gt_72)
        and (last_willr_14 > -45.0)
        and (last_rsi_14 < 60.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_112"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_5_113"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_58)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_5_114"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_115"
      elif (last_rsi_3_gt_82) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_5_116"
      elif (last_rsi_3_gt_78) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_5_117"
      elif (last_rsi_3_gt_82) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_5_118"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_119"
      elif (last_rsi_3 > 46.0) and (last_rsi_14_lt_56) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_5_120"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_5_121"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_52) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_5_122"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_12) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_5_123"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_5_124"
      elif (
        (last_rsi_3_gt_68)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_5_125"
      elif (last_rsi_3_gt_82) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_5_126"
      elif (last_rsi_3_gt_82) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_5_127"
      elif (last_rsi_3_gt_86) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_5_128"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_5_129"
      elif (
        (last_rsi_3 > 66.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_5_130"
      elif (last_rsi_14 < 46.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_5_131"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_5_132"
      elif (
        (last_rsi_3_gt_72)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_5_133"
    elif 0.07 > current_profit >= 0.06:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_54 = last_rsi_14 < 54.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_rsi_3_gt_66 = last_rsi_3 > 66.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_3_gt_65 = last_rsi_3 > 65.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_rsi_3_gt_62 = last_rsi_3 > 62.0
      last_rsi_14_lt_56 = last_rsi_14 < 56.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_rsi_14_gt_66 = last_rsi_14 > 66.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_6_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 62.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_6_2"
      elif (
        (last_willr_14_gt_neg_15)
        and (last_stochrsi_k > 98.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_6_3"
      elif (
        (last_willr_14_gt_neg_25)
        and (last_rsi_14 > 68.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_6_4"
      elif (last_willr_14_gt_neg_8) and (last_rsi_14_gt_66) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_6_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_6_7"
      elif (
        (last_willr_14_gt_neg_8)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_6_8"
      elif (
        (last_willr_14 > -7.0)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_9"
      elif (
        (last_willr_14_gt_neg_15)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_6_10"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_6_11"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_6_12"
      elif (last_rsi_3_gt_85) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_6_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_6_14"
      elif (last_rsi_3_gt_88) and (last_rsi_14 > 60.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_6_15"
      elif (
        (last_rsi_3_gt_75)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_6_16"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_6_17"
      elif (last_rsi_3_gt_80) and (last_rsi_14 > 65.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_6_18"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_gt_66)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_6_19"
      elif (last_rsi_3 > 44.0) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_6_20"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_6_21"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_8)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_6_22"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_25) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_6_23"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_gt_66)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_6_24"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_25"
      elif (last_rsi_3_gt_70) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_6_26"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_6_27"
      elif (last_rsi_3_gt_65) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_6_28"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_6_29"
      elif (last_rsi_3_gt_75) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_6_30"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_6_31"
      elif (last_rsi_3_gt_75) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_6_32"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_8)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_33"
      elif (last_rsi_3_gt_65) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_6_34"
      elif (last_rsi_3_gt_82) and (last_willr_14 > -9.0) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_6_35"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_30)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_36"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_37"
      elif (last_rsi_3_gt_70) and (last_willr_14_gt_neg_30) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_6_38"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_8) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_6_39"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_6_40"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_41"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14 > -40.0)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_6_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_6_43"
      elif (
        (last_rsi_3 > 55.0)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_6_44"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_12) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_6_45"
      elif (last_rsi_3_gt_75) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_6_46"
      elif (
        (last_rsi_3_gt_80)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_6_47"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_48"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_10) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_6_50"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_52) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_6_51"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14 > 54.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_6_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_53"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_52)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_6_54"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_20)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_55"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_6_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 42.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_6_57"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_59"
      elif (
        (last_rsi_3_gt_65)
        and (last_rsi_14_lt_46)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_6_61"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_6_62"
      elif (last_rsi_3_gt_62) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_6_63"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_64"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_6_65"
      elif (last_rsi_3_gt_76) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_6_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_48)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_6_67"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_6_68"
      elif (
        (last_rsi_3 > 93.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_6_69"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_6_70"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_50) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_6_71"
      elif (last_rsi_3_gt_72) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_6_72"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_6_73"
      elif (
        (last_rsi_3 > 95.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_74"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_75"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_56) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_6_76"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_77"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14 > -22.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_6_78"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_6_79"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_6_80"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_81"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_82"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_83"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_6_84"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_85"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_86"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_87"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14 > -26.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_6_88"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_6_89"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_6_90"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_91"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_6_92"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_93"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_6_94"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_6_95"
      elif (
        (last_rsi_3_gt_56)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_96"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_6_97"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_15m > 66.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_98"
      elif (
        (last_rsi_3 > 54.0)
        and (last_rsi_14 < 58.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_6_99"
      elif (last_rsi_3_gt_92) and (last_rsi_14 > 70.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_6_100"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14 > -22.0)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_6_101"
      elif (
        (last_rsi_3_gt_62)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_6_102"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14 < 62.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_6_103"
      elif (
        (last_rsi_3 > 58.0)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_104"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_6_105"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_106"
      elif (
        (last_rsi_3 > 68.0)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_6_107"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_6_108"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_109"
      elif (last_rsi_3_gt_66) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_6_110"
      elif (
        (last_rsi_3 > 44.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_6_111"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14 > -40.0)
        and (last_rsi_14 < 58.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_112"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_6_113"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_56)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_6_114"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_115"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_6_116"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_6_117"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_6_118"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_119"
      elif (last_rsi_3 > 48.0) and (last_rsi_14_lt_54) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_6_120"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_6_121"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_50) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_6_122"
      elif (last_rsi_3_gt_82) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_6_123"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_6_124"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_6_125"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_6_126"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_6_127"
      elif (last_rsi_3_gt_88) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_6_128"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_6_129"
      elif (
        (last_rsi_3 > 68.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_6_130"
      elif (last_rsi_14 < 44.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_6_131"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_6_132"
      elif (
        (last_rsi_3_gt_74)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_6_133"
    elif 0.08 > current_profit >= 0.07:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_gt_68 = last_rsi_3 > 68.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_64 = last_rsi_3 > 64.0
      last_rsi_14_lt_54 = last_rsi_14 < 54.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_rsi_14_gt_68 = last_rsi_14 > 68.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_94 = last_rsi_3 > 94.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_60 = last_rsi_3 > 60.0
      last_rsi_3_gt_62 = last_rsi_3 > 62.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_7_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 64.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_7_2"
      elif (
        (last_willr_14_gt_neg_10)
        and (last_stochrsi_k > 98.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_7_3"
      elif (
        (last_willr_14_gt_neg_20)
        and (last_rsi_14 > 70.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_7_4"
      elif (last_willr_14_gt_neg_6) and (last_rsi_14_gt_68) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_7_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_7_7"
      elif (
        (last_willr_14_gt_neg_6)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_7_8"
      elif (
        (last_willr_14_gt_neg_6)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_9"
      elif (
        (last_willr_14_gt_neg_10)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_7_10"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_7_11"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_7_12"
      elif (last_rsi_3_gt_90) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_7_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_7_14"
      elif (last_rsi_3_gt_90) and (last_rsi_14 > 62.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_7_15"
      elif (
        (last_rsi_3_gt_80)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_7_16"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_7_17"
      elif (last_rsi_3_gt_85) and (last_rsi_14 > 70.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_7_18"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_14_gt_68)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_7_19"
      elif (last_rsi_3 > 46.0) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_7_20"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_7_21"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_6)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_7_22"
      elif (last_rsi_3_gt_85) and (last_willr_14_gt_neg_20) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_7_23"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_14_gt_68)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_7_24"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_25"
      elif (last_rsi_3_gt_75) and (last_willr_14_gt_neg_8) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_7_26"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_7_27"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_7_28"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_7_29"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_7_30"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_7_31"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_7_32"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_6)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_7_34"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_8) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_7_35"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_36"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_37"
      elif (last_rsi_3_gt_75) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_7_38"
      elif (last_rsi_3 > 93.0) and (last_willr_14 > -7.0) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_7_39"
      elif (
        (last_rsi_3_gt_75)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_7_40"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_41"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14 > -35.0)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_7_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_7_43"
      elif (
        (last_rsi_3_gt_60)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_7_44"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_7_45"
      elif (last_rsi_3_gt_80) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_7_46"
      elif (
        (last_rsi_3_gt_82)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_7_47"
      elif (
        (last_rsi_3 > 55.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_48"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_8) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_7_50"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_50) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_7_51"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14 > 56.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_7_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_53"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_7_54"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_18)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_55"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_7_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_7_57"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_59"
      elif (
        (last_rsi_3 > 65.0)
        and (last_rsi_14_lt_44)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_7_61"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_7_62"
      elif (last_rsi_3_gt_64) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_7_63"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_64"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_7_65"
      elif (last_rsi_3_gt_78) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_7_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_46)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_7_67"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_7_68"
      elif (
        (last_rsi_3_gt_94) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_7_69"
      elif (last_rsi_3_gt_62) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_7_70"
      elif (last_rsi_3_gt_60) and (last_rsi_14_lt_48) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_7_71"
      elif (last_rsi_3_gt_74) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_7_72"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_7_73"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_74"
      elif (
        (last_rsi_3 > 92.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_75"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_54) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_7_76"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_77"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_7_78"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_7_79"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_7_80"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_81"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_82"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_83"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_7_84"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_85"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_86"
      elif (
        (last_rsi_3_gt_62)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_87"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14 > -24.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_7_88"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_44)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_7_89"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_7_90"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_91"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_7_92"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_93"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_7_94"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_7_95"
      elif (
        (last_rsi_3 > 58.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_96"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_7_97"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_15m > 68.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_98"
      elif (
        (last_rsi_3_gt_56)
        and (last_rsi_14 < 56.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_7_99"
      elif (last_rsi_3_gt_94) and (last_rsi_14 > 72.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_7_100"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_7_101"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_7_102"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14 < 60.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_7_103"
      elif (
        (last_rsi_3_gt_60)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_104"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_7_105"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_106"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_7_107"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_7_108"
      elif (
        (last_rsi_3_gt_72)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_109"
      elif (last_rsi_3_gt_68) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_7_110"
      elif (
        (last_rsi_3 > 46.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_7_111"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14 > -35.0)
        and (last_rsi_14 < 56.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_112"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_7_113"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_54)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_7_114"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_115"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_7_116"
      elif (last_rsi_3_gt_82) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_7_117"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_7_118"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_119"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_52) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_7_120"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_7_121"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_48) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_7_122"
      elif (last_rsi_3_gt_84) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_7_123"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_7_124"
      elif (
        (last_rsi_3_gt_72)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_7_125"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_7_126"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_7_127"
      elif (last_rsi_3_gt_90) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_7_128"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_7_129"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_7_130"
      elif (last_rsi_14 < 42.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_7_131"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_7_132"
      elif (
        (last_rsi_3_gt_76)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_7_133"
    elif 0.09 > current_profit >= 0.08:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_rsi_3_gt_95 = last_rsi_3 > 95.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_14_lt_42 = last_rsi_14 < 42.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_66 = last_rsi_3 > 66.0
      last_rsi_14_lt_52 = last_rsi_14 < 52.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_rsi_14_gt_70 = last_rsi_14 > 70.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_rsi_3_gt_75 = last_rsi_3 > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_64 = last_rsi_3 > 64.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_8_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 66.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_8_2"
      elif (
        (last_willr_14_gt_neg_8)
        and (last_stochrsi_k > 98.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_8_3"
      elif (
        (last_willr_14_gt_neg_15)
        and (last_rsi_14 > 72.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_8_4"
      elif (last_willr_14_gt_neg_4) and (last_rsi_14_gt_70) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_8_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_8_7"
      elif (
        (last_willr_14_gt_neg_4)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_8_8"
      elif (
        (last_willr_14_gt_neg_5)
        and (last_rsi_3_gt_95)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_9"
      elif (
        (last_willr_14_gt_neg_8)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_8_10"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_8_11"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_8_12"
      elif (last_rsi_3_gt_95) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_8_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_8_14"
      elif (last_rsi_3_gt_92) and (last_rsi_14 > 64.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_8_15"
      elif (
        (last_rsi_3_gt_85)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_8_16"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_8_17"
      elif (last_rsi_3_gt_90) and (last_rsi_14 > 72.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_8_18"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_gt_70)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_8_19"
      elif (last_rsi_3 > 48.0) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_8_20"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_8_21"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_4)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_8_22"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_15) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_8_23"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_gt_70)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_8_24"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_25"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_6) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_8_26"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_8_27"
      elif (last_rsi_3_gt_75) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_8_28"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_8_29"
      elif (last_rsi_3_gt_85) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_8_30"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_8_31"
      elif (last_rsi_3_gt_85) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_8_32"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_4)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_8_34"
      elif (last_rsi_3_gt_86) and (last_willr_14 > -7.0) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_8_35"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_36"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_37"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_20) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_8_38"
      elif (last_rsi_3 > 94.0) and (last_willr_14_gt_neg_6) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_8_39"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_8_40"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_41"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_30)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_8_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_8_43"
      elif (
        (last_rsi_3 > 65.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_8_44"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_8) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_8_45"
      elif (last_rsi_3_gt_85) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_8_46"
      elif (
        (last_rsi_3_gt_84)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_8_47"
      elif (
        (last_rsi_3 > 60.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_48"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_6) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_8_50"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_48) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_8_51"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14 > 58.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_8_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_53"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_48)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_8_54"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_16)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_55"
      elif (
        (last_rsi_3_gt_75)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_8_56"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 38.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_8_57"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_59"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_42)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_60"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_8_61"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_8_62"
      elif (last_rsi_3_gt_66) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_8_63"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_64"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_8_65"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_8_66"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14_lt_44)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_8_67"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_8_68"
      elif (
        (last_rsi_3_gt_95) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_8_69"
      elif (last_rsi_3_gt_64) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_8_70"
      elif (last_rsi_3 > 62.0) and (last_rsi_14_lt_46) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_8_71"
      elif (last_rsi_3_gt_76) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_8_72"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_8_73"
      elif (
        (last_rsi_3 > 97.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_74"
      elif (
        (last_rsi_3 > 94.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_75"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_52) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_8_76"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_77"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_8_78"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_8_79"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_8_80"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_81"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_82"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_83"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_8_84"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_85"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_86"
      elif (
        (last_rsi_3_gt_64)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_87"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14 > -22.0)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_8_88"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_42)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_8_89"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_8_90"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_91"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_8_92"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_93"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_8_94"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_8_95"
      elif (
        (last_rsi_3 > 60.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_96"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_8_97"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_15m_gt_70)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_98"
      elif (
        (last_rsi_3 > 58.0)
        and (last_rsi_14 < 54.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_8_99"
      elif (last_rsi_3 > 96.0) and (last_rsi_14 > 74.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_8_100"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_18)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_8_101"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_8_102"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14 < 58.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_8_103"
      elif (
        (last_rsi_3 > 62.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_104"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_8_105"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_106"
      elif (
        (last_rsi_3 > 72.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_8_107"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_8_108"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_109"
      elif (last_rsi_3_gt_70) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_8_110"
      elif (
        (last_rsi_3 > 48.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_8_111"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_30)
        and (last_rsi_14 < 54.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_112"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_8_113"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_52)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_8_114"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_115"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_8_116"
      elif (last_rsi_3_gt_84) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_8_117"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_8_118"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_119"
      elif (last_rsi_3 > 52.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_8_120"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_8_121"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_46) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_8_122"
      elif (last_rsi_3_gt_86) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_8_123"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_8_124"
      elif (
        (last_rsi_3_gt_74)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_8_125"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_8_126"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_8_127"
      elif (last_rsi_3_gt_92) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_8_128"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_8_129"
      elif (
        (last_rsi_3 > 72.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_8_130"
      elif (last_rsi_14 < 40.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_8_131"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_8_132"
      elif (
        (last_rsi_3_gt_78)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_8_133"
    elif 0.1 > current_profit >= 0.09:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_3_gt_72 = last_rsi_3 > 72.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_14_lt_40 = last_rsi_14 < 40.0
      last_rsi_3_gt_94 = last_rsi_3 > 94.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_rsi_3_gt_95 = last_rsi_3 > 95.0
      last_rsi_3_gt_96 = last_rsi_3 > 96.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_gt_50 = last_rsi_3 > 50.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_3_gt_68 = last_rsi_3 > 68.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_rsi_14_gt_72 = last_rsi_14 > 72.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_98 = last_rsi_3 > 98.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_66 = last_rsi_3 > 66.0
      last_rsi_14_lt_42 = last_rsi_14 < 42.0
      last_rsi_3_gt_76 = last_rsi_3 > 76.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_9_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 68.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_9_2"
      elif (
        (last_willr_14_gt_neg_6)
        and (last_stochrsi_k > 98.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_9_3"
      elif (
        (last_willr_14_gt_neg_10)
        and (last_rsi_14 > 74.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_9_4"
      elif (last_willr_14_gt_neg_2) and (last_rsi_14_gt_72) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_9_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14_lt_40)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_9_7"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_9_8"
      elif (
        (last_willr_14_gt_neg_4)
        and (last_rsi_3_gt_95)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_9"
      elif (
        (last_willr_14_gt_neg_6)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_9_10"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_9_11"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_9_12"
      elif (last_rsi_3_gt_96) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_9_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_9_14"
      elif (last_rsi_3_gt_94) and (last_rsi_14 > 66.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_9_15"
      elif (
        (last_rsi_3_gt_90)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_9_16"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_9_17"
      elif (last_rsi_3_gt_92) and (last_rsi_14 > 74.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_9_18"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_14_gt_72)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_9_19"
      elif (last_rsi_3_gt_50) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_9_20"
      elif (last_rsi_3_gt_90) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_9_21"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_2)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_9_22"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_10) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_9_23"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_14_gt_72)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_9_24"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_25"
      elif (last_rsi_3_gt_85) and (last_willr_14_gt_neg_4) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_9_26"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_9_27"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_9_28"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_9_29"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_9_30"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_9_31"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_9_32"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_2)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_9_34"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_6) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_9_35"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_15)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_36"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_37"
      elif (last_rsi_3_gt_85) and (last_willr_14_gt_neg_15) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_9_38"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_5) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_9_39"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_9_40"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_41"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_25)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_9_42"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_9_43"
      elif (
        (last_rsi_3_gt_70)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_9_44"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_6) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_9_45"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_9_46"
      elif (
        (last_rsi_3_gt_86)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_9_47"
      elif (
        (last_rsi_3 > 65.0)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_48"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_4) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_9_50"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_46) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_9_51"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14 > 60.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_9_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_53"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_46)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_9_54"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_14)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_55"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_9_56"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14 < 36.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_9_57"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_59"
      elif (
        (last_rsi_3 > 75.0)
        and (last_rsi_14_lt_40)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_60"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_20) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_9_61"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_9_62"
      elif (last_rsi_3_gt_68) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_9_63"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_64"
      elif (last_rsi_3_gt_68) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_9_65"
      elif (last_rsi_3_gt_82) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_9_66"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_42)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_9_67"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_9_68"
      elif (
        (last_rsi_3_gt_96) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_9_69"
      elif (last_rsi_3_gt_66) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_9_70"
      elif (last_rsi_3 > 64.0) and (last_rsi_14_lt_44) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_9_71"
      elif (last_rsi_3_gt_78) and (last_rsi_14_lt_42) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_9_72"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_9_73"
      elif (
        (last_rsi_3_gt_98)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_74"
      elif (
        (last_rsi_3_gt_96)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_75"
      elif (last_rsi_3_gt_68) and (last_rsi_14_lt_50) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_9_76"
      elif (
        (last_rsi_3_gt_76)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_77"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_9_78"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_9_79"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_9_80"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_81"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_82"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_83"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_9_84"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_85"
      elif (
        (last_rsi_3_gt_94)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_86"
      elif (
        (last_rsi_3_gt_66)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_87"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_20)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_9_88"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_40)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_9_89"
      elif (
        (last_rsi_3_gt_92)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_9_90"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_91"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_9_92"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_93"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_9_94"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_9_95"
      elif (
        (last_rsi_3 > 62.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_96"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_9_97"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_15m > 72.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_98"
      elif (
        (last_rsi_3 > 60.0)
        and (last_rsi_14 < 52.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_9_99"
      elif (last_rsi_3_gt_98) and (last_rsi_14 > 76.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_9_100"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_16)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_9_101"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_9_102"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14 < 56.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_9_103"
      elif (
        (last_rsi_3 > 64.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_104"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_9_105"
      elif (
        (last_rsi_3_gt_72)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_106"
      elif (
        (last_rsi_3 > 74.0)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_9_107"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_9_108"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_109"
      elif (last_rsi_3_gt_72) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_9_110"
      elif (
        (last_rsi_3_gt_50)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_9_111"
      elif (
        (last_rsi_3_gt_80)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_14 < 52.0)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_112"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_9_113"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_9_114"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_115"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_9_116"
      elif (last_rsi_3_gt_86) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_9_117"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_9_118"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_119"
      elif (last_rsi_3 > 54.0) and (last_rsi_14_lt_48) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_9_120"
      elif (last_rsi_3 > 60.0) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_9_121"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_44) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_9_122"
      elif (last_rsi_3_gt_88) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_9_123"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_9_124"
      elif (
        (last_rsi_3_gt_76)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_9_125"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_9_126"
      elif (last_rsi_3_gt_90) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_9_127"
      elif (last_rsi_3_gt_94) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_9_128"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_9_129"
      elif (
        (last_rsi_3 > 74.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_9_130"
      elif (last_rsi_14 < 38.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_9_131"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_9_132"
      elif (
        (last_rsi_3_gt_80)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_9_133"
    elif 0.12 > current_profit >= 0.1:
      # Reused long exit decision threshold checks for this profit bracket
      last_rsi_3_gt_95 = last_rsi_3 > 95.0
      last_rsi_3_gt_90 = last_rsi_3 > 90.0
      last_rsi_14_lt_46 = last_rsi_14 < 46.0
      last_rsi_3_4h_lt_20 = last_rsi_3_4h < 20.0
      last_rsi_3_1h_lt_20 = last_rsi_3_1h < 20.0
      last_rsi_3_4h_lt_10 = last_rsi_3_4h < 10.0
      last_rsi_3_gt_96 = last_rsi_3 > 96.0
      last_rsi_3_gt_80 = last_rsi_3 > 80.0
      last_rsi_14_lt_44 = last_rsi_14 < 44.0
      last_rsi_3_1h_lt_15 = last_rsi_3_1h < 15.0
      last_rsi_3_1h_lt_50 = last_rsi_3_1h < 50.0
      last_rsi_3_gt_70 = last_rsi_3 > 70.0
      last_rsi_3_gt_94 = last_rsi_3 > 94.0
      last_rsi_3_1h_lt_10 = last_rsi_3_1h < 10.0
      last_rsi_3_1h_lt_25 = last_rsi_3_1h < 25.0
      last_rsi_3_4h_lt_40 = last_rsi_3_4h < 40.0
      last_rsi_3_gt_92 = last_rsi_3 > 92.0
      last_rsi_3_4h_lt_25 = last_rsi_3_4h < 25.0
      last_rsi_3_gt_86 = last_rsi_3 > 86.0
      last_rsi_3_1d_lt_25 = last_rsi_3_1d < 25.0
      last_rsi_3_gt_88 = last_rsi_3 > 88.0
      last_rsi_3_gt_82 = last_rsi_3 > 82.0
      last_rsi_3_gt_74 = last_rsi_3 > 74.0
      last_aroonu_14_4h_gt_50 = last_aroonu_14_4h > 50.0
      last_rsi_3_1h_lt_60 = last_rsi_3_1h < 60.0
      last_rsi_14_lt_40 = last_rsi_14 < 40.0
      last_rsi_3_gt_85 = last_rsi_3 > 85.0
      last_stochrsi_k_4h_gt_30 = last_stochrsi_k_4h > 30.0
      last_stochrsi_k_4h_gt_40 = last_stochrsi_k_4h > 40.0
      last_rsi_14_lt_42 = last_rsi_14 < 42.0
      last_stochrsi_k_4h_gt_20 = last_stochrsi_k_4h > 20.0
      last_stochrsi_k_4h_gt_90 = last_stochrsi_k_4h > 90.0
      last_rsi_3_4h_lt_15 = last_rsi_3_4h < 15.0
      last_stochrsi_k_1h_gt_70 = last_stochrsi_k_1h > 70.0
      last_stochrsi_k_1h_gt_80 = last_stochrsi_k_1h > 80.0
      last_rsi_14_lt_48 = last_rsi_14 < 48.0
      last_stochrsi_k_1h_gt_40 = last_stochrsi_k_1h > 40.0
      last_aroonu_14_1h_gt_75 = last_aroonu_14_1h > 75.0
      last_rsi_3_4h_lt_60 = last_rsi_3_4h < 60.0
      last_rsi_14_gt_74 = last_rsi_14 > 74.0
      last_aroonu_14_4h_gt_25 = last_aroonu_14_4h > 25.0
      last_rsi_3_gt_99 = last_rsi_3 > 99.0
      last_aroonu_14_4h_gt_75 = last_aroonu_14_4h > 75.0
      last_stochrsi_k_1h_gt_30 = last_stochrsi_k_1h > 30.0
      last_rsi_3_gt_84 = last_rsi_3 > 84.0
      last_stochrsi_k_4h_gt_25 = last_stochrsi_k_4h > 25.0
      last_rsi_3_gt_68 = last_rsi_3 > 68.0
      last_rsi_14_lt_38 = last_rsi_14 < 38.0
      last_rsi_3_gt_78 = last_rsi_3 > 78.0
      last_rsi_3_1h_lt_40 = last_rsi_3_1h < 40.0
      last_rsi_3_1h_lt_45 = last_rsi_3_1h < 45.0
      last_rsi_3_1h_lt_35 = last_rsi_3_1h < 35.0
      last_rsi_14_4h_gt_70 = last_rsi_14_4h > 70.0
      last_rsi_3_1d_lt_30 = last_rsi_3_1d < 30.0
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_10_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 70.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_10_2"
      elif (
        (last_willr_14_gt_neg_4)
        and (last_stochrsi_k > 98.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h_gt_20) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_10_3"
      elif (
        (last_willr_14_gt_neg_5)
        and (last_rsi_14 > 76.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_10_4"
      elif (last_willr_14_gt_neg_1) and (last_rsi_14_gt_74) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_10_5"
      elif (
        (last_rsi_3_gt_70)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14_lt_40)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_10_7"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_stochrsi_k > 95.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_10_8"
      elif (
        (last_willr_14 > -3.0)
        and (last_rsi_3_gt_95)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_9"
      elif (
        (last_willr_14_gt_neg_4)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_10_10"
      elif (
        (last_rsi_3_gt_94)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_10_11"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_10_12"
      elif (last_rsi_3_gt_96) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_10_13"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_10_14"
      elif (last_rsi_3_gt_96) and (last_rsi_14 > 68.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_10_15"
      elif (
        (last_rsi_3_gt_95)
        and (last_aroonu_14_4h_gt_25)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_10_16"
      elif (
        (last_rsi_3 > 97.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_10)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_10_17"
      elif (last_rsi_3_gt_94) and (last_rsi_14 > 76.0) and (last_rsi_3_4h_lt_20) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_10_18"
      elif (
        (last_rsi_3_gt_94)
        and (last_rsi_14_gt_74)
        and (last_rsi_3_4h_lt_10)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_10_19"
      elif (last_rsi_3 > 60.0) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_10_20"
      elif (last_rsi_3_gt_95) and (last_rsi_14_lt_50) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_4h_gt_90):
        return True, f"exit_{mode_name}_d_10_21"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_1)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_10_22"
      elif (last_rsi_3_gt_95) and (last_willr_14_gt_neg_5) and (last_rsi_3_1h_lt_15) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_10_23"
      elif (
        (last_rsi_3_gt_94)
        and (last_rsi_14_gt_74)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_10_24"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_10)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_25"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_4h_lt_15) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_10_26"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_10_27"
      elif (last_rsi_3_gt_85) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_10_28"
      elif (
        (last_rsi_3_gt_96)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_10_29"
      elif (last_rsi_3_gt_95) and (last_rsi_3_1h_lt_25) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_70):
        return True, f"exit_{mode_name}_d_10_30"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_15)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_10_31"
      elif (last_rsi_3_gt_95) and (last_rsi_3_1h_lt_15) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_10_32"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_1)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_10_34"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_5) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_10_35"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_10)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_36"
      elif (
        (last_rsi_3_gt_84)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_37"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_10_38"
      elif (last_rsi_3_gt_96) and (last_willr_14_gt_neg_4) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_10_39"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h_gt_30)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_10_40"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h_gt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_41"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_20)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_10_42"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_15)
        and (last_rsi_3_4h_lt_40)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_10_43"
      elif (
        (last_rsi_3 > 75.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_10_44"
      elif (last_rsi_3_gt_96) and (last_willr_14_gt_neg_4) and (last_rsi_3_1h_lt_10):
        return True, f"exit_{mode_name}_d_10_45"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_10) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_10_46"
      elif (
        (last_rsi_3_gt_88)
        and (last_stochrsi_k_1h_gt_80)
        and (last_stochrsi_k_4h_gt_40)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_10_47"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_42)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_48"
      elif (
        (last_rsi_3_gt_95)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_20)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_49"
      elif (last_rsi_3_gt_80) and (last_willr_14_gt_neg_2) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_10_50"
      elif (last_rsi_3_gt_68) and (last_rsi_14_lt_44) and (last_rsi_3_4h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_10_51"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14 > 62.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_10_52"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_20)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_53"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_44)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_10_54"
      elif (
        (last_rsi_3_gt_96)
        and (last_willr_14_gt_neg_12)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_55"
      elif (
        (last_rsi_3_gt_85)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_10_56"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 34.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_10_57"
      elif (
        (last_rsi_3_gt_95)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_58"
      elif (
        (last_rsi_3_gt_85)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_59"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_38)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_60"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_15) and (last_rsi_3_4h_lt_10) and (last_stochrsi_k_1h_gt_30):
        return True, f"exit_{mode_name}_d_10_61"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_10_62"
      elif (last_rsi_3_gt_70) and (last_rsi_3_1d_lt_25) and (last_stochrsi_k_1h_gt_80) and (last_stochrsi_k_4h_gt_30):
        return True, f"exit_{mode_name}_d_10_63"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_64"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_15):
        return True, f"exit_{mode_name}_d_10_65"
      elif (last_rsi_3_gt_84) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_20) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_10_66"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14_lt_40)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_10_67"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_25)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_10_68"
      elif (
        (last_rsi_3 > 97.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_10_69"
      elif (last_rsi_3_gt_68) and (last_rsi_14_lt_38) and (last_rsi_3_1h_lt_25) and (last_stochrsi_k_4h_gt_20):
        return True, f"exit_{mode_name}_d_10_70"
      elif (last_rsi_3 > 66.0) and (last_rsi_14_lt_42) and (last_rsi_3_4h_lt_25) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_10_71"
      elif (last_rsi_3_gt_80) and (last_rsi_14_lt_40) and (last_rsi_3_1h_lt_10) and (last_aroonu_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_10_72"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_15)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_10_73"
      elif (
        (last_rsi_3_gt_99)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h_lt_25)
        and (last_rsi_3_1d_lt_25)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_74"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_75"
      elif (last_rsi_3_gt_70) and (last_rsi_14_lt_48) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_10_76"
      elif (
        (last_rsi_3_gt_78)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_77"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_20)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_10_78"
      elif (last_rsi_3_gt_94) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h_lt_10):
        return True, f"exit_{mode_name}_d_10_79"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_10_80"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_81"
      elif (
        (last_rsi_3_gt_84)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_82"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_83"
      elif (last_rsi_3_gt_92) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_10_84"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_85"
      elif (
        (last_rsi_3_gt_96)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_86"
      elif (
        (last_rsi_3_gt_68)
        and (last_rsi_14_lt_42)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_87"
      elif (
        (last_rsi_3_gt_90)
        and (last_willr_14_gt_neg_18)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_10_88"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_38)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_10_89"
      elif (
        (last_rsi_3_gt_94)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_10_90"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h_lt_25)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_91"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_40)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_10_92"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h_gt_75)
        and (last_stochrsi_k_1h_gt_70)
        and (last_aroonu_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_93"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_25)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_10_94"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_10_95"
      elif (
        (last_rsi_3 > 64.0)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_45)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_96"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_lt_44)
        and (last_rsi_3_1h_lt_35)
        and (last_aroonu_14_4h_gt_50)
        and (last_stochrsi_k_4h_gt_30)
      ):
        return True, f"exit_{mode_name}_d_10_97"
      elif (
        (last_rsi_3_gt_92)
        and (last_rsi_3_15m > 74.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_98"
      elif (
        (last_rsi_3 > 62.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h_lt_60)
        and (last_aroonu_14_4h_gt_50)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_10_99"
      elif (last_rsi_3_gt_99) and (last_rsi_14 > 78.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_10_100"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_14)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_4h_gt_40)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_10_101"
      elif (
        (last_rsi_3_gt_70)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_40)
        and (last_stochrsi_k_4h_gt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_10_102"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14 < 54.0)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_14_4h_gt_70)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_10_103"
      elif (
        (last_rsi_3 > 66.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_104"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h_gt_90)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_10_105"
      elif (
        (last_rsi_3_gt_74)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_106"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_1h_lt_50)
        and (last_stochrsi_k_1h_gt_70)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_10_107"
      elif (last_rsi_3 > 58.0) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_60) and (last_stochrsi_k_1h_gt_80):
        return True, f"exit_{mode_name}_d_10_108"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_3_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_109"
      elif (last_rsi_3_gt_74) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_10_110"
      elif (
        (last_rsi_3 > 52.0)
        and (last_rsi_14_lt_42)
        and (last_rsi_3_1h_lt_50)
        and (last_rsi_14_4h_gt_70)
        and (last_aroonu_14_1h_gt_75)
        and (last_aroonu_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_10_111"
      elif (
        (last_rsi_3_gt_82)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_112"
      elif (
        (last_rsi_3_gt_86)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1d_lt_30)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_10_113"
      elif (
        (last_rsi_3_gt_86)
        and (last_rsi_14_lt_48)
        and (last_rsi_3_1h_lt_20)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d_lt_30)
      ):
        return True, f"exit_{mode_name}_d_10_114"
      elif (
        (last_rsi_3_gt_80)
        and (last_rsi_14_lt_46)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_115"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_aroonu_14_4h_gt_50):
        return True, f"exit_{mode_name}_d_10_116"
      elif (last_rsi_3_gt_88) and (last_rsi_3_1h_lt_50) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0):
        return True, f"exit_{mode_name}_d_10_117"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_60) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_10_118"
      elif (
        (last_rsi_3_gt_88)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h_lt_60)
        and (last_rsi_3_4h_lt_60)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_119"
      elif (last_rsi_3_gt_56) and (last_rsi_14_lt_46) and (last_rsi_3_1h_lt_40) and (last_aroonu_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_10_120"
      elif (last_rsi_3 > 62.0) and (last_rsi_14_lt_44) and (last_rsi_3_1h_lt_50) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_10_121"
      elif (last_rsi_3 > 60.0) and (last_rsi_14_lt_42) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_10_122"
      elif (last_rsi_3_gt_90) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h_lt_10) and (last_rsi_3_1d_lt_30):
        return True, f"exit_{mode_name}_d_10_123"
      elif (
        (last_rsi_3_gt_90)
        and (last_rsi_3_1h_lt_15)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_10_124"
      elif (
        (last_rsi_3_gt_78)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_10)
        and (last_rsi_3_4h_lt_40)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_10_125"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_15) and (last_rsi_3_4h_lt_40) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_10_126"
      elif (last_rsi_3_gt_92) and (last_rsi_3_1h_lt_10) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_10_127"
      elif (last_rsi_3_gt_96) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_10_128"
      elif (
        (last_rsi_3_gt_88)
        and (last_rsi_3_4h_lt_25)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_10_129"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h_gt_80)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_10_130"
      elif (last_rsi_14 < 36.0) and (last_rsi_3_1h_lt_20) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_10_131"
      elif (
        (last_rsi_3_gt_82)
        and (last_rsi_3_1h_lt_35)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_10_132"
      elif (
        (last_rsi_3_gt_82)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_10_133"
    elif 0.2 > current_profit >= 0.12:
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_11_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 74.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_11_2"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h > 20.0) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_11_3"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_rsi_14 > 78.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_11_4"
      elif (last_willr_14_gt_neg_1) and (last_rsi_14 > 76.0) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_11_5"
      elif (
        (last_rsi_3 > 70.0)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k_gt_70)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_11_7"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_stochrsi_k > 98.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_11_8"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_rsi_3 > 95.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_9"
      elif (
        (last_willr_14_gt_neg_2)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_11_10"
      elif (
        (last_rsi_3 > 96.0)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_11_11"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h < 10.0)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_11_12"
      elif (last_rsi_3 > 98.0) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_11_13"
      elif (last_rsi_3 > 95.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_11_14"
      elif (last_rsi_3 > 98.0) and (last_rsi_14 > 70.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_11_15"
      elif (
        (last_rsi_3 > 98.0)
        and (last_aroonu_14_4h > 25.0)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_11_16"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_1h < 10.0)
        and (last_stochrsi_k_4h > 90.0)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_17"
      elif (last_rsi_3 > 96.0) and (last_rsi_14 > 78.0) and (last_rsi_3_4h < 20.0) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_11_18"
      elif (
        (last_rsi_3 > 96.0)
        and (last_rsi_14 > 76.0)
        and (last_rsi_3_4h < 10.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_11_19"
      elif (last_rsi_3 > 80.0) and (last_rsi_14 < 40.0) and (last_rsi_3_1h < 10.0) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_11_20"
      elif (last_rsi_3 > 98.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h < 20.0) and (last_stochrsi_k_4h > 90.0):
        return True, f"exit_{mode_name}_d_11_21"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_1)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_11_22"
      elif (last_rsi_3 > 98.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h < 15.0) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_11_23"
      elif (
        (last_rsi_3 > 96.0)
        and (last_rsi_14 > 76.0)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_11_24"
      elif (
        (last_rsi_3 > 97.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_4h < 10.0)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_25"
      elif (last_rsi_3 > 95.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h < 15.0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_11_26"
      elif (
        (last_rsi_3 > 95.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h < 20.0)
        and (last_stochrsi_k_4h > 20.0)
      ):
        return True, f"exit_{mode_name}_d_11_27"
      elif (last_rsi_3 > 90.0) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_11_28"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h < 20.0)
        and (last_stochrsi_k_1h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_29"
      elif (last_rsi_3 > 98.0) and (last_rsi_3_1h < 25.0) and (last_rsi_3_4h < 10.0) and (last_stochrsi_k_1h > 70.0):
        return True, f"exit_{mode_name}_d_11_30"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 15.0)
        and (last_rsi_3_4h < 15.0)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_11_31"
      elif (
        (last_rsi_3 > 98.0) and (last_rsi_3_1h < 15.0) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_32"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_1)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_11_34"
      elif (last_rsi_3 > 92.0) and (last_willr_14_gt_neg_4) and (last_rsi_3_1d < 25.0) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_11_35"
      elif (
        (last_rsi_3 > 95.0)
        and (last_willr_14_gt_neg_5)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d < 25.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_36"
      elif (
        (last_rsi_3 > 86.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_1d < 25.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_37"
      elif (last_rsi_3 > 95.0) and (last_willr_14_gt_neg_5) and (last_rsi_3_4h < 10.0) and (last_stochrsi_k_4h > 20.0):
        return True, f"exit_{mode_name}_d_11_38"
      elif (last_rsi_3 > 97.0) and (last_willr_14 > -3.0) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h < 10.0):
        return True, f"exit_{mode_name}_d_11_39"
      elif (
        (last_rsi_3 > 95.0)
        and (last_willr_14_gt_neg_5)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h > 30.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_11_40"
      elif (
        (last_rsi_3 > 97.0)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_41"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_15)
        and (last_stochrsi_k_4h > 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_11_42"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 15.0)
        and (last_rsi_3_4h < 40.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_11_43"
      elif (
        (last_rsi_3 > 80.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_11_44"
      elif (last_rsi_3 > 98.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1h < 10.0):
        return True, f"exit_{mode_name}_d_11_45"
      elif (last_rsi_3 > 94.0) and (last_rsi_3_1h < 15.0) and (last_rsi_3_4h < 10.0) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_11_46"
      elif (
        (last_rsi_3 > 90.0)
        and (last_stochrsi_k_1h > 80.0)
        and (last_stochrsi_k_4h > 40.0)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_11_47"
      elif (
        (last_rsi_3 > 75.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_48"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h < 20.0)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_49"
      elif (last_rsi_3 > 85.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_11_50"
      elif (last_rsi_3 > 70.0) and (last_rsi_14 < 42.0) and (last_rsi_3_4h < 20.0) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_11_51"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 > 64.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h > 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_11_52"
      elif (
        (last_rsi_3 > 70.0)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h < 20.0)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_53"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_14 < 42.0)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_11_54"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_10)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_55"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_11_56"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 32.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_11_57"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_58"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_11_59"
      elif (
        (last_rsi_3 > 85.0)
        and (last_rsi_14 < 36.0)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_60"
      elif (
        (last_rsi_3 > 96.0) and (last_willr_14_gt_neg_10) and (last_rsi_3_4h < 10.0) and (last_stochrsi_k_1h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_61"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_11_62"
      elif (
        (last_rsi_3 > 72.0) and (last_rsi_3_1d < 25.0) and (last_stochrsi_k_1h > 80.0) and (last_stochrsi_k_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_63"
      elif (
        (last_rsi_3 > 92.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_64"
      elif (last_rsi_3 > 72.0) and (last_rsi_14 < 38.0) and (last_rsi_3_1h < 20.0) and (last_rsi_3_4h < 15.0):
        return True, f"exit_{mode_name}_d_11_65"
      elif (last_rsi_3 > 86.0) and (last_rsi_14 < 44.0) and (last_rsi_3_1h < 20.0) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_11_66"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 38.0)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_11_67"
      elif (
        (last_rsi_3 > 88.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 25.0)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h > 25.0)
      ):
        return True, f"exit_{mode_name}_d_11_68"
      elif (
        (last_rsi_3 > 98.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_11_69"
      elif (last_rsi_3 > 70.0) and (last_rsi_14 < 36.0) and (last_rsi_3_1h < 25.0) and (last_stochrsi_k_4h > 20.0):
        return True, f"exit_{mode_name}_d_11_70"
      elif (last_rsi_3 > 68.0) and (last_rsi_14 < 40.0) and (last_rsi_3_4h < 25.0) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_11_71"
      elif (last_rsi_3 > 82.0) and (last_rsi_14 < 38.0) and (last_rsi_3_1h < 10.0) and (last_aroonu_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_11_72"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 15.0)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_11_73"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h < 25.0)
        and (last_rsi_3_1d < 25.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_74"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_75"
      elif (last_rsi_3 > 72.0) and (last_rsi_14 < 46.0) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_11_76"
      elif (
        (last_rsi_3 > 80.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_77"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_11_78"
      elif (last_rsi_3 > 96.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h < 10.0):
        return True, f"exit_{mode_name}_d_11_79"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h > 25.0)
      ):
        return True, f"exit_{mode_name}_d_11_80"
      elif (
        (last_rsi_3 > 88.0)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_81"
      elif (
        (last_rsi_3 > 86.0)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_11_82"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 40.0)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_11_83"
      elif (last_rsi_3 > 94.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_11_84"
      elif (
        (last_rsi_3 > 92.0)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 40.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_85"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_86"
      elif (
        (last_rsi_3 > 70.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h < 45.0)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_87"
      elif (
        (last_rsi_3 > 92.0)
        and (last_willr_14_gt_neg_16)
        and (last_stochrsi_k_1h > 40.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_11_88"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_14 < 36.0)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_11_89"
      elif (
        (last_rsi_3 > 96.0)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h < 50.0)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h > 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_11_90"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 25.0)
        and (last_aroonu_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_91"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 40.0)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_11_92"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14 < 46.0)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h > 75.0)
        and (last_stochrsi_k_1h > 70.0)
        and (last_aroonu_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_93"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 < 46.0)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_11_94"
      elif (
        (last_rsi_3 > 88.0)
        and (last_willr_14_gt_neg_8)
        and (last_rsi_3_1h < 45.0)
        and (last_rsi_3_4h < 40.0)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_11_95"
      elif (
        (last_rsi_3 > 66.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 45.0)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_96"
      elif (
        (last_rsi_3 > 88.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 35.0)
        and (last_aroonu_14_4h > 50.0)
        and (last_stochrsi_k_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_97"
      elif (
        (last_rsi_3 > 94.0)
        and (last_rsi_3_15m > 76.0)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_3_4h < 60.0)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_98"
      elif (
        (last_rsi_3 > 64.0)
        and (last_rsi_14 < 48.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h < 60.0)
        and (last_aroonu_14_4h > 50.0)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_11_99"
      elif (last_rsi_3 > 99.0) and (last_rsi_14 > 80.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_11_100"
      elif (
        (last_rsi_3 > 88.0)
        and (last_willr_14_gt_neg_12)
        and (last_rsi_3_1h < 50.0)
        and (last_stochrsi_k_4h > 40.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_11_101"
      elif (
        (last_rsi_3 > 72.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_3_4h < 40.0)
        and (last_stochrsi_k_4h > 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_11_102"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_14 < 52.0)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_14_4h > 70.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_11_103"
      elif (
        (last_rsi_3 > 68.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 60.0)
        and (last_stochrsi_k_1h > 40.0)
        and (last_stochrsi_k_4h > 90.0)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_11_104"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h > 90.0)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_11_105"
      elif (
        (last_rsi_3 > 76.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 50.0)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h > 70.0)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_11_106"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 50.0)
        and (last_stochrsi_k_1h > 70.0)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_11_107"
      elif (last_rsi_3 > 60.0) and (last_rsi_14 < 44.0) and (last_rsi_3_1h < 60.0) and (last_stochrsi_k_1h > 80.0):
        return True, f"exit_{mode_name}_d_11_108"
      elif (
        (last_rsi_3 > 80.0)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h < 50.0)
        and (last_rsi_3_4h < 20.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_109"
      elif (last_rsi_3 > 76.0) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_11_110"
      elif (
        (last_rsi_3 > 54.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h < 50.0)
        and (last_rsi_14_4h > 70.0)
        and (last_aroonu_14_1h > 75.0)
        and (last_aroonu_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_11_111"
      elif (
        (last_rsi_3 > 84.0)
        and (last_willr_14_gt_neg_15)
        and (last_rsi_14 < 48.0)
        and (last_rsi_3_1h < 35.0)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_112"
      elif (
        (last_rsi_3 > 88.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1d < 30.0)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_11_113"
      elif (
        (last_rsi_3 > 88.0)
        and (last_rsi_14 < 46.0)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 30.0)
      ):
        return True, f"exit_{mode_name}_d_11_114"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_115"
      elif (last_rsi_3 > 94.0) and (last_rsi_3_1h < 15.0) and (last_rsi_3_4h < 40.0) and (last_aroonu_14_4h > 50.0):
        return True, f"exit_{mode_name}_d_11_116"
      elif (
        (last_rsi_3 > 90.0) and (last_rsi_3_1h < 50.0) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0)
      ):
        return True, f"exit_{mode_name}_d_11_117"
      elif (last_rsi_3 > 94.0) and (last_rsi_3_1h < 20.0) and (last_rsi_3_4h < 60.0) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_11_118"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_3_4h < 60.0)
        and (last_stochrsi_k_1h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_11_119"
      elif (last_rsi_3 > 58.0) and (last_rsi_14 < 44.0) and (last_rsi_3_1h < 40.0) and (last_aroonu_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_11_120"
      elif (last_rsi_3 > 64.0) and (last_rsi_14 < 42.0) and (last_rsi_3_1h < 50.0) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_11_121"
      elif (last_rsi_3 > 62.0) and (last_rsi_14 < 40.0) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_11_122"
      elif (last_rsi_3 > 92.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h < 10.0) and (last_rsi_3_1d < 30.0):
        return True, f"exit_{mode_name}_d_11_123"
      elif (
        (last_rsi_3 > 92.0)
        and (last_rsi_3_1h < 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_11_124"
      elif (
        (last_rsi_3 > 80.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h < 10.0)
        and (last_rsi_3_4h < 40.0)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_11_125"
      elif (last_rsi_3 > 94.0) and (last_rsi_3_1h < 15.0) and (last_rsi_3_4h < 40.0) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_11_126"
      elif (last_rsi_3 > 94.0) and (last_rsi_3_1h < 10.0) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_11_127"
      elif (last_rsi_3 > 98.0) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_11_128"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_11_129"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h > 80.0)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_11_130"
      elif (last_rsi_14 < 34.0) and (last_rsi_3_1h < 20.0) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_11_131"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_3_1h < 35.0)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_11_132"
      elif (
        (last_rsi_3 > 84.0)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_11_133"
    elif current_profit >= 0.2:
      if (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
        and (last_kst_1h < last_ksts_9_1h)
        and (last_kst_4h < last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_12_1"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 78.0)
        and (last_cmf_20_1h_lt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_12_2"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h_lt_0)
        and (last_cmf_20_4h_lt_0)
        and ((last_stochrsi_k_4h > 20.0) and (last_stochrsi_k_change_pct_4h_lt_neg_10))
      ):
        return True, f"exit_{mode_name}_d_12_3"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14 > 80.0)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h < last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h < last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_12_4"
      elif (last_willr_14_gt_neg_1) and (last_rsi_14 > 78.0) and (last_roc_9_1h_lt_neg_5) and (last_roc_9_4h_lt_neg_5):
        return True, f"exit_{mode_name}_d_12_5"
      elif (
        (last_rsi_3 > 70.0)
        and (last_stochrsi_k_gt_70)
        and (last_rsi_14 < 40.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_6"
      elif (
        (last_rsi_14_lt_50)
        and (last_stochrsi_k > 95.0)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_12_7"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_stochrsi_k > 99.0)
        and (last_cmf_20_1h < -0.1)
        and (last_cmf_20_4h < -0.1)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_12_8"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_3 > 99.0)
        and (last_change_pct_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_9"
      elif (
        (last_willr_14_gt_neg_1)
        and (last_rsi_14_lt_50)
        and (last_roc_9_1h_lt_neg_10)
        and (last_roc_9_4h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_12_10"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_14 < 45.0)
        and (last_roc_9_15m < -10.0)
        and (last_roc_9_1h_lt_neg_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_12_11"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_4h < 10.0)
        and (last_roc_9_1h < -20.0)
        and (last_roc_9_4h_lt_neg_20)
      ):
        return True, f"exit_{mode_name}_d_12_12"
      elif (last_rsi_3 > 99.0) and (last_rsi_3_4h_lt_5) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_12_13"
      elif (last_rsi_3 > 99.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_5) and (last_aroonu_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_12_14"
      elif (last_rsi_3 > 99.0) and (last_rsi_14 > 75.0) and (last_roc_9_4h < -30.0):
        return True, f"exit_{mode_name}_d_12_15"
      elif (
        (last_rsi_3 > 99.0)
        and (last_aroonu_14_4h > 25.0)
        and (last_roc_9_4h_lt_neg_25)
        and (last_aroonu_14_1d > 50.0)
        and (last_change_pct_1d < -15.0)
      ):
        return True, f"exit_{mode_name}_d_12_16"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h < 10.0)
        and (last_stochrsi_k_4h > 90.0)
        and (last_roc_9_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_12_17"
      elif (last_rsi_3 > 99.0) and (last_rsi_14 > 80.0) and (last_rsi_3_4h < 20.0) and (last_roc_2_1d < -50.0):
        return True, f"exit_{mode_name}_d_12_18"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_14 > 78.0)
        and (last_rsi_3_4h < 10.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_12_19"
      elif (last_rsi_3 > 90.0) and (last_rsi_14 < 40.0) and (last_rsi_3_1h < 10.0) and (last_aroonu_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_12_20"
      elif (last_rsi_3 > 99.0) and (last_rsi_14_lt_50) and (last_rsi_3_1h < 20.0) and (last_stochrsi_k_4h > 90.0):
        return True, f"exit_{mode_name}_d_12_21"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_1)
        and (last_change_pct_4h_lt_neg_5)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_12_22"
      elif (last_rsi_3 > 99.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h < 15.0) and (last_rsi_3_1d < 5.0):
        return True, f"exit_{mode_name}_d_12_23"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_14 > 78.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_12_24"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_4h < 10.0)
        and (last_roc_9_4h < -15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_25"
      elif (last_rsi_3 > 99.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h < 15.0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_d_12_26"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h < 20.0)
        and (last_stochrsi_k_4h > 20.0)
      ):
        return True, f"exit_{mode_name}_d_12_27"
      elif (last_rsi_3 > 95.0) and (last_rsi_14_lt_50) and (last_rsi_3_15m < 10.0) and (last_roc_9_4h > 50.0):
        return True, f"exit_{mode_name}_d_12_28"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h < 20.0)
        and (last_stochrsi_k_1h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_12_29"
      elif (last_rsi_3 > 99.0) and (last_rsi_3_1h < 25.0) and (last_rsi_3_4h < 10.0) and (last_stochrsi_k_1h > 70.0):
        return True, f"exit_{mode_name}_d_12_30"
      elif (
        (last_rsi_3 > 95.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 15.0)
        and (last_rsi_3_4h < 15.0)
        and (last_stochrsi_k_1h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_12_31"
      elif (
        (last_rsi_3 > 99.0) and (last_rsi_3_1h < 15.0) and (last_roc_2_4h_lt_neg_30) and (last_stochrsi_k_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_12_32"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_1)
        and (last_roc_2_1h < -10.0)
        and (last_roc_9_1h > 30.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_33"
      elif (last_rsi_3 > 65.0) and (last_rsi_3_15m_lt_30) and (last_rsi_14_1h > 80.0) and (last_roc_9_1h > 40.0):
        return True, f"exit_{mode_name}_d_12_34"
      elif (last_rsi_3 > 94.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1d < 25.0) and (last_stochrsi_k_1h_gt_75):
        return True, f"exit_{mode_name}_d_12_35"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_1)
        and (last_roc_9_4h_lt_neg_25)
        and (last_rsi_3_1d < 25.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_36"
      elif (
        (last_rsi_3 > 88.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_1d < 25.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_37"
      elif (last_rsi_3 > 99.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h < 10.0) and (last_stochrsi_k_4h > 20.0):
        return True, f"exit_{mode_name}_d_12_38"
      elif (last_rsi_3 > 98.0) and (last_willr_14_gt_neg_2) and (last_cmf_20_4h_lt_0) and (last_rsi_3_4h < 10.0):
        return True, f"exit_{mode_name}_d_12_39"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_1h > 30.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_12_40"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_stochrsi_k_4h > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_41"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_4h > 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 70.0))
      ):
        return True, f"exit_{mode_name}_d_12_42"
      elif (
        (last_rsi_3 > 95.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 15.0)
        and (last_rsi_3_4h < 40.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_12_43"
      elif (
        (last_rsi_3 > 85.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_12_44"
      elif (last_rsi_3 > 99.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h < 10.0):
        return True, f"exit_{mode_name}_d_12_45"
      elif (last_rsi_3 > 96.0) and (last_rsi_3_1h < 15.0) and (last_rsi_3_4h < 10.0) and (last_roc_2_1d < -20.0):
        return True, f"exit_{mode_name}_d_12_46"
      elif (
        (last_rsi_3 > 98.0)
        and (last_stochrsi_k_1h > 80.0)
        and (last_stochrsi_k_4h > 40.0)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -5.0))
      ):
        return True, f"exit_{mode_name}_d_12_47"
      elif (
        (last_rsi_3 > 80.0)
        and (last_rsi_14 < 38.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_48"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_4h < 20.0)
        and (last_change_pct_1d_lt_neg_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_49"
      elif (last_rsi_3 > 90.0) and (last_willr_14_gt_neg_2) and (last_rsi_3_1d < 10.0) and (last_stochrsi_k_1h_gt_90):
        return True, f"exit_{mode_name}_d_12_50"
      elif (last_rsi_3 > 72.0) and (last_rsi_14 < 40.0) and (last_rsi_3_4h < 20.0) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_12_51"
      elif (
        (last_rsi_3 > 86.0)
        and (last_rsi_14 > 66.0)
        and (last_willr_14_gt_neg_10)
        and (last_stochrsi_k_1h > 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_12_52"
      elif (
        (last_rsi_3 > 70.0)
        and (last_rsi_14_lt_50)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h < 20.0)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_53"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 < 40.0)
        and (last_stochrsi_k_1h_gt_50)
        and (last_roc_9_4h_lt_neg_10)
        and (last_change_pct_1d < -10.0)
      ):
        return True, f"exit_{mode_name}_d_12_54"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_8)
        and (last_roc_9_4h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_55"
      elif (
        (last_rsi_3 > 95.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_10)
      ):
        return True, f"exit_{mode_name}_d_12_56"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
        and (last_stochrsi_k_4h_gt_70)
      ):
        return True, f"exit_{mode_name}_d_12_57"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_58"
      elif (
        (last_rsi_3 > 95.0)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
        and (last_stochrsi_k_4h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_12_59"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14 < 34.0)
        and (last_rsi_14_4h > 65.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_stochrsi_k_1d_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_60"
      elif (last_rsi_3 > 98.0) and (last_willr_14_gt_neg_5) and (last_rsi_3_4h < 10.0) and (last_stochrsi_k_1h > 30.0):
        return True, f"exit_{mode_name}_d_12_61"
      elif (
        (last_rsi_3 > 92.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
        and (last_change_pct_1d_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_12_62"
      elif (
        (last_rsi_3 > 74.0) and (last_rsi_3_1d < 25.0) and (last_stochrsi_k_1h > 80.0) and (last_stochrsi_k_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_12_63"
      elif (
        (last_rsi_3 > 94.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_64"
      elif (last_rsi_3 > 74.0) and (last_rsi_14 < 36.0) and (last_rsi_3_1h < 20.0) and (last_rsi_3_4h < 15.0):
        return True, f"exit_{mode_name}_d_12_65"
      elif (last_rsi_3 > 88.0) and (last_rsi_14 < 42.0) and (last_rsi_3_1h < 20.0) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_12_66"
      elif (
        (last_rsi_3 > 50.0)
        and (last_rsi_14 < 36.0)
        and (last_stochrsi_k_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_12_67"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 25.0)
        and (last_roc_2_4h_lt_neg_30)
        and (last_stochrsi_k_4h > 25.0)
      ):
        return True, f"exit_{mode_name}_d_12_68"
      elif (
        (last_rsi_3 > 99.0) and (last_roc_9_4h > 20.0) and (last_stochrsi_k_4h_gt_50) and (last_change_pct_4h_lt_neg_5)
      ):
        return True, f"exit_{mode_name}_d_12_69"
      elif (last_rsi_3 > 72.0) and (last_rsi_14 < 34.0) and (last_rsi_3_1h < 25.0) and (last_stochrsi_k_4h > 20.0):
        return True, f"exit_{mode_name}_d_12_70"
      elif (last_rsi_3 > 70.0) and (last_rsi_14 < 38.0) and (last_rsi_3_4h < 25.0) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_12_71"
      elif (last_rsi_3 > 84.0) and (last_rsi_14 < 36.0) and (last_rsi_3_1h < 10.0) and (last_aroonu_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_12_72"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 15.0)
        and (last_roc_9_4h_lt_neg_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_12_73"
      elif (
        (last_rsi_3 > 99.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_4h < 25.0)
        and (last_rsi_3_1d < 25.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_74"
      elif (
        (last_rsi_3 > 98.0)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_75"
      elif (last_rsi_3 > 74.0) and (last_rsi_14 < 44.0) and (last_roc_9_1h > 80.0) and (last_stochrsi_k_4h_gt_80):
        return True, f"exit_{mode_name}_d_12_76"
      elif (
        (last_rsi_3 > 82.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_77"
      elif (
        (last_rsi_3 > 92.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 20.0)
        and (last_rsi_3_1d < 20.0)
      ):
        return True, f"exit_{mode_name}_d_12_78"
      elif (last_rsi_3 > 98.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h_lt_30) and (last_rsi_3_4h < 10.0):
        return True, f"exit_{mode_name}_d_12_79"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
        and (last_stochrsi_k_4h > 25.0)
      ):
        return True, f"exit_{mode_name}_d_12_80"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_81"
      elif (
        (last_rsi_3 > 88.0)
        and (last_willr_14_gt_neg_4)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 15.0)
        and (last_stochrsi_k_4h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_12_82"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h < 40.0)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_12_83"
      elif (last_rsi_3 > 96.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_20):
        return True, f"exit_{mode_name}_d_12_84"
      elif (
        (last_rsi_3 > 94.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h_lt_30)
        and (last_rsi_3_4h < 40.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_85"
      elif (
        (last_rsi_3 > 99.0)
        and (last_rsi_14_4h > 80.0)
        and (last_roc_2_1h < -5.0)
        and (last_roc_9_1h > 5.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_86"
      elif (
        (last_rsi_3 > 72.0)
        and (last_rsi_14 < 38.0)
        and (last_rsi_3_1h < 45.0)
        and (last_rsi_3_4h < 50.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_87"
      elif (
        (last_rsi_3 > 94.0)
        and (last_willr_14_gt_neg_14)
        and (last_stochrsi_k_1h > 40.0)
        and (last_stochrsi_k_4h_gt_50)
        and (last_change_pct_1h < -2.0)
      ):
        return True, f"exit_{mode_name}_d_12_88"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 < 34.0)
        and (last_roc_9_1h_lt_neg_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_12_89"
      elif (
        (last_rsi_3 > 98.0)
        and (last_willr_14_gt_neg_25)
        and (last_rsi_3_1h < 50.0)
        and (last_rsi_3_4h_lt_30)
        and (last_aroonu_14_4h > 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_12_90"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 25.0)
        and (last_aroonu_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_91"
      elif (
        (last_rsi_3 > 86.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 40.0)
        and (last_stochrsi_k_1h_gt_25)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_12_92"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_15m < 50.0)
        and (last_aroonu_14_1h > 75.0)
        and (last_stochrsi_k_1h > 70.0)
        and (last_aroonu_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_93"
      elif (
        (last_rsi_3 > 86.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 25.0)
        and (last_rsi_3_4h < 45.0)
        and (last_aroonu_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 90.0))
      ):
        return True, f"exit_{mode_name}_d_12_94"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_6)
        and (last_rsi_3_1h < 45.0)
        and (last_rsi_3_4h < 40.0)
        and (last_stochrsi_k_4h_gt_10)
        and (isinstance(last_aroonu_14_1d, np.float64) and (last_aroonu_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_12_95"
      elif (
        (last_rsi_3 > 68.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h < 45.0)
        and (last_rsi_3_1d < 45.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_96"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14 < 40.0)
        and (last_rsi_3_1h < 35.0)
        and (last_aroonu_14_4h > 50.0)
        and (last_stochrsi_k_4h > 30.0)
      ):
        return True, f"exit_{mode_name}_d_12_97"
      elif (
        (last_rsi_3 > 96.0)
        and (last_rsi_3_15m > 78.0)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_3_4h < 60.0)
        and (last_rsi_3_1d > 80.0)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_98"
      elif (
        (last_rsi_3 > 66.0)
        and (last_rsi_14 < 46.0)
        and (last_rsi_3_1h < 65.0)
        and (last_rsi_3_4h < 60.0)
        and (last_aroonu_14_4h > 50.0)
        and (last_stoch_k_4h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_12_99"
      elif (last_rsi_3 > 99.0) and (last_rsi_14 > 82.0) and (last_rsi_3_15m_gt_70) and (last_rsi_3_4h < 80.0):
        return True, f"exit_{mode_name}_d_12_100"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_3_1h < 50.0)
        and (last_stochrsi_k_4h > 40.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 40.0))
      ):
        return True, f"exit_{mode_name}_d_12_101"
      elif (
        (last_rsi_3 > 74.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_3_4h < 40.0)
        and (last_stochrsi_k_4h > 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_12_102"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14_lt_50)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_14_4h > 70.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 80.0))
      ):
        return True, f"exit_{mode_name}_d_12_103"
      elif (
        (last_rsi_3 > 70.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 60.0)
        and (last_stochrsi_k_1h > 40.0)
        and (last_stochrsi_k_4h > 90.0)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_12_104"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_15m < 55.0)
        and (last_stochrsi_k_4h > 90.0)
        and (last_roc_9_4h_gt_25)
      ):
        return True, f"exit_{mode_name}_d_12_105"
      elif (
        (last_rsi_3 > 78.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 50.0)
        and (last_stochrsi_k_1h_gt_50)
        and (last_rsi_14_4h > 70.0)
        and (last_roc_9_4h_gt_40)
      ):
        return True, f"exit_{mode_name}_d_12_106"
      elif (
        (last_rsi_3 > 80.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_1h < 50.0)
        and (last_stochrsi_k_1h > 70.0)
        and (last_rsi_14_4h > 50.0)
      ):
        return True, f"exit_{mode_name}_d_12_107"
      elif (last_rsi_3 > 62.0) and (last_rsi_14 < 42.0) and (last_rsi_3_1h < 60.0) and (last_stochrsi_k_1h > 80.0):
        return True, f"exit_{mode_name}_d_12_108"
      elif (
        (last_rsi_3 > 82.0)
        and (last_willr_14_gt_neg_2)
        and (last_rsi_3_1h < 50.0)
        and (last_rsi_3_4h < 20.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_109"
      elif (last_rsi_3 > 78.0) and (last_rsi_3_4h < 65.0) and (last_stochrsi_k_4h_gt_50) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_12_110"
      elif (
        (last_rsi_3_gt_56)
        and (last_rsi_14 < 38.0)
        and (last_rsi_3_1h < 50.0)
        and (last_rsi_14_4h > 70.0)
        and (last_aroonu_14_1h > 75.0)
        and (last_aroonu_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_12_111"
      elif (
        (last_rsi_3 > 86.0)
        and (last_willr_14_gt_neg_10)
        and (last_rsi_14 < 46.0)
        and (last_rsi_3_1h < 35.0)
        and (last_rsi_3_4h_lt_35)
        and (last_rsi_3_1d < 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_112"
      elif (
        (last_rsi_3 > 90.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1d < 30.0)
        and (last_stochrsi_k_4h_gt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h > 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_12_113"
      elif (
        (last_rsi_3 > 90.0)
        and (last_rsi_14 < 44.0)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h_lt_30)
        and (last_rsi_3_1d < 30.0)
      ):
        return True, f"exit_{mode_name}_d_12_114"
      elif (
        (last_rsi_3 > 84.0)
        and (last_rsi_14 < 42.0)
        and (last_rsi_3_15m_lt_30)
        and (last_stochrsi_k_1h_gt_50)
        and (last_stochrsi_k_4h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_115"
      elif (last_rsi_3 > 96.0) and (last_rsi_3_1h < 15.0) and (last_rsi_3_4h < 40.0) and (last_aroonu_14_4h > 50.0):
        return True, f"exit_{mode_name}_d_12_116"
      elif (
        (last_rsi_3 > 92.0) and (last_rsi_3_1h < 50.0) and (last_aroonu_14_1h > 80.0) and (last_aroonu_14_4h > 80.0)
      ):
        return True, f"exit_{mode_name}_d_12_117"
      elif (last_rsi_3 > 96.0) and (last_rsi_3_1h < 20.0) and (last_rsi_3_4h < 60.0) and (last_aroonu_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_12_118"
      elif (
        (last_rsi_3 > 92.0)
        and (last_willr_14_gt_neg_20)
        and (last_rsi_3_1h < 60.0)
        and (last_rsi_3_4h < 60.0)
        and (last_stochrsi_k_1h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_12_119"
      elif (last_rsi_3 > 60.0) and (last_rsi_14 < 42.0) and (last_rsi_3_1h < 40.0) and (last_aroonu_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_12_120"
      elif (last_rsi_3 > 66.0) and (last_rsi_14 < 40.0) and (last_rsi_3_1h < 50.0) and (last_rsi_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_12_121"
      elif (last_rsi_3 > 64.0) and (last_rsi_14 < 38.0) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_1h_gt_50):
        return True, f"exit_{mode_name}_d_12_122"
      elif (last_rsi_3 > 94.0) and (last_willr_14_gt_neg_1) and (last_rsi_3_1h < 10.0) and (last_rsi_3_1d < 30.0):
        return True, f"exit_{mode_name}_d_12_123"
      elif (
        (last_rsi_3 > 94.0)
        and (last_rsi_3_1h < 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_12_124"
      elif (
        (last_rsi_3 > 82.0)
        and (last_willr_14_gt_neg_1)
        and (last_rsi_3_1h < 10.0)
        and (last_rsi_3_4h < 40.0)
        and (last_rsi_3_1d_lt_40)
        and (last_close < (last_high_max_30_1d * 0.50))
      ):
        return True, f"exit_{mode_name}_d_12_125"
      elif (last_rsi_3 > 96.0) and (last_rsi_3_1h < 15.0) and (last_rsi_3_4h < 40.0) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_12_126"
      elif (last_rsi_3 > 96.0) and (last_rsi_3_1h < 10.0) and (last_rsi_3_4h_lt_30) and (last_rsi_3_1d_lt_40):
        return True, f"exit_{mode_name}_d_12_127"
      elif (last_rsi_3 > 99.0) and (last_rsi_3_4h_lt_30) and (last_aroonu_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_12_128"
      elif (
        (last_rsi_3 > 92.0)
        and (last_rsi_3_4h < 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 80.0))
      ):
        return True, f"exit_{mode_name}_d_12_129"
      elif (
        (last_rsi_3 > 80.0)
        and (last_rsi_14_1h > 65.0)
        and (last_stochrsi_k_1h > 80.0)
        and (last_cci_20_change_pct_1h < -0.0)
      ):
        return True, f"exit_{mode_name}_d_12_130"
      elif (last_rsi_14 < 32.0) and (last_rsi_3_1h < 20.0) and (last_rsi_3_4h_lt_30) and (last_stochrsi_k_4h_gt_50):
        return True, f"exit_{mode_name}_d_12_131"
      elif (
        (last_rsi_3 > 86.0)
        and (last_rsi_3_1h < 35.0)
        and (last_rsi_3_4h_lt_35)
        and (last_aroonu_14_1h > 50.0)
        and (last_stochrsi_k_1h > 40.0)
      ):
        return True, f"exit_{mode_name}_d_12_132"
      elif (
        (last_rsi_3 > 86.0)
        and (last_aroonu_14_15m > 75.0)
        and (last_aroonu_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_12_133"

    #  Here ends exit signal conditions for long_exit_dec

    return False, None

  # Long Exit Stop Loss
  # ---------------------------------------------------------------------------------------------
  def long_exit_stoploss(
    self,
    mode_name: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode
    doom_stops_enable = self.doom_stops_enable
    trade_leverage = trade.leverage
    stoploss_doom = f"exit_{mode_name}_stoploss_doom"
    stoploss_u_e = f"exit_{mode_name}_stoploss_u_e"

    is_backtest = self.is_backtest_mode()
    trade_open_date = None if is_backtest else trade.open_date_utc.replace(tzinfo=None)
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    if not self.stops_enable:
      return False, None

    entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
    if is_system_v3_2:
      # Stoploss doom
      if self.system_v3_2_stops_enable and (
        profit_stake
        < -(
          entry_cost
          * (
            self.system_v3_2_stop_threshold_doom_futures
            if is_futures_mode
            else self.system_v3_2_stop_threshold_doom_spot
          )
          / trade_leverage
        )
      ):
        return True, stoploss_doom
    elif is_system_v3_1:
      # Stoploss doom
      if doom_stops_enable and (
        profit_stake
        < -(
          entry_cost
          * (
            self.system_v3_1_stop_threshold_doom_futures
            if is_futures_mode
            else self.system_v3_1_stop_threshold_doom_spot
          )
          / trade_leverage
        )
      ):
        return True, stoploss_doom
    elif is_system_v3:
      # Stoploss doom
      if doom_stops_enable and (
        profit_stake
        < -(
          entry_cost
          * (
            self.system_v3_stop_threshold_doom_futures if is_futures_mode else self.system_v3_stop_threshold_doom_spot
          )
          / trade_leverage
        )
      ):
        return True, stoploss_doom
    else:
      # Stoploss doom
      if (
        doom_stops_enable
        and (
          profit_stake
          < -(entry_cost * (self.stop_threshold_doom_futures if is_futures_mode else self.stop_threshold_doom_spot))
        )
        and (
          self.has_valid_entry_conditions(trade, current_rate, last_candle, previous_candle_1, filled_orders) == False
        )
        # temporary
        and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
      ):
        return True, stoploss_doom

    last_close = last_candle["close"]
    last_ema_200 = last_candle["EMA_200"]
    last_rsi_14 = last_candle["RSI_14"]
    last_cmf_20 = last_candle["CMF_20"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    previous_rsi_14 = previous_candle_1["RSI_14"]

    # Stoploss u_e
    if (
      self.u_e_stops_enable
      and (
        profit_stake
        < -(
          entry_cost * (self.stop_threshold_futures if is_futures_mode else self.stop_threshold_spot)
          # / trade.leverage
        )
      )
      and (last_close < last_ema_200)
      and (last_cmf_20 < -0.0)
      and (((last_ema_200 - last_close) / last_close) < 0.010)
      and (last_rsi_14 > previous_rsi_14)
      and (last_rsi_14 > (last_rsi_14_1h + 24.0))
      # and (current_time - timedelta(minutes=720) > trade.open_date_utc)
      # temporary
      and (is_backtest or trade_open_date >= datetime(2025, 4, 3))
    ):
      return True, stoploss_u_e

    #  Here ends exit signal conditions for long_exit_stoploss

    return False, None

  ###############################################################################################

  # LONG EXIT FUNCTIONS ENDS HERE

  ###############################################################################################

  # LONG GRIND FUNCTIONS STARTS HERE

  ###############################################################################################

  #
  #  /$$       /$$$$$$ /$$   /$$ /$$$$$$         /$$$$$$ /$$$$$$$ /$$$$$$/$$   /$$/$$$$$$$
  # | $$      /$$__  $| $$$ | $$/$$__  $$       /$$__  $| $$__  $|_  $$_| $$$ | $| $$__  $$
  # | $$     | $$  \ $| $$$$| $| $$  \__/      | $$  \__| $$  \ $$ | $$ | $$$$| $| $$  \ $$
  # | $$     | $$  | $| $$ $$ $| $$ /$$$$      | $$ /$$$| $$$$$$$/ | $$ | $$ $$ $| $$  | $$
  # | $$     | $$  | $| $$  $$$| $$|_  $$      | $$|_  $| $$__  $$ | $$ | $$  $$$| $$  | $$
  # | $$     | $$  | $| $$\  $$| $$  \ $$      | $$  \ $| $$  \ $$ | $$ | $$\  $$| $$  | $$
  # | $$$$$$$|  $$$$$$| $$ \  $|  $$$$$$/      |  $$$$$$| $$  | $$/$$$$$| $$ \  $| $$$$$$$/
  # |________/\______/|__/  \__/\______/        \______/|__/  |__|______|__/  \__|_______/
  #

  # Long Grinding Adjust Trade Position v2
  # ---------------------------------------------------------------------------------------------
  def long_grind_adjust_trade_position_v2(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    long_grind_exit_v2 = self.long_grind_exit_v2
    stake_currency = self.config["stake_currency"]
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    is_backtest = self.is_backtest_mode()
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    is_futures = self.is_futures_mode
    trade_leverage = trade.leverage
    trade_get_custom_data = trade.get_custom_data
    trade_set_custom_data = trade.set_custom_data
    trade_is_short = trade.is_short
    derisk_enable = self.derisk_enable
    long_rebuy_mode_tags = self.long_rebuy_mode_tags
    long_grind_mode_tags = self.long_grind_mode_tags

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    previous_candle = df.iloc[-2]

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_exits = trade.nr_of_successful_exits

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = self.config["exit_pricing"]["price_side"]
        if trade_is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]
    first_filled_entry = filled_entries[0]
    last_filled_entry = filled_entries[-1]

    current_stake_amount = trade_amount * exit_rate
    slice_amount = first_filled_entry.safe_filled * first_filled_entry.safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    is_rebuy_mode = all(c in long_rebuy_mode_tags for c in enter_tags) or (
      any(c in long_rebuy_mode_tags for c in enter_tags)
      and all(c in (long_rebuy_mode_tags + long_grind_mode_tags) for c in enter_tags)
    )

    has_order_tags = hasattr(first_filled_order, "ft_order_tag")

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate
    stake_scale_leverage = trade_leverage if is_futures else 1.0
    derisk_flag_timeout = None

    def get_derisk_flag_timeout():
      nonlocal derisk_flag_timeout
      if derisk_flag_timeout is None:
        derisk_flag_timeout = current_time - timedelta(hours=96)

      return derisk_flag_timeout

    grind_1_max_sub_grinds = 0
    grind_1_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_1_stakes_futures if is_futures else self.grinding_v2_grind_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_1_sub_thresholds = (
      self.grinding_v2_grind_1_thresholds_futures if is_futures else self.grinding_v2_grind_1_thresholds_spot
    )
    grind_1_max_sub_grinds = len(grind_1_stakes)
    grind_1_derisk_grinds = (
      self.grinding_v2_grind_1_derisk_futures if is_futures else self.grinding_v2_grind_1_derisk_spot
    )
    grind_1_profit_threshold = (
      self.grinding_v2_grind_1_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_1_profit_threshold_spot
    )

    grind_2_max_sub_grinds = 0
    grind_2_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_2_stakes_futures if is_futures else self.grinding_v2_grind_2_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_2_sub_thresholds = (
      self.grinding_v2_grind_2_thresholds_futures if is_futures else self.grinding_v2_grind_2_thresholds_spot
    )
    grind_2_max_sub_grinds = len(grind_2_stakes)
    grind_2_derisk_grinds = (
      self.grinding_v2_grind_2_derisk_futures if is_futures else self.grinding_v2_grind_2_derisk_spot
    )
    grind_2_profit_threshold = (
      self.grinding_v2_grind_2_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_2_profit_threshold_spot
    )

    grind_3_max_sub_grinds = 0
    grind_3_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_3_stakes_futures if is_futures else self.grinding_v2_grind_3_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_3_sub_thresholds = (
      self.grinding_v2_grind_3_thresholds_futures if is_futures else self.grinding_v2_grind_3_thresholds_spot
    )
    grind_3_max_sub_grinds = len(grind_3_stakes)
    grind_3_derisk_grinds = (
      self.grinding_v2_grind_3_derisk_futures if is_futures else self.grinding_v2_grind_3_derisk_spot
    )
    grind_3_profit_threshold = (
      self.grinding_v2_grind_3_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_3_profit_threshold_spot
    )

    grind_4_max_sub_grinds = 0
    grind_4_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_4_stakes_futures if is_futures else self.grinding_v2_grind_4_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_4_sub_thresholds = (
      self.grinding_v2_grind_4_thresholds_futures if is_futures else self.grinding_v2_grind_4_thresholds_spot
    )
    grind_4_max_sub_grinds = len(grind_4_stakes)
    grind_4_derisk_grinds = (
      self.grinding_v2_grind_4_derisk_futures if is_futures else self.grinding_v2_grind_4_derisk_spot
    )
    grind_4_profit_threshold = (
      self.grinding_v2_grind_4_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_4_profit_threshold_spot
    )

    grind_5_max_sub_grinds = 0
    grind_5_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_5_stakes_futures if is_futures else self.grinding_v2_grind_5_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_5_sub_thresholds = (
      self.grinding_v2_grind_5_thresholds_futures if is_futures else self.grinding_v2_grind_5_thresholds_spot
    )
    grind_5_max_sub_grinds = len(grind_5_stakes)
    grind_5_derisk_grinds = (
      self.grinding_v2_grind_5_derisk_futures if is_futures else self.grinding_v2_grind_5_derisk_spot
    )
    grind_5_profit_threshold = (
      self.grinding_v2_grind_5_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_5_profit_threshold_spot
    )

    is_derisk_1 = False
    is_derisk_1_found = False  # derisk_level_1 de-risk exit
    derisk_1_order = None
    is_derisk_2 = False
    is_derisk_2_found = False  # derisk_level_2 de-risk exit
    derisk_2_order = None
    is_derisk_3 = False
    is_derisk_3_found = False  # derisk_level_3 de-risk exit
    derisk_3_order = None
    buyback_1_sub_grind_count = 0
    buyback_1_total_amount = 0.0
    buyback_1_total_cost = 0.0
    buyback_1_current_open_rate = 0.0
    buyback_1_current_grind_stake = 0.0
    buyback_1_current_grind_stake_profit = 0.0
    buyback_1_is_exit_found = False
    buyback_1_found = False
    buyback_1_buy_orders = []
    buyback_1_orders = []
    buyback_1_distance_ratio = 0.0
    buyback_1_exit_order = None
    buyback_1_exit_distance_ratio = 0.0
    buyback_2_sub_grind_count = 0
    buyback_2_total_amount = 0.0
    buyback_2_total_cost = 0.0
    buyback_2_current_open_rate = 0.0
    buyback_2_current_grind_stake = 0.0
    buyback_2_current_grind_stake_profit = 0.0
    buyback_2_is_exit_found = False
    buyback_2_found = False
    buyback_2_buy_orders = []
    buyback_2_orders = []
    buyback_2_distance_ratio = 0.0
    buyback_2_exit_order = None
    buyback_2_exit_distance_ratio = 0.0
    buyback_3_sub_grind_count = 0
    buyback_3_total_amount = 0.0
    buyback_3_total_cost = 0.0
    buyback_3_current_open_rate = 0.0
    buyback_3_current_grind_stake = 0.0
    buyback_3_current_grind_stake_profit = 0.0
    buyback_3_is_exit_found = False
    buyback_3_found = False
    buyback_3_buy_orders = []
    buyback_3_orders = []
    buyback_3_distance_ratio = 0.0
    buyback_3_exit_order = None
    buyback_3_exit_distance_ratio = 0.0
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_stake_profit = 0.0
    grind_1_is_exit_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_orders = []
    grind_1_distance_ratio = 0.0
    grind_1_exit_order = None
    grind_1_exit_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_stake_profit = 0.0
    grind_2_is_exit_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_orders = []
    grind_2_distance_ratio = 0.0
    grind_2_exit_order = None
    grind_2_exit_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_stake_profit = 0.0
    grind_3_is_exit_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_orders = []
    grind_3_distance_ratio = 0.0
    grind_3_exit_order = None
    grind_3_exit_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_stake_profit = 0.0
    grind_4_is_exit_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_orders = []
    grind_4_distance_ratio = 0.0
    grind_4_exit_order = None
    grind_4_exit_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_stake_profit = 0.0
    grind_5_is_exit_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_orders = []
    grind_5_distance_ratio = 0.0
    grind_5_exit_order = None
    grind_5_exit_distance_ratio = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "buy") and (order is not first_filled_order):
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        if not buyback_1_is_exit_found and order_tag == "buyback_1_entry":
          buyback_1_sub_grind_count += 1
          buyback_1_total_amount += order.safe_filled
          buyback_1_total_cost += order.safe_filled * order.safe_price
          buyback_1_buy_orders.append(order.id)
          buyback_1_orders.append(order)
          if not buyback_1_found:
            buyback_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_1_found = True
        elif not buyback_2_is_exit_found and order_tag == "buyback_2_entry":
          buyback_2_sub_grind_count += 1
          buyback_2_total_amount += order.safe_filled
          buyback_2_total_cost += order.safe_filled * order.safe_price
          buyback_2_buy_orders.append(order.id)
          buyback_2_orders.append(order)
          if not buyback_2_found:
            buyback_2_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_2_found = True
        elif not buyback_3_is_exit_found and order_tag == "buyback_3_entry":
          buyback_3_sub_grind_count += 1
          buyback_3_total_amount += order.safe_filled
          buyback_3_total_cost += order.safe_filled * order.safe_price
          buyback_3_buy_orders.append(order.id)
          buyback_3_orders.append(order)
          if not buyback_3_found:
            buyback_3_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_3_found = True
        elif not grind_1_is_exit_found and order_tag == "grind_1_entry":
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order.safe_filled
          grind_1_total_cost += order.safe_filled * order.safe_price
          grind_1_buy_orders.append(order.id)
          grind_1_orders.append(order)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_1_found = True
        elif not grind_2_is_exit_found and order_tag == "grind_2_entry":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order.safe_filled
          grind_2_total_cost += order.safe_filled * order.safe_price
          grind_2_buy_orders.append(order.id)
          grind_2_orders.append(order)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_2_found = True
        elif not grind_3_is_exit_found and order_tag == "grind_3_entry":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order.safe_filled
          grind_3_total_cost += order.safe_filled * order.safe_price
          grind_3_buy_orders.append(order.id)
          grind_3_orders.append(order)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_3_found = True
        elif not grind_4_is_exit_found and order_tag == "grind_4_entry":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order.safe_filled
          grind_4_total_cost += order.safe_filled * order.safe_price
          grind_4_buy_orders.append(order.id)
          grind_4_orders.append(order)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_4_found = True
        elif not grind_5_is_exit_found and order_tag == "grind_5_entry":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order.safe_filled
          grind_5_total_cost += order.safe_filled * order.safe_price
          grind_5_buy_orders.append(order.id)
          grind_5_orders.append(order)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_5_found = True
      elif order.ft_order_side == "sell":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          # break
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag.partition(" ")[0]
        if order_tag in ["derisk_level_1", "d"]:
          if not is_derisk_1_found:
            is_derisk_1_found = True
            is_derisk_1 = True
            derisk_1_order = order
        elif order_tag == "derisk_level_2":
          if not is_derisk_2_found:
            is_derisk_2_found = True
            is_derisk_2 = True
            derisk_2_order = order
        elif order_tag == "derisk_level_3":
          if not is_derisk_3_found:
            is_derisk_3_found = True
            is_derisk_3 = True
            derisk_3_order = order
        elif not buyback_1_is_exit_found and order_tag in ["buyback_1_exit", "buyback_1_derisk"]:
          buyback_1_is_exit_found = True
          buyback_1_exit_order = order
        elif not buyback_2_is_exit_found and order_tag in ["buyback_2_exit", "buyback_2_derisk"]:
          buyback_2_is_exit_found = True
          buyback_2_exit_order = order
        elif not buyback_3_is_exit_found and order_tag in ["buyback_3_exit", "buyback_3_derisk"]:
          buyback_3_is_exit_found = True
          buyback_3_exit_order = order
        elif not grind_1_is_exit_found and order_tag in ["grind_1_exit", "grind_1_derisk"]:
          grind_1_is_exit_found = True
          grind_1_exit_order = order
        elif not grind_2_is_exit_found and order_tag in ["grind_2_exit", "grind_2_derisk"]:
          grind_2_is_exit_found = True
          grind_2_exit_order = order
        elif not grind_3_is_exit_found and order_tag in ["grind_3_exit", "grind_3_derisk"]:
          grind_3_is_exit_found = True
          grind_3_exit_order = order
        elif not grind_4_is_exit_found and order_tag in ["grind_4_exit", "grind_4_derisk"]:
          grind_4_is_exit_found = True
          grind_4_exit_order = order
        elif not grind_5_is_exit_found and order_tag in ["grind_5_exit", "grind_5_derisk"]:
          grind_5_is_exit_found = True
          grind_5_exit_order = order
        elif order_tag == "derisk_global":
          if not buyback_1_is_exit_found:
            buyback_1_is_exit_found = True
            buyback_1_exit_order = order
          if not buyback_2_is_exit_found:
            buyback_2_is_exit_found = True
            buyback_2_exit_order = order
          if not buyback_3_is_exit_found:
            buyback_3_is_exit_found = True
            buyback_3_exit_order = order
          if not grind_1_is_exit_found:
            grind_1_is_exit_found = True
            grind_1_exit_order = order
          if not grind_2_is_exit_found:
            grind_2_is_exit_found = True
            grind_2_exit_order = order
          if not grind_3_is_exit_found:
            grind_3_is_exit_found = True
            grind_3_exit_order = order
          if not grind_4_is_exit_found:
            grind_4_is_exit_found = True
            grind_4_exit_order = order
          if not grind_5_is_exit_found:
            grind_5_is_exit_found = True
            grind_5_exit_order = order

    if buyback_1_sub_grind_count > 0:
      buyback_1_current_open_rate = buyback_1_total_cost / buyback_1_total_amount
      buyback_1_current_grind_stake = buyback_1_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_1_current_grind_stake_profit = buyback_1_current_grind_stake - buyback_1_total_cost
    if buyback_2_sub_grind_count > 0:
      buyback_2_current_open_rate = buyback_2_total_cost / buyback_2_total_amount
      buyback_2_current_grind_stake = buyback_2_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_2_current_grind_stake_profit = buyback_2_current_grind_stake - buyback_2_total_cost
    if buyback_3_sub_grind_count > 0:
      buyback_3_current_open_rate = buyback_3_total_cost / buyback_3_total_amount
      buyback_3_current_grind_stake = buyback_3_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_3_current_grind_stake_profit = buyback_3_current_grind_stake - buyback_3_total_cost
    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_current_grind_stake_profit = grind_1_current_grind_stake - grind_1_total_cost
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_current_grind_stake_profit = grind_2_current_grind_stake - grind_2_total_cost
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 - trade_fee_close)
      grind_3_current_grind_stake_profit = grind_3_current_grind_stake - grind_3_total_cost
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 - trade_fee_close)
      grind_4_current_grind_stake_profit = grind_4_current_grind_stake - grind_4_total_cost
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 - trade_fee_close)
      grind_5_current_grind_stake_profit = grind_5_current_grind_stake - grind_5_total_cost

    if grind_1_is_exit_found:
      grind_1_exit_distance_ratio = (exit_rate - grind_1_exit_order.safe_price) / grind_1_exit_order.safe_price
    if grind_2_is_exit_found:
      grind_2_exit_distance_ratio = (exit_rate - grind_2_exit_order.safe_price) / grind_2_exit_order.safe_price
    if grind_3_is_exit_found:
      grind_3_exit_distance_ratio = (exit_rate - grind_3_exit_order.safe_price) / grind_3_exit_order.safe_price
    if grind_4_is_exit_found:
      grind_4_exit_distance_ratio = (exit_rate - grind_4_exit_order.safe_price) / grind_4_exit_order.safe_price
    if buyback_1_is_exit_found:
      buyback_1_exit_distance_ratio = (exit_rate - buyback_1_exit_order.safe_price) / buyback_1_exit_order.safe_price
    elif is_derisk_1_found:
      buyback_1_exit_distance_ratio = (exit_rate - derisk_1_order.safe_price) / derisk_1_order.safe_price
    if buyback_2_is_exit_found:
      buyback_2_exit_distance_ratio = (exit_rate - buyback_2_exit_order.safe_price) / buyback_2_exit_order.safe_price
    elif is_derisk_2_found:
      buyback_2_exit_distance_ratio = (exit_rate - derisk_2_order.safe_price) / derisk_2_order.safe_price
    if buyback_3_is_exit_found:
      buyback_3_exit_distance_ratio = (exit_rate - buyback_3_exit_order.safe_price) / buyback_3_exit_order.safe_price
    elif is_derisk_3_found:
      buyback_3_exit_distance_ratio = (exit_rate - derisk_3_order.safe_price) / derisk_3_order.safe_price

    # all buybacks & grinds
    current_open_grind_stake_profit = (
      buyback_1_current_grind_stake_profit
      + buyback_2_current_grind_stake_profit
      + buyback_3_current_grind_stake_profit
      + grind_1_current_grind_stake_profit
      + grind_2_current_grind_stake_profit
      + grind_3_current_grind_stake_profit
      + grind_4_current_grind_stake_profit
      + grind_5_current_grind_stake_profit
    )
    num_open_grinds_and_buybacks = (
      buyback_1_sub_grind_count
      + buyback_2_sub_grind_count
      + buyback_3_sub_grind_count
      + grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
    )

    # Rebuy mode, the first entry is lower than normal slot stake
    if is_rebuy_mode:
      slice_amount /= self.rebuy_mode_stake_multiplier
    # not reached the max allowed stake for all grinds
    is_not_trade_max_stake = (current_stake_amount < (slice_amount * self.grinding_v2_max_stake)) and (
      num_open_grinds_and_buybacks < self.grinding_v2_max_grinds_and_buybacks
    )
    slice_profit_lt_neg_0_06 = slice_profit < -0.06

    is_long_extra_checks_entry = (
      (current_time - timedelta(minutes=5) > last_filled_entry.order_filled_utc)
      and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
      and (
        (current_stake_amount < ((first_filled_entry.safe_filled * first_filled_entry.safe_price) * 0.50))
        or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
        or slice_profit_lt_neg_0_06
      )
    )
    is_long_buyback_entry = self.long_buyback_entry_v2(last_candle, previous_candle, slice_profit, True)
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_aroonu_14 = last_candle["AROONU_14"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    is_long_grind_entry = (
      self.long_grind_entry_v3(
        last_candle,
        previous_candle,
        num_open_grinds_and_buybacks,
        slice_profit,
        slice_profit_entry,
        slice_profit_exit,
        True,
      )
      or (
        (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
        and (num_open_grinds_and_buybacks == 0)
        and (
          (last_rsi_3 > 10.0)
          and (last_rsi_3_15m > 20.0)
          and (last_rsi_3_1h > 20.0)
          and (last_rsi_3_1h > 20.0)
          and (last_aroonu_14 < 50.0)
          and (last_aroonu_14_15m < 50.0)
        )
      )
      or (
        is_futures
        and trade.liquidation_price is not None
        and (
          (trade_is_short and current_rate > trade.liquidation_price * 0.90)
          or (not trade_is_short and current_rate < trade.liquidation_price * 1.10)
        )
        and (slice_profit < -0.03)
        and (last_rsi_3 > 10.0)
        and (last_rsi_3_15m > 20.0)
        # and (last_candle["RSI_3_1h"] > 20.0)
        # and (last_candle["RSI_3_1h"] > 20.0)
        and (last_aroonu_14 < 50.0)
        and (last_aroonu_14_15m < 50.0)
      )
    )

    # De-risk level 1

    # flag it
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_1_enable
      and (not is_derisk_1_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_1_flag") is not True)
      and (
        profit_stake
        < (
          slice_amount
          * (self.grinding_v2_derisk_level_1_futures[0] if is_futures else self.grinding_v2_derisk_level_1_spot[0])
        )
        / trade_leverage
      )
    ):
      trade_set_custom_data(key="grinding_v2_derisk_level_1_flag", value=True)
      trade_set_custom_data(key="grinding_v2_derisk_level_1_profit", value=profit_stake)
      trade_set_custom_data(key="grinding_v2_derisk_level_1_time", value=current_time.isoformat())

    flag_is_derisk_level_1 = False
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_1_enable
      and (not is_derisk_1_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_1_flag") is True)
    ):
      flag_profit = trade_get_custom_data(key="grinding_v2_derisk_level_1_profit")
      flag_time = datetime.fromisoformat(trade_get_custom_data(key="grinding_v2_derisk_level_1_time"))
      if get_derisk_flag_timeout() > flag_time:
        if profit_stake > flag_profit:
          trade_set_custom_data(key="grinding_v2_derisk_level_1_flag", value=False)
        else:
          flag_is_derisk_level_1 = True

    if (
      derisk_enable
      and self.grinding_v2_derisk_level_1_enable
      and (not is_derisk_1_found)
      and not is_rebuy_mode
      and (
        flag_is_derisk_level_1
        or (
          profit_stake
          < (
            slice_amount
            * (self.grinding_v2_derisk_level_1_futures[1] if is_futures else self.grinding_v2_derisk_level_1_spot[1])
          )
          / trade_leverage
        )
      )
    ):
      sell_amount = (
        (
          first_filled_entry.safe_filled
          * (
            self.grinding_v2_derisk_level_1_stake_futures if is_futures else self.grinding_v2_derisk_level_1_stake_spot
          )
        )
        * exit_rate
        / trade_leverage
      )
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Level 1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Level 1 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_1"

    # De-risk level 2

    # flag it
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_2_enable
      and (not is_derisk_2_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_2_flag") is not True)
      and (
        profit_stake
        < (
          slice_amount
          * (self.grinding_v2_derisk_level_2_futures[0] if is_futures else self.grinding_v2_derisk_level_2_spot[0])
        )
        / trade_leverage
      )
    ):
      trade_set_custom_data(key="grinding_v2_derisk_level_2_flag", value=True)
      trade_set_custom_data(key="grinding_v2_derisk_level_2_profit", value=profit_stake)
      trade_set_custom_data(key="grinding_v2_derisk_level_2_time", value=current_time.isoformat())

    flag_is_derisk_level_2 = False
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_2_enable
      and (not is_derisk_2_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_2_flag") is True)
    ):
      flag_profit = trade_get_custom_data(key="grinding_v2_derisk_level_2_profit")
      flag_time = datetime.fromisoformat(trade_get_custom_data(key="grinding_v2_derisk_level_2_time"))
      if get_derisk_flag_timeout() > flag_time:
        if profit_stake > flag_profit:
          trade_set_custom_data(key="grinding_v2_derisk_level_2_flag", value=False)
        else:
          flag_is_derisk_level_2 = True

    if (
      derisk_enable
      and self.grinding_v2_derisk_level_2_enable
      and (not is_derisk_2_found)
      and not is_rebuy_mode
      and (
        flag_is_derisk_level_2
        or (
          profit_stake
          < (
            slice_amount
            * (self.grinding_v2_derisk_level_2_futures[1] if is_futures else self.grinding_v2_derisk_level_2_spot[1])
          )
          / trade_leverage
        )
      )
    ):
      sell_amount = (
        (
          first_filled_entry.safe_filled
          * (
            self.grinding_v2_derisk_level_2_stake_futures if is_futures else self.grinding_v2_derisk_level_2_stake_spot
          )
        )
        * exit_rate
        / trade_leverage
      )
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Level 2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Level 2 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_2"

    # De-risk level 3

    # flag it
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_3_enable
      and (not is_derisk_3_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_3_flag") is not True)
      and (
        profit_stake
        < (
          slice_amount
          * (self.grinding_v2_derisk_level_3_futures[0] if is_futures else self.grinding_v2_derisk_level_3_spot[0])
        )
        / trade_leverage
      )
    ):
      trade_set_custom_data(key="grinding_v2_derisk_level_3_flag", value=True)
      trade_set_custom_data(key="grinding_v2_derisk_level_3_profit", value=profit_stake)
      trade_set_custom_data(key="grinding_v2_derisk_level_3_time", value=current_time.isoformat())

    flag_is_derisk_level_3 = False
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_3_enable
      and (not is_derisk_3_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_3_flag") is True)
    ):
      flag_profit = trade_get_custom_data(key="grinding_v2_derisk_level_3_profit")
      flag_time = datetime.fromisoformat(trade_get_custom_data(key="grinding_v2_derisk_level_3_time"))
      if get_derisk_flag_timeout() > flag_time:
        if profit_stake > flag_profit:
          trade_set_custom_data(key="grinding_v2_derisk_level_3_flag", value=False)
        else:
          flag_is_derisk_level_3 = True

    if (
      derisk_enable
      and self.grinding_v2_derisk_level_3_enable
      and (not is_derisk_3_found)
      and not is_rebuy_mode
      and (
        flag_is_derisk_level_3
        or (
          profit_stake
          < (
            slice_amount
            * (self.grinding_v2_derisk_level_3_futures[1] if is_futures else self.grinding_v2_derisk_level_3_spot[1])
          )
          / trade_leverage
        )
      )
    ):
      sell_amount = (
        (
          first_filled_entry.safe_filled
          * (
            self.grinding_v2_derisk_level_3_stake_futures if is_futures else self.grinding_v2_derisk_level_3_stake_spot
          )
        )
        * exit_rate
        / trade_leverage
      )
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Level 3",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_3"

    # De-risk global
    if (
      self.grinding_v2_derisk_global_enable
      and is_derisk_1_found
      and (
        current_open_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_derisk_global_futures if is_futures else self.grinding_v2_derisk_global_spot)
        )
        / trade_leverage
      )
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Global",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Global [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_global"

    # Grinding 1

    if (
      (self.grinding_v2_grind_1_enable)
      and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and is_long_grind_entry
      and is_long_extra_checks_entry
      and (grind_1_sub_grind_count < grind_1_max_sub_grinds)
      and (grind_1_sub_grind_count == 0 or (grind_1_distance_ratio < grind_1_sub_thresholds[grind_1_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_1_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_1_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
      if (grind_profit > (grind_1_profit_threshold + fee_open_rate + fee_close_rate)) and long_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_1_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_1_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_1_exit"
          for grind_entry_id in grind_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_1_use_derisk
    #   and (grind_1_sub_grind_count > 0)
    #   and (((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < grind_1_derisk_grinds)
    #   and (grind_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_1_use_derisk
      and (grind_1_sub_grind_count > 0)
      and (grind_1_current_grind_stake_profit < (slice_amount * grind_1_derisk_grinds))
      and (is_backtest or grind_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_1_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "grind_1_derisk"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 2

    if (
      (self.grinding_v2_grind_2_enable)
      # and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and is_long_grind_entry
      and is_long_extra_checks_entry
      and (grind_2_sub_grind_count < grind_2_max_sub_grinds)
      and (grind_2_sub_grind_count == 0 or (grind_2_distance_ratio < grind_2_sub_thresholds[grind_2_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_2_stakes[grind_2_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_2_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_2_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_2_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_2_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
      if (grind_profit > (grind_2_profit_threshold + fee_open_rate + fee_close_rate)) and long_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_2_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_2_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_2_exit"
          for grind_entry_id in grind_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_2_use_derisk
    #   and (grind_2_sub_grind_count > 0)
    #   and (((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < grind_2_derisk_grinds)
    #   and (grind_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_2_use_derisk
      and (grind_2_sub_grind_count > 0)
      and (grind_2_current_grind_stake_profit < (slice_amount * grind_2_derisk_grinds))
      and (is_backtest or grind_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_2_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_2_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "grind_2_derisk"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 3

    if (
      (self.grinding_v2_grind_3_enable)
      # and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and is_long_grind_entry
      and is_long_extra_checks_entry
      and (grind_3_sub_grind_count < grind_3_max_sub_grinds)
      and (grind_3_sub_grind_count == 0 or (grind_3_distance_ratio < grind_3_sub_thresholds[grind_3_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_3_stakes[grind_3_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_3_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_3_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_3_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_3_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
      if (grind_profit > (grind_3_profit_threshold + fee_open_rate + fee_close_rate)) and long_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_3_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_3_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_3_exit"
          for grind_entry_id in grind_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_3_use_derisk
    #   and (grind_3_sub_grind_count > 0)
    #   and (((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < grind_3_derisk_grinds)
    #   and (grind_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_3_use_derisk
      and (grind_3_sub_grind_count > 0)
      and (grind_3_current_grind_stake_profit < (slice_amount * grind_3_derisk_grinds))
      and (is_backtest or grind_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_3_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_3_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_3_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "grind_3_derisk"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 4

    if (
      (self.grinding_v2_grind_4_enable)
      # and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and (
        is_long_grind_entry
        # or (
        #   is_derisk_1_found
        #   # only queue 4 grinds open
        #   and (num_open_grinds_and_buybacks == grind_4_sub_grind_count)
        #   and (last_candle["protections_long_global"] == True)
        #   and (
        #     (slice_profit < -0.04)
        #     and (last_candle["RSI_3"] > 10.0)
        #     and (last_candle["RSI_3_15m"] > 20.0)
        #     and (last_candle["AROONU_14"] < 50.0)
        #     and (last_candle["AROONU_14_15m"] < 50.0)
        #   )
        # )
        # or (
        #   (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
        #   and (num_open_grinds_and_buybacks == 0)
        #   and (
        #     (last_candle["RSI_3"] > 10.0)
        #     and (last_candle["RSI_3_15m"] > 20.0)
        #     and (last_candle["RSI_3_1h"] > 20.0)
        #     and (last_candle["RSI_3_1h"] > 20.0)
        #     and (last_candle["AROONU_14"] < 50.0)
        #     and (last_candle["AROONU_14_15m"] < 50.0)
        #   )
        # )
      )
      and is_long_extra_checks_entry
      and (grind_4_sub_grind_count < grind_4_max_sub_grinds)
      and (grind_4_sub_grind_count == 0 or (grind_4_distance_ratio < grind_4_sub_thresholds[grind_4_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_4_stakes[grind_4_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_4_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_4_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_4_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_4_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
      if (grind_profit > (grind_4_profit_threshold + fee_open_rate + fee_close_rate)) and long_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_4_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_4_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_4_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_4_exit"
          for grind_entry_id in grind_4_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_4_use_derisk
    #   and (grind_4_sub_grind_count > 0)
    #   and (((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < grind_4_derisk_grinds)
    #   and (grind_4_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_4_use_derisk
      and (grind_4_sub_grind_count > 0)
      and (grind_4_current_grind_stake_profit < (slice_amount * grind_4_derisk_grinds))
      and (is_backtest or grind_4_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_4_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_4_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_4_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "grind_4_derisk"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 5

    if (
      (self.grinding_v2_grind_5_enable)
      and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and (
        is_long_grind_entry
        or (
          is_derisk_1_found
          and (slice_profit_entry < -0.10)
          and (slice_profit_exit < -0.04)
          and (last_candle["protections_long_global"] == True)
          # and (
          #   (slice_profit < -0.04)
          #   and (last_candle["RSI_3"] > 10.0)
          #   and (last_candle["RSI_3_15m"] > 20.0)
          #   and (last_candle["AROONU_14"] < 50.0)
          #   and (last_candle["AROONU_14_15m"] < 50.0)
          # )
        )
      )
      and is_long_extra_checks_entry
      and (grind_5_sub_grind_count < grind_5_max_sub_grinds)
      and (grind_5_sub_grind_count == 0 or (grind_5_distance_ratio < grind_5_sub_thresholds[grind_5_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_5_stakes[grind_5_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_5_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_5_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_5_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_5_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
      if (grind_profit > (grind_5_profit_threshold + fee_open_rate + fee_close_rate)) and long_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_5_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_5_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_5_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_5_exit"
          for grind_entry_id in grind_5_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_5_use_derisk
    #   and (grind_5_sub_grind_count > 0)
    #   and (((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < grind_5_derisk_grinds)
    #   and (grind_5_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_5_use_derisk
      and (grind_5_sub_grind_count > 0)
      and (grind_5_current_grind_stake_profit < (slice_amount * grind_5_derisk_grinds))
      and (is_backtest or grind_5_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_5_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_5_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_5_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "grind_5_derisk"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Buyback 1

    if (
      self.grinding_v2_buyback_1_enable
      and is_derisk_1_found
      and is_long_buyback_entry
      and is_long_extra_checks_entry
      and (buyback_1_current_open_rate == 0)
      and (
        buyback_1_exit_distance_ratio
        < (
          self.grinding_v2_buyback_1_distance_ratio_futures
          if is_futures
          else self.grinding_v2_buyback_1_distance_ratio_spot
        )
      )
      and is_not_trade_max_stake
    ):
      buy_amount = (
        slice_amount
        * (self.grinding_v2_buyback_1_stake_futures if is_futures else self.grinding_v2_buyback_1_stake_spot)
        / trade_leverage
      )
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "buyback-entry",
          tag="buyback_1_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Buyback entry (buyback_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if buyback_1_sub_grind_count > 0:
      grind_profit = (exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate
      if (
        grind_profit
        > (
          (
            self.grinding_v2_buyback_1_profit_threshold_futures
            if is_futures
            else self.grinding_v2_buyback_1_profit_threshold_spot
          )
          + fee_open_rate
          + fee_close_rate
        )
      ) and long_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
        sell_amount = buyback_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "buyback-exit",
              tag="buyback_1_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_1_total_amount,
            )
          )
          log.info(
            f"Buyback exit (buyback_1_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "buyback_1_exit"
          for grind_entry_id in buyback_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_1_use_derisk
    #   and (buyback_1_sub_grind_count > 0)
    #   and (
    #     ((exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_1_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_1_derisk_spot
    #     )
    #   )
    #   and (buyback_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_buyback_1_use_derisk
      and (buyback_1_sub_grind_count > 0)
      and (
        buyback_1_current_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_buyback_1_derisk_futures if is_futures else self.grinding_v2_buyback_1_derisk_spot)
        )
      )
      and (is_backtest or buyback_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = buyback_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate)
            if buyback_1_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "buyback-derisk",
            tag="buyback_1_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=buyback_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=buyback_1_total_amount,
          )
        )
        log.info(
          f"Buyback de-risk (buyback_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({buyback_1_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "buyback_1_derisk"
        for grind_entry_id in buyback_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # # Buyback 2

    if (
      self.grinding_v2_buyback_2_enable
      and is_derisk_2_found
      and is_long_buyback_entry
      and is_long_extra_checks_entry
      and (buyback_2_current_open_rate == 0)
      and (
        buyback_2_exit_distance_ratio
        < (
          self.grinding_v2_buyback_2_distance_ratio_futures
          if is_futures
          else self.grinding_v2_buyback_2_distance_ratio_spot
        )
      )
      and is_not_trade_max_stake
    ):
      buy_amount = (
        slice_amount
        * (self.grinding_v2_buyback_2_stake_futures if is_futures else self.grinding_v2_buyback_2_stake_spot)
        / trade_leverage
      )
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "buyback-entry",
          tag="buyback_2_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Buyback entry (buyback_2_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_2_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if buyback_2_sub_grind_count > 0:
      grind_profit = (exit_rate - buyback_2_current_open_rate) / buyback_2_current_open_rate
      if (
        grind_profit
        > (
          (
            self.grinding_v2_buyback_2_profit_threshold_futures
            if is_futures
            else self.grinding_v2_buyback_2_profit_threshold_spot
          )
          + fee_open_rate
          + fee_close_rate
        )
      ) and long_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
        sell_amount = buyback_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "buyback-exit",
              tag="buyback_2_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_2_total_amount,
            )
          )
          log.info(
            f"Buyback exit (buyback_2_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "buyback_2_exit"
          for grind_entry_id in buyback_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_2_use_derisk
    #   and (buyback_2_sub_grind_count > 0)
    #   and (
    #     ((exit_rate - buyback_2_current_open_rate) / buyback_2_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_2_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_2_derisk_spot
    #     )
    #   )
    #   and (buyback_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_buyback_2_use_derisk
      and (buyback_2_sub_grind_count > 0)
      and (
        buyback_2_current_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_buyback_2_derisk_futures if is_futures else self.grinding_v2_buyback_2_derisk_spot)
        )
      )
      and (is_backtest or buyback_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = buyback_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_2_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - buyback_2_current_open_rate) / buyback_2_current_open_rate)
            if buyback_2_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "buyback-derisk",
            tag="buyback_2_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=buyback_2_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=buyback_2_total_amount,
          )
        )
        log.info(
          f"Buyback de-risk (buyback_2_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({buyback_2_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "buyback_2_derisk"
        for grind_entry_id in buyback_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # # Buyback 3

    if (
      self.grinding_v2_buyback_3_enable
      and is_derisk_3_found
      and is_long_buyback_entry
      and is_long_extra_checks_entry
      and (buyback_3_current_open_rate == 0)
      and (
        buyback_3_exit_distance_ratio
        < (
          self.grinding_v2_buyback_3_distance_ratio_futures
          if is_futures
          else self.grinding_v2_buyback_3_distance_ratio_spot
        )
      )
      and is_not_trade_max_stake
    ):
      buy_amount = (
        slice_amount
        * (self.grinding_v2_buyback_3_stake_futures if is_futures else self.grinding_v2_buyback_3_stake_spot)
        / trade_leverage
      )
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "buyback-entry",
          tag="buyback_3_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Buyback entry (buyback_3_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_3_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if buyback_3_sub_grind_count > 0:
      grind_profit = (exit_rate - buyback_3_current_open_rate) / buyback_3_current_open_rate
      if (
        grind_profit
        > (
          (
            self.grinding_v2_buyback_3_profit_threshold_futures
            if is_futures
            else self.grinding_v2_buyback_3_profit_threshold_spot
          )
          + fee_open_rate
          + fee_close_rate
        )
      ) and long_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
        sell_amount = buyback_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "buyback-exit",
              tag="buyback_3_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_3_total_amount,
            )
          )
          log.info(
            f"Buyback exit (buyback_3_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "buyback_3_exit"
          for grind_entry_id in buyback_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_3_use_derisk
    #   and (buyback_3_sub_grind_count > 0)
    #   and (
    #     ((exit_rate - buyback_3_current_open_rate) / buyback_3_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_3_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_3_derisk_spot
    #     )
    #   )
    #   and (buyback_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_buyback_3_use_derisk
      and (buyback_3_sub_grind_count > 0)
      and (
        buyback_3_current_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_buyback_3_derisk_futures if is_futures else self.grinding_v2_buyback_3_derisk_spot)
        )
      )
      and (is_backtest or buyback_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = buyback_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_3_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - buyback_3_current_open_rate) / buyback_3_current_open_rate)
            if buyback_3_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "buyback-derisk",
            tag="buyback_3_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=buyback_3_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
            coin_amount=buyback_3_total_amount,
          )
        )
        log.info(
          f"Buyback de-risk (buyback_3_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({buyback_3_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "buyback_3_derisk"
        for grind_entry_id in buyback_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    return None

  def long_buyback_entry_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    previous_ema_26 = previous_candle["EMA_26"]
    previous_ema_12 = previous_candle["EMA_12"]

    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_close_max_48 = last_candle["close_max_48"]
    last_high_max_6_1h = last_candle["high_max_6_1h"]
    last_high_max_12_1h = last_candle["high_max_12_1h"]
    last_open = last_candle["open"]

    last_ema_12 = last_candle["EMA_12"]
    last_ema_26 = last_candle["EMA_26"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]

    last_close = last_candle["close"]
    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_roc_2_1h = last_candle["ROC_2_1h"]
    last_roc_2_4h = last_candle["ROC_2_4h"]
    last_protections_long_global = last_candle["protections_long_global"]
    last_enter_long = last_candle["enter_long"]
    last_aroonu_14 = last_candle["AROONU_14"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_stochrsi_k_15m = last_candle["STOCHRSIk_14_14_3_3_15m"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_roc_2_1d = last_candle["ROC_2_1d"]
    last_ema_16 = last_candle["EMA_16"]
    last_bbl_20 = last_candle["BBL_20_2.0"]

    # Reused long buyback entry v2 thresholds
    last_rsi_14_lt_36 = last_rsi_14 < 36.0
    last_roc_2_4h_gt_neg_5 = last_roc_2_4h > -5.0
    last_roc_2_1h_gt_neg_5 = last_roc_2_1h > -5.0
    last_rsi_3_4h_gt_10 = last_rsi_3_4h > 10.0
    last_rsi_3_1h_gt_10 = last_rsi_3_1h > 10.0
    last_rsi_3_1d_gt_10 = last_rsi_3_1d > 10.0
    last_rsi_3_15m_gt_10 = last_rsi_3_15m > 10.0
    last_roc_9_4h_gt_neg_5 = last_roc_9_4h > -5.0
    last_roc_9_1h_gt_neg_5 = last_roc_9_1h > -5.0
    last_roc_9_1d_gt_neg_5 = last_roc_9_1d > -5.0
    if (last_protections_long_global == True) and (
      (last_enter_long == True)
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3 > 20.0)
        and (last_rsi_3_15m > 20.0)
        # and (last_candle["RSI_3_1h"] > 20.0)
        # and (last_candle["RSI_3_4h"] > 20.0)
        and (last_aroonu_14 < 25.0)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        # and (last_candle["ROC_9_4h"] > -20.0)
        # and (last_candle["ROC_9_4h"] < 40.0)
        # and (last_candle["ROC_9_1d"] > -20.0)
        # and (last_candle["ROC_9_1d"] < 50.0)
        and (last_stochrsi_k < 20.0)
        and (last_stochrsi_k_15m < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 30.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_4h"] < 30.0)
        and (last_close > (last_close_max_48 * 0.90))
        and (last_close > (last_high_max_6_1h * 0.85))
        and (last_close > (last_high_max_12_1h * 0.80))
        # and (last_candle["close"] < (last_candle["low_min_24_4h"] * 1.20))
        and (last_close < (last_ema_16 * 0.980))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3 > 5.0)
        and (last_rsi_3_15m > 15.0)
        and (last_rsi_3_1h > 15.0)
        and (last_rsi_3_4h > 15.0)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        # and (last_candle["ROC_2_1d"] > -10.0)
        # and (last_candle["ROC_9_1h"] > -10.0)
        # and (last_candle["ROC_9_4h"] > -10.0)
        and (last_roc_9_1d_gt_neg_5)
        and (last_ema_26 > last_ema_12)
        and ((last_ema_26 - last_ema_12) > (last_open * 0.020))
        and ((previous_ema_26 - previous_ema_12) > (last_open / 100.0))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3 > 10.0)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_rsi_3_1d_gt_10)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        and (last_roc_2_1d > -5.0)
        and (last_roc_9_1h_gt_neg_5)
        and (last_roc_9_4h_gt_neg_5)
        and (last_roc_9_1d > -10.0)
        # and (last_candle["ROC_9_4h"] < 40.0)
        # and (last_candle["ROC_9_1d"] < 50.0)
        and (last_aroonu_14_15m < 25.0)
        and (last_close > (last_close_max_48 * 0.90))
        and (last_close > (last_high_max_6_1h * 0.85))
        and (last_close > (last_high_max_12_1h * 0.80))
        # and (last_candle["close"] < (last_candle["low_min_24_4h"] * 1.20))
        and (last_close < (last_ema_12 * 0.980))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_rsi_3_1d_gt_10)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        # and (last_candle["ROC_2_1d"] > -5.0)
        and (last_roc_9_1h_gt_neg_5)
        and (last_roc_9_4h_gt_neg_5)
        and (last_roc_9_1d_gt_neg_5)
        and (last_stochrsi_k_1h < 80.0)
        and (last_stochrsi_k_4h < 70.0)
        # and (last_candle["close"] > (last_candle["close_max_48"] * 0.90))
        # and (last_candle["close"] > (last_candle["high_max_6_1h"] * 0.85))
        # and (last_candle["close"] > (last_candle["high_max_12_1h"] * 0.80))
        and (last_close < (last_ema_26 * 0.960))
        and (last_close < (last_bbl_20 * 0.999))
      )
    ):
      return True

    return False

  def long_grind_entry_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    previous_ema_26 = previous_candle["EMA_26"]
    previous_ema_12 = previous_candle["EMA_12"]
    last_bbl_20_2_0 = last_candle["BBL_20_2.0"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_low_min_24_4h = last_candle["low_min_24_4h"]
    last_low_min_12_4h = last_candle["low_min_12_4h"]

    last_ema_12 = last_candle["EMA_12"]
    last_ema_26 = last_candle["EMA_26"]
    last_stochrsik_14_14_3_3 = last_candle["STOCHRSIk_14_14_3_3"]
    last_close_max_48 = last_candle["close_max_48"]
    last_open = last_candle["open"]
    last_aroonu_14 = last_candle["AROONU_14"]
    last_roc_2_1d = last_candle["ROC_2_1d"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_high_max_12_1h = last_candle["high_max_12_1h"]
    last_high_max_6_1h = last_candle["high_max_6_1h"]

    last_close = last_candle["close"]
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_rsi_14 = last_candle["RSI_14"]
    last_roc_2_1h = last_candle["ROC_2_1h"]
    last_roc_2_4h = last_candle["ROC_2_4h"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_protections_long_global = last_candle["protections_long_global"]
    last_enter_long = last_candle["enter_long"]
    last_stochrsi_k_15m = last_candle["STOCHRSIk_14_14_3_3_15m"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_willr_14 = last_candle["WILLR_14"]
    last_ema_16 = last_candle["EMA_16"]

    # Reused long grind entry v2 thresholds
    last_rsi_3_gt_5 = last_rsi_3 > 5.0
    last_rsi_3_4h_gt_10 = last_rsi_3_4h > 10.0
    last_rsi_3_1h_gt_10 = last_rsi_3_1h > 10.0
    last_rsi_3_15m_gt_10 = last_rsi_3_15m > 10.0
    last_rsi_3_gt_10 = last_rsi_3 > 10.0
    last_rsi_14_lt_36 = last_rsi_14 < 36.0
    last_aroonu_14_lt_25 = last_aroonu_14 < 25.0
    last_stochrsik_14_14_3_3_lt_20 = last_stochrsik_14_14_3_3 < 20.0
    last_rsi_3_1d_gt_10 = last_rsi_3_1d > 10.0
    last_roc_9_4h_gt_neg_10 = last_roc_9_4h > -10.0
    last_roc_9_1h_gt_neg_10 = last_roc_9_1h > -10.0
    last_roc_2_4h_gt_neg_10 = last_roc_2_4h > -10.0
    last_roc_2_1h_gt_neg_10 = last_roc_2_1h > -10.0
    last_rsi_3_15m_gt_15 = last_rsi_3_15m > 15.0
    last_roc_2_4h_gt_neg_5 = last_roc_2_4h > -5.0
    last_roc_2_1h_gt_neg_5 = last_roc_2_1h > -5.0
    last_roc_2_1d_gt_neg_10 = last_roc_2_1d > -10.0
    last_rsi_3_4h_gt_15 = last_rsi_3_4h > 15.0
    last_rsi_3_1h_gt_15 = last_rsi_3_1h > 15.0
    last_rsi_3_15m_gt_5 = last_rsi_3_15m > 5.0
    last_roc_9_1d_gt_neg_30 = last_roc_9_1d > -30.0

    if (last_protections_long_global == True) and (
      (last_enter_long == True)
      or (
        (last_rsi_14 < 46.0)
        and (last_rsi_3_gt_10)
        and (last_rsi_3_15m_gt_15)
        and (last_rsi_3_1h_gt_15)
        and (last_rsi_3_4h_gt_15)
        and (last_roc_2_1h_gt_neg_10)
        and (last_roc_2_4h_gt_neg_10)
        and (last_roc_2_1d_gt_neg_10)
        and (last_roc_9_1h > -25.0)
        and (last_roc_9_4h > -25.0)
        and (last_roc_9_1d > -25.0)
        # and (last_candle["ROC_9_1d"] < 40.0)
        and (last_aroonu_14_lt_25)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 30.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_4h"] < 30.0)
        and (last_close > (last_close_max_48 * 0.90))
        and (last_close > (last_high_max_6_1h * 0.85))
        and (last_close > (last_high_max_12_1h * 0.80))
        and (last_close < (last_low_min_24_4h * 1.20))
        and (last_close < (last_ema_16 * 0.968))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3_gt_5)
        and (last_rsi_3_15m_gt_15)
        and (last_rsi_3_1h_gt_15)
        and (last_rsi_3_4h_gt_15)
        # and (last_candle["RSI_3_1d"] > 15.0)
        and (last_roc_2_1h_gt_neg_10)
        and (last_roc_2_4h_gt_neg_10)
        # and (last_candle["ROC_2_1d"] > -10.0)
        and (last_roc_9_1h_gt_neg_10)
        and (last_roc_9_4h_gt_neg_10)
        and (last_roc_9_1d_gt_neg_30)
        and (last_stochrsik_14_14_3_3 < 50.0)
        and (last_ema_26 > last_ema_12)
        and ((last_ema_26 - last_ema_12) > (last_open * 0.020))
        and ((previous_ema_26 - previous_ema_12) > (last_open / 100.0))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3_gt_10)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_rsi_3_1d_gt_10)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        and (last_roc_2_1d > -5.0)
        and (last_roc_9_1h_gt_neg_10)
        and (last_roc_9_4h_gt_neg_10)
        and (last_roc_9_1d > -10.0)
        # and (last_roc_9_4h < 40.0)
        # and (last_candle["ROC_9_1d"] < 50.0)
        and (last_aroonu_14_15m < 25.0)
        and (last_close > (last_close_max_48 * 0.90))
        and (last_close > (last_high_max_6_1h * 0.85))
        and (last_close > (last_high_max_12_1h * 0.80))
        # and (last_close < (last_candle["low_min_24_4h"] * 1.20))
        and (last_close < (last_ema_12 * 0.980))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3_gt_10)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_rsi_3_1d_gt_10)
        and (last_roc_2_1h_gt_neg_10)
        and (last_roc_2_4h_gt_neg_10)
        and (last_roc_2_1d_gt_neg_10)
        # and (last_roc_9_1h > -10.0)
        # and (last_roc_9_4h > -10.0)
        # and (last_candle["ROC_9_1d"] > -10.0)
        and (last_aroonu_14_lt_25)
        and (last_close > (last_close_max_48 * 0.90))
        and (last_close > (last_high_max_6_1h * 0.85))
        and (last_close > (last_high_max_12_1h * 0.80))
        and (last_close < (last_ema_26 * 0.962))
        and (last_close < (last_bbl_20_2_0 * 0.999))
      )
      or (
        (last_rsi_14 < 35.0)
        and (last_rsi_3_gt_10)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        # and (last_candle["RSI_3_1d"] > 10.0)
        and (last_roc_2_1h_gt_neg_10)
        and (last_roc_2_4h_gt_neg_10)
        and (last_roc_2_1d_gt_neg_10)
        and (last_roc_9_1h_gt_neg_10)
        and (last_roc_9_4h_gt_neg_10)
        # and (last_candle["ROC_9_1d"] > -10.0)
        and (last_aroonu_14_lt_25)
        # and (last_candle["AROONU_14_15m"] < 25.0)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 20.0)
        # and (last_close > (last_candle["close_max_48"] * 0.90))
        # and (last_close > (last_candle["high_max_6_1h"] * 0.85))
        # and (last_close > (last_candle["high_max_12_1h"] * 0.80))
        and (last_close < (last_low_min_12_4h * 1.25))
        and (last_close < (last_candle["EMA_9"] * 0.968))
        and (last_close < (last_candle["EMA_20"] * 0.980))
      )
      or (
        (last_rsi_14 > 35.0)
        and (last_rsi_3_gt_10)
        and (last_rsi_3 < 40.0)
        # and (last_candle["RSI_4"] < 40.0)
        and (last_rsi_3_15m_gt_15)
        # and (last_rsi_3_1h > 20.0)
        # and (last_rsi_3_4h > 20.0)
        # and (last_candle["RSI_3_1d"] > 20.0)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        # and (last_candle["ROC_2_1d"] > -5.0)
        and (last_roc_9_1h_gt_neg_10)
        and (last_roc_9_4h_gt_neg_10)
        # and (last_candle["ROC_9_1d"] > -10.0)
        and (last_aroonu_14_lt_25)
        # and (last_candle["AROONU_14_15m"] < 25.0)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 50.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_4h"] < 50.0)
        # and (last_close > (last_candle["close_max_48"] * 0.90))
        # and (last_close > (last_candle["high_max_6_1h"] * 0.85))
        # and (last_close > (last_candle["high_max_12_1h"] * 0.80))
        and (last_candle["RSI_20"] < previous_candle["RSI_20"])
        and (last_close < (last_candle["SMA_16"] * 0.955))
        # and (last_close < (last_candle["EMA_20"] * 0.980))
      )
      or (
        (last_rsi_3_gt_5)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_roc_2_1h_gt_neg_5)
        and (last_roc_2_4h_gt_neg_5)
        and (last_roc_9_1h > -5.0)
        and (last_roc_9_4h > -5.0)
        and (last_willr_14 < -50.0)
        # and (last_candle["AROONU_14"] < 25.0)
        and (last_stochrsik_14_14_3_3_lt_20)
        and (last_candle["WILLR_84_1h"] < -70.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 40.0)
        and (last_close < (last_low_min_24_4h * 1.30))
        and (last_candle["BBB_20_2.0_1h"] > 12.0)
        and (last_close_max_48 >= (last_close * 1.10))
      )
      or (
        (last_rsi_3 < 30.0)
        and (last_rsi_3_gt_5)
        and (last_rsi_3_15m_gt_5)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        # and (last_roc_2_1h > -5.0)
        # and (last_roc_2_4h > -5.0)
        # and (last_roc_9_1h > -5.0)
        # and (last_roc_9_4h > -5.0)
        and (last_roc_9_1d_gt_neg_30)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_close < (last_candle["low_min_24_4h"] * 1.50))
        and (last_ema_26 > last_ema_12)
        and ((last_ema_26 - last_ema_12) > (last_open * 0.034))
        and ((previous_ema_26 - previous_ema_12) > (last_open / 100.0))
      )
      or (
        (last_rsi_3_gt_5)
        and (last_rsi_3_15m > 25.0)
        and (last_rsi_3_1h > 30.0)
        and (last_close < (last_candle["high_max_24_4h"] * 0.90))
        and (last_close < (last_close_max_48 * 0.90))
        and (last_close > (last_candle["close_min_12"] * 1.08))
      )
      or (
        (last_rsi_3_gt_5)
        and (last_rsi_3_15m_gt_5)
        and (last_stochrsik_14_14_3_3_lt_20)
        and (last_rsi_14 < (last_rsi_14_1h - 45.0))
      )
      or (
        (last_rsi_3_gt_10)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_rsi_3_1d_gt_10)
        and (last_stochrsik_14_14_3_3_lt_20)
        and (last_close < (last_candle["SMA_30"] * 0.978))
        and (last_close < (last_bbl_20_2_0 * 0.999))
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3_gt_5)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_rsi_3_1d_gt_10)
        and (last_stochrsik_14_14_3_3 < 30.0)
        and (last_close > (last_close_max_48 * 0.85))
        and (last_close > (last_high_max_6_1h * 0.80))
        and (last_close > (last_high_max_12_1h * 0.75))
        and (last_close < (last_low_min_12_4h * 1.25))
        and (last_ema_26 > last_ema_12)
        and ((last_ema_26 - last_ema_12) > (last_open * 0.018))
        and ((previous_ema_26 - previous_ema_12) > (last_open / 100.0))
      )
      or (
        (last_rsi_3_gt_5)
        and (previous_candle["SMA_9"] < previous_candle["SMA_21"])
        and (last_candle["SMA_9"] > last_candle["SMA_21"])
        and (last_close < (last_candle["EMA_100"] * 0.984))
        and (last_rsi_3_1h > 20.0)
        and (last_rsi_3_4h > 20.0)
      )
      or (
        (slice_profit < -0.12)
        and (last_rsi_3_gt_5)
        and (last_rsi_3_15m_gt_10)
        and (last_rsi_14 < 40.0)
        and (last_aroonu_14_lt_25)
        and (last_aroonu_14_15m < 30.0)
        and (last_stochrsik_14_14_3_3_lt_20)
        and (last_stochrsi_k_15m < 30.0)
        and (last_rsi_14_1h < 50.0)
        and (last_candle["RSI_14_4h"] < 50.0)
      )
      or (
        (last_rsi_14_lt_36)
        and (last_rsi_3_gt_5)
        and (last_rsi_3_1h_gt_10)
        and (last_rsi_3_4h_gt_10)
        and (last_close < (last_ema_12 * 0.999))
        and (last_close < (last_bbl_20_2_0 * 0.996))
      )
    ):
      return True

    return False

  def long_buyback_exit_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_14 = last_candle["RSI_14"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_close = last_candle["close"]
    last_bbu_20 = last_candle["BBU_20_2.0"]

    if (
      (last_rsi_3 > 99.0)
      or (last_rsi_14 > 70.0)
      or (last_willr_14 > -0.1)
      or (last_stochrsi_k > 95.0)
      or (last_close > (last_bbu_20 * 1.01))
      or ((last_rsi_3 > 90.0) and (last_rsi_14 < 50.0))
    ):
      return True

    return False

  def long_grind_exit_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_14 = last_candle["RSI_14"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_close = last_candle["close"]
    last_bbu_20 = last_candle["BBU_20_2.0"]

    if (
      (last_rsi_3 > 99.0)
      or (last_rsi_14 > 70.0)
      or (last_willr_14 > -0.1)
      or (last_stochrsi_k > 95.0)
      or (last_close > (last_bbu_20 * 1.01))
      or ((last_rsi_3 > 90.0) and (last_rsi_14 < 50.0))
      or (
        (last_rsi_3 > 80.0)
        and (last_candle["RSI_3_1h"] < 20.0)
        and (last_candle["RSI_3_4h"] < 20.0)
        and (last_candle["ROC_9_1d"] > -10.0)
        and (last_candle["BTC_RSI_14_4h"] < 35.0)
      )
    ):
      return True

    return False

  # Long Grinding Adjust Trade Position v3
  # ---------------------------------------------------------------------------------------------
  def long_grind_adjust_trade_position_v3(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    config = self.config
    stake_currency = config["stake_currency"]
    is_futures_mode = self.is_futures_mode
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_leverage = trade.leverage
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close
    trade_is_short = trade.is_short
    is_backtest = self.is_backtest_mode()
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_14 = last_candle["RSI_14"]
    last_close = last_candle["close"]
    last_ema_20 = last_candle["EMA_20"]
    last_aroonu_14 = last_candle["AROONU_14"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_bbu_20 = last_candle["BBU_20_2.0"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_btc_rsi_14_4h = last_candle["BTC_RSI_14_4h"]
    previous_candle = df.iloc[-2]

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_exits = trade.nr_of_successful_exits

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    current_stake_amount = trade_amount * exit_rate
    slice_amount = filled_entries[0].safe_filled * filled_entries[0].safe_price
    slice_profit = (exit_rate - filled_orders[-1].safe_price) / filled_orders[-1].safe_price
    slice_profit_entry = (exit_rate - filled_entries[-1].safe_price) / filled_entries[-1].safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    is_rebuy_mode = all(c in self.long_rebuy_mode_tags for c in enter_tags) or (
      any(c in self.long_rebuy_mode_tags for c in enter_tags)
      and all(c in (self.long_rebuy_mode_tags + self.long_grind_mode_tags) for c in enter_tags)
    )
    # Rebuy mode, the first entry is lower than normal slot stake
    if is_rebuy_mode:
      slice_amount /= self.system_v3_rebuy_mode_stake_multiplier

    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)

    has_order_tags = hasattr(filled_orders[0], "ft_order_tag")

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate
    fee_rate = fee_open_rate + fee_close_rate
    stake_scale_leverage = trade_leverage if is_futures_mode else 1.0
    grind_entry_retry_time = current_time - timedelta(minutes=5)

    # =========================================================================
    # GRINDING CONFIGURATION
    # =========================================================================
    if is_futures_mode:
      grind_1_stakes = self.system_v3_grind_1_stakes_futures
      grind_1_sub_thresholds = self.system_v3_grind_1_thresholds_futures
      grind_1_derisk_grinds = self.system_v3_grind_1_derisk_futures
      grind_1_profit_threshold = self.system_v3_grind_1_profit_threshold_futures

      grind_2_stakes = self.system_v3_grind_2_stakes_futures
      grind_2_sub_thresholds = self.system_v3_grind_2_thresholds_futures
      grind_2_derisk_grinds = self.system_v3_grind_2_derisk_futures
      grind_2_profit_threshold = self.system_v3_grind_2_profit_threshold_futures

      grind_3_stakes = self.system_v3_grind_3_stakes_futures
      grind_3_sub_thresholds = self.system_v3_grind_3_thresholds_futures
      grind_3_derisk_grinds = self.system_v3_grind_3_derisk_futures
      grind_3_profit_threshold = self.system_v3_grind_3_profit_threshold_futures

      grind_4_stakes = self.system_v3_grind_4_stakes_futures
      grind_4_sub_thresholds = self.system_v3_grind_4_thresholds_futures
      grind_4_derisk_grinds = self.system_v3_grind_4_derisk_futures
      grind_4_profit_threshold = self.system_v3_grind_4_profit_threshold_futures

      grind_5_stakes = self.system_v3_grind_5_stakes_futures
      grind_5_sub_thresholds = self.system_v3_grind_5_thresholds_futures
      grind_5_derisk_grinds = self.system_v3_grind_5_derisk_futures
      grind_5_profit_threshold = self.system_v3_grind_5_profit_threshold_futures

      rebuy_stakes = self.system_v3_1_rebuy_stakes_futures
      rebuy_sub_thresholds = self.system_v3_1_rebuy_thresholds_futures
    else:
      grind_1_stakes = self.system_v3_grind_1_stakes_spot
      grind_1_sub_thresholds = self.system_v3_grind_1_thresholds_spot
      grind_1_derisk_grinds = self.system_v3_grind_1_derisk_spot
      grind_1_profit_threshold = self.system_v3_grind_1_profit_threshold_spot

      grind_2_stakes = self.system_v3_grind_2_stakes_spot
      grind_2_sub_thresholds = self.system_v3_grind_2_thresholds_spot
      grind_2_derisk_grinds = self.system_v3_grind_2_derisk_spot
      grind_2_profit_threshold = self.system_v3_grind_2_profit_threshold_spot

      grind_3_stakes = self.system_v3_grind_3_stakes_spot
      grind_3_sub_thresholds = self.system_v3_grind_3_thresholds_spot
      grind_3_derisk_grinds = self.system_v3_grind_3_derisk_spot
      grind_3_profit_threshold = self.system_v3_grind_3_profit_threshold_spot

      grind_4_stakes = self.system_v3_grind_4_stakes_spot
      grind_4_sub_thresholds = self.system_v3_grind_4_thresholds_spot
      grind_4_derisk_grinds = self.system_v3_grind_4_derisk_spot
      grind_4_profit_threshold = self.system_v3_grind_4_profit_threshold_spot

      grind_5_stakes = self.system_v3_grind_5_stakes_spot
      grind_5_sub_thresholds = self.system_v3_grind_5_thresholds_spot
      grind_5_derisk_grinds = self.system_v3_grind_5_derisk_spot
      grind_5_profit_threshold = self.system_v3_grind_5_profit_threshold_spot

      rebuy_stakes = self.system_v3_1_rebuy_stakes_spot
      rebuy_sub_thresholds = self.system_v3_1_rebuy_thresholds_spot

    grind_1_max_sub_grinds = 0
    grind_1_stakes = scale_stakes_for_min_stake(
      grind_1_stakes, slice_amount, min_stake, trade_leverage, trade_leverage
    )
    grind_1_max_sub_grinds = len(grind_1_stakes)

    grind_2_max_sub_grinds = 0
    grind_2_stakes = scale_stakes_for_min_stake(
      grind_2_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_2_max_sub_grinds = len(grind_2_stakes)

    grind_3_max_sub_grinds = 0
    grind_3_stakes = scale_stakes_for_min_stake(
      grind_3_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_3_max_sub_grinds = len(grind_3_stakes)

    grind_4_max_sub_grinds = 0
    grind_4_stakes = scale_stakes_for_min_stake(
      grind_4_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_4_max_sub_grinds = len(grind_4_stakes)

    grind_5_max_sub_grinds = 0
    grind_5_stakes = scale_stakes_for_min_stake(
      grind_5_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_5_max_sub_grinds = len(grind_5_stakes)

    rebuy_max_sub_grinds = len(rebuy_stakes)

    is_derisk_1 = False
    is_derisk_1_found = False  # derisk_level_1 de-risk exit
    derisk_1_order = None
    is_derisk_2 = False
    is_derisk_2_found = False  # derisk_level_2 de-risk exit
    derisk_2_order = None
    is_derisk_3 = False
    is_derisk_3_found = False  # derisk_level_3 de-risk exit
    derisk_3_order = None
    is_derisk_4 = False
    is_derisk_4_found = False  # derisk_level_4 de-risk exit
    derisk_4_order = None
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_profit_stake = 0.0
    grind_1_current_grind_profit_rate = 0.0
    grind_1_is_exit_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_orders = []
    grind_1_distance_ratio = 0.0
    grind_1_exit_order = None
    grind_1_exit_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_profit_stake = 0.0
    grind_2_current_grind_profit_rate = 0.0
    grind_2_is_exit_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_orders = []
    grind_2_distance_ratio = 0.0
    grind_2_exit_order = None
    grind_2_exit_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_profit_stake = 0.0
    grind_3_current_grind_profit_rate = 0.0
    grind_3_is_exit_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_orders = []
    grind_3_distance_ratio = 0.0
    grind_3_exit_order = None
    grind_3_exit_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_profit_stake = 0.0
    grind_4_current_grind_profit_rate = 0.0
    grind_4_is_exit_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_orders = []
    grind_4_distance_ratio = 0.0
    grind_4_exit_order = None
    grind_4_exit_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_profit_stake = 0.0
    grind_5_current_grind_profit_rate = 0.0
    grind_5_is_exit_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_orders = []
    grind_5_distance_ratio = 0.0
    grind_5_exit_order = None
    grind_5_exit_distance_ratio = 0.0
    buyback_1_sub_grind_count = 0
    buyback_1_total_amount = 0.0
    buyback_1_total_cost = 0.0
    buyback_1_current_open_rate = 0.0
    buyback_1_current_grind_stake = 0.0
    buyback_1_current_grind_stake_profit = 0.0
    buyback_1_is_exit_found = False
    buyback_1_found = False
    buyback_1_buy_orders = []
    buyback_1_orders = []
    buyback_1_distance_ratio = 0.0
    buyback_1_exit_order = None
    buyback_1_exit_distance_ratio = 0.0
    rebuy_sub_grind_count = 0
    rebuy_total_amount = 0.0
    rebuy_total_cost = 0.0
    rebuy_current_open_rate = 0.0
    rebuy_current_grind_stake = 0.0
    rebuy_current_grind_stake_profit = 0.0
    rebuy_is_exit_found = False
    rebuy_found = False
    rebuy_buy_orders = []
    rebuy_orders = []
    rebuy_distance_ratio = 0.0
    rebuy_exit_order = None
    rebuy_exit_distance_ratio = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "buy") and (order is not filled_orders[0]):
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        if not grind_1_is_exit_found and order_tag == "grind_1_entry":
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order.safe_filled
          grind_1_total_cost += order.safe_filled * order.safe_price
          grind_1_buy_orders.append(order.id)
          grind_1_orders.append(order)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_1_found = True
        elif not grind_2_is_exit_found and order_tag == "grind_2_entry":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order.safe_filled
          grind_2_total_cost += order.safe_filled * order.safe_price
          grind_2_buy_orders.append(order.id)
          grind_2_orders.append(order)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_2_found = True
        elif not grind_3_is_exit_found and order_tag == "grind_3_entry":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order.safe_filled
          grind_3_total_cost += order.safe_filled * order.safe_price
          grind_3_buy_orders.append(order.id)
          grind_3_orders.append(order)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_3_found = True
        elif not grind_4_is_exit_found and order_tag == "grind_4_entry":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order.safe_filled
          grind_4_total_cost += order.safe_filled * order.safe_price
          grind_4_buy_orders.append(order.id)
          grind_4_orders.append(order)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_4_found = True
        elif not grind_5_is_exit_found and order_tag == "grind_5_entry":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order.safe_filled
          grind_5_total_cost += order.safe_filled * order.safe_price
          grind_5_buy_orders.append(order.id)
          grind_5_orders.append(order)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_5_found = True
        elif not buyback_1_is_exit_found and order_tag == "buyback_1_entry":
          buyback_1_sub_grind_count += 1
          buyback_1_total_amount += order.safe_filled
          buyback_1_total_cost += order.safe_filled * order.safe_price
          buyback_1_buy_orders.append(order.id)
          buyback_1_orders.append(order)
          if not buyback_1_found:
            buyback_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_1_found = True
        elif not rebuy_is_exit_found and order_tag == "rebuy_entry":
          rebuy_sub_grind_count += 1
          rebuy_total_amount += order.safe_filled
          rebuy_total_cost += order.safe_filled * order.safe_price
          rebuy_buy_orders.append(order.id)
          rebuy_orders.append(order)
          if not rebuy_found:
            rebuy_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            rebuy_found = True
      elif order.ft_order_side == "sell":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          # break
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag.partition(" ")[0]
        if order_tag == "derisk_level_1":
          if not is_derisk_1_found:
            is_derisk_1_found = True
            is_derisk_1 = True
            derisk_1_order = order
        elif order_tag == "derisk_level_2":
          if not is_derisk_2_found:
            is_derisk_2_found = True
            is_derisk_2 = True
            derisk_2_order = order
        elif order_tag == "derisk_level_3":
          if not is_derisk_3_found:
            is_derisk_3_found = True
            is_derisk_3 = True
            derisk_3_order = order
        elif order_tag == "derisk_level_4":
          if not is_derisk_4_found:
            is_derisk_4_found = True
            is_derisk_4 = True
            derisk_4_order = order
        elif not grind_1_is_exit_found and order_tag in ["grind_1_exit", "grind_1_derisk"]:
          grind_1_is_exit_found = True
          grind_1_exit_order = order
        elif not grind_2_is_exit_found and order_tag in ["grind_2_exit", "grind_2_derisk"]:
          grind_2_is_exit_found = True
          grind_2_exit_order = order
        elif not grind_3_is_exit_found and order_tag in ["grind_3_exit", "grind_3_derisk"]:
          grind_3_is_exit_found = True
          grind_3_exit_order = order
        elif not grind_4_is_exit_found and order_tag in ["grind_4_exit", "grind_4_derisk"]:
          grind_4_is_exit_found = True
          grind_4_exit_order = order
        elif not grind_5_is_exit_found and order_tag in ["grind_5_exit", "grind_5_derisk"]:
          grind_5_is_exit_found = True
          grind_5_exit_order = order
        elif not buyback_1_is_exit_found and order_tag in ["buyback_1_exit", "buyback_1_derisk"]:
          buyback_1_is_exit_found = True
          buyback_1_exit_order = order
        elif not rebuy_is_exit_found and order_tag in ["rebuy_exit", "rebuy_derisk"]:
          rebuy_is_exit_found = True
          rebuy_exit_order = order
        elif order_tag == "derisk_global":
          if not grind_1_is_exit_found:
            grind_1_is_exit_found = True
            grind_1_exit_order = order
          if not grind_2_is_exit_found:
            grind_2_is_exit_found = True
            grind_2_exit_order = order
          if not grind_3_is_exit_found:
            grind_3_is_exit_found = True
            grind_3_exit_order = order
          if not grind_4_is_exit_found:
            grind_4_is_exit_found = True
            grind_4_exit_order = order
          if not grind_5_is_exit_found:
            grind_5_is_exit_found = True
            grind_5_exit_order = order
          if not buyback_1_is_exit_found:
            buyback_1_is_exit_found = True
            buyback_1_exit_order = order
          if not rebuy_is_exit_found:
            rebuy_is_exit_found = True
            rebuy_exit_order = order

    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_current_grind_profit_stake = grind_1_current_grind_stake - grind_1_total_cost
      grind_1_current_grind_profit_rate = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_current_grind_profit_stake = grind_2_current_grind_stake - grind_2_total_cost
      grind_2_current_grind_profit_rate = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 - trade_fee_close)
      grind_3_current_grind_profit_stake = grind_3_current_grind_stake - grind_3_total_cost
      grind_3_current_grind_profit_rate = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 - trade_fee_close)
      grind_4_current_grind_profit_stake = grind_4_current_grind_stake - grind_4_total_cost
      grind_4_current_grind_profit_rate = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 - trade_fee_close)
      grind_5_current_grind_profit_stake = grind_5_current_grind_stake - grind_5_total_cost
      grind_5_current_grind_profit_rate = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
    if rebuy_sub_grind_count > 0:
      rebuy_current_open_rate = rebuy_total_cost / rebuy_total_amount
      rebuy_current_grind_stake = rebuy_total_amount * exit_rate * (1 - trade_fee_close)
      rebuy_current_grind_stake_profit = rebuy_current_grind_stake - rebuy_total_cost
    if buyback_1_sub_grind_count > 0:
      buyback_1_current_open_rate = buyback_1_total_cost / buyback_1_total_amount
      buyback_1_current_grind_stake = buyback_1_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_1_current_grind_stake_profit = buyback_1_current_grind_stake - buyback_1_total_cost

    if grind_1_is_exit_found:
      grind_1_exit_distance_ratio = (exit_rate - grind_1_exit_order.safe_price) / grind_1_exit_order.safe_price
    if grind_2_is_exit_found:
      grind_2_exit_distance_ratio = (exit_rate - grind_2_exit_order.safe_price) / grind_2_exit_order.safe_price
    if grind_3_is_exit_found:
      grind_3_exit_distance_ratio = (exit_rate - grind_3_exit_order.safe_price) / grind_3_exit_order.safe_price
    if grind_4_is_exit_found:
      grind_4_exit_distance_ratio = (exit_rate - grind_4_exit_order.safe_price) / grind_4_exit_order.safe_price
    if grind_5_is_exit_found:
      grind_5_exit_distance_ratio = (exit_rate - grind_5_exit_order.safe_price) / grind_5_exit_order.safe_price
    if buyback_1_is_exit_found:
      buyback_1_exit_distance_ratio = (exit_rate - buyback_1_exit_order.safe_price) / buyback_1_exit_order.safe_price
    elif is_derisk_4_found:
      buyback_1_exit_distance_ratio = (exit_rate - derisk_4_order.safe_price) / derisk_4_order.safe_price
    if rebuy_is_exit_found:
      rebuy_exit_distance_ratio = (exit_rate - rebuy_exit_order.safe_price) / rebuy_exit_order.safe_price

    # all buybacks & grinds
    current_open_grind_stake_profit = (
      grind_1_current_grind_profit_stake
      + grind_2_current_grind_profit_stake
      + grind_3_current_grind_profit_stake
      + grind_4_current_grind_profit_stake
      + grind_5_current_grind_profit_stake
      + buyback_1_current_grind_stake_profit
      + rebuy_current_grind_stake_profit
    )
    num_open_grinds_and_buybacks = (
      grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
      + buyback_1_sub_grind_count
      + rebuy_sub_grind_count
    )

    # not reached the max allowed stake for all grinds
    is_not_trade_max_stake_v3 = current_stake_amount < (slice_amount * self.system_v3_max_stake)
    is_not_trade_max_stake_v3_1 = current_stake_amount < (slice_amount * self.system_v3_1_max_stake)

    # grind_1_cluster_max_profit_stake = trade.get_custom_data(key="grind_1_cluster_max_profit_stake") or 0.0
    # grind_1_cluster_max_profit_rate = trade.get_custom_data(key="grind_1_cluster_max_profit_rate") or 0.0
    # if grind_1_current_grind_profit_stake > grind_1_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_1_cluster_max_profit_stake", value=grind_1_current_grind_profit_stake)
    # if grind_1_current_grind_profit_rate > grind_1_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_1_cluster_max_profit_rate", value=grind_1_current_grind_profit_rate)

    # grind_2_cluster_max_profit_stake = trade.get_custom_data(key="grind_2_cluster_max_profit_stake") or 0.0
    # grind_2_cluster_max_profit_rate = trade.get_custom_data(key="grind_2_cluster_max_profit_rate") or 0.0
    # if grind_2_current_grind_profit_stake > grind_2_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_2_cluster_max_profit_stake", value=grind_2_current_grind_profit_stake)
    # if grind_2_current_grind_profit_rate > grind_2_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_2_cluster_max_profit_rate", value=grind_2_current_grind_profit_rate)

    # grind_3_cluster_max_profit_stake = trade.get_custom_data(key="grind_3_cluster_max_profit_stake") or 0.0
    # grind_3_cluster_max_profit_rate = trade.get_custom_data(key="grind_3_cluster_max_profit_rate") or 0.0
    # if grind_3_current_grind_profit_stake > grind_3_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_3_cluster_max_profit_stake", value=grind_3_current_grind_profit_stake)
    # if grind_3_current_grind_profit_rate > grind_3_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_3_cluster_max_profit_rate", value=grind_3_current_grind_profit_rate)

    # grind_4_cluster_max_profit_stake = trade.get_custom_data(key="grind_4_cluster_max_profit_stake") or 0.0
    # grind_4_cluster_max_profit_rate = trade.get_custom_data(key="grind_4_cluster_max_profit_rate") or 0.0
    # if grind_4_current_grind_profit_stake > grind_4_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_4_cluster_max_profit_stake", value=grind_4_current_grind_profit_stake)
    # if grind_4_current_grind_profit_rate > grind_4_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_4_cluster_max_profit_rate", value=grind_4_current_grind_profit_rate)

    # grind_5_cluster_max_profit_stake = trade.get_custom_data(key="grind_5_cluster_max_profit_stake") or 0.0
    # grind_5_cluster_max_profit_rate = trade.get_custom_data(key="grind_5_cluster_max_profit_rate") or 0.0
    # if grind_5_current_grind_profit_stake > grind_5_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_5_cluster_max_profit_stake", value=grind_5_current_grind_profit_stake)
    # if grind_5_current_grind_profit_rate > grind_5_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_5_cluster_max_profit_rate", value=grind_5_current_grind_profit_rate)

    is_long_extra_checks_entry = (
      grind_entry_retry_time > filled_entries[-1].order_filled_utc
      # and ((current_time - timedelta(hours=6) > filled_orders[-1].order_filled_utc) or (slice_profit < -0.02))
      and (
        (current_time - timedelta(hours=6) > filled_orders[-1].order_filled_utc)
        or (slice_profit < -0.06)
        or (is_derisk_3)
      )
      # and (
      #   (current_stake_amount < (filled_entries[0].cost * 0.50))
      #   or (current_time - timedelta(hours=6) > filled_orders[-1].order_filled_utc)
      #   or (slice_profit < -0.06)
      # )
    )
    # is_long_extra_checks_entry = True
    stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
    send_notifications = not is_backtest
    # =========================================================================
    # DE-RISK CONFIGURATION
    # =========================================================================

    if is_system_v3:
      derisk_1_enable = self.system_v3_derisk_level_1_enable
      derisk_2_enable = self.system_v3_derisk_level_2_enable
      derisk_3_enable = self.system_v3_derisk_level_3_enable
      derisk_4_enable = False
      if is_futures_mode:
        derisk_1_threshold = self.system_v3_derisk_level_1_futures[1]
        derisk_1_stake = self.system_v3_derisk_level_1_stake_futures
        derisk_2_threshold = self.system_v3_derisk_level_2_futures[1]
        derisk_2_stake = self.system_v3_derisk_level_2_stake_futures
        derisk_3_threshold = self.system_v3_derisk_level_3_futures[1]
        derisk_3_stake = self.system_v3_derisk_level_3_stake_futures
      else:
        derisk_1_threshold = self.system_v3_derisk_level_1_spot[1]
        derisk_1_stake = self.system_v3_derisk_level_1_stake_spot
        derisk_2_threshold = self.system_v3_derisk_level_2_spot[1]
        derisk_2_stake = self.system_v3_derisk_level_2_stake_spot
        derisk_3_threshold = self.system_v3_derisk_level_3_spot[1]
        derisk_3_stake = self.system_v3_derisk_level_3_stake_spot
    elif is_system_v3_1:
      derisk_1_enable = False
      derisk_2_enable = False
      derisk_3_enable = False
      derisk_4_enable = False
    elif is_system_v3_2:
      derisk_1_enable = self.system_v3_2_derisk_level_1_enable
      derisk_2_enable = self.system_v3_2_derisk_level_2_enable
      derisk_3_enable = self.system_v3_2_derisk_level_3_enable
      derisk_4_enable = self.system_v3_2_derisk_level_4_enable
      if is_futures_mode:
        derisk_1_threshold = self.system_v3_2_derisk_level_1_futures[1]
        derisk_1_stake = self.system_v3_2_derisk_level_1_stake_futures
        derisk_2_threshold = self.system_v3_2_derisk_level_2_futures[1]
        derisk_2_stake = self.system_v3_2_derisk_level_2_stake_futures
        derisk_3_threshold = self.system_v3_2_derisk_level_3_futures[1]
        derisk_3_stake = self.system_v3_2_derisk_level_3_stake_futures
        derisk_4_threshold = self.system_v3_2_derisk_level_4_futures[1]
        derisk_4_stake = self.system_v3_2_derisk_level_4_stake_futures
      else:
        derisk_1_threshold = self.system_v3_2_derisk_level_1_spot[1]
        derisk_1_stake = self.system_v3_2_derisk_level_1_stake_spot
        derisk_2_threshold = self.system_v3_2_derisk_level_2_spot[1]
        derisk_2_stake = self.system_v3_2_derisk_level_2_stake_spot
        derisk_3_threshold = self.system_v3_2_derisk_level_3_spot[1]
        derisk_3_stake = self.system_v3_2_derisk_level_3_stake_spot
        derisk_4_threshold = self.system_v3_2_derisk_level_4_spot[1]
        derisk_4_stake = self.system_v3_2_derisk_level_4_stake_spot
    derisk_enable = self.derisk_enable
    # ---------------------------------------------------------------------
    # De-risk level 1
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_1_enable
      and not (is_derisk_1_found)
      and not is_rebuy_mode
      and profit_stake < slice_amount * derisk_1_threshold / trade_leverage
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_1_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 1 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_1"
    # ---------------------------------------------------------------------
    # De-risk level 2
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_2_enable
      and not is_derisk_2_found
      and not is_rebuy_mode
      and profit_stake < slice_amount * derisk_2_threshold / trade_leverage
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_2_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 2 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_2"
    # ---------------------------------------------------------------------
    # De-risk level 3
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_3_enable
      and not is_derisk_3_found
      and not is_rebuy_mode
      and profit_stake < slice_amount * derisk_3_threshold / trade_leverage
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_3_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 3",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_3"
    # ---------------------------------------------------------------------
    # De-risk level 4
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_4_enable
      and not is_derisk_4_found
      and not is_rebuy_mode
      and profit_stake < (slice_amount * derisk_4_threshold / trade_leverage)
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_4_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 4",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 4 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_4"

    # =========================================================================
    # GRINDING CONFIGURATION
    # =========================================================================
    system_v3_grind_1_enable = self.system_v3_grind_1_enable
    system_v3_grind_1_use_derisk = self.system_v3_grind_1_use_derisk
    system_v3_grind_2_enable = self.system_v3_grind_2_enable
    system_v3_grind_2_use_derisk = self.system_v3_grind_2_use_derisk
    system_v3_grind_3_enable = self.system_v3_grind_3_enable
    system_v3_grind_3_use_derisk = self.system_v3_grind_3_use_derisk
    system_v3_grind_4_enable = self.system_v3_grind_4_enable
    system_v3_grind_4_use_derisk = self.system_v3_grind_4_use_derisk
    system_v3_grind_5_enable = self.system_v3_grind_5_enable
    system_v3_grind_5_use_derisk = self.system_v3_grind_5_use_derisk
    long_grind_exit_v3 = self.long_grind_exit_v3
    long_grind_entry_v3 = self.long_grind_entry_v3
    is_long_grind_entry = (
      long_grind_entry_v3(
        last_candle,
        previous_candle,
        num_open_grinds_and_buybacks,
        slice_profit,
        slice_profit_entry,
        slice_profit_exit,
        True,
      )
      if is_long_extra_checks_entry
      else False
    )
    # Grinding 1

    if (
      (system_v3_grind_1_enable)
      # and is_derisk_1_found
      and is_long_extra_checks_entry
      and (grind_1_sub_grind_count < grind_1_max_sub_grinds)
      and (grind_1_sub_grind_count == 0 or (grind_1_distance_ratio < grind_1_sub_thresholds[grind_1_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and is_long_grind_entry
    ):
      buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="grind_1_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Grinding entry (grind_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_1_sub_grind_count > 0 and (
      grind_1_current_grind_profit_rate >= (grind_1_profit_threshold + fee_open_rate + fee_close_rate)
    ):
      ft_exit_amount, tag = long_grind_exit_v3(
        last_rsi_3,
        last_rsi_14,
        last_willr_14,
        last_stochrsi_k,
        last_close,
        last_bbu_20,
        last_rsi_3_1h,
        last_rsi_3_4h,
        last_roc_9_1d,
        last_btc_rsi_14_4h,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_1_exit",
        "grind_1_exit",
        # grind_1_cluster_max_profit_stake,
        # grind_1_cluster_max_profit_rate,
        grind_1_current_grind_profit_stake,
        grind_1_current_grind_profit_rate,
        grind_1_total_amount,
        grind_1_profit_threshold,
        grind_1_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      system_v3_grind_1_use_derisk
      and (grind_1_sub_grind_count > 0)
      and (((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < grind_1_derisk_grinds)
    ):
      # if (
      #   system_v3_grind_1_use_derisk
      #   and (grind_1_sub_grind_count > 0)
      #   and (grind_1_current_grind_profit_stake < (slice_amount * grind_1_derisk_grinds))
      #   and (grind_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_exit_found
            else profit_ratio
          )
        if send_notifications:
          send_msg(
            notification_msg(
              "grinding-derisk",
              tag="grind_1_derisk",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_1_current_grind_profit_stake,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
        log.info(
          f"Grinding de-risk (grind_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_1_derisk"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 2

    if (
      (system_v3_grind_2_enable)
      # and is_derisk_1_found
      and is_long_extra_checks_entry
      and (grind_2_sub_grind_count < grind_2_max_sub_grinds)
      and (grind_2_sub_grind_count == 0 or (grind_2_distance_ratio < grind_2_sub_thresholds[grind_2_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and is_long_grind_entry
    ):
      buy_amount = slice_amount * grind_2_stakes[grind_2_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="grind_2_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Grinding entry (grind_2_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_2_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_2_sub_grind_count > 0 and (
      grind_2_current_grind_profit_rate >= (grind_2_profit_threshold + fee_open_rate + fee_close_rate)
    ):
      ft_exit_amount, tag = long_grind_exit_v3(
        last_rsi_3,
        last_rsi_14,
        last_willr_14,
        last_stochrsi_k,
        last_close,
        last_bbu_20,
        last_rsi_3_1h,
        last_rsi_3_4h,
        last_roc_9_1d,
        last_btc_rsi_14_4h,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_2_exit",
        "grind_2_exit",
        # grind_2_cluster_max_profit_stake,
        # grind_2_cluster_max_profit_rate,
        grind_2_current_grind_profit_stake,
        grind_2_current_grind_profit_rate,
        grind_2_total_amount,
        grind_2_profit_threshold,
        grind_2_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      system_v3_grind_2_use_derisk
      and (grind_2_sub_grind_count > 0)
      and (((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < grind_2_derisk_grinds)
    ):
      # if (
      #   system_v3_grind_2_use_derisk
      #   and (grind_2_sub_grind_count > 0)
      #   and (grind_2_current_grind_profit_stake < (slice_amount * grind_2_derisk_grinds))
      #   and (grind_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_exit_found
            else profit_ratio
          )
        if send_notifications:
          send_msg(
            notification_msg(
              "grinding-derisk",
              tag="grind_2_derisk",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_2_current_grind_profit_stake,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
        log.info(
          f"Grinding de-risk (grind_2_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_total_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_2_derisk"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 3

    if (
      (system_v3_grind_3_enable)
      # and is_derisk_1_found
      and is_long_extra_checks_entry
      and (grind_3_sub_grind_count < grind_3_max_sub_grinds)
      and (grind_3_sub_grind_count == 0 or (grind_3_distance_ratio < grind_3_sub_thresholds[grind_3_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and is_long_grind_entry
    ):
      buy_amount = slice_amount * grind_3_stakes[grind_3_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="grind_3_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Grinding entry (grind_3_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_3_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_3_sub_grind_count > 0 and (
      grind_3_current_grind_profit_rate >= (grind_3_profit_threshold + fee_open_rate + fee_close_rate)
    ):
      ft_exit_amount, tag = long_grind_exit_v3(
        last_rsi_3,
        last_rsi_14,
        last_willr_14,
        last_stochrsi_k,
        last_close,
        last_bbu_20,
        last_rsi_3_1h,
        last_rsi_3_4h,
        last_roc_9_1d,
        last_btc_rsi_14_4h,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_3_exit",
        "grind_3_exit",
        # grind_3_cluster_max_profit_stake,
        # grind_3_cluster_max_profit_rate,
        grind_3_current_grind_profit_stake,
        grind_3_current_grind_profit_rate,
        grind_3_total_amount,
        grind_3_profit_threshold,
        grind_3_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      system_v3_grind_3_use_derisk
      and (grind_3_sub_grind_count > 0)
      and (((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < grind_3_derisk_grinds)
    ):
      # if (
      #   system_v3_grind_3_use_derisk
      #   and (grind_3_sub_grind_count > 0)
      #   and (grind_3_current_grind_profit_stake < (slice_amount * grind_3_derisk_grinds))
      #   and (grind_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_exit_found
            else profit_ratio
          )
        if send_notifications:
          send_msg(
            notification_msg(
              "grinding-derisk",
              tag="grind_3_derisk",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_3_current_grind_profit_stake,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
        log.info(
          f"Grinding de-risk (grind_3_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_3_total_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_3_derisk"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 4

    if (
      (system_v3_grind_4_enable)
      # and is_derisk_1_found
      # and is_long_grind_entry
      and is_long_extra_checks_entry
      and (grind_4_sub_grind_count < grind_4_max_sub_grinds)
      and (grind_4_sub_grind_count == 0 or (grind_4_distance_ratio < grind_4_sub_thresholds[grind_4_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and (
        is_long_grind_entry
        or (
          (slice_profit_entry < -0.06)
          and (last_rsi_3 > 5.0)
          and (last_rsi_3_15m > 10.0)
          and (last_rsi_14 < 35.0)
          and (last_close < (last_ema_20 * 0.985))
        )
        or (
          (slice_profit_entry < -0.06)
          and (num_open_grinds_and_buybacks == 0)
          and (last_rsi_14 < 30.0)
          and (last_close < (last_ema_20 * 0.980))
        )
      )
    ):
      buy_amount = slice_amount * grind_4_stakes[grind_4_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="grind_4_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Grinding entry (grind_4_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_4_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_4_sub_grind_count > 0 and (
      grind_4_current_grind_profit_rate >= (grind_4_profit_threshold + fee_open_rate + fee_close_rate)
    ):
      ft_exit_amount, tag = long_grind_exit_v3(
        last_rsi_3,
        last_rsi_14,
        last_willr_14,
        last_stochrsi_k,
        last_close,
        last_bbu_20,
        last_rsi_3_1h,
        last_rsi_3_4h,
        last_roc_9_1d,
        last_btc_rsi_14_4h,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_4_exit",
        "grind_4_exit",
        # grind_4_cluster_max_profit_stake,
        # grind_4_cluster_max_profit_rate,
        grind_4_current_grind_profit_stake,
        grind_4_current_grind_profit_rate,
        grind_4_total_amount,
        grind_4_profit_threshold,
        grind_4_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      system_v3_grind_4_use_derisk
      and (grind_4_sub_grind_count > 0)
      and (((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < grind_4_derisk_grinds)
    ):
      # if (
      #   system_v3_grind_4_use_derisk
      #   and (grind_4_sub_grind_count > 0)
      #   and (grind_4_current_grind_profit_stake < (slice_amount * grind_4_derisk_grinds))
      #   and (grind_4_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_exit_found
            else profit_ratio
          )
        if send_notifications:
          send_msg(
            notification_msg(
              "grinding-derisk",
              tag="grind_4_derisk",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_4_current_grind_profit_stake,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
        log.info(
          f"Grinding de-risk (grind_4_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_4_total_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_4_derisk"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 5
    trade_liquidation_price = trade.liquidation_price
    if (
      (system_v3_grind_5_enable)
      # and is_derisk_1_found
      # and is_long_grind_entry
      and is_long_extra_checks_entry
      and (grind_5_sub_grind_count < grind_5_max_sub_grinds)
      and (grind_5_sub_grind_count == 0 or (grind_5_distance_ratio < grind_5_sub_thresholds[grind_5_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and (
        is_long_grind_entry
        or (
          (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
          and (slice_profit_entry < -0.06)
          and (last_rsi_3 > 10.0)
          and (last_rsi_3_15m > 20.0)
          and (last_aroonu_14 < 50.0)
        )
        or (
          (is_futures_mode)
          and (slice_profit_entry < -0.15)
          and (trade_liquidation_price is not None)
          and (
            (trade_is_short and current_rate > trade_liquidation_price * 0.80)
            or (not trade_is_short and current_rate < trade_liquidation_price * 1.20)
          )
        )
      )
    ):
      buy_amount = slice_amount * grind_5_stakes[grind_5_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="grind_5_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Grinding entry (grind_5_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_5_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_5_sub_grind_count > 0 and (
      grind_5_current_grind_profit_rate >= (grind_5_profit_threshold + fee_open_rate + fee_close_rate)
    ):
      ft_exit_amount, tag = long_grind_exit_v3(
        last_rsi_3,
        last_rsi_14,
        last_willr_14,
        last_stochrsi_k,
        last_close,
        last_bbu_20,
        last_rsi_3_1h,
        last_rsi_3_4h,
        last_roc_9_1d,
        last_btc_rsi_14_4h,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_5_exit",
        "grind_5_exit",
        # grind_5_cluster_max_profit_stake,
        # grind_5_cluster_max_profit_rate,
        grind_5_current_grind_profit_stake,
        grind_5_current_grind_profit_rate,
        grind_5_total_amount,
        grind_5_profit_threshold,
        grind_5_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      system_v3_grind_5_use_derisk
      and (grind_5_sub_grind_count > 0)
      and (((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < grind_5_derisk_grinds)
    ):
      # if (
      #   system_v3_grind_5_use_derisk
      #   and (grind_5_sub_grind_count > 0)
      #   and (grind_5_current_grind_profit_stake < (slice_amount * grind_5_derisk_grinds))
      #   and (grind_5_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_exit_found
            else profit_ratio
          )
        if send_notifications:
          send_msg(
            notification_msg(
              "grinding-derisk",
              tag="grind_5_derisk",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_5_current_grind_profit_stake,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
        log.info(
          f"Grinding de-risk (grind_5_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_5_total_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_5_derisk"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # =========================================================================
    # BUYBACK CONFIGURATION
    # =========================================================================
    system_v3_buyback_1_enable = self.system_v3_buyback_1_enable
    system_v3_buyback_1_use_derisk = self.system_v3_buyback_1_use_derisk
    if is_futures_mode:
      buyback_1_threshold = self.system_v3_buyback_1_distance_ratio_negative_futures
      buyback_1_distance = self.system_v3_buyback_1_distance_ratio_positive_futures
      buyback_1_stake = self.system_v3_buyback_1_stake_futures
      buyback_1_derisk = self.system_v3_buyback_1_derisk_futures
    else:
      buyback_1_threshold = self.system_v3_buyback_1_distance_ratio_negative_spot
      buyback_1_distance = self.system_v3_buyback_1_distance_ratio_positive_spot
      buyback_1_stake = self.system_v3_buyback_1_stake_spot
      buyback_1_derisk = self.system_v3_buyback_1_derisk_spot
    is_long_buyback_entry = (
      self.long_buyback_entry_v3(last_candle, previous_candle, slice_profit, True)
      if (self.system_v3_buyback_1_enable and is_system_v3_2 and is_derisk_4_found)
      else False
    )

    # Buyback 1
    if (
      system_v3_buyback_1_enable
      and is_system_v3_2
      and is_derisk_4_found
      # and is_long_extra_checks_entry
      and (buyback_1_current_open_rate == 0)
      and (buyback_1_exit_distance_ratio < buyback_1_threshold or buyback_1_exit_distance_ratio > buyback_1_distance)
      and is_not_trade_max_stake_v3
      and is_long_buyback_entry
    ):
      buy_amount = slice_amount * buyback_1_stake / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "buyback-entry",
            tag="buyback_1_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Buyback entry (buyback_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    # if buyback_1_sub_grind_count > 0:
    #   grind_profit = (exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate
    #   if (
    #     grind_profit
    #     > (
    #       (
    #         self.system_v3_buyback_1_profit_threshold_futures
    #         if self.is_futures_mode
    #         else self.system_v3_buyback_1_profit_threshold_spot
    #       )
    #       + fee_open_rate
    #       + fee_close_rate
    #     )
    #   ) and self.long_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
    #     sell_amount = buyback_1_total_amount * exit_rate / trade.leverage
    #     if ((current_stake_amount / trade.leverage) - sell_amount) < (min_stake * 1.55):
    #       sell_amount = (trade.amount * exit_rate / trade.leverage) - (min_stake * 1.55)
    #     ft_sell_amount = sell_amount * trade.leverage * (trade.stake_amount / trade.amount) / exit_rate
    #     if sell_amount > min_stake and ft_sell_amount > min_stake:
    #       self.dp.send_msg(
    #         self.notification_msg(
    #           "buyback-exit",
    #           tag="buyback_1_exit",
    #           pair=trade.pair,
    #           rate=exit_rate,
    #           stake_amount=sell_amount,
    #           profit_stake=profit_stake,
    #           profit_ratio=profit_ratio,
    #           stake_currency=self.config["stake_currency"],
    #           grind_profit_stake=grind_profit * sell_amount * trade.leverage,
    #           grind_profit_pct=grind_profit,
    #           coin_amount=buyback_1_total_amount,
    #         )
    #       )
    #       log.info(
    #         f"Buyback exit (buyback_1_exit) [{current_time}] [{trade.pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade.leverage} {self.config['stake_currency']})"
    #       )
    #       order_tag = "buyback_1_exit"
    #       for grind_entry_id in buyback_1_buy_orders:
    #         order_tag += " " + str(grind_entry_id)
    #       if has_order_tags:
    #         return -ft_sell_amount, order_tag
    #       else:
    #         return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_1_use_derisk
    #   and (buyback_1_sub_grind_count > 0)
    #   and (
    #     ((exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_1_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_1_derisk_spot
    #     )
    #   )
    #   and (buyback_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      system_v3_buyback_1_use_derisk
      and (buyback_1_sub_grind_count > 0)
      and (buyback_1_current_grind_stake_profit < (slice_amount * buyback_1_derisk))
    ):
      sell_amount = buyback_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate)
            if buyback_1_is_exit_found
            else profit_ratio
          )
        if send_notifications:
          send_msg(
            notification_msg(
              "buyback-derisk",
              tag="buyback_1_derisk",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=buyback_1_current_grind_stake_profit,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_1_total_amount,
            )
          )
        log.info(
          f"Buyback de-risk (buyback_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {buyback_1_total_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({buyback_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "buyback_1_derisk"
        for grind_entry_id in buyback_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Rebuy
    is_long_rebuy_entry = (
      self.long_rebuy_entry_v3(last_candle, previous_candle, slice_profit, True) if is_system_v3_1 else False
    )
    if (
      is_system_v3_1
      and (
        (0 <= rebuy_sub_grind_count < rebuy_max_sub_grinds)
        and (slice_profit_entry < rebuy_sub_thresholds[rebuy_sub_grind_count])
      )
      and is_not_trade_max_stake_v3_1
      and is_long_rebuy_entry
    ):
      buy_amount = slice_amount * rebuy_stakes[rebuy_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      if send_notifications:
        send_msg(
          notification_msg(
            "rebuy",
            tag="rebuy_entry",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
      log.info(
        f"Rebuy (rebuy_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      if has_order_tags:
        return buy_amount, "rebuy_entry"
      else:
        return buy_amount

    return None

  def long_grind_entry_v3(
    self,
    last_candle: Series,
    previous_candle: Series,
    num_open_grinds_and_buybacks: int,
    slice_profit: float,
    slice_profit_entry: float,
    slice_profit_exit: float,
    is_derisk: bool,
  ) -> float:
    if last_candle["protections_long_global"] != True:
      return False
    # g0 — signal entry
    if last_candle["enter_long"] == True:
      self._grind_entry_tag = "g0"
      return True

    last_close = last_candle["close"]
    last_open = last_candle["open"]
    last_close_min_12 = last_candle["close_min_12"]
    last_close_max_48 = last_candle["close_max_48"]
    last_high_max_24_1h = last_candle["high_max_24_1h"]
    last_low_min_12_4h = last_candle["low_min_12_4h"]
    last_low_min_24_4h = last_candle["low_min_24_4h"]
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    last_rsi_20 = last_candle["RSI_20"]
    last_sma_9 = last_candle["SMA_9"]
    last_sma_16 = last_candle["SMA_16"]
    last_sma_21 = last_candle["SMA_21"]
    last_sma_30 = last_candle["SMA_30"]
    last_ema_9 = last_candle["EMA_9"]
    last_ema_12 = last_candle["EMA_12"]
    last_ema_16 = last_candle["EMA_16"]
    last_ema_20 = last_candle["EMA_20"]
    last_ema_26 = last_candle["EMA_26"]
    last_ema_100 = last_candle["EMA_100"]
    last_ema_12_4h = last_candle["EMA_12_4h"]
    last_ema_50_4h = last_candle["EMA_50_4h"]
    last_ema_100_4h = last_candle["EMA_100_4h"]
    last_ema_200_4h = last_candle["EMA_200_4h"]
    last_aroonu_14 = last_candle["AROONU_14"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    last_aroonu_14_1h = last_candle["AROONU_14_1h"]
    last_aroonu_14_4h = last_candle["AROONU_14_4h"]
    last_aroonu_14_1d = last_candle["AROONU_14_1d"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_stochrsi_k_15m = last_candle["STOCHRSIk_14_14_3_3_15m"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_stochrsi_k_1d = last_candle["STOCHRSIk_14_14_3_3_1d"]
    last_willr_14 = last_candle["WILLR_14"]
    last_willr_84_1h = last_candle["WILLR_84_1h"]
    last_bbl_20 = last_candle["BBL_20_2.0"]
    last_bbands_20_1h = last_candle["BBB_20_2.0_1h"]
    last_cmf_20 = last_candle["CMF_20"]
    prev_rsi_20 = previous_candle["RSI_20"]
    prev_sma_9 = previous_candle["SMA_9"]
    prev_sma_21 = previous_candle["SMA_21"]
    prev_ema_12 = previous_candle["EMA_12"]
    prev_ema_26 = previous_candle["EMA_26"]

    # g1 — AROONU dip + EMA_16 drop
    if (
      (last_rsi_3 > 10.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_3_1h > 15.0)
      and (last_rsi_3_4h > 15.0)
      and (last_rsi_14 < 45.0)
      and (last_aroonu_14 < 25.0)
      and (last_aroonu_14_4h < 100.0)
      and (last_roc_9_1h < 20.0)
      and (last_close > (last_close_max_48 * 0.90))
      and (last_close < (last_low_min_24_4h * 1.60))
      and (last_close < (last_ema_16 * 0.975))
      and ((last_rsi_3_1h > 35.0) or (last_aroonu_14_1h < 100.0))
      and ((last_aroonu_14_1h < 100.0) or (last_aroonu_14_1d < 100.0))
      and ((last_aroonu_14_1d < 100.0) or (last_stochrsi_k_1h < 90.0))
    ):
      self._grind_entry_tag = "g1"
      return True
    # g2 — EMA_26 > EMA_12 divergence + BBL
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 15.0)
      and (last_rsi_3_4h > 15.0)
      and (last_rsi_14 < 30.0)
      and (last_stochrsi_k < 30.0)
      and (last_ema_26 > last_ema_12)
      and ((last_ema_26 - last_ema_12) > (last_open * 0.020))
      and ((prev_ema_26 - prev_ema_12) > (last_open / 100.0))
      and (last_close < (last_bbl_20 * 1.010))
    ):
      self._grind_entry_tag = "g2"
      return True
    # g3 — AROONU_15m dip + EMA_12 drop
    if (
      (last_rsi_3 > 10.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 10.0)
      and (last_rsi_3_4h > 15.0)
      and (last_rsi_14 < 35.0)
      and (last_aroonu_14_15m < 25.0)
      and (last_stochrsi_k_15m < 70.0)
      and (last_stochrsi_k_1h < 90.0)
      and (last_roc_9_1h > -15.0)
      and (last_roc_9_4h > -15.0)
      and (last_close > (last_close_max_48 * 0.85))
      and (last_close < (last_ema_12 * 0.980))
      and ((last_rsi_3_1h > 20.0) or (last_rsi_3_1d > 20.0))
      and ((last_rsi_3_1h > 20.0) or (last_stochrsi_k_1d < 70.0))
      and ((last_rsi_3_1h > 25.0) or (last_stochrsi_k_1h < 70.0))
      and ((last_rsi_3_4h > 30.0) or (last_stochrsi_k_4h < 60.0))
    ):
      self._grind_entry_tag = "g3"
      return True
    # g4 — multi-TF RSI + EMA_26 + BBL
    if (
      (last_rsi_3 > 10.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 10.0)
      and (last_rsi_3_4h > 10.0)
      and (last_rsi_3_1d > 10.0)
      and (last_rsi_14 < 35.0)
      and (last_aroonu_14 < 25.0)
      and (last_roc_9_1h > -20.0)
      and (last_roc_9_4h > -20.0)
      # and (last_close > (last_close_max_48 * 0.90))
      and (last_close < (last_ema_26 * 0.970))
      and (last_close < (last_bbl_20 * 0.999))
    ):
      self._grind_entry_tag = "g4"
      return True
    # g5 — deep dip + EMA_9/20
    if (
      (last_rsi_3 > 10.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 15.0)
      and (last_rsi_3_4h > 15.0)
      and (last_rsi_14 < 35.0)
      and (last_aroonu_14 < 30.0)
      and (last_roc_9_4h > -20.0)
      and (last_close > (last_high_max_24_1h * 0.80))
      and (last_close < (last_low_min_12_4h * 1.50))
      and (last_close < (last_ema_9 * 0.975))
      and (last_close < (last_ema_20 * 0.970))
    ):
      self._grind_entry_tag = "g5"
      return True
    # g6 — RSI_20 falling + SMA_16 drop
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3 < 40.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_14 > 35.0)
      and (last_roc_9_1h > -20.0)
      and (last_roc_9_4h > -20.0)
      and (last_aroonu_14 < 25.0)
      and (last_close < (last_low_min_12_4h * 1.60))
      and (last_rsi_20 < prev_rsi_20)
      and (last_close < (last_sma_16 * 0.960))
      and ((last_aroonu_14_1d < 100.0) or (last_roc_9_1d < 50.0))
    ):
      self._grind_entry_tag = "g6"
      return True
    # g7 — WILLR deep + BBB wide
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 20.0)
      and (last_rsi_3_1h > 20.0)
      and (last_rsi_3_4h > 20.0)
      and (last_willr_14 < -50.0)
      and (last_willr_84_1h < -70.0)
      and (last_stochrsi_k < 30.0)
      and (last_stochrsi_k_1h < 90.0)
      and (last_roc_9_1h > -10.0)
      and (last_roc_9_1h < 20.0)
      and (last_roc_9_4h > -10.0)
      and (last_close < (last_low_min_24_4h * 1.50))
      and (last_bbands_20_1h > 12.0)
      and (last_close_max_48 >= (last_close * 1.10))
    ):
      self._grind_entry_tag = "g7"
      return True
    # g8 — EMA_26/12 gap wide + low_min_24_1h
    if (
      (last_rsi_3 < 30.0)
      and (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 10.0)
      and (last_rsi_3_4h > 10.0)
      and (last_roc_9_1h > -10.0)
      and (last_roc_9_4h > -25.0)
      # and (last_close < (last_candle["low_min_24_1h"] * 1.30))
      and (last_ema_26 > last_ema_12)
      and ((last_ema_26 - last_ema_12) > (last_open * 0.030))
      and ((prev_ema_26 - prev_ema_12) > (last_open / 100.0))
    ):
      self._grind_entry_tag = "g8"
      return True
    # g9 — pullback recovery
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_3_1h > 20.0)
      and (last_rsi_3_4h > 20.0)
      and (last_stochrsi_k < 50.0)
      and (last_close < (last_close_max_48 * 0.90))
      and (last_close > (last_close_min_12 * 1.03))
    ):
      self._grind_entry_tag = "g9"
      return True
    # g10 — RSI_14 divergence vs 1h
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 20.0)
      and (last_stochrsi_k < 20.0)
      and (last_rsi_14 < (last_rsi_14_1h - 45.0))
    ):
      self._grind_entry_tag = "g10"
      return True
    # g11 — multi-TF RSI + SMA_30 + BBL
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 10.0)
      and (last_cmf_20 > 0.0)
      and (last_close < (last_sma_30 * 0.965))
      and (last_close < (last_bbl_20 * 1.000))
    ):
      self._grind_entry_tag = "g11"
      return True
    # g12 — EMA_26/12 divergence + close_max_48
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_3_1h > 10.0)
      and (last_stochrsi_k < 30.0)
      and (last_close > (last_close_max_48 * 0.90))
      and (last_close < (last_low_min_12_4h * 1.60))
      and (last_ema_26 > last_ema_12)
      and ((last_ema_26 - last_ema_12) > (last_open * 0.025))
      and ((prev_ema_26 - prev_ema_12) > (last_open / 100.0))
    ):
      self._grind_entry_tag = "g12"
      return True
    # g13 — SMA_9 cross SMA_21 + EMA_100 drop
    if (
      (last_rsi_3 > 5.0)
      and (last_rsi_3_1h > 20.0)
      and (last_rsi_14_1h > 40.0)
      and (last_stochrsi_k_15m < 80.0)
      and (last_roc_9_1h > -15.0)
      and (last_roc_9_4h > -15.0)
      and (prev_sma_9 < prev_sma_21)
      and (last_sma_9 > last_sma_21)
      and (last_close < (last_ema_100 * 0.975))
      and ((last_rsi_3_4h > 30.0) or (last_aroonu_14_4h < 100.0))
      and ((last_rsi_3_4h > 40.0) or (last_roc_9_4h < 30.0))
    ):
      self._grind_entry_tag = "g13"
      return True
    # g14 — SMA_9 cross SMA_21 + 4h uptrend (trend follower)
    if (
      (last_rsi_3 > 5.0)
      and (last_aroonu_14_15m < 50.0)
      and (last_stochrsi_k < 40.0)
      and (last_stochrsi_k_15m < 70.0)
      and (prev_sma_9 < prev_sma_21)
      and (last_sma_9 > last_sma_21)
      and (last_ema_12_4h > last_ema_200_4h)
      and (last_close > (last_close_max_48 * 0.90))
      and ((last_rsi_3_1h > 30.0) or (last_stochrsi_k_1h < 70.0))
      and ((last_rsi_3_1h > 40.0) or (last_aroonu_14_1h < 80.0))
      and ((last_rsi_3_1d > 25.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_stochrsi_k_1h < 80.0) or (last_stochrsi_k_1d < 90.0))
    ):
      self._grind_entry_tag = "g14"
      return True
    # g15 — deep loss recovery (slice_profit < -0.16)
    if (
      (slice_profit < -0.16)
      and (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 10.0)
      and (last_rsi_14 < 40.0)
      and (last_aroonu_14 < 25.0)
      and (last_aroonu_14_15m < 30.0)
      and (last_stochrsi_k < 30.0)
      and (last_stochrsi_k_15m < 30.0)
      and ((last_rsi_3_1h > 30.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_rsi_3_4h > 30.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1d > 30.0) or (last_stochrsi_k_1d < 80.0))
    ):
      self._grind_entry_tag = "g15"
      return True
    # g16 — EMA_12 drop + BBL
    if (
      (last_rsi_3 > 8.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_3_1h > 15.0)
      and (last_rsi_3_4h > 15.0)
      and (last_rsi_14 < 35.0)
      and (last_close < (last_ema_12 * 0.965))
      and (last_close < (last_bbl_20 * 0.999))
    ):
      self._grind_entry_tag = "g16"
      return True
    # g17 — StochRSI + EMA_20 drop
    if (
      (last_rsi_3 > 15.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_3_1h > 15.0)
      and (last_rsi_3_4h > 15.0)
      and (last_rsi_14 < 30.0)
      and (last_stochrsi_k < 30.0)
      and (last_close < (last_ema_20 * 0.975))
      and ((last_aroonu_14_4h < 100.0) or (last_aroonu_14_1d < 100.0))
    ):
      self._grind_entry_tag = "g17"
      return True
    # g18 — moderate loss recovery (slice_profit < -0.10)
    if (
      (slice_profit < -0.10)
      and (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_3_1h > 20.0)
      and (last_rsi_3_4h > 20.0)
      and (last_rsi_14 < 40.0)
      and (last_close < (last_ema_26 * 0.970))
      and (last_close < (last_bbl_20 * 0.999))
    ):
      self._grind_entry_tag = "g18"
      return True
    # g19 — EMA_26/12 wide gap (slice_profit < -0.06)
    if (
      (slice_profit < -0.06)
      and (last_rsi_3 < 30.0)
      and (last_rsi_3 > 5.0)
      and (last_rsi_3_15m > 10.0)
      and (last_ema_26 > last_ema_12)
      and ((last_ema_26 - last_ema_12) > (last_open * 0.035))
      and ((prev_ema_26 - prev_ema_12) > (last_open / 100.0))
    ):
      self._grind_entry_tag = "g19"
      return True
    # AROONU 4h uptrend pullback recovery
    if (
      (last_rsi_3 > 10.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_3_1h > 20.0)
      and (last_rsi_14 < 42.0)
      and (last_rsi_14_4h > 50.0)
      and (last_aroonu_14 < 30.0)
      and (last_aroonu_14_4h > 50.0)
      and (last_roc_9_1d > -15.0)
      and (last_ema_50_4h > last_ema_100_4h)
      and (last_close < (last_close_max_48 * 0.95))
      and ((last_rsi_3_15m > 20.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1h > 30.0) or (last_roc_9_4h < 30.0) or (last_roc_9_1d < 30.0))
      and ((last_rsi_3_1h > 50.0) or (last_roc_9_1d < 60.0))
      and ((last_rsi_3_4h > 40.0) or (last_aroonu_14_4h < 90.0))
      and ((last_rsi_3_4h > 45.0) or (last_aroonu_14_4h < 100.0))
      and ((last_rsi_3_4h > 60.0) or (last_roc_9_4h < 40.0))
      and ((last_aroonu_14_4h < 100.0) or (last_stochrsi_k_1d < 80.0))
      and ((last_aroonu_14_4h < 100.0) or (last_aroonu_14_1d < 100.0))
      and ((last_stochrsi_k_4h < 90.0) or (last_roc_9_4h < 30.0))
    ):
      self._grind_entry_tag = "g20"
      return True
    if (
      (slice_profit_entry < -0.02)
      and (last_rsi_3 > 10.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_14 < 35.0)
      and (last_aroonu_14_15m < 50.0)
      and (last_close < (last_ema_20 * 0.955))
    ):
      self._grind_entry_tag = "g21"
      return True
    # g22 — early recovery rebuild: reclaiming off the low BEFORE the 4h trend confirms (g14 needs
    #        EMA_12_4h > EMA_200_4h and fires too late for a deep-derisk bounce). Anti-fake-rise gating via
    #        multi-TF RSI recovery + reclaim off the 4h low + not-extended. NOTE: slice_profit_entry gate
    #        removed — it self-defeats in recovery (last grind buy is in profit); underwater-scope TBD.
    if (
      (last_rsi_3 > 30.0)
      and (last_rsi_3_15m > 30.0)
      and (last_rsi_14 > 45.0)
      and (last_rsi_14_1h > 45.0)
      and (last_roc_9_1h > 0.0)
      and (last_roc_9_4h > -10.0)
      # anti-parabolic: even at a formed bottom, a parabolic 4h overshoot reverses (dead-cat).
      # cross-coin (SFP/CELR/DYDX/APE): cuts 17 severe at ~1% good cost within recovery-starts.
      and (last_roc_9_4h < 25.0)
      # recovery-started gate: only rebuild once the 4h bottom is IN (not still making new lows).
      # g22's job is the recovery rebuild — NOT entering mid-dump (that's g1..g21). AROOND high =
      # a fresh 4h low was just made = still dumping; require it low = bottom formed = recovery start.
      and (last_aroonu_14_4h < 50.0)
      # aggressive risk-free: g22 fires ONLY deep below the 4h 200-EMA (fresh recovery zone). The
      # near/above-EMA overextended-bounce zone is where dead-cats live AND where g22's late-recovery
      # adds sit — we sacrifice those wins on purpose, because g23 (extended-continuation, ~0.2% severe)
      # backstops the real recoveries above. So g22 stays clean, g23 captures the continuation.
      and (last_close < last_ema_200_4h)
      and (last_close > (last_low_min_12_4h * 1.10))
      and (last_close > (last_ema_20 * 0.97))
      and (last_close < (last_ema_20 * 1.02))
      and ((last_rsi_3_1h > 30.0) or (last_stochrsi_k_1d < 80.0))
      and ((last_rsi_3_1h > 35.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_4h > 50.0) or (last_aroonu_14_1h < 100.0))
      and ((last_rsi_3_1d > 10.0) or (last_aroonu_14_1d < 70.0))
      and ((last_rsi_3_1d > 10.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1d > 15.0) or (last_aroonu_14_1h < 70.0))
      and ((last_rsi_3_1d > 40.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_rsi_3_1d > 40.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1d > 45.0) or (last_aroonu_14_1h < 100.0))
      and ((last_rsi_3_1d > 45.0) or (last_aroonu_14_4h < 100.0))
      and ((last_rsi_3_1d > 45.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_rsi_3_1d > 45.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1d > 50.0) or (last_aroonu_14_15m < 100.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1d > 65.0) or (last_aroonu_14_1h < 70.0) or (last_aroonu_14_1d < 90.0))
      and ((last_aroonu_14_15m < 70.0) or (last_aroonu_14_1h < 100.0))
      and ((last_aroonu_14_15m < 80.0) or (last_stochrsi_k_15m < 80.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1h < 80.0) or (last_stochrsi_k_1h < 80.0) or (last_stochrsi_k_1d < 90.0))
      and ((last_aroonu_14_1h < 100.0) or (last_stochrsi_k_1d < 80.0))
      and ((last_stochrsi_k_1h < 50.0) or (last_roc_9_1d > -40.0))
      and ((last_roc_9_1d > -20.0) or (last_aroonu_14_4h < 100.0))
      and ((last_roc_9_1d > -20.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_roc_9_1d > -30.0) or (last_stochrsi_k_1h < 90.0))
    ):
      self._grind_entry_tag = "g22"
      return True
    # g23 — pump-continuation scalp: extended zone ABOVE g22's EMA_20*1.02 cap. Only rides a CONFIRMED
    # continuation (price already advancing past the reclaim), so dead-cats (which roll over before
    # reaching the extended zone) are structurally avoided. Complements g22: g22 = early recovery-start
    # (ambiguous zone, dead-cat risk trimmed by P1), g23 = confirmed continuation (clean, ~0.2% severe).
    if (
      (last_rsi_3 > 30.0)
      and (last_rsi_3_15m > 30.0)
      and (last_rsi_14 > 50.0)
      and (last_rsi_14_1h > 50.0)
      and (last_roc_9_1h > 0.0)
      and (last_roc_9_4h > 0.0)
      # anti-parabolic blow-off + anti-exhaustion top
      and (last_roc_9_4h < 25.0)
      and ((last_stochrsi_k < 97.0) or (last_rsi_14 < 80.0))
      and (last_close > (last_low_min_12_4h * 1.10))
      # extended zone: above g22's 1.02*EMA cap = continuation confirmed, not a reclaim
      and (last_close >= (last_ema_20 * 1.02))
      and (last_close < (last_ema_20 * 1.12))
      and ((last_rsi_3_1h > 45.0) or (last_aroonu_14_4h < 80.0))
      and ((last_rsi_3_1h > 65.0) or (last_aroonu_14_15m < 60.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 65.0) or (last_stochrsi_k_15m < 60.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_4h > 40.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_rsi_3_4h > 50.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_1d > 15.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_rsi_3_1d > 30.0) or (last_aroonu_14_1h < 100.0))
      and ((last_rsi_3_1d > 30.0) or (last_aroonu_14_4h < 100.0))
      and ((last_rsi_3_1d > 50.0) or (last_stochrsi_k_1h < 80.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1d > 55.0) or (last_aroonu_14_15m < 100.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_aroonu_14_15m < 80.0) or (last_aroonu_14_1h < 100.0) or (last_roc_9_1d < 10.0))
      and ((last_aroonu_14_15m < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_1h < 100.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_4h < 100.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_1d < 90.0) or (last_roc_9_1d < 20.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_1d < 100.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_15m < 90.0) or (last_stochrsi_k_1d < 70.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_aroonu_14_1h < 80.0) or (last_aroonu_14_4h < 100.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_aroonu_14_1h < 100.0) or (last_aroonu_14_4h < 100.0))
      and ((last_aroonu_14_4h < 70.0) or (last_aroonu_14_1d < 100.0) or (last_roc_9_4h < 10.0))
      and ((last_aroonu_14_4h < 70.0) or (last_roc_9_1d < 50.0))
      and ((last_aroonu_14_4h < 100.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_aroonu_14_4h < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1d < 100.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_stochrsi_k_15m < 80.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_stochrsi_k_15m < 90.0) or (last_aroonu_14_1h < 100.0))
      and ((last_stochrsi_k_15m < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_stochrsi_k_1h < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_stochrsi_k_1h < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_stochrsi_k_1h < 90.0) or (last_stochrsi_k_1d < 90.0))
    ):
      self._grind_entry_tag = "g23"
      return True
    # g24 — trend-pullback continuation add: the zone ABOVE the 4h 200-EMA that g22 explicitly sacrifices.
    if (
      # momentum healthy on the pullback: RSI holds up (a real reversal cracks RSI hard)
      (last_rsi_3 > 20.0)
      and (last_rsi_3_15m > 20.0)
      and (last_rsi_14 > 40.0)
      # trend intact + this is a PULLBACK not a reversal: 4h still rising, 1h not in freefall
      and (last_roc_9_1h > -10.0)
      and (last_roc_9_4h > 0.0)
      and (last_roc_9_4h < 25.0)  # anti-parabolic blow-off top
      # bull scope-gate: confirmed 4h uptrend + price above the 200-EMA regime (complements g22's <200EMA)
      and (last_ema_12_4h > last_ema_200_4h)
      and (last_close > last_ema_200_4h)
      # shallow pullback to the short EMA — buy the dip WITHIN the trend, never the top nor a deep dump
      and (last_close < (last_ema_20 * 1.01))
      and (last_close > (last_ema_20 * 0.94))
      and ((last_rsi_3_15m > 40.0) or (last_stochrsi_k_15m < 70.0))
      and ((last_rsi_3_1h > 10.0) or (last_rsi_3_4h > 30.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1h > 15.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_1h > 25.0) or (last_aroonu_14_1h < 70.0))
      and ((last_rsi_3_1h > 25.0) or (last_rsi_3_1d > 45.0) or (last_aroonu_14_1d < 70.0))
      and ((last_rsi_3_1h > 25.0) or (last_aroonu_14_1h < 80.0))
      and ((last_rsi_3_1h > 30.0) or (last_rsi_3_4h > 60.0) or (last_aroonu_14_1d < 70.0))
      and ((last_rsi_3_1h > 30.0) or (last_rsi_3_4h > 60.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1h > 30.0) or (last_stochrsi_k_1d < 80.0) or (last_roc_9_1d < 10.0))
      and ((last_rsi_3_1h > 35.0) or (last_rsi_3_4h > 45.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1h > 35.0) or (last_aroonu_14_1h < 60.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_1h > 35.0) or (last_stochrsi_k_1d < 90.0) or (last_roc_9_1d < 20.0))
      and ((last_rsi_3_1h > 40.0) or (last_rsi_3_4h > 40.0) or (last_aroonu_14_1d < 90.0))
      and ((last_rsi_3_1h > 40.0) or (last_rsi_3_4h > 65.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 40.0) or (last_rsi_3_1d > 60.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_1h > 40.0) or (last_aroonu_14_1h < 100.0))
      and ((last_rsi_3_1h > 40.0) or (last_aroonu_14_4h < 100.0))
      and ((last_rsi_3_1h > 40.0) or (last_aroonu_14_1d < 100.0) or (last_roc_9_1d < 20.0))
      and ((last_rsi_3_1h > 40.0) or (last_stochrsi_k_1d < 80.0) or (last_roc_9_1d < 50.0))
      and ((last_rsi_3_1h > 35.0) or (last_rsi_3_4h > 50.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 40.0) or (last_rsi_3_4h > 55.0) or (last_aroonu_14_4h < 90.0))
      and ((last_rsi_3_1h > 45.0) or (last_aroonu_14_4h < 80.0) or (last_roc_9_1d < 10.0))
      and ((last_rsi_3_1h > 50.0) or (last_aroonu_14_1h < 80.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1h > 50.0) or (last_rsi_3_4h > 55.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1h > 50.0) or (last_aroonu_14_1h < 70.0) or (last_aroonu_14_1d < 70.0))
      and ((last_rsi_3_1h > 50.0) or (last_aroonu_14_4h < 80.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_1h > 50.0) or (last_aroonu_14_4h < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1h > 55.0) or (last_rsi_3_4h > 55.0) or (last_stochrsi_k_15m < 70.0))
      and ((last_rsi_3_1h > 55.0) or (last_aroonu_14_1h < 80.0) or (last_aroonu_14_4h < 80.0))
      and ((last_rsi_3_1h > 55.0) or (last_stochrsi_k_4h < 90.0) or (last_roc_9_1d < 10.0))
      and ((last_rsi_3_1h > 60.0) or (last_aroonu_14_15m < 70.0) or (last_aroonu_14_4h < 80.0))
      and ((last_rsi_3_1h > 60.0) or (last_stochrsi_k_1h < 60.0) or (last_stochrsi_k_1d < 90.0))
      and ((last_rsi_3_1h > 65.0) or (last_aroonu_14_15m < 70.0) or (last_aroonu_14_1h < 100.0))
      and ((last_rsi_3_1h > 65.0) or (last_aroonu_14_1h < 70.0) or (last_aroonu_14_1d < 90.0))
      and ((last_rsi_3_1h > 65.0) or (last_aroonu_14_1h < 100.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_4h > 25.0) or (last_roc_9_1d < 30.0))
      and ((last_rsi_3_4h > 40.0) or (last_rsi_3_1d > 60.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_4h > 40.0) or (last_aroonu_14_15m < 70.0) or (last_aroonu_14_1d < 90.0))
      and ((last_rsi_3_4h > 40.0) or (last_aroonu_14_1d < 90.0) or (last_roc_9_1d < 10.0))
      and ((last_rsi_3_4h > 40.0) or (last_stochrsi_k_15m < 60.0) or (last_aroonu_14_1d < 90.0))
      and ((last_rsi_3_4h > 45.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_4h > 50.0) or (last_aroonu_14_4h < 70.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_4h > 50.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_4h > 55.0) or (last_aroonu_14_15m < 70.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_4h > 60.0) or (last_rsi_3_1d > 65.0) or (last_aroonu_14_15m < 70.0))
      and ((last_rsi_3_4h > 60.0) or (last_aroonu_14_15m < 90.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_rsi_3_4h > 60.0) or (last_aroonu_14_15m < 100.0) or (last_stochrsi_k_15m < 80.0))
      and ((last_rsi_3_4h > 60.0) or (last_stochrsi_k_15m < 70.0) or (last_stochrsi_k_1h < 70.0))
      and ((last_rsi_3_1d > 30.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1d > 35.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_rsi_3_1d > 35.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_rsi_3_1d > 35.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1d > 45.0) or (last_stochrsi_k_1h < 70.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1d > 50.0) or (last_stochrsi_k_15m < 90.0) or (last_roc_9_1d < 10.0))
      and ((last_rsi_3_1d > 60.0) or (last_aroonu_14_1h < 80.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_14_1h < 70.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_15m < 80.0) or (last_aroonu_14_1h < 80.0) or (last_aroonu_14_4h < 80.0))
      and ((last_aroonu_14_15m < 80.0) or (last_stochrsi_k_15m < 70.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_aroonu_14_15m < 80.0) or (last_aroonu_14_1d < 100.0))
      and ((last_aroonu_14_15m < 80.0) or (last_stochrsi_k_15m < 80.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_aroonu_14_15m < 90.0) or (last_aroonu_14_1h < 80.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_aroonu_14_15m < 90.0) or (last_aroonu_14_1h < 100.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_1h < 100.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_4h < 100.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_1d < 80.0) or (last_roc_9_1d < 10.0))
      and ((last_aroonu_14_1h < 70.0) or (last_aroonu_14_4h < 100.0))
      and ((last_aroonu_14_1h < 70.0) or (last_aroonu_14_1d < 90.0) or (last_roc_9_1d < 10.0))
      and ((last_aroonu_14_1h < 80.0) or (last_aroonu_14_4h < 100.0))
      and ((last_aroonu_14_1h < 90.0) or (last_stochrsi_k_1h < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1h < 90.0) or (last_stochrsi_k_1h < 90.0) or (last_roc_9_1d < 10.0))
      and ((last_aroonu_14_1h < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1h < 100.0) or (last_stochrsi_k_1d < 90.0))
      and ((last_aroonu_14_4h < 70.0) or (last_aroonu_14_1d < 100.0) or (last_roc_9_1d < 20.0))
      and ((last_aroonu_14_4h < 90.0) or (last_stochrsi_k_4h < 90.0) or (last_roc_9_1d < 10.0))
      and ((last_aroonu_14_4h < 90.0) or (last_roc_9_1d < 30.0))
      and ((last_aroonu_14_4h < 100.0) or (last_aroonu_14_1d < 100.0))
      and ((last_aroonu_14_4h < 100.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_aroonu_14_4h < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1d < 100.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_aroonu_14_1d < 100.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_aroonu_14_1d < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1d < 100.0) or (last_roc_9_4h < 15.0) or (last_roc_9_1d < 50.0))
      # do not buy an overbought top on the bounce
      and ((last_stochrsi_k < 90.0) or (last_rsi_14 < 70.0))
      and ((last_stochrsi_k_15m < 80.0) or (last_stochrsi_k_1h < 80.0) or (last_roc_9_1d < 10.0))
      and ((last_stochrsi_k_15m < 80.0) or (last_aroonu_14_1d < 100.0))
      and ((last_stochrsi_k_15m < 80.0) or (last_stochrsi_k_1d < 90.0) or (last_roc_9_1d < 20.0))
      and ((last_stochrsi_k_15m < 90.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_stochrsi_k_15m < 90.0) or (last_stochrsi_k_1d < 90.0))
      and ((last_stochrsi_k_1h < 80.0) or (last_stochrsi_k_1d < 90.0))
      and ((last_stochrsi_k_1h < 80.0) or (last_roc_9_1d > -20.0))
      and ((last_stochrsi_k_1h < 90.0) or (last_roc_9_4h < 15.0))
      and ((last_stochrsi_k_4h < 90.0) or (last_roc_9_4h < 15.0))
      and ((last_stochrsi_k_4h < 90.0) or (last_roc_9_1d > -15.0))
      and ((last_stochrsi_k_1d < 90.0) or (last_roc_9_4h < 20.0))
    ):
      self._grind_entry_tag = "g24"
      return True
    if (
      (last_rsi_3 > 15.0)
      and (last_rsi_3_15m > 15.0)
      and (last_rsi_14 > 40.0)
      and (last_rsi_14_1h > 40.0)
      # the coil signature: 1h momentum negative-to-flat under a flat price
      and (last_roc_9_1h > -15.0)
      and (last_roc_9_1h < 2.0)
      and (last_close > (last_ema_20 * 0.98))
      and (last_close < (last_ema_20 * 1.02))
      # squeeze integrity: regime still broken, 4h reclaim HELD, not dripping to new lows
      and (last_close < last_ema_200_4h)
      and (last_close > (last_low_min_12_4h * 1.10))
      and (last_close > (last_close_min_12 * 1.005))
      # general protections first
      and ((last_rsi_3_15m > 20.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1h > 15.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_1h > 20.0) or (last_rsi_3_4h > 20.0) or (last_aroonu_14_1d < 90.0))
      and ((last_rsi_3_1h > 20.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_rsi_3_1h > 30.0) or (last_rsi_3_1d > 30.0) or (last_stochrsi_k_1h < 70.0))
      and ((last_rsi_3_1h > 35.0) or (last_aroonu_14_1h < 70.0))
      and ((last_rsi_3_1h > 35.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_1h > 40.0) or (last_aroonu_14_4h < 80.0))
      and ((last_rsi_3_1h > 45.0) or (last_aroonu_14_1h < 90.0) or (last_stochrsi_k_1h < 70.0))
      and ((last_rsi_3_1h > 40.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 45.0) or (last_aroonu_14_1h < 90.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 45.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_1h > 50.0) or (last_aroonu_14_1h < 70.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_1h > 55.0) or (last_rsi_3_4h > 60.0) or (last_aroonu_14_4h < 60.0))
      and ((last_rsi_3_1h > 50.0) or (last_aroonu_14_4h < 80.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 50.0) or (last_stochrsi_k_1d < 90.0) or (last_roc_9_1d < 30.0))
      and ((last_rsi_3_1h > 55.0) or (last_aroonu_14_4h < 80.0) or (last_aroonu_14_1d < 100.0))
      and ((last_rsi_3_1h > 55.0) or (last_aroonu_14_4h < 90.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_rsi_3_1h > 60.0) or (last_rsi_3_1d > 60.0) or (last_aroonu_14_1h < 80.0))
      and ((last_rsi_3_1h > 60.0) or (last_stochrsi_k_4h < 70.0) or (last_stochrsi_k_1d < 80.0))
      and ((last_rsi_3_1h > 60.0) or (last_stochrsi_k_4h < 80.0) or (last_roc_9_4h < 10.0))
      and ((last_rsi_3_4h > 10.0) or (last_rsi_3_1d > 40.0) or (last_stochrsi_k_15m < 80.0))
      and ((last_rsi_3_4h > 25.0) or (last_stochrsi_k_4h < 50.0) or (last_roc_9_4h < 10.0))
      and ((last_rsi_3_4h > 35.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_4h > 40.0) or (last_rsi_3_1d > 40.0) or (last_aroonu_14_15m < 70.0))
      and ((last_rsi_3_4h > 40.0) or (last_aroonu_14_15m < 100.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_rsi_3_4h > 40.0) or (last_aroonu_14_4h < 70.0))
      and ((last_rsi_3_4h > 50.0) or (last_aroonu_14_15m < 80.0) or (last_aroonu_14_4h < 80.0))
      and ((last_rsi_3_4h > 50.0) or (last_stochrsi_k_15m < 70.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_4h > 55.0) or (last_aroonu_14_1h < 100.0) or (last_aroonu_14_1d < 80.0))
      and ((last_rsi_3_4h > 60.0) or (last_rsi_3_1d > 60.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_rsi_3_4h > 60.0) or (last_aroonu_14_15m < 70.0) or (last_aroonu_14_1h < 70.0))
      and ((last_rsi_3_4h > 60.0) or (last_aroonu_14_1h < 100.0) or (last_stochrsi_k_1d < 80.0))
      and ((last_rsi_3_4h > 60.0) or (last_aroonu_14_4h < 70.0) or (last_roc_9_1d < 20.0))
      and ((last_rsi_3_4h > 65.0) or (last_aroonu_14_1h < 70.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_rsi_3_4h > 65.0) or (last_aroonu_14_4h < 80.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_4h > 65.0) or (last_stochrsi_k_4h < 90.0) or (last_roc_9_4h < 10.0))
      and ((last_rsi_3_1d > 10.0) or (last_stochrsi_k_4h < 70.0))
      and ((last_rsi_3_1d > 20.0) or (last_aroonu_14_1d < 90.0))
      and ((last_rsi_3_1d > 25.0) or (last_stochrsi_k_15m < 70.0))
      and ((last_rsi_3_1d > 25.0) or (last_aroonu_14_1h < 70.0))
      and ((last_rsi_3_1d > 25.0) or (last_stochrsi_k_1h < 90.0))
      and ((last_rsi_3_1d > 30.0) or (last_aroonu_14_15m < 100.0))
      and ((last_rsi_3_1d > 30.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_15m < 70.0) or (last_aroonu_14_1h < 100.0) or (last_stochrsi_k_1d < 80.0))
      and ((last_aroonu_14_15m < 70.0) or (last_aroonu_14_4h < 70.0) or (last_roc_9_4h < 10.0))
      and ((last_aroonu_14_15m < 80.0) or (last_stochrsi_k_15m < 70.0))
      and ((last_aroonu_14_15m < 80.0) or (last_aroonu_14_1h < 100.0))
      and ((last_aroonu_14_15m < 100.0) or (last_aroonu_14_4h < 90.0))
      and ((last_aroonu_14_15m < 100.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_1h < 80.0) or (last_aroonu_14_4h < 100.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_aroonu_14_1h < 80.0) or (last_stochrsi_k_4h < 100.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_aroonu_14_1h < 80.0) or (last_stochrsi_k_4h < 90.0) or (last_roc_9_4h < 10.0))
      and ((last_aroonu_14_1h < 100.0) or (last_aroonu_14_1d < 100.0))
      and ((last_aroonu_14_1h < 100.0) or (last_stochrsi_k_15m < 80.0))
      and ((last_aroonu_14_1h < 100.0) or (last_stochrsi_k_4h < 80.0) or (last_roc_9_4h < 10.0))
      and ((last_aroonu_14_1h < 100.0) or (last_stochrsi_k_1d < 90.0) or (last_roc_9_1d < 20.0))
      and ((last_aroonu_14_4h < 70.0) or (last_roc_9_1d > -25.0))
      and ((last_aroonu_14_4h < 70.0) or (last_roc_9_1d < 50.0))
      and ((last_aroonu_14_4h < 80.0) or (last_stochrsi_k_4h < 80.0) or (last_roc_9_4h < 10.0))
      and ((last_aroonu_14_4h < 80.0) or (last_stochrsi_k_1d < 80.0) or (last_roc_9_1d < 10.0))
      and ((last_aroonu_14_4h < 90.0) or (last_stochrsi_k_4h < 90.0))
      and ((last_aroonu_14_4h < 90.0) or (last_roc_9_4h < 10.0))
      and ((last_stochrsi_k_15m < 60.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_stochrsi_k_1h < 70.0) or (last_stochrsi_k_4h < 80.0))
      and ((last_stochrsi_k_1h < 90.0) or (last_roc_9_4h > -20.0))
      and ((last_stochrsi_k_4h < 70.0) or (last_roc_9_1d > -25.0))
      and ((last_stochrsi_k_4h < 80.0) or (last_stochrsi_k_1d < 90.0) or (last_roc_9_1d < 20.0))
      and ((last_roc_9_1d > -40.0) or (last_aroonu_14_1h < 90.0))
      and ((last_roc_9_1d > -40.0) or (last_stochrsi_k_1h < 80.0))
      and ((last_roc_9_1d > -25.0) or (last_stochrsi_k_15m < 90.0))
      and ((last_roc_9_1d > -25.0) or (last_aroonu_14_4h < 80.0))
      and ((last_roc_9_1d > -15.0) or (last_stochrsi_k_4h < 80.0))
    ):
      self._grind_entry_tag = "g27"
      return True

    self._grind_entry_tag = ""
    return False

  def long_buyback_entry_v3(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    if (last_candle["protections_long_global"] == True) and (
      (last_candle["enter_long"] == True)
      or (
        (last_candle["RSI_3"] > 10.0)
        and (last_candle["RSI_3_15m"] > 10.0)
        and (last_candle["AROONU_14"] < 30.0)
        and (last_candle["AROONU_14_15m"] < 30.0)
      )
    ):
      return True

    return False

  def long_rebuy_entry_v3(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    if (last_candle["protections_long_global"] == True) and (
      (last_candle["enter_long"] == True)
      or (
        (last_candle["RSI_3"] > 10.0)
        and (last_candle["RSI_3_15m"] > 10.0)
        and (last_candle["AROONU_14"] < 30.0)
        and (last_candle["AROONU_14_15m"] < 30.0)
        and (last_candle["close"] < (last_candle["EMA_26"] * 0.988))
      )
    ):
      return True

  def long_grind_exit_v3(
    self,
    last_rsi_3: float,
    last_rsi_14: float,
    last_willr_14: float,
    last_stochrsi_k: float,
    last_close: float,
    last_bbu_20: float,
    last_rsi_3_1h: float,
    last_rsi_3_4h: float,
    last_roc_9_1d: float,
    last_btc_rsi_14_4h: float,
    slice_profit: float,
    current_time: datetime,
    min_stake: float,
    current_stake_amount: float,
    exit_rate: float,
    profit_stake: float,
    profit_ratio: float,
    name: str,
    tag: str,
    # max_profit: float,
    # max_profit_rate: float,
    grind_profit_stake: float,
    grind_profit_rate: float,
    grind_total_amount: float,
    grind_exit_profit_threshold: float,
    grind_open_orders,
    trade: Trade,
  ) -> tuple:
    is_normal_exit = False
    if (
      (last_rsi_3 > 99.0)
      or (last_rsi_14 > 70.0)
      or (last_willr_14 > -0.1)
      or (last_stochrsi_k > 95.0)
      or (last_close > (last_bbu_20 * 1.01))
      or ((last_rsi_3 > 90.0) and (last_rsi_14 < 50.0))
      or (
        (last_rsi_3 > 80.0)
        and (last_rsi_3_1h < 20.0)
        and (last_rsi_3_4h < 20.0)
        and (last_roc_9_1d > -10.0)
        and (last_btc_rsi_14_4h < 35.0)
      )
    ):
      is_normal_exit = True

    is_trailing_exit = False
    # if 0.01 <= grind_profit_rate < 0.02:
    #   if grind_profit_rate < (max_profit_rate - 0.025):
    #     is_trailing_exit = True
    # elif 0.02 <= grind_profit_rate <= 0.05:
    #   if grind_profit_rate < (max_profit_rate - 0.035):
    #     is_trailing_exit = True
    # elif 0.05 <= grind_profit_rate <= 0.08:
    #   if grind_profit_rate < (max_profit_rate - 0.045):
    #     is_trailing_exit = True
    # elif 0.08 <= grind_profit_rate <= 0.12:
    #   if grind_profit_rate < (max_profit_rate - 0.050):
    #     is_trailing_exit = True
    # elif 0.12 <= grind_profit_rate:
    #   if grind_profit_rate < (max_profit_rate - 0.055):
    #     is_trailing_exit = True
    # is_trailing_exit = grind_profit_rate > 0.04
    if is_normal_exit or is_trailing_exit:
      stake_currency = self.config["stake_currency"]
      stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
      trade_pair = trade.pair
      trade_leverage = trade.leverage
      trade_amount = trade.amount
      trade_stake_amount = trade.stake_amount
      exit_amount = grind_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - exit_amount) < (min_stake * 1.55):
        exit_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_exit_amount = exit_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if exit_amount > min_stake and ft_exit_amount > min_stake:
        self.dp.send_msg(
          self.notification_msg(
            "grinding-exit",
            tag=name,
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=exit_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit_stake,
            grind_profit_pct=grind_profit_rate,
            coin_amount=grind_total_amount,
          )
        )
        log.info(
          f"Grinding exit ({name}) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {exit_amount:{stake_fmt}} | Coin amount: {grind_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit_rate * 100.0):.2f}% ({grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = tag
        for grind_entry in grind_open_orders:
          order_tag += " " + str(grind_entry.id)
        return -ft_exit_amount, order_tag

    return None, None

  # Long Grinding Adjust Trade Position
  # ---------------------------------------------------------------------------------------------
  def long_grind_adjust_trade_position(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    stake_currency = self.config["stake_currency"]
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    runmode_value = dp.runmode.value
    is_backtest = runmode_value in ["backtest", "hyperopt"]
    trade_open_date = None if is_backtest else trade.open_date_utc.replace(tzinfo=None)
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    is_futures = self.is_futures_mode
    derisk_use_grind_stops = self.derisk_use_grind_stops
    long_rebuy_mode_tags = self.long_rebuy_mode_tags
    long_grind_mode_tags = self.long_grind_mode_tags
    trade_leverage = trade.leverage

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    previous_candle = df.iloc[-2]

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_entries = trade.nr_of_successful_entries
    count_of_exits = trade.nr_of_successful_exits

    if count_of_entries == 0:
      return None

    first_filled_entry = filled_entries[0]
    last_filled_entry = filled_entries[-1]
    last_filled_order = filled_orders[-1]

    has_order_tags = hasattr(filled_orders[0], "ft_order_tag")

    if runmode_value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = self.config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    slice_amount = first_filled_entry.safe_filled * first_filled_entry.safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    current_stake_amount = trade_amount * current_rate
    is_derisk = trade_amount < (first_filled_entry.safe_filled * 0.95)
    is_derisk_calc = False
    is_rebuy_mode = all(c in long_rebuy_mode_tags for c in enter_tags) or (
      any(c in long_rebuy_mode_tags for c in enter_tags)
      and all(c in (long_rebuy_mode_tags + long_grind_mode_tags) for c in enter_tags)
    )
    is_grind_mode = all(c in long_grind_mode_tags for c in enter_tags)

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate
    stake_scale_leverage = trade_leverage if is_futures else 1.0
    grind_mode_stake_multipliers = (
      self.grind_mode_stake_multiplier_futures if is_futures else self.grind_mode_stake_multiplier_spot
    )
    regular_mode_stake_multipliers = (
      self.regular_mode_stake_multiplier_futures if is_futures else self.regular_mode_stake_multiplier_spot
    )
    grind_entry_retry_time = current_time - timedelta(minutes=10)
    grind_order_age_time = current_time - timedelta(hours=6)
    grind_force_order_age_time = current_time - timedelta(hours=24)

    # Rebuy mode
    if is_rebuy_mode:
      slice_amount /= self.rebuy_mode_stake_multiplier
    # Grind mode
    elif is_grind_mode:
      slice_amount /= grind_mode_stake_multipliers[0]
    elif not is_derisk and (is_backtest or trade_open_date >= datetime(2024, 2, 5)):
      rebuy_stake, order_tag, is_derisk_calc = self.long_adjust_trade_position_no_derisk(
        trade,
        enter_tags,
        current_time,
        current_rate,
        current_profit,
        min_stake,
        max_stake,
        current_entry_rate,
        current_exit_rate,
        current_entry_profit,
        current_exit_profit,
        last_candle,
        previous_candle,
        filled_orders,
        filled_entries,
        filled_exits,
        exit_rate,
        slice_amount,
        slice_profit_entry,
        slice_profit,
        profit_ratio,
        profit_stake,
        profit_init_ratio,
        current_stake_amount,
        has_order_tags,
        count_of_exits,
      )
      if rebuy_stake is not None:
        if has_order_tags:
          return rebuy_stake, order_tag
        else:
          return rebuy_stake
      elif count_of_exits == 0:
        return None
      elif not is_derisk_calc:
        return None

    if not is_rebuy_mode and not is_grind_mode:
      # First entry is lower now, therefore the grinds must adjust
      if is_backtest or trade_open_date >= datetime(2024, 4, 16):
        slice_amount /= regular_mode_stake_multipliers[0]

    is_not_trade_max_stake = current_stake_amount < (
      ((first_filled_entry.safe_filled * first_filled_entry.safe_price) * self.grinding_v1_max_stake)
      / (grind_mode_stake_multipliers[0] if is_grind_mode else 1.0)
    )

    grind_1_max_sub_grinds = 0
    grind_1_stakes = scale_stakes_for_min_stake(
      self.grind_1_stakes_futures if is_futures else self.grind_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_1_sub_thresholds = self.grind_1_sub_thresholds_futures if is_futures else self.grind_1_sub_thresholds_spot
    grind_1_max_sub_grinds = len(grind_1_stakes)
    grind_1_stop_grinds = self.grind_1_stop_grinds_futures if is_futures else self.grind_1_stop_grinds_spot
    grind_1_profit_threshold = (
      self.grind_1_profit_threshold_futures if is_futures else self.grind_1_profit_threshold_spot
    )

    grind_2_max_sub_grinds = 0
    grind_2_stakes = scale_stakes_for_min_stake(
      self.grind_2_stakes_futures if is_futures else self.grind_2_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_2_sub_thresholds = self.grind_2_sub_thresholds_futures if is_futures else self.grind_2_sub_thresholds_spot
    grind_2_max_sub_grinds = len(grind_2_stakes)
    grind_2_stop_grinds = self.grind_2_stop_grinds_futures if is_futures else self.grind_2_stop_grinds_spot
    grind_2_profit_threshold = (
      self.grind_2_profit_threshold_futures if is_futures else self.grind_2_profit_threshold_spot
    )

    grind_3_max_sub_grinds = 0
    grind_3_stakes = scale_stakes_for_min_stake(
      self.grind_3_stakes_futures if is_futures else self.grind_3_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_3_sub_thresholds = self.grind_3_sub_thresholds_futures if is_futures else self.grind_3_sub_thresholds_spot
    grind_3_max_sub_grinds = len(grind_3_stakes)
    grind_3_stop_grinds = self.grind_3_stop_grinds_futures if is_futures else self.grind_3_stop_grinds_spot
    grind_3_profit_threshold = (
      self.grind_3_profit_threshold_futures if is_futures else self.grind_3_profit_threshold_spot
    )

    grind_4_max_sub_grinds = 0
    grind_4_stakes = scale_stakes_for_min_stake(
      self.grind_4_stakes_futures if is_futures else self.grind_4_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_4_sub_thresholds = self.grind_4_sub_thresholds_futures if is_futures else self.grind_4_sub_thresholds_spot
    grind_4_max_sub_grinds = len(grind_4_stakes)
    grind_4_stop_grinds = self.grind_4_stop_grinds_futures if is_futures else self.grind_4_stop_grinds_spot
    grind_4_profit_threshold = (
      self.grind_4_profit_threshold_futures if is_futures else self.grind_4_profit_threshold_spot
    )

    grind_5_max_sub_grinds = 0
    grind_5_stakes = scale_stakes_for_min_stake(
      self.grind_5_stakes_futures if is_futures else self.grind_5_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_5_sub_thresholds = self.grind_5_sub_thresholds_futures if is_futures else self.grind_5_sub_thresholds_spot
    grind_5_max_sub_grinds = len(grind_5_stakes)
    grind_5_stop_grinds = self.grind_5_stop_grinds_futures if is_futures else self.grind_5_stop_grinds_spot
    grind_5_profit_threshold = (
      self.grind_5_profit_threshold_futures if is_futures else self.grind_5_profit_threshold_spot
    )

    grind_6_max_sub_grinds = 0
    grind_6_stakes = scale_stakes_for_min_stake(
      self.grind_6_stakes_futures if is_futures else self.grind_6_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_6_sub_thresholds = self.grind_6_sub_thresholds_futures if is_futures else self.grind_6_sub_thresholds_spot
    grind_6_max_sub_grinds = len(grind_6_stakes)
    grind_6_stop_grinds = self.grind_6_stop_grinds_futures if is_futures else self.grind_6_stop_grinds_spot
    grind_6_profit_threshold = (
      self.grind_6_profit_threshold_futures if is_futures else self.grind_6_profit_threshold_spot
    )

    grind_1_derisk_1_max_sub_grinds = 0
    grind_1_derisk_1_stakes = scale_stakes_for_min_stake(
      self.grind_1_derisk_1_stakes_futures if is_futures else self.grind_1_derisk_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_1_derisk_1_sub_thresholds = (
      self.grind_1_derisk_1_sub_thresholds_futures if is_futures else self.grind_1_derisk_1_sub_thresholds_spot
    )
    grind_1_derisk_1_max_sub_grinds = len(grind_1_derisk_1_stakes)
    grind_1_derisk_1_stop_grinds = (
      self.grind_1_derisk_1_stop_grinds_futures if is_futures else self.grind_1_derisk_1_stop_grinds_spot
    )
    grind_1_derisk_1_profit_threshold = (
      self.grind_1_derisk_1_profit_threshold_futures if is_futures else self.grind_1_derisk_1_profit_threshold_spot
    )

    grind_2_derisk_1_max_sub_grinds = 0
    grind_2_derisk_1_stakes = scale_stakes_for_min_stake(
      self.grind_2_derisk_1_stakes_futures if is_futures else self.grind_2_derisk_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_2_derisk_1_sub_thresholds = (
      self.grind_2_derisk_1_sub_thresholds_futures if is_futures else self.grind_2_derisk_1_sub_thresholds_spot
    )
    grind_2_derisk_1_max_sub_grinds = len(grind_2_derisk_1_stakes)
    grind_2_derisk_1_stop_grinds = (
      self.grind_2_derisk_1_stop_grinds_futures if is_futures else self.grind_2_derisk_1_stop_grinds_spot
    )
    grind_2_derisk_1_profit_threshold = (
      self.grind_2_derisk_1_profit_threshold_futures if is_futures else self.grind_2_derisk_1_profit_threshold_spot
    )

    partial_sell = False
    is_derisk_found = False  # d de-risk
    is_derisk_1 = False
    is_derisk_1_found = False  # d1 de-risk exit
    derisk_1_order = None
    derisk_1_reentry_order = None
    derisk_1_sub_grind_count = 0
    derisk_1_total_amount = 0.0
    derisk_1_total_cost = 0.0
    derisk_1_current_open_rate = 0.0
    derisk_1_current_grind_stake = 0.0
    derisk_1_current_grind_stake_profit = 0.0
    derisk_1_is_sell_found = False
    derisk_1_reentry_found = False
    derisk_1_buy_orders = []
    derisk_1_distance_ratio = 0.0
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_stake_profit = 0.0
    grind_1_is_sell_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_stake_profit = 0.0
    grind_2_is_sell_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_stake_profit = 0.0
    grind_3_is_sell_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_stake_profit = 0.0
    grind_4_is_sell_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_stake_profit = 0.0
    grind_5_is_sell_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_distance_ratio = 0.0
    grind_6_sub_grind_count = 0
    grind_6_total_amount = 0.0
    grind_6_total_cost = 0.0
    grind_6_current_open_rate = 0.0
    grind_6_current_grind_stake = 0.0
    grind_6_current_grind_stake_profit = 0.0
    grind_6_is_sell_found = False
    grind_6_found = False
    grind_6_buy_orders = []
    grind_6_distance_ratio = 0.0
    grind_1_derisk_1_sub_grind_count = 0
    grind_1_derisk_1_total_amount = 0.0
    grind_1_derisk_1_total_cost = 0.0
    grind_1_derisk_1_current_open_rate = 0.0
    grind_1_derisk_1_current_grind_stake = 0.0
    grind_1_derisk_1_current_grind_stake_profit = 0.0
    grind_1_derisk_1_is_sell_found = False
    grind_1_derisk_1_found = False
    grind_1_derisk_1_buy_orders = []
    grind_1_derisk_1_distance_ratio = 0.0
    grind_2_derisk_1_sub_grind_count = 0
    grind_2_derisk_1_total_amount = 0.0
    grind_2_derisk_1_total_cost = 0.0
    grind_2_derisk_1_current_open_rate = 0.0
    grind_2_derisk_1_current_grind_stake = 0.0
    grind_2_derisk_1_current_grind_stake_profit = 0.0
    grind_2_derisk_1_is_sell_found = False
    grind_2_derisk_1_found = False
    grind_2_derisk_1_buy_orders = []
    grind_2_derisk_1_distance_ratio = 0.0
    for order in reversed(filled_orders):
      order_side = order.ft_order_side
      if (order_side == "buy") and (order is not filled_orders[0]):
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag
        order_safe_filled = order.safe_filled
        order_safe_price = order.safe_price
        order_id = order.id
        if not is_derisk_1 and order_tag == "d1":
          derisk_1_sub_grind_count += 1
          derisk_1_total_amount += order_safe_filled
          derisk_1_total_cost += order_safe_filled * order_safe_price
          derisk_1_buy_orders.append(order_id)
          if not derisk_1_reentry_found and not is_derisk_1:
            derisk_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            derisk_1_reentry_found = True
            derisk_1_reentry_order = order
        elif not grind_1_derisk_1_is_sell_found and order_tag == "dl1":
          grind_1_derisk_1_sub_grind_count += 1
          grind_1_derisk_1_total_amount += order_safe_filled
          grind_1_derisk_1_total_cost += order_safe_filled * order_safe_price
          grind_1_derisk_1_buy_orders.append(order_id)
          if not grind_1_derisk_1_found:
            grind_1_derisk_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_1_derisk_1_found = True
        elif not grind_2_derisk_1_is_sell_found and order_tag == "dl2":
          grind_2_derisk_1_sub_grind_count += 1
          grind_2_derisk_1_total_amount += order_safe_filled
          grind_2_derisk_1_total_cost += order_safe_filled * order_safe_price
          grind_2_derisk_1_buy_orders.append(order_id)
          if not grind_2_derisk_1_found:
            grind_2_derisk_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_2_derisk_1_found = True
        elif not grind_6_is_sell_found and order_tag == "gd6":
          grind_6_sub_grind_count += 1
          grind_6_total_amount += order_safe_filled
          grind_6_total_cost += order_safe_filled * order_safe_price
          grind_6_buy_orders.append(order_id)
          if not grind_6_found:
            grind_6_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_6_found = True
        elif not grind_5_is_sell_found and order_tag == "gd5":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order_safe_filled
          grind_5_total_cost += order_safe_filled * order_safe_price
          grind_5_buy_orders.append(order_id)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_5_found = True
        elif not grind_4_is_sell_found and order_tag == "gd4":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order_safe_filled
          grind_4_total_cost += order_safe_filled * order_safe_price
          grind_4_buy_orders.append(order_id)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_4_found = True
        elif not grind_3_is_sell_found and order_tag == "gd3":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order_safe_filled
          grind_3_total_cost += order_safe_filled * order_safe_price
          grind_3_buy_orders.append(order_id)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_3_found = True
        elif not grind_2_is_sell_found and order_tag == "gd2":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order_safe_filled
          grind_2_total_cost += order_safe_filled * order_safe_price
          grind_2_buy_orders.append(order_id)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_2_found = True
        elif not grind_1_is_sell_found and order_tag not in [
          "r",
          "d1",
          "dl1",
          "dl2",
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "gm0",
          "gmd0",
          "gdr",
        ]:
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order_safe_filled
          grind_1_total_cost += order_safe_filled * order_safe_price
          grind_1_buy_orders.append(order_id)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_1_found = True
      elif order_side == "sell":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          break
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag.partition(" ")[0]
        if order_tag in ["dl1", "ddl1"]:
          grind_1_derisk_1_is_sell_found = True
        elif order_tag in ["dl2", "ddl2"]:
          grind_2_derisk_1_is_sell_found = True
        elif order_tag in ["gd6", "dd6"]:
          grind_6_is_sell_found = True
        elif order_tag in ["gd5", "dd5"]:
          grind_5_is_sell_found = True
        if order_tag in ["gd4", "dd4"]:
          grind_4_is_sell_found = True
        elif order_tag in ["gd3", "dd3"]:
          grind_3_is_sell_found = True
        elif order_tag in ["gd2", "dd2"]:
          grind_2_is_sell_found = True
        elif order_tag == "d1":
          if not is_derisk_1_found:
            is_derisk_1_found = True
            is_derisk_1 = True
            derisk_1_order = order
        elif order_tag in ["p", "r", "d", "dd0", "partial_exit", "force_exit", ""]:
          if order_tag == "d":
            is_derisk_found = True
            is_derisk = True
          grind_1_is_sell_found = True
          grind_2_is_sell_found = True
          grind_3_is_sell_found = True
          grind_4_is_sell_found = True
          grind_5_is_sell_found = True
          grind_6_is_sell_found = True
          grind_1_derisk_1_is_sell_found = True
          grind_2_derisk_1_is_sell_found = True
        elif order_tag not in [
          "dl1",
          "ddl1",
          "dl2",
          "ddl2",
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "dd2",
          "dd3",
          "dd4",
          "dd5",
          "dd6",
          "gm0",
          "gmd0",
          "gdr",
        ]:
          grind_1_is_sell_found = True

    if derisk_1_sub_grind_count > 0:
      derisk_1_current_open_rate = derisk_1_total_cost / derisk_1_total_amount
      derisk_1_current_grind_stake = derisk_1_total_amount * exit_rate * (1 - trade_fee_close)
      derisk_1_current_grind_stake_profit = derisk_1_current_grind_stake - derisk_1_total_cost
    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_current_grind_stake_profit = grind_1_current_grind_stake - grind_1_total_cost
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_current_grind_stake_profit = grind_2_current_grind_stake - grind_2_total_cost
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 - trade_fee_close)
      grind_3_current_grind_stake_profit = grind_3_current_grind_stake - grind_3_total_cost
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 - trade_fee_close)
      grind_4_current_grind_stake_profit = grind_4_current_grind_stake - grind_4_total_cost
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 - trade_fee_close)
      grind_5_current_grind_stake_profit = grind_5_current_grind_stake - grind_5_total_cost
    if grind_6_sub_grind_count > 0:
      grind_6_current_open_rate = grind_6_total_cost / grind_6_total_amount
      grind_6_current_grind_stake = grind_6_total_amount * exit_rate * (1 - trade_fee_close)
      grind_6_current_grind_stake_profit = grind_6_current_grind_stake - grind_6_total_cost
    if grind_1_derisk_1_sub_grind_count > 0:
      grind_1_derisk_1_current_open_rate = grind_1_derisk_1_total_cost / grind_1_derisk_1_total_amount
      grind_1_derisk_1_current_grind_stake = grind_1_derisk_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_derisk_1_current_grind_stake_profit = grind_1_derisk_1_current_grind_stake - grind_1_derisk_1_total_cost
    if grind_2_derisk_1_sub_grind_count > 0:
      grind_2_derisk_1_current_open_rate = grind_2_derisk_1_total_cost / grind_2_derisk_1_total_amount
      grind_2_derisk_1_current_grind_stake = grind_2_derisk_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_derisk_1_current_grind_stake_profit = grind_2_derisk_1_current_grind_stake - grind_2_derisk_1_total_cost

    num_open_grinds = (
      grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
      + grind_6_sub_grind_count
      + grind_1_derisk_1_sub_grind_count
      + grind_2_derisk_1_sub_grind_count
    )
    grinds_total_stake_profit = (
      derisk_1_current_grind_stake_profit
      + grind_1_derisk_1_current_grind_stake_profit
      + grind_2_derisk_1_current_grind_stake_profit
      + grind_1_current_grind_stake_profit
      + grind_2_current_grind_stake_profit
      + grind_3_current_grind_stake_profit
      + grind_4_current_grind_stake_profit
      + grind_5_current_grind_stake_profit
      + grind_6_current_grind_stake_profit
    )
    grinds_total_amount = (
      derisk_1_total_amount
      + grind_1_derisk_1_total_amount
      + grind_2_derisk_1_total_amount
      + grind_1_total_amount
      + grind_2_total_amount
      + grind_3_total_amount
      + grind_4_total_amount
      + grind_5_total_amount
      + grind_6_total_amount
    )
    stake_fmt = ".8f" if self.config["stake_currency"] in ("BTC", "ETH", "BNB", "SOL") else ".3f"
    # Sell remaining if partial fill on exit
    if partial_sell:
      order = filled_exits[-1]
      sell_amount = order.safe_remaining * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        send_msg(
          f"Exit (remaining) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {order.safe_remaining} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        order_tag = "p"
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    if is_grind_mode and (
      (first_filled_entry.safe_filled * (trade_stake_amount / trade_amount) - (min_stake * 1.5)) > min_stake
    ):
      is_first_entry_exit_found = False
      for order in filled_orders:
        if order.ft_order_side == "sell":
          order_tag = ""
          if has_order_tags:
            if order.ft_order_tag is not None:
              order_tag = order.ft_order_tag.partition(" ")[0]
          else:
            # no order tag support, assume the first exit is for the first buy
            is_first_entry_exit_found = True
          if order_tag in ["gm0", "gmd0"]:
            is_first_entry_exit_found = True
            break
      if not is_first_entry_exit_found:
        first_entry = first_filled_entry
        first_entry_distance_ratio = (exit_rate - first_entry.safe_price) / first_entry.safe_price
        # First entry exit
        if first_entry_distance_ratio > (
          (self.grind_mode_first_entry_profit_threshold_spot + fee_open_rate + fee_close_rate)
          if is_futures
          else (self.grind_mode_first_entry_profit_threshold_spot + fee_open_rate + fee_close_rate)
        ):
          sell_amount = first_entry.safe_filled * exit_rate / trade_leverage
          if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
            sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
          ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
          if sell_amount > min_stake and ft_sell_amount > min_stake:
            grind_profit = (exit_rate - first_entry.safe_price) / first_entry.safe_price
            coin_amount = sell_amount / exit_rate
            send_msg(
              notification_msg(
                "grinding-exit",
                tag="gm0",
                pair=trade_pair,
                rate=exit_rate,
                stake_amount=sell_amount,
                profit_stake=profit_stake,
                profit_ratio=profit_ratio,
                stake_currency=stake_currency,
                grind_profit_stake=grind_profit * sell_amount * trade_leverage,
                grind_profit_pct=grind_profit,
                coin_amount=coin_amount,
              )
            )
            log.info(
              f"Grinding exit (gm0) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {coin_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
            )
            order_tag = "gm0"
            for grind_entry_id in grind_1_buy_orders:
              order_tag += " " + str(grind_entry_id)
            if has_order_tags:
              return -ft_sell_amount, order_tag
            else:
              return -ft_sell_amount
        # First entry de-risk
        if derisk_use_grind_stops and (
          first_entry_distance_ratio
          < (
            self.grind_mode_first_entry_stop_threshold_spot
            if is_futures
            else self.grind_mode_first_entry_stop_threshold_spot
          )
        ):
          sell_amount = first_entry.safe_filled * exit_rate / trade_leverage
          if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
            sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
          ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
          if sell_amount > min_stake and ft_sell_amount > min_stake:
            grind_profit = (exit_rate - first_entry.safe_price) / first_entry.safe_price
            coin_amount = sell_amount / exit_rate
            send_msg(
              notification_msg(
                "grinding-derisk",
                tag="gmd0",
                pair=trade_pair,
                rate=exit_rate,
                stake_amount=sell_amount,
                profit_stake=profit_stake,
                profit_ratio=profit_ratio,
                stake_currency=stake_currency,
                grind_profit_stake=grind_profit * sell_amount * trade_leverage,
                grind_profit_pct=grind_profit,
                coin_amount=coin_amount,
              )
            )
            log.info(
              f"Grinding de-risk (gmd0) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {coin_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
            )
            order_tag = "gmd0"
            for grind_entry_id in grind_1_buy_orders:
              order_tag += " " + str(grind_entry_id)
            if has_order_tags:
              return -ft_sell_amount, order_tag
            else:
              return -ft_sell_amount

    is_long_grind_entry = self.long_grind_entry_v3(
      last_candle, previous_candle, num_open_grinds, slice_profit, slice_profit_entry, slice_profit_exit, True
    )  # 120 grinds via the v3 entry set (g0..g23) instead of the legacy grind mode
    slice_profit_lt_neg_0_06 = slice_profit < -0.06
    num_open_grinds_eq_0 = num_open_grinds == 0

    # Grinding derisk 1
    # Buy
    if (
      has_order_tags
      and is_derisk_1
      and not derisk_1_reentry_found
      and (not partial_sell)
      and (grind_1_derisk_1_sub_grind_count < grind_1_derisk_1_max_sub_grinds)
      and is_not_trade_max_stake
    ):
      if (
        (
          (
            (grind_1_derisk_1_sub_grind_count > 0)
            and grind_1_derisk_1_distance_ratio < grind_1_derisk_1_sub_thresholds[grind_1_derisk_1_sub_grind_count]
          )
          or ((is_derisk or is_derisk_calc) and grind_1_derisk_1_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * grind_1_derisk_1_stakes[grind_1_derisk_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_1_derisk_1_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate
          grind_profit_stake = grind_1_derisk_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="dl1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_derisk_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (dl1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_derisk_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "dl1"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_1_derisk_1_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate
      if grind_profit > (grind_1_derisk_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_1_derisk_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="dl1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_derisk_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (dl1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "dl1"
          for grind_entry_id in grind_1_derisk_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (grind_1_derisk_1_sub_grind_count > 0)
      # and (
      #   ((exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate)
      #   < grind_1_derisk_1_stop_grinds
      # )
      and (grind_1_derisk_1_current_grind_stake_profit < (slice_amount * grind_1_derisk_1_stop_grinds))
      and (is_derisk or is_derisk_calc)
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_1_derisk_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_derisk_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate)
            if grind_1_derisk_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="ddl1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_derisk_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (ddl1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "ddl1"
        for grind_entry_id in grind_1_derisk_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding derisk 2
    # Buy
    if (
      has_order_tags
      and is_derisk_1
      and not derisk_1_reentry_found
      and (not partial_sell)
      and (grind_2_derisk_1_sub_grind_count < grind_2_derisk_1_max_sub_grinds)
      and is_not_trade_max_stake
    ):
      if (
        (
          (
            (grind_2_derisk_1_sub_grind_count > 0)
            and grind_2_derisk_1_distance_ratio < grind_2_derisk_1_sub_thresholds[grind_2_derisk_1_sub_grind_count]
          )
          or ((is_derisk or is_derisk_calc) and grind_2_derisk_1_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * grind_2_derisk_1_stakes[grind_2_derisk_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_2_derisk_1_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate
          grind_profit_stake = grind_2_derisk_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="dl2",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_derisk_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (dl2) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_derisk_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "dl2"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_2_derisk_1_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate
      if grind_profit > (grind_2_derisk_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_2_derisk_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="dl2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_derisk_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (dl2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "dl2"
          for grind_entry_id in grind_2_derisk_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (grind_2_derisk_1_sub_grind_count > 0)
      # and (
      #   ((exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate)
      #   < grind_2_derisk_1_stop_grinds
      # )
      and (grind_2_derisk_1_current_grind_stake_profit < (slice_amount * grind_2_derisk_1_stop_grinds))
      and (is_derisk or is_derisk_calc)
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_2_derisk_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_derisk_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate)
            if grind_2_derisk_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="ddl2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_derisk_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (ddl2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "ddl2"
        for grind_entry_id in grind_2_derisk_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 1
    # Buy
    if (not partial_sell) and (grind_1_sub_grind_count < grind_1_max_sub_grinds):
      if (
        (
          ((grind_1_sub_grind_count > 0) and grind_1_distance_ratio < grind_1_sub_thresholds[grind_1_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_1_sub_grind_count == 0)
          or (is_grind_mode and grind_1_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_1_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
          grind_profit_stake = grind_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd1"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    if (
      is_futures
      and has_order_tags
      and (not partial_sell)
      and slice_profit < (-0.65 / trade_leverage)
      and (is_derisk or is_derisk_calc or is_grind_mode)
      and (grind_1_sub_grind_count < grind_1_max_sub_grinds)
    ):
      buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      grind_profit = 0.0
      grind_profit_stake = 0.0
      if grind_1_sub_grind_count > 0:
        grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
        grind_profit_stake = grind_1_current_grind_stake_profit
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="gd1",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
          grind_profit_stake=grind_1_current_grind_stake_profit,
          grind_profit_pct=grind_profit,
        )
      )
      log.info(
        f"Grinding entry (gd1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
      )
      order_tag = "gd1"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    # Sell
    if grind_1_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
      if grind_profit > (grind_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd1"
          for grind_entry_id in grind_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_1_sub_grind_count > 0)
        # and (((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < grind_1_stop_grinds)
        and (grind_1_current_grind_stake_profit < (slice_amount * grind_1_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd1"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 2
    # Buy
    if has_order_tags and (not partial_sell) and (grind_2_sub_grind_count < grind_2_max_sub_grinds):
      if (
        (
          ((grind_2_sub_grind_count > 0) and grind_2_distance_ratio < grind_2_sub_thresholds[grind_2_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_2_sub_grind_count == 0)
          or (is_grind_mode and grind_2_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_2_stakes[grind_2_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_2_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
          grind_profit_stake = grind_2_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd2",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd2) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd2"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_2_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
      if grind_profit > (grind_2_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd2"
          for grind_entry_id in grind_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_2_sub_grind_count > 0)
        # and (((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < grind_2_stop_grinds)
        and (grind_2_current_grind_stake_profit < (slice_amount * grind_2_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd2"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 3
    # Buy
    if has_order_tags and (not partial_sell) and (grind_3_sub_grind_count < grind_3_max_sub_grinds):
      if (
        (
          ((grind_3_sub_grind_count > 0) and grind_3_distance_ratio < grind_3_sub_thresholds[grind_3_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_3_sub_grind_count == 0)
          or (is_grind_mode and grind_3_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_3_stakes[grind_3_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_3_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
          grind_profit_stake = grind_3_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd3",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_3_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd3) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd3"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_3_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
      if grind_profit > (grind_3_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd3",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd3"
          for grind_entry_id in grind_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_3_sub_grind_count > 0)
        # and (((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < grind_3_stop_grinds)
        and (grind_3_current_grind_stake_profit < (slice_amount * grind_3_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd3",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd3"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 4
    # Buy
    if has_order_tags and (not partial_sell) and (grind_4_sub_grind_count < grind_4_max_sub_grinds):
      if (
        (
          ((grind_4_sub_grind_count > 0) and grind_4_distance_ratio < grind_4_sub_thresholds[grind_4_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_4_sub_grind_count == 0)
          or (is_grind_mode and grind_4_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_4_stakes[grind_4_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_4_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
          grind_profit_stake = grind_4_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd4",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_4_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd4) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd4"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_4_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
      if grind_profit > (grind_4_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_4_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd4",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd4"
          for grind_entry_id in grind_4_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_4_sub_grind_count > 0)
        # and (((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < grind_4_stop_grinds)
        and (grind_4_current_grind_stake_profit < (slice_amount * grind_4_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd4",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd4"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    gd5_liquidation_rescue_eligible = (
      is_futures
      and (slice_profit_entry < -0.12)
      and (trade.liquidation_price is not None)
      and (current_rate < trade.liquidation_price * 1.20)
      and (trade.get_custom_data(key="gd5_liquidation_rescue_used") is None)
    )

    # Grinding 5
    # Buy
    if has_order_tags and (not partial_sell) and (grind_5_sub_grind_count < grind_5_max_sub_grinds):
      if (
        (
          ((grind_5_sub_grind_count > 0) and grind_5_distance_ratio < grind_5_sub_thresholds[grind_5_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_5_sub_grind_count == 0)
          or (is_grind_mode and grind_5_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and (is_long_grind_entry or gd5_liquidation_rescue_eligible)
        and is_not_trade_max_stake
      ):
        if gd5_liquidation_rescue_eligible:
          trade.set_custom_data(key="gd5_liquidation_rescue_used", value=True)

        buy_amount = slice_amount * grind_5_stakes[grind_5_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_5_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
          grind_profit_stake = grind_5_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd5",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_5_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd5) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd5"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_5_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
      if grind_profit > (grind_5_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_5_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd5",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd5"
          for grind_entry_id in grind_5_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_5_sub_grind_count > 0)
        # and (((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < grind_5_stop_grinds)
        and (grind_5_current_grind_stake_profit < (slice_amount * grind_5_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd5",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd5"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 6
    # Buy
    if has_order_tags and (not partial_sell) and (grind_6_sub_grind_count < grind_6_max_sub_grinds):
      if (
        (
          ((grind_6_sub_grind_count > 0) and grind_6_distance_ratio < grind_6_sub_thresholds[grind_6_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_6_sub_grind_count == 0)
          or (is_grind_mode and grind_6_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and is_long_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_6_stakes[grind_6_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_6_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
          grind_profit_stake = grind_6_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd6",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_6_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd6) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_6_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd6"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_6_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
      if grind_profit > (grind_6_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_6_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd6",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_6_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd6"
          for grind_entry_id in grind_6_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_6_sub_grind_count > 0)
        # and (((exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate) < grind_6_stop_grinds)
        and (grind_6_current_grind_stake_profit < (slice_amount * grind_6_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2026, 6, 18))
    ):
      sell_amount = grind_6_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_6_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate)
            if grind_6_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd6",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_6_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd6"
        for grind_entry_id in grind_6_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # De-risk 1 reentry
    if (
      is_derisk_1
      and not derisk_1_reentry_found
      and derisk_1_order is not None
      and (
        ((current_rate - derisk_1_order.safe_price) / derisk_1_order.safe_price)
        < (self.regular_mode_derisk_1_reentry_futures if is_futures else self.regular_mode_derisk_1_reentry_spot)
      )
    ):
      if (
        (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_lt_neg_0_06)
        and (
          num_open_grinds_eq_0
          or (grind_order_age_time > last_filled_order.order_filled_utc)
          or slice_profit_lt_neg_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit < -0.03))
        and (
          # (last_candle["protections_long_rebuy"] == True)
          # and (last_candle["protections_long_global"] == True)
          (last_candle["global_protections_long_pump"] == True)
          and (last_candle["global_protections_long_dump"] == True)
        )
        and is_long_grind_entry
      ):
        buy_amount = derisk_1_order.safe_filled * derisk_1_order.safe_price
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if derisk_1_sub_grind_count > 0:
          grind_profit = (exit_rate - derisk_1_current_open_rate) / derisk_1_current_open_rate
          grind_profit_stake = derisk_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "re-entry",
            tag="d1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=derisk_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Re-entry (d1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({derisk_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "d1"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # De-risk level 1
    if (
      has_order_tags
      # and not is_derisk_1
      and derisk_1_reentry_found
      and derisk_1_reentry_order is not None
      # and (trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 4, 5) or is_backtest)
      and derisk_1_distance_ratio
      < (
        (self.regular_mode_derisk_1_reentry_futures if is_futures else self.regular_mode_derisk_1_reentry_spot)
        / stake_scale_leverage
      )
    ):
      sell_amount = derisk_1_reentry_order.safe_filled * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="d1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk (d1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "d1"

    # # De-risk
    # if (
    #   not is_derisk_found
    #   and (trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 2, 5) or is_backtest)
    #   and profit_stake
    #   < (
    #     slice_amount
    #     * (
    #       (self.regular_mode_derisk_futures if self.is_futures_mode else self.regular_mode_derisk_spot)
    #       if (trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 4, 16) or is_backtest)
    #       else (self.regular_mode_derisk_futures_old if self.is_futures_mode else self.regular_mode_derisk_spot_old)
    #     )
    #     # / (trade.leverage if self.is_futures_mode else 1.0)
    #   )
    # ):
    #   sell_amount = trade.amount * exit_rate / trade.leverage
    #   if ((current_stake_amount / trade.leverage) - sell_amount) < (min_stake * 1.55):
    #     sell_amount = (trade.amount * exit_rate / trade.leverage) - (min_stake * 1.55)
    #   ft_sell_amount = sell_amount * trade.leverage * (trade.stake_amount / trade.amount) / exit_rate
    #   if sell_amount > min_stake and ft_sell_amount > min_stake:
    #     grind_profit = 0.0
    #     self.dp.send_msg(
    #       f"De-risk [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
    #     )
    #     log.info(
    #       f"De-risk [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
    #     )
    #     return -ft_sell_amount, "d", is_derisk

    # # De-risk
    # if (num_open_grinds > 0) and (
    #   grinds_total_stake_profit
    #   < (slice_amount * (self.grinds_stop_futures if self.is_futures_mode else self.grinds_stop_spot))
    # ):
    #   sell_amount = grinds_total_amount * exit_rate / trade.leverage
    #   if ((current_stake_amount / trade.leverage) - sell_amount) < (min_stake * 1.55):
    #     sell_amount = (trade.amount * exit_rate / trade.leverage) - (min_stake * 1.55)
    #   ft_sell_amount = sell_amount * trade.leverage * (trade.stake_amount / trade.amount) / exit_rate
    #   if sell_amount > min_stake and ft_sell_amount > min_stake:
    #     self.dp.send_msg(
    #       f"De-risk (dd0) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
    #     )
    #     log.info(
    #       f"De-risk (dd0) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
    #     )
    #     order_tag = "dd0"
    #     for grind_entry_id in (
    #       grind_1_buy_orders
    #       + grind_2_buy_orders
    #       + grind_3_buy_orders
    #       + grind_4_buy_orders
    #       + grind_5_buy_orders
    #       + grind_6_buy_orders
    #       + grind_1_derisk_1_buy_orders
    #       + grind_2_derisk_1_buy_orders
    #     ):
    #       order_tag += " " + str(grind_entry_id)
    #     if has_order_tags:
    #       return -ft_sell_amount, order_tag
    #     else:
    #       return -ft_sell_amount

    return None

  # Long Grinding Entry
  # ---------------------------------------------------------------------------------------------
  def long_grind_entry(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    last_aroonu_14 = last_candle["AROONU_14"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    previous_ema_12 = previous_candle["EMA_12"]
    previous_ema_26 = previous_candle["EMA_26"]

    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_close = last_candle["close"]
    last_ema_26 = last_candle["EMA_26"]
    last_ema_12 = last_candle["EMA_12"]
    last_rsi_3 = last_candle["RSI_3"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_open = last_candle["open"]

    # Reused long regular grind-entry thresholds
    last_rsi_14_lt_36 = last_rsi_14 < 36.0
    last_rsi_3_4h_gt_20 = last_rsi_3_4h > 20.0
    last_rsi_3_1h_gt_20 = last_rsi_3_1h > 20.0
    last_rsi_3_15m_gt_10 = last_rsi_3_15m > 10.0
    last_rsi_3_4h_gt_10 = last_rsi_3_4h > 10.0
    last_rsi_3_1h_gt_10 = last_rsi_3_1h > 10.0
    last_rsi_14_4h_lt_60 = last_rsi_14_4h < 60.0
    last_rsi_14_1h_lt_80 = last_rsi_14_1h < 80.0
    last_aroonu_14_15m_lt_25 = last_aroonu_14_15m < 25.0
    last_aroonu_14_lt_25 = last_aroonu_14 < 25.0

    if (
      (last_candle["protections_long_global"] == True)
      and (last_candle["protections_long_rebuy"] == True)
      and (last_candle["global_protections_long_pump"] == True)
      and (last_candle["global_protections_long_dump"] == True)
      and (
        (last_candle["enter_long"] == True)
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3 > 10.0)
          and (last_rsi_3_15m_gt_10)
          and (last_aroonu_14_lt_25)
          and (last_stochrsi_k_1h < 70.0)
          and (last_stochrsi_k_4h < 70.0)
          and (last_close < (last_candle["EMA_16"] * 0.980))
        )
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3_15m > 5.0)
          and (last_rsi_3_1h > 5.0)
          and (last_rsi_3_4h > 5.0)
          and (last_ema_26 > last_ema_12)
          and ((last_ema_26 - last_ema_12) > (last_open * 0.030))
          and ((previous_ema_26 - previous_ema_12) > (last_open / 100.0))
        )
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3 > 5.0)
          and (last_rsi_3_15m_gt_10)
          and (last_rsi_3_1h_gt_10)
          and (last_rsi_3_4h_gt_10)
          and (last_ema_26 > last_ema_12)
          and ((last_ema_26 - last_ema_12) > (last_open * 0.020))
          and ((previous_ema_26 - previous_ema_12) > (last_open / 100.0))
        )
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3 > 16.0)
          and (last_aroonu_14_15m_lt_25)
          and (last_close < (last_ema_12 * 0.984))
        )
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3_15m_gt_10)
          and (last_rsi_3_1h_gt_10)
          and (last_rsi_3_4h_gt_10)
          and (last_candle["AROONU_14_1h"] > last_candle["AROOND_14_1h"])
          and (last_candle["AROONU_14_4h"] > last_candle["AROOND_14_4h"])
          and (last_close < (last_ema_26 * 0.978))
          and (last_close < (last_candle["BBL_20_2.0"] * 0.999))
        )
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3_1h_gt_20)
          and (last_rsi_3_4h_gt_20)
          and (last_rsi_14_1h_lt_80)
          and (last_rsi_14_4h_lt_60)
          and (last_aroonu_14 > last_candle["AROOND_14"])
          and (previous_candle["AROONU_14"] < previous_candle["AROOND_14"])
        )
        or (
          (last_rsi_14_lt_36)
          and (last_rsi_3_15m > 15.0)
          and (last_rsi_3_1h_gt_20)
          and (last_rsi_3_4h_gt_20)
          and (last_rsi_14_1h_lt_80)
          and (last_rsi_14_4h_lt_60)
          and (last_candle["KST_10_15_20_30_10_10_10_15"] > last_candle["KSTs_9"])
          and (previous_candle["KST_10_15_20_30_10_10_10_15"] < previous_candle["KSTs_9"])
        )
        or (
          is_derisk
          and (last_rsi_3 > 20.0)
          and (last_rsi_3_15m > 20.0)
          and (last_rsi_3_1h_gt_20)
          and (last_rsi_3_4h_gt_20)
          and (last_rsi_14_lt_36)
          and (last_aroonu_14_lt_25)
          and (last_aroonu_14_15m_lt_25)
          and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 50.0)
          and (last_close < (last_candle["EMA_20"] * 0.980))
        )
      )
    ):
      return True

    return False

  # Long Grinding Adjust Trade Position No De-Risk
  # ---------------------------------------------------------------------------------------------
  def long_adjust_trade_position_no_derisk(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    last_candle: Series,
    previous_candle: Series,
    filled_orders: "Orders",
    filled_entries: "Orders",
    filled_exits: "Orders",
    exit_rate: float,
    slice_amount: float,
    slice_profit_entry: float,
    slice_profit: float,
    profit_ratio: float,
    profit_stake: float,
    profit_init_ratio: float,
    current_stake_amount: float,
    has_order_tags: bool,
    count_of_exits: int,
    **kwargs,
  ) -> tuple[Optional[float], str, bool]:
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    stake_currency = self.config["stake_currency"]
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    is_backtest = dp.runmode.value in ["backtest", "hyperopt"]
    trade_open_date = None if is_backtest else trade.open_date_utc.replace(tzinfo=None)
    is_futures = self.is_futures_mode
    trade_leverage = trade.leverage
    stake_scale_leverage = trade_leverage if is_futures else 1.0
    regular_mode_use_grind_stops = self.regular_mode_use_grind_stops

    # Reused no-derisk slice-profit gates
    slice_profit_lt_neg_0_02 = slice_profit < -0.02
    slice_profit_lt_neg_0_03 = slice_profit < -0.03
    slice_profit_lt_neg_0_06 = slice_profit < -0.06

    last_filled_entry = filled_entries[-1]
    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]

    max_rebuy_sub_grinds = 0
    regular_mode_rebuy_stakes = scale_stakes_for_min_stake(
      self.regular_mode_rebuy_stakes_futures if is_futures else self.regular_mode_rebuy_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_rebuy_sub_thresholds = (
      self.regular_mode_rebuy_thresholds_futures if is_futures else self.regular_mode_rebuy_thresholds_spot
    )
    max_rebuy_sub_grinds = len(regular_mode_rebuy_stakes)

    max_grind_1_sub_grinds = 0
    regular_mode_grind_1_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_1_stakes_futures if is_futures else self.regular_mode_grind_1_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_1_sub_thresholds = (
      self.regular_mode_grind_1_thresholds_futures if is_futures else self.regular_mode_grind_1_thresholds_spot
    )
    max_grind_1_sub_grinds = len(regular_mode_grind_1_stakes)
    regular_mode_grind_1_stop_grinds = (
      self.regular_mode_grind_1_stop_grinds_futures if is_futures else self.regular_mode_grind_1_stop_grinds_spot
    )
    regular_mode_grind_1_profit_threshold = (
      self.regular_mode_grind_1_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_1_profit_threshold_spot
    )

    max_grind_2_sub_grinds = 0
    regular_mode_grind_2_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_2_stakes_futures if is_futures else self.regular_mode_grind_2_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_2_sub_thresholds = (
      self.regular_mode_grind_2_thresholds_futures if is_futures else self.regular_mode_grind_2_thresholds_spot
    )
    max_grind_2_sub_grinds = len(regular_mode_grind_2_stakes)
    regular_mode_grind_2_stop_grinds = (
      self.regular_mode_grind_2_stop_grinds_futures if is_futures else self.regular_mode_grind_2_stop_grinds_spot
    )
    regular_mode_grind_2_profit_threshold = (
      self.regular_mode_grind_2_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_2_profit_threshold_spot
    )

    max_grind_3_sub_grinds = 0
    regular_mode_grind_3_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_3_stakes_futures if is_futures else self.regular_mode_grind_3_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_3_sub_thresholds = (
      self.regular_mode_grind_3_thresholds_futures if is_futures else self.regular_mode_grind_3_thresholds_spot
    )
    max_grind_3_sub_grinds = len(regular_mode_grind_3_stakes)
    regular_mode_grind_3_stop_grinds = (
      self.regular_mode_grind_3_stop_grinds_futures if is_futures else self.regular_mode_grind_3_stop_grinds_spot
    )
    regular_mode_grind_3_profit_threshold = (
      self.regular_mode_grind_3_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_3_profit_threshold_spot
    )

    max_grind_4_sub_grinds = 0
    regular_mode_grind_4_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_4_stakes_futures if is_futures else self.regular_mode_grind_4_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_4_sub_thresholds = (
      self.regular_mode_grind_4_thresholds_futures if is_futures else self.regular_mode_grind_4_thresholds_spot
    )
    max_grind_4_sub_grinds = len(regular_mode_grind_4_stakes)
    regular_mode_grind_4_stop_grinds = (
      self.regular_mode_grind_4_stop_grinds_futures if is_futures else self.regular_mode_grind_4_stop_grinds_spot
    )
    regular_mode_grind_4_profit_threshold = (
      self.regular_mode_grind_4_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_4_profit_threshold_spot
    )

    max_grind_5_sub_grinds = 0
    regular_mode_grind_5_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_5_stakes_futures if is_futures else self.regular_mode_grind_5_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_5_sub_thresholds = (
      self.regular_mode_grind_5_thresholds_futures if is_futures else self.regular_mode_grind_5_thresholds_spot
    )
    max_grind_5_sub_grinds = len(regular_mode_grind_5_stakes)
    regular_mode_grind_5_stop_grinds = (
      self.regular_mode_grind_5_stop_grinds_futures if is_futures else self.regular_mode_grind_5_stop_grinds_spot
    )
    regular_mode_grind_5_profit_threshold = (
      self.regular_mode_grind_5_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_5_profit_threshold_spot
    )

    max_grind_6_sub_grinds = 0
    regular_mode_grind_6_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_6_stakes_futures if is_futures else self.regular_mode_grind_6_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_6_sub_thresholds = (
      self.regular_mode_grind_6_thresholds_futures if is_futures else self.regular_mode_grind_6_thresholds_spot
    )
    max_grind_6_sub_grinds = len(regular_mode_grind_6_stakes)
    regular_mode_grind_6_stop_grinds = (
      self.regular_mode_grind_6_stop_grinds_futures if is_futures else self.regular_mode_grind_6_stop_grinds_spot
    )
    regular_mode_grind_6_profit_threshold = (
      self.regular_mode_grind_6_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_6_profit_threshold_spot
    )

    partial_sell = False
    is_derisk = False
    is_derisk_1 = False
    rebuy_sub_grind_count = 0
    rebuy_total_amount = 0.0
    rebuy_total_cost = 0.0
    rebuy_current_open_rate = 0.0
    rebuy_current_grind_stake = 0.0
    rebuy_current_grind_stake_profit = 0.0
    rebuy_is_sell_found = False
    rebuy_found = False
    rebuy_buy_orders = []
    rebuy_distance_ratio = 0.0
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_stake_profit = 0.0
    grind_1_is_sell_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_stake_profit = 0.0
    grind_2_is_sell_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_stake_profit = 0.0
    grind_3_is_sell_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_stake_profit = 0.0
    grind_4_is_sell_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_stake_profit = 0.0
    grind_5_is_sell_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_distance_ratio = 0.0
    grind_6_sub_grind_count = 0
    grind_6_total_amount = 0.0
    grind_6_total_cost = 0.0
    grind_6_current_open_rate = 0.0
    grind_6_current_grind_stake = 0.0
    grind_6_current_grind_stake_profit = 0.0
    grind_6_is_sell_found = False
    grind_6_found = False
    grind_6_buy_orders = []
    grind_6_distance_ratio = 0.0
    for order in reversed(filled_orders):
      order_side = order.ft_order_side
      if (order_side == "buy") and (order is not first_filled_order):
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag
        order_safe_filled = order.safe_filled
        order_safe_price = order.safe_price
        order_id = order.id
        if not grind_1_is_sell_found and order_tag == "g1":
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order_safe_filled
          grind_1_total_cost += order_safe_filled * order_safe_price
          grind_1_buy_orders.append(order_id)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_1_found = True
        elif not grind_2_is_sell_found and order_tag == "g2":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order_safe_filled
          grind_2_total_cost += order_safe_filled * order_safe_price
          grind_2_buy_orders.append(order_id)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_2_found = True
        elif not grind_3_is_sell_found and order_tag == "g3":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order_safe_filled
          grind_3_total_cost += order_safe_filled * order_safe_price
          grind_3_buy_orders.append(order_id)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_3_found = True
        elif not grind_4_is_sell_found and order_tag == "g4":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order_safe_filled
          grind_4_total_cost += order_safe_filled * order_safe_price
          grind_4_buy_orders.append(order_id)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_4_found = True
        elif not grind_5_is_sell_found and order_tag == "g5":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order_safe_filled
          grind_5_total_cost += order_safe_filled * order_safe_price
          grind_5_buy_orders.append(order_id)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_5_found = True
        elif not grind_6_is_sell_found and order_tag == "g6":
          grind_6_sub_grind_count += 1
          grind_6_total_amount += order_safe_filled
          grind_6_total_cost += order_safe_filled * order_safe_price
          grind_6_buy_orders.append(order_id)
          if not grind_6_found:
            grind_6_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_6_found = True
        elif not rebuy_is_sell_found and order_tag not in [
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "dl1",
          "dl2",
          "gd1",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "gm0",
          "gmd0",
        ]:
          rebuy_sub_grind_count += 1
          rebuy_total_amount += order_safe_filled
          rebuy_total_cost += order_safe_filled * order_safe_price
          rebuy_buy_orders.append(order_id)
          if not rebuy_found:
            rebuy_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            rebuy_found = True
      elif order_side == "sell":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          break
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag.partition(" ")[0]
        if order_tag in ["g1", "sg1"]:
          grind_1_is_sell_found = True
        elif order_tag in ["g2", "sg2"]:
          grind_2_is_sell_found = True
        elif order_tag in ["g3", "sg3"]:
          grind_3_is_sell_found = True
        elif order_tag in ["g4", "sg4"]:
          grind_4_is_sell_found = True
        elif order_tag in ["g5", "sg5"]:
          grind_5_is_sell_found = True
        elif order_tag in ["g6", "sg6"]:
          grind_6_is_sell_found = True
        elif order_tag in ["d", "d1", "dd0", "ddl1", "ddl2", "dd1", "dd2", "dd3", "dd4", "dd5", "dd6"]:
          is_derisk = True
          if order_tag == "d1":
            is_derisk_1 = True
          grind_1_is_sell_found = True
          grind_2_is_sell_found = True
          grind_3_is_sell_found = True
          grind_4_is_sell_found = True
          grind_5_is_sell_found = True
          grind_6_is_sell_found = True
          rebuy_is_sell_found = True
        elif order_tag not in [
          "p",
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "dl1",
          "dl2",
          "gd1",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "gm0",
          "gmd0",
        ]:
          rebuy_is_sell_found = True
        if not is_derisk:
          start_amount = first_filled_order.safe_filled
          current_amount = 0.0
          for order2 in filled_orders:
            if order2.ft_order_side == "buy":
              current_amount += order2.safe_filled
            elif order2.ft_order_side == "sell":
              current_amount -= order2.safe_filled
            if order2 is order:
              if current_amount < (start_amount * 0.95):
                is_derisk = True
        # found sells for all modes
        if (
          rebuy_is_sell_found
          and grind_1_is_sell_found
          and grind_2_is_sell_found
          and grind_3_is_sell_found
          and grind_4_is_sell_found
          and grind_5_is_sell_found
          and grind_6_is_sell_found
        ):
          break

    # The trade already de-risked
    if is_derisk:
      return None, "", is_derisk
    if not has_order_tags and count_of_exits > 0:
      return None, "", is_derisk

    if rebuy_sub_grind_count > 0:
      rebuy_current_open_rate = rebuy_total_cost / rebuy_total_amount
      rebuy_current_grind_stake = rebuy_total_amount * exit_rate * (1 - trade_fee_close)
      rebuy_current_grind_stake_profit = rebuy_current_grind_stake - rebuy_total_cost
    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_current_grind_stake_profit = grind_1_current_grind_stake - grind_1_total_cost
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_current_grind_stake_profit = grind_2_current_grind_stake - grind_2_total_cost
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 - trade_fee_close)
      grind_3_current_grind_stake_profit = grind_3_current_grind_stake - grind_3_total_cost
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 - trade_fee_close)
      grind_4_current_grind_stake_profit = grind_4_current_grind_stake - grind_4_total_cost
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 - trade_fee_close)
      grind_5_current_grind_stake_profit = grind_5_current_grind_stake - grind_5_total_cost
    if grind_6_sub_grind_count > 0:
      grind_6_current_open_rate = grind_6_total_cost / grind_6_total_amount
      grind_6_current_grind_stake = grind_6_total_amount * exit_rate * (1 - trade_fee_close)
      grind_6_current_grind_stake_profit = grind_6_current_grind_stake - grind_6_total_cost

    num_open_grinds = (
      grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
      + grind_6_sub_grind_count
    )

    is_scalp_mode = all(c in self.long_scalp_mode_tags for c in enter_tags)

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate

    # Sell remaining if partial fill on exit
    if partial_sell:
      order = filled_exits[-1]
      sell_amount = order.safe_remaining * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        send_msg(
          f"Exit (remaining) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {order.safe_remaining} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        order_tag = "p"
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        return -ft_sell_amount, order_tag, is_derisk

    is_long_grind_entry = self.long_grind_entry(last_candle, previous_candle, slice_profit, False)

    # Rebuy
    if (not partial_sell) and (not rebuy_is_sell_found) and (rebuy_sub_grind_count < max_rebuy_sub_grinds):
      if (
        (0 <= rebuy_sub_grind_count < max_rebuy_sub_grinds)
        and (slice_profit_entry < regular_mode_rebuy_sub_thresholds[rebuy_sub_grind_count])
        and (
          (rebuy_distance_ratio if (rebuy_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_rebuy_sub_thresholds[rebuy_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=12) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_06))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_rebuy_stakes[rebuy_sub_grind_count] / stake_scale_leverage
        if buy_amount > max_stake:
          buy_amount = max_stake
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        send_msg(
          notification_msg(
            "rebuy",
            tag="r",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"Rebuy (r) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        order_tag = "r"
        return buy_amount, order_tag, is_derisk

    # Grinding g1
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_1_sub_grind_count < max_grind_1_sub_grinds):
      if (
        (
          (grind_1_distance_ratio if (grind_1_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_1_sub_thresholds[grind_1_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_lt_neg_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_lt_neg_0_03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_1_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
          grind_profit_stake = grind_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g1"
        return buy_amount, order_tag, is_derisk

    if (
      is_futures
      and has_order_tags
      and (not partial_sell)
      and slice_profit < (-0.65 / trade_leverage)
      and (grind_1_sub_grind_count < max_grind_1_sub_grinds)
    ):
      buy_amount = slice_amount * regular_mode_grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None, "", is_derisk
      grind_profit = 0.0
      grind_profit_stake = 0.0
      if grind_1_sub_grind_count > 0:
        grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
        grind_profit_stake = grind_1_current_grind_stake_profit
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="g1",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
          grind_profit_stake=grind_1_current_grind_stake_profit,
          grind_profit_pct=grind_profit,
        )
      )
      log.info(
        f"Grinding entry (g1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit} {stake_currency})"
      )
      order_tag = "g1"
      return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_1_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
      if grind_profit > (regular_mode_grind_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g1"
          for grind_entry_id in grind_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_1_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and (((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < regular_mode_grind_1_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg1"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g2
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_2_sub_grind_count < max_grind_2_sub_grinds):
      if (
        (
          (grind_2_distance_ratio if (grind_2_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_2_sub_thresholds[grind_2_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_lt_neg_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_lt_neg_0_03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_2_stakes[grind_2_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_2_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
          grind_profit_stake = grind_2_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g2",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g2) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g2"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_2_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
      if grind_profit > (regular_mode_grind_2_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g2"
          for grind_entry_id in grind_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_2_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and (((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < regular_mode_grind_2_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg2"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g3
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_3_sub_grind_count < max_grind_3_sub_grinds):
      if (
        (
          (grind_3_distance_ratio if (grind_3_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_3_sub_thresholds[grind_3_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_lt_neg_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_lt_neg_0_03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_3_stakes[grind_3_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_3_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
          grind_profit_stake = grind_3_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g3",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_3_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g3) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g3"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_3_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
      if grind_profit > (regular_mode_grind_3_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g3",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g3"
          for grind_entry_id in grind_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_3_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and (((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < regular_mode_grind_3_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg3",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg3"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g4
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_4_sub_grind_count < max_grind_4_sub_grinds):
      if (
        (
          (grind_4_distance_ratio if (grind_4_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_4_sub_thresholds[grind_4_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_lt_neg_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_lt_neg_0_03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_4_stakes[grind_4_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_4_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
          grind_profit_stake = grind_4_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g4",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_4_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g4) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g4"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_4_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
      if grind_profit > (regular_mode_grind_4_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_4_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g4",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g4"
          for grind_entry_id in grind_4_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_4_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and (((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < regular_mode_grind_4_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg4",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg4"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g5
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_5_sub_grind_count < max_grind_5_sub_grinds):
      if (
        (
          (grind_5_distance_ratio if (grind_5_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_5_sub_thresholds[grind_5_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_lt_neg_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_lt_neg_0_03))
        and is_long_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_5_stakes[grind_5_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_5_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
          grind_profit_stake = grind_5_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g5",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_5_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g5) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g5"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_5_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
      if grind_profit > (regular_mode_grind_5_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_5_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g5",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g5"
          for grind_entry_id in grind_5_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_5_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and (((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < regular_mode_grind_5_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg5",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg5"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g6
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_6_sub_grind_count < max_grind_6_sub_grinds):
      if (
        (
          (grind_6_distance_ratio if (grind_6_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_6_sub_thresholds[grind_6_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_lt_neg_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_lt_neg_0_06)
        )
        # and ((num_open_grinds == 0) or (slice_profit_lt_neg_0_03))
        and (is_long_grind_entry)
      ):
        buy_amount = slice_amount * regular_mode_grind_6_stakes[grind_6_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_6_sub_grind_count > 0:
          grind_profit = (exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
          grind_profit_stake = grind_6_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g6",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_6_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g6) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_6_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g6"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_6_sub_grind_count > 0:
      grind_profit = (exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
      if grind_profit > (regular_mode_grind_6_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_6_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g6",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_6_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g6"
          for grind_entry_id in grind_6_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_6_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and (((exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate) < regular_mode_grind_6_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_6_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_6_current_open_rate > 0.0:
          grind_profit = (
            ((exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate)
            if grind_6_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg6",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_6_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg6"
        for grind_entry_id in grind_6_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # De-risk
    if (
      self.derisk_enable
      and (
        profit_stake
        < (
          slice_amount
          * (
            (self.regular_mode_derisk_futures if is_futures else self.regular_mode_derisk_spot)
            if (is_backtest or trade_open_date >= datetime(2024, 9, 13))
            else (self.regular_mode_derisk_futures_old if is_futures else self.regular_mode_derisk_spot_old)
          )
          / trade_leverage
        )
      )
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="d",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "d", is_derisk

    # De-risk level 1
    if (
      self.derisk_enable
      and has_order_tags
      and not is_derisk_1
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
      and profit_stake
      < (
        slice_amount
        * (
          (self.regular_mode_derisk_1_scalp_mode_futures if is_futures else self.regular_mode_derisk_1_scalp_mode_spot)
          if is_scalp_mode
          else (
            (self.regular_mode_derisk_1_futures if is_futures else self.regular_mode_derisk_1_spot)
            if (is_backtest or trade_open_date >= datetime(2024, 9, 13))
            else (self.regular_mode_derisk_1_futures_old if is_futures else self.regular_mode_derisk_1_spot_old)
          )
        )
        / trade_leverage
      )
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="d1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk (d1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "d1", is_derisk

    return None, "", is_derisk

  # Long Rebuy Adjust Trade Position
  # ---------------------------------------------------------------------------------------------
  def long_rebuy_adjust_trade_position(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ) -> Optional[float]:
    # Stake limits and rebuy amounts are margin, before leverage.
    config = self.config

    dp = self.dp
    is_futures_mode = self.is_futures_mode
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_leverage = trade.leverage

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_entries = trade.nr_of_successful_entries
    count_of_exits = trade.nr_of_successful_exits

    if count_of_entries == 0:
      return None

    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]
    last_filled_entry = filled_entries[-1]

    has_order_tags = hasattr(first_filled_order, "ft_order_tag")

    # The first exit is de-risk (providing the trade is still open)
    # Preserve the existing grind handoff budget after de-risk.
    if (count_of_exits > 0) and (filled_exits[0].ft_order_tag == "derisk_level_3"):
      if len(df) < 2:
        return None
      return self.long_grind_adjust_trade_position_v2(
        trade,
        enter_tags,
        current_time,
        current_rate,
        current_profit,
        min_stake,
        max_stake / trade_leverage,
        current_entry_rate,
        current_exit_rate,
        current_entry_profit,
        current_exit_profit,
      )

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    slice_amount = filled_entries[0].safe_filled * filled_entries[0].safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    if count_of_exits > 0:
      last_filled_exit_price = filled_exits[-1].safe_price
      slice_profit_exit = (exit_rate - last_filled_exit_price) / last_filled_exit_price
    else:
      slice_profit_exit = 0.0

    current_stake_amount = trade_amount * current_rate
    stake_scale_leverage = trade_leverage if is_futures_mode else 1.0

    rebuy_mode_stakes = self.rebuy_mode_stakes_futures if is_futures_mode else self.rebuy_mode_stakes_spot
    max_sub_grinds = len(rebuy_mode_stakes)
    rebuy_mode_sub_thresholds = (
      self.rebuy_mode_thresholds_futures if is_futures_mode else self.rebuy_mode_thresholds_spot
    )
    partial_sell = False
    sub_grind_count = 0
    total_amount = 0.0
    total_cost = 0.0
    current_open_rate = 0.0
    current_grind_stake = 0.0
    current_grind_stake_profit = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "buy") and (order is not first_filled_order):
        sub_grind_count += 1
        total_amount += order.safe_filled
        total_cost += order.safe_filled * order.safe_price
      elif order.ft_order_side == "sell":
        if (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
        break
    if sub_grind_count > 0:
      current_open_rate = total_cost / total_amount
      current_grind_stake = total_amount * exit_rate * (1 - trade.fee_close)
      current_grind_stake_profit = current_grind_stake - total_cost

    if (len(df) >= 2) and (not partial_sell) and (sub_grind_count < max_sub_grinds):
      last_candle = df.iloc[-1]
      previous_candle = df.iloc[-2]
      if (
        ((0 <= sub_grind_count < max_sub_grinds) and (slice_profit_entry < rebuy_mode_sub_thresholds[sub_grind_count]))
        # and (
        #   (last_candle["close"] > (last_candle["close_max_12"] * 0.94))
        #   and (last_candle["close"] > (last_candle["close_max_24"] * 0.92))
        #   and (last_candle["close"] > (last_candle["close_max_48"] * 0.90))
        #   and (last_candle["close"] > (last_candle["high_max_24_1h"] * 0.88))
        #   and (last_candle["close"] > (last_candle["high_max_48_1h"] * 0.86))
        #   and (last_candle["btc_pct_close_max_72_5m"] < 0.03)
        #   and (last_candle["btc_pct_close_max_24_5m"] < 0.03)
        # )
        and (
          (last_candle["RSI_3"] > 10.0)
          and (last_candle["RSI_3_15m"] > 10.0)
          # and (last_candle["RSI_3_1h"] > 10.0)
          # and (last_candle["RSI_3_4h"] > 10.0)
          and (last_candle["RSI_14"] < 40.0)
          and (last_candle["ROC_2"] > -0.0)
          and (last_candle["close"] < (last_candle["EMA_26"] * 0.988))
        )
      ):
        buy_amount = slice_amount * rebuy_mode_stakes[sub_grind_count] / trade_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount <= max_stake:
          dp.send_msg(
            self.notification_msg(
              "rebuy",
              tag="r",
              pair=trade_pair,
              rate=current_rate,
              stake_amount=buy_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=config["stake_currency"],
            )
          )
          log.info(
            f"Rebuy (r) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
          )
          if has_order_tags:
            return buy_amount, "r"
          else:
            return buy_amount

    if self.derisk_enable and (
      profit_stake
      < (
        slice_amount * (self.rebuy_mode_derisk_futures if is_futures_mode else self.rebuy_mode_derisk_spot)
        # / (trade.leverage if self.is_futures_mode else 1.0)
      )
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade.stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        dp.send_msg(
          f"❌​​ ​**Rebuy De-risk:** `Level 3`\n"
          f"🪙​ **Pair:** `{trade_pair}`\n"
          f"〽️​ **Rate:** `{exit_rate}`\n"
          f"💰 **Stake amount:** `{sell_amount}`\n"
          f"💵​ **Profit (stake):** `{profit_stake}`\n"
          f"💸 **Profit (percent):** `{(profit_ratio * 100.0):.2f}%`"
        )
        log.info(
          f"Rebuy De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        if has_order_tags:
          return -ft_sell_amount, "derisk_level_3"
        else:
          return -ft_sell_amount

    return None

  # Long Rebuy Adjust Trade Position v3
  # ---------------------------------------------------------------------------------------------
  def long_rebuy_adjust_trade_position_v3(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ) -> Optional[float]:
    # Stake limits and rebuy amounts are margin, before leverage.
    dp = self.dp
    is_futures_mode = self.is_futures_mode
    config = self.config
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_leverage = trade.leverage

    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_entries = trade.nr_of_successful_entries
    count_of_exits = trade.nr_of_successful_exits

    if count_of_entries == 0:
      return None

    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]
    last_filled_entry = filled_entries[-1]

    has_order_tags = hasattr(first_filled_order, "ft_order_tag")

    # The first exit is de-risk (providing the trade is still open)
    # Preserve the existing grind handoff budget after de-risk.
    if (count_of_exits > 0) and (filled_exits[0].ft_order_tag == "derisk_level_3"):
      return self.long_grind_adjust_trade_position_v3(
        trade,
        enter_tags,
        current_time,
        current_rate,
        current_profit,
        min_stake,
        max_stake / trade_leverage,
        current_entry_rate,
        current_exit_rate,
        current_entry_profit,
        current_exit_profit,
      )

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    slice_amount = filled_entries[0].safe_filled * filled_entries[0].safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    current_stake_amount = trade_amount * current_rate
    stake_scale_leverage = trade_leverage if is_futures_mode else 1.0

    if is_futures_mode:
      rebuy_mode_stakes = self.system_v3_rebuy_mode_stakes_futures
      rebuy_mode_sub_thresholds = self.system_v3_rebuy_mode_thresholds_futures
    else:
      rebuy_mode_stakes = self.system_v3_rebuy_mode_stakes_spot
      rebuy_mode_sub_thresholds = self.system_v3_rebuy_mode_thresholds_spot
    max_sub_grinds = len(rebuy_mode_stakes)
    partial_sell = False
    sub_grind_count = 0
    total_amount = 0.0
    total_cost = 0.0
    current_open_rate = 0.0
    current_grind_stake = 0.0
    current_grind_stake_profit = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "buy") and (order is not first_filled_order):
        sub_grind_count += 1
        total_amount += order.safe_filled
        total_cost += order.safe_filled * order.safe_price
      elif order.ft_order_side == "sell":
        if (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
        break
    if sub_grind_count > 0:
      current_open_rate = total_cost / total_amount
      current_grind_stake = total_amount * exit_rate * (1 - trade.fee_close)
      current_grind_stake_profit = current_grind_stake - total_cost
    if (not partial_sell) and (sub_grind_count < max_sub_grinds):
      df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
      if len(df) >= 1:
        last_candle = df.iloc[-1]
        if (
          (
            (0 <= sub_grind_count < max_sub_grinds)
            and (slice_profit_entry < rebuy_mode_sub_thresholds[sub_grind_count])
          )
          and (last_candle["protections_long_global"] == True)
          and (
            (last_candle["RSI_3"] > 10.0)
            and (last_candle["RSI_3_15m"] > 10.0)
            and (last_candle["AROONU_14"] < 30.0)
            and (last_candle["AROONU_14_15m"] < 30.0)
            # and (last_candle["ROC_9"] > -5.0)
            # and (last_candle["ROC_9_15m"] > -5.0)
            # and (last_candle["close"] > (last_candle["close_max_12"] * 0.99))
            and (last_candle["close"] < (last_candle["EMA_26"] * 0.988))
          )
        ):
          stake_currency = config["stake_currency"]
          stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
          send_notifications = not self.is_backtest_mode()
          buy_amount = slice_amount * rebuy_mode_stakes[sub_grind_count] / trade_leverage
          if buy_amount < (min_stake * 1.5):
            buy_amount = min_stake * 1.5
          if buy_amount <= max_stake:
            if send_notifications:
              dp.send_msg(
                self.notification_msg(
                  "rebuy",
                  tag="r",
                  pair=trade_pair,
                  rate=current_rate,
                  stake_amount=buy_amount,
                  profit_stake=profit_stake,
                  profit_ratio=profit_ratio,
                  stake_currency=stake_currency,
                )
              )
            log.info(
              f"Rebuy (r) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
            )
            if has_order_tags:
              return buy_amount, "r"
            else:
              return buy_amount

    if self.derisk_enable and (
      profit_stake
      < (
        slice_amount
        * (self.system_v3_rebuy_mode_derisk_futures if is_futures_mode else self.system_v3_rebuy_mode_derisk_spot)
      )
      / trade_leverage
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade.stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        stake_currency = config["stake_currency"]
        stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
        send_notifications = not self.is_backtest_mode()
        grind_profit = 0.0
        if send_notifications:
          dp.send_msg(
            f"❌​​ ​**Rebuy De-risk:** `Level 3`\n"
            f"🪙​ **Pair:** `{trade_pair}`\n"
            f"〽️​ **Rate:** `{exit_rate}`\n"
            f"💰 **Stake amount:** `{sell_amount:{stake_fmt}}`\n"
            f"💵​ **Profit (stake):** `{profit_stake:{stake_fmt}}`\n"
            f"💸 **Profit (percent):** `{(profit_ratio * 100.0):.2f}%`"
          )
        log.info(
          f"Rebuy De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        if has_order_tags:
          return -ft_sell_amount, "derisk_level_3"
        else:
          return -ft_sell_amount

    return None

  ###############################################################################################

  # LONG GRIND FUNCTIONS ENDS HERE

  ###############################################################################################

  #   ______   __    __   ______   _______  ________         ______   ______  _______   ________
  #  /      \ |  \  |  \ /      \ |       \|        \       /      \ |      \|       \ |        \
  # |  $$$$$$\| $$  | $$|  $$$$$$\| $$$$$$$\\$$$$$$$$      |  $$$$$$\ \$$$$$$| $$$$$$$\| $$$$$$$$
  # | $$___\$$| $$__| $$| $$  | $$| $$__| $$  | $$         | $$___\$$  | $$  | $$  | $$| $$__
  #  \$$    \ | $$    $$| $$  | $$| $$    $$  | $$          \$$    \   | $$  | $$  | $$| $$  \
  #  _\$$$$$$\| $$$$$$$$| $$  | $$| $$$$$$$\  | $$          _\$$$$$$\  | $$  | $$  | $$| $$$$$
  # |  \__| $$| $$  | $$| $$__/ $$| $$  | $$  | $$         |  \__| $$ _| $$_ | $$__/ $$| $$_____
  #  \$$    $$| $$  | $$ \$$    $$| $$  | $$  | $$          \$$    $$|   $$ \| $$    $$| $$     \
  #   \$$$$$$  \$$   \$$  \$$$$$$  \$$   \$$   \$$           \$$$$$$  \$$$$$$ \$$$$$$$  \$$$$$$$$
  #

  # Short Side Functions for handling short orders
  # ---------------------------------------------------------------------------------------------

  ###############################################################################################

  # SHORT EXIT FUNCTIONS STARTS HERE

  ###############################################################################################

  #   ______  __    __  ______  _______ ________        ________ __    __ ______ ________
  #  /      \|  \  |  \/      \|       |        \      |        |  \  |  |      |        \
  # |  $$$$$$| $$  | $|  $$$$$$| $$$$$$$\$$$$$$$$      | $$$$$$$| $$  | $$\$$$$$$\$$$$$$$$
  # | $$___\$| $$__| $| $$  | $| $$__| $$ | $$         | $$__    \$$\/  $$ | $$    | $$
  #  \$$    \| $$    $| $$  | $| $$    $$ | $$         | $$  \    >$$  $$  | $$    | $$
  #  _\$$$$$$| $$$$$$$| $$  | $| $$$$$$$\ | $$         | $$$$$   /  $$$$\  | $$    | $$
  # |  \__| $| $$  | $| $$__/ $| $$  | $$ | $$         | $$_____|  $$ \$$\_| $$_   | $$
  #  \$$    $| $$  | $$\$$    $| $$  | $$ | $$         | $$     | $$  | $|   $$ \  | $$
  #   \$$$$$$ \$$   \$$ \$$$$$$ \$$   \$$  \$$          \$$$$$$$$\$$   \$$\$$$$$$   \$$
  #

  # Short Exit Normal
  # ---------------------------------------------------------------------------------------------
  def short_exit_normal(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_normal_mode_name

    sell = False

    # if the profit is negative skip checking these
    if profit_init_ratio > 0.0:
      # Original sell signals
      sell, signal_name = self.short_exit_signals(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

      # Main sell signals
      if not sell:
        sell, signal_name = self.short_exit_main(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Williams %R based sells
      if not sell:
        sell, signal_name = self.short_exit_williams_r(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Downtrend/descending based sells
      if not sell:
        sell, signal_name = self.short_exit_dec(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

    # Stoplosses
    if not sell:
      sell, signal_name = self.short_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      previous_sell_reason = ""
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
        previous_sell_reason = target_data["sell_reason"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ] and (
        previous_sell_reason
        not in [
          f"exit_{mode_name}_stoploss_doom",
          f"exit_{mode_name}_stoploss_u_e",
        ]
      ):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_normal

    return False, None

  # Short Exit Pump
  # ---------------------------------------------------------------------------------------------
  def short_exit_pump(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_pump_mode_name

    sell = False

    # if the profit is negative skip checking these
    if profit_init_ratio > 0.0:
      # Original sell signals
      sell, signal_name = self.short_exit_signals(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

      # Main sell signals
      if not sell:
        sell, signal_name = self.short_exit_main(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Williams %R based sells
      if not sell:
        sell, signal_name = self.short_exit_williams_r(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Downtrend/descending based sells
      if not sell:
        sell, signal_name = self.short_exit_dec(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

    # Stoplosses
    if not sell:
      sell, signal_name = self.short_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ]:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_pump

    return False, None

  # Short Exit Quick
  # ---------------------------------------------------------------------------------------------
  def short_exit_quick(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_quick_mode_name

    sell = False

    # if the profit is negative skip checking these
    if profit_init_ratio > 0.0:
      # Original sell signals
      sell, signal_name = self.short_exit_signals(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

      # Main sell signals
      if not sell:
        sell, signal_name = self.short_exit_main(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Williams %R based sells
      if not sell:
        sell, signal_name = self.short_exit_williams_r(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Downtrend/descending based sells
      if not sell:
        sell, signal_name = self.short_exit_dec(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

    # Stoplosses
    if not sell:
      sell, signal_name = self.short_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Extra sell logic
    if not sell:
      last_rsi_14 = last_candle["RSI_14"]
      last_rsi_3 = last_candle["RSI_3"]
      last_rsi_3_15m = last_candle["RSI_3_15m"]
      last_willr_14 = last_candle["WILLR_14"]
      if (0.09 >= profit_init_ratio > 0.02) and (last_rsi_14 < 22.0):
        sell, signal_name = True, f"exit_{mode_name}_q_1"

      elif (0.09 >= profit_init_ratio > 0.02) and (last_candle["MFI_14"] < 16.0):
        sell, signal_name = True, f"exit_{mode_name}_q_2"

      elif (0.09 >= profit_init_ratio > 0.02) and (last_willr_14 <= -99.9):
        sell, signal_name = True, f"exit_{mode_name}_q_3"

      elif (
        (0.09 >= profit_init_ratio > 0.02)
        and (last_rsi_14 <= 18.0)
        and (last_rsi_3 < 10.0)
        and (last_rsi_3_15m < 10.0)
      ):
        sell, signal_name = True, f"exit_{mode_name}_q_4"
      elif (0.09 >= profit_init_ratio > 0.02) and (last_rsi_3_15m < 4.0):
        sell, signal_name = True, f"exit_{mode_name}_q_5"
      elif (0.09 >= profit_init_ratio > 0.02) and (last_rsi_3 < 15.0) and (last_rsi_3_15m < 15.0):
        sell, signal_name = True, f"exit_{mode_name}_q_6"
      elif (0.09 >= profit_init_ratio > 0.02) and (last_rsi_3 < 10.0) and (last_rsi_3_15m < 20.0):
        sell, signal_name = True, f"exit_{mode_name}_q_7"
      elif (0.09 >= profit_init_ratio > 0.02) and (last_rsi_3 < 8.0) and (last_rsi_3_15m < 25.0):
        sell, signal_name = True, f"exit_{mode_name}_q_8"
      elif (0.09 >= profit_init_ratio > 0.02) and (last_rsi_3 < 6.0) and (last_rsi_3_15m < 30.0):
        sell, signal_name = True, f"exit_{mode_name}_q_9"
      elif (0.09 >= profit_init_ratio > 0.02) and (last_rsi_3 < 1.0):
        sell, signal_name = True, f"exit_{mode_name}_q_10"

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      previous_sell_reason = ""
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
        previous_sell_reason = target_data["sell_reason"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ] and (
        previous_sell_reason
        not in [
          f"exit_{mode_name}_stoploss_doom",
          f"exit_{mode_name}_stoploss_u_e",
        ]
      ):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_quick

    return False, None

  # Short Exit Rebuy
  # ---------------------------------------------------------------------------------------------
  def short_exit_rebuy(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode
    trade_leverage = trade.leverage

    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_rebuy_mode_name

    is_backtest = self.is_backtest_mode()
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    sell = False

    # Original sell signals
    sell, signal_name = self.short_exit_signals(
      mode_name,
      profit_current_stake_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Main sell signals
    if not sell:
      sell, signal_name = self.short_exit_main(
        mode_name,
        profit_current_stake_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Williams %R based sells
    if not sell:
      sell, signal_name = self.short_exit_williams_r(
        mode_name,
        profit_current_stake_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Downtrend/descending based sells
    if not sell:
      sell, signal_name = self.short_exit_dec(
        mode_name,
        profit_current_stake_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Stoplosses
    if not sell:
      entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
      if is_system_v3_2:
        if self.system_v3_2_stops_enable and profit_stake < -(
          entry_cost
          * (
            self.system_v3_2_stop_threshold_futures_rebuy
            if is_futures_mode
            else self.system_v3_2_stop_threshold_spot_rebuy
          )
          / trade_leverage
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      elif is_system_v3_1:
        if profit_stake < -(
          entry_cost
          * (
            self.system_v3_1_stop_threshold_futures_rebuy
            if is_futures_mode
            else self.system_v3_1_stop_threshold_spot_rebuy
          )
          / trade_leverage
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      elif is_system_v3:
        if profit_stake < -(
          entry_cost
          * (
            self.system_v3_stop_threshold_futures_rebuy
            if is_futures_mode
            else self.system_v3_stop_threshold_spot_rebuy
          )
          / trade_leverage
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      else:
        if (
          profit_stake
          < -(
            entry_cost
            * (self.stop_threshold_futures_rebuy if is_futures_mode else self.stop_threshold_spot_rebuy)
            / trade_leverage
          )
          # temporary
          and (is_backtest or trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 9, 13))
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ]:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_rebuy

    return False, None

  # Short Exit High Profit
  # ---------------------------------------------------------------------------------------------
  def short_exit_high_profit(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_high_profit_mode_name

    sell = False

    # Original sell signals
    sell, signal_name = self.short_exit_signals(
      mode_name,
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Main sell signals
    if not sell:
      sell, signal_name = self.short_exit_main(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Williams %R based sells
    if not sell:
      sell, signal_name = self.short_exit_williams_r(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Stoplosses
    if not sell:
      sell, signal_name = self.short_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )
    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ]:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.03:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      # f"exit_{self.short_high_profit_mode_name}_stoploss_doom",
      # f"exit_{self.short_high_profit_mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_high_profit

    return False, None

  # Short Exit Rapid
  # ---------------------------------------------------------------------------------------------
  def short_exit_rapid(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode
    stops_enable = self.stops_enable
    trade_leverage = trade.leverage

    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_rapid_mode_name

    is_backtest = self.is_backtest_mode()
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    sell = False
    signal_name = None

    # if the profit is negative skip checking these
    if profit_init_ratio > 0.0:
      # Original sell signals
      sell, signal_name = self.short_exit_signals(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

      # Main sell signals
      if not sell:
        sell, signal_name = self.short_exit_main(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Williams %R based sells
      if not sell:
        sell, signal_name = self.short_exit_williams_r(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

      # Downtrend/descending based sells
      if not sell:
        sell, signal_name = self.short_exit_dec(
          mode_name,
          profit_init_ratio,
          max_profit,
          max_loss,
          last_candle,
          previous_candle_1,
          trade,
          current_time,
          enter_tags,
        )

    # Extra exit logic
    if not sell:
      last_rsi_14 = last_candle["RSI_14"]
      last_rsi_3 = last_candle["RSI_3"]
      last_rsi_3_15m = last_candle["RSI_3_15m"]
      last_willr_14 = last_candle["WILLR_14"]
      if (0.09 >= profit_init_ratio > 0.005) and (last_rsi_14 < 22.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_1"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_candle["MFI_14"] < 16.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_2"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_willr_14 <= -99.9):
        sell, signal_name = True, f"exit_{mode_name}_rpd_3"
      elif (
        (0.09 >= profit_init_ratio > 0.005)
        and (last_rsi_14 <= 28.0)
        and (last_rsi_3 < 10.0)
        and (last_rsi_3_15m < 10.0)
      ):
        sell, signal_name = True, f"exit_{mode_name}_rpd_4"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_rsi_3_15m < 4.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_5"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_rsi_3 < 15.0) and (last_rsi_3_15m < 15.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_6"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_rsi_3 < 10.0) and (last_rsi_3_15m < 20.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_7"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_rsi_3 < 8.0) and (last_rsi_3_15m < 25.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_8"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_rsi_3 < 6.0) and (last_rsi_3_15m < 30.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_9"
      elif (0.09 >= profit_init_ratio > 0.005) and (last_rsi_3 < 1.0):
        sell, signal_name = True, f"exit_{mode_name}_rpd_10"

      entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
      if is_system_v3_2:
        # Stoplosses
        if self.system_v3_2_stops_enable and (
          profit_stake
          < -(
            entry_cost
            * (
              self.system_v3_2_stop_threshold_rapid_futures
              if is_futures_mode
              else self.system_v3_2_stop_threshold_rapid_spot
            )
            / trade_leverage
          )
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      elif is_system_v3_1:
        # Stoplosses
        if stops_enable and (
          profit_stake
          < -(
            entry_cost
            * (
              self.system_v3_1_stop_threshold_rapid_futures
              if is_futures_mode
              else self.system_v3_1_stop_threshold_rapid_spot
            )
            / trade_leverage
          )
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      elif is_system_v3:
        # Stoplosses
        if stops_enable and (
          profit_stake
          < -(
            entry_cost
            * (
              self.system_v3_stop_threshold_rapid_futures
              if is_futures_mode
              else self.system_v3_stop_threshold_rapid_spot
            )
            / trade_leverage
          )
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      else:
        # Stoplosses
        if (
          (
            stops_enable
            and (
              profit_stake
              < -(
                entry_cost * (self.stop_threshold_rapid_futures if is_futures_mode else self.stop_threshold_rapid_spot)
              )
            )
          )
          # temporary
          and (is_backtest or trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 9, 13))
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.001):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      previous_sell_reason = ""
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
        previous_sell_reason = target_data["sell_reason"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ] and (
        previous_sell_reason
        not in [
          f"exit_{mode_name}_stoploss_doom",
          f"exit_{mode_name}_stoploss_u_e",
        ]
      ):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_rapid

    return False, None

  # Short Exit Grind
  # ---------------------------------------------------------------------------------------------
  def short_exit_grind(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    if profit_init_ratio > 0.25:
      return True, f"exit_{self.short_grind_mode_name}_g"

    #  Here ends exit signal conditions for short_exit_grind

    return False, None

  # Short Exit Top Coins
  # ---------------------------------------------------------------------------------------------
  def short_exit_top_coins(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_top_coins_mode_name

    sell = False

    # Original sell signals
    sell, signal_name = self.short_exit_signals(
      mode_name,
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Main sell signals
    if not sell:
      sell, signal_name = self.short_exit_main(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Williams %R based sells
    if not sell:
      sell, signal_name = self.short_exit_williams_r(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Downtrend/descending based sells
    if not sell:
      sell, signal_name = self.short_exit_dec(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Stoplosses
    if not sell:
      sell, signal_name = self.short_exit_stoploss(
        mode_name,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        max_profit,
        max_loss,
        filled_orders,
        filled_entries,
        filled_exits,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      previous_sell_reason = ""
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
        previous_sell_reason = target_data["sell_reason"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ] and (
        previous_sell_reason
        not in [
          f"exit_{mode_name}_stoploss_doom",
          f"exit_{mode_name}_stoploss_u_e",
        ]
      ):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_top_coins

    return False, None

  # Short Exit Scalp
  # ---------------------------------------------------------------------------------------------
  def short_exit_scalp(
    self,
    pair: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    enter_tags,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode
    trade_leverage = trade.leverage

    mark_profit_target = self.mark_profit_target
    set_profit_target = self._set_profit_target
    exit_profit_target = self.exit_profit_target

    mode_name = self.short_scalp_mode_name

    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    sell = False

    # Original sell signals
    sell, signal_name = self.short_exit_signals(
      mode_name,
      profit_init_ratio,
      max_profit,
      max_loss,
      last_candle,
      previous_candle_1,
      trade,
      current_time,
      enter_tags,
    )

    # Main sell signals
    if not sell:
      sell, signal_name = self.short_exit_main(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Williams %R based sells
    if not sell:
      sell, signal_name = self.short_exit_williams_r(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Downtrend/descending based sells
    if not sell:
      sell, signal_name = self.short_exit_dec(
        mode_name,
        profit_init_ratio,
        max_profit,
        max_loss,
        last_candle,
        previous_candle_1,
        trade,
        current_time,
        enter_tags,
      )

    # Extra exit logic
    if not sell:
      entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
      if is_system_v3_2:
        # Stoplosses
        if self.system_v3_2_stops_enable and (
          profit_stake
          < -(
            entry_cost
            * (
              self.system_v3_2_stop_threshold_scalp_futures
              if is_futures_mode
              else self.system_v3_2_stop_threshold_scalp_spot
            )
            / trade_leverage
          )
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      elif is_system_v3_1:
        # Stoplosses
        if profit_stake < -(
          entry_cost
          * (
            self.system_v3_1_stop_threshold_scalp_futures
            if is_futures_mode
            else self.system_v3_1_stop_threshold_scalp_spot
          )
          / trade_leverage
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      elif is_system_v3:
        # Stoplosses
        if profit_stake < -(
          entry_cost
          * (
            self.system_v3_stop_threshold_scalp_futures
            if is_futures_mode
            else self.system_v3_stop_threshold_scalp_spot
          )
          / trade_leverage
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"
      else:
        # Stoplosses
        if profit_stake < -(
          entry_cost * (self.stop_threshold_scalp_futures if is_futures_mode else self.stop_threshold_scalp_spot)
          # / (trade.leverage if self.is_futures_mode else 1.0)
        ):
          sell, signal_name = True, f"exit_{mode_name}_stoploss_doom"

    cache = self.target_profit_cache
    cache_data = cache.data if cache is not None else None
    profit_target_get = cache_data.get if cache_data is not None else None

    # Profit Target Signal
    # Check if pair exist on target_profit_cache
    target_data = profit_target_get(pair) if profit_target_get is not None else None
    if target_data is not None:
      previous_rate = target_data["rate"]
      previous_profit = target_data["profit"]
      previous_sell_reason = target_data["sell_reason"]
      previous_time_profit_reached = datetime.fromisoformat(target_data["time_profit_reached"])

      sell_max, signal_name_max = exit_profit_target(
        mode_name,
        pair,
        trade,
        current_time,
        current_rate,
        profit_stake,
        profit_ratio,
        profit_current_stake_ratio,
        profit_init_ratio,
        last_candle,
        previous_candle_1,
        previous_rate,
        previous_profit,
        previous_sell_reason,
        previous_time_profit_reached,
        enter_tags,
      )
      if sell_max and signal_name_max is not None:
        return True, f"{signal_name_max}_m"
      if previous_sell_reason == f"exit_{mode_name}_stoploss_u_e":
        if profit_ratio > (previous_profit + 0.005):
          mark_pair, mark_signal = mark_profit_target(
            mode_name,
            pair,
            True,
            previous_sell_reason,
            trade,
            current_time,
            current_rate,
            profit_ratio,
            last_candle,
            previous_candle_1,
          )
          if mark_pair:
            set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
      elif (profit_init_ratio > (previous_profit + 0.001)) and (
        previous_sell_reason != f"exit_{mode_name}_stoploss_doom"
      ):
        # Update the target, raise it.
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          True,
          previous_sell_reason,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    # Add the pair to the list, if a sell triggered and conditions met
    if sell and signal_name is not None:
      previous_profit = None
      target_data = profit_target_get(pair) if profit_target_get is not None else None
      if target_data is not None:
        previous_profit = target_data["profit"]
      if signal_name in [
        f"exit_{mode_name}_stoploss_doom",
        f"exit_{mode_name}_stoploss_u_e",
      ]:
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
      elif (previous_profit is None) or (previous_profit < profit_init_ratio):
        mark_pair, mark_signal = mark_profit_target(
          mode_name,
          pair,
          sell,
          signal_name,
          trade,
          current_time,
          current_rate,
          profit_init_ratio,
          last_candle,
          previous_candle_1,
        )
        if mark_pair:
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)
        else:
          # Just sell it, without maximize
          return True, f"{signal_name}"
    else:
      if profit_init_ratio >= 0.005:
        previous_profit = None
        target_data = profit_target_get(pair) if profit_target_get is not None else None
        if target_data is not None:
          previous_profit = target_data["profit"]
        if (previous_profit is None) or (previous_profit < profit_init_ratio):
          mark_signal = f"exit_profit_{mode_name}_max"
          set_profit_target(pair, mark_signal, current_rate, profit_init_ratio, current_time)

    if signal_name not in [
      f"exit_profit_{mode_name}_max",
      f"exit_{mode_name}_stoploss_doom",
      f"exit_{mode_name}_stoploss_u_e",
    ]:
      if sell and (signal_name is not None):
        return True, f"{signal_name}"

    #  Here ends exit signal conditions for short_exit_derisk

    return False, None

  # Short Exit Signals
  # ---------------------------------------------------------------------------------------------
  def short_exit_signals(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_rsi_14 = last_candle["RSI_14"]
    last_close = last_candle["close"]
    last_ema_200 = last_candle["EMA_200"]
    last_ema_50 = last_candle["EMA_50"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_bbl_20 = last_candle["BBL_20_2.0"]
    last_bbl_20_1h = last_candle["BBL_20_2.0_1h"]
    bb_below_count = last_candle["BB_BELOW_COUNT"]
    current_profit_gt_0_01 = current_profit > 0.01

    # Sell signal 1
    if (last_rsi_14 < 16.0) and (last_close < last_bbl_20) and bb_below_count >= 5:
      if last_close < last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_1_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_1_2_1"

    # Sell signal 2
    elif (last_rsi_14 < 14.0) and (last_close < last_bbl_20) and bb_below_count >= 3:
      if last_close < last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_2_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_2_2_1"

    # Sell signal 3
    elif last_rsi_14 < 12.0:
      if last_close < last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_3_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_3_2_1"

    # Sell signal 4
    elif (last_rsi_14 < 16.0) and (last_rsi_14_1h < 20.0):
      if last_close < last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_4_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_4_2_1"

    # Sell signal 6
    elif (last_close > last_ema_200) and (last_close < last_ema_50) and (last_rsi_14 < 21.0):
      if current_profit_gt_0_01:
        return True, f"exit_{mode_name}_6_1"

    # # Sell signal 7
    # elif (last_candle["RSI_14_1h"] < 21.0) and (last_candle["crossed_above_EMA_12_26"]):
    #   if last_candle["close"] < last_candle["EMA_200"]:
    #     if current_profit_gt_0_01:
    #       return True, f"exit_{mode_name}_7_1_1"
    #   else:
    #     if current_profit_gt_0_01:
    #       return True, f"exit_{mode_name}_7_2_1"

    # Sell signal 8
    elif last_close < last_bbl_20_1h * 0.86:
      if last_close < last_ema_200:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_8_1_1"
      else:
        if current_profit_gt_0_01:
          return True, f"exit_{mode_name}_8_2_1"

    #  Here ends exit signal conditions for short_exit_signals

    return False, None

  # Short Exit Main
  # ---------------------------------------------------------------------------------------------
  def short_exit_main(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_rsi_14 = last_candle["RSI_14"]
    last_close = last_candle["close"]
    last_ema_200 = last_candle["EMA_200"]

    if last_close < last_ema_200:
      if 0.01 > current_profit >= 0.001:
        if last_rsi_14 > 90.0:
          return True, f"exit_{mode_name}_o_0"
      elif 0.02 > current_profit >= 0.01:
        if last_rsi_14 > 72.0:
          return True, f"exit_{mode_name}_o_1"
      elif 0.03 > current_profit >= 0.02:
        if last_rsi_14 > 70.0:
          return True, f"exit_{mode_name}_o_2"
      elif 0.04 > current_profit >= 0.03:
        if last_rsi_14 > 68.0:
          return True, f"exit_{mode_name}_o_3"
      elif 0.05 > current_profit >= 0.04:
        if last_rsi_14 > 66.0:
          return True, f"exit_{mode_name}_o_4"
      elif 0.06 > current_profit >= 0.05:
        if last_rsi_14 > 64.0:
          return True, f"exit_{mode_name}_o_5"
      elif 0.07 > current_profit >= 0.06:
        if last_rsi_14 > 62.0:
          return True, f"exit_{mode_name}_o_6"
      elif 0.08 > current_profit >= 0.07:
        if last_rsi_14 > 60.0:
          return True, f"exit_{mode_name}_o_7"
      elif 0.09 > current_profit >= 0.08:
        if last_rsi_14 > 58.0:
          return True, f"exit_{mode_name}_o_8"
      elif 0.1 > current_profit >= 0.09:
        if last_rsi_14 > 56.0:
          return True, f"exit_{mode_name}_o_9"
      elif 0.12 > current_profit >= 0.1:
        if last_rsi_14 > 54.0:
          return True, f"exit_{mode_name}_o_10"
      elif 0.2 > current_profit >= 0.12:
        if last_rsi_14 > 56.0:
          return True, f"exit_{mode_name}_o_11"
      elif current_profit >= 0.2:
        if last_rsi_14 > 58.0:
          return True, f"exit_{mode_name}_o_12"
    elif last_close > last_ema_200:
      if 0.01 > current_profit >= 0.001:
        if last_rsi_14 > 88.0:
          return True, f"exit_{mode_name}_u_0"
      elif 0.02 > current_profit >= 0.01:
        if last_rsi_14 > 70.0:
          return True, f"exit_{mode_name}_u_1"
      elif 0.03 > current_profit >= 0.02:
        if last_rsi_14 > 68.0:
          return True, f"exit_{mode_name}_u_2"
      elif 0.04 > current_profit >= 0.03:
        if last_rsi_14 > 66.0:
          return True, f"exit_{mode_name}_u_3"
      elif 0.05 > current_profit >= 0.04:
        if last_rsi_14 > 64.0:
          return True, f"exit_{mode_name}_u_4"
      elif 0.06 > current_profit >= 0.05:
        if last_rsi_14 > 62.0:
          return True, f"exit_{mode_name}_u_5"
      elif 0.07 > current_profit >= 0.06:
        if last_rsi_14 > 60.0:
          return True, f"exit_{mode_name}_u_6"
      elif 0.08 > current_profit >= 0.07:
        if last_rsi_14 > 58.0:
          return True, f"exit_{mode_name}_u_7"
      elif 0.09 > current_profit >= 0.08:
        if last_rsi_14 > 56.0:
          return True, f"exit_{mode_name}_u_8"
      elif 0.1 > current_profit >= 0.09:
        if last_rsi_14 > 54.0:
          return True, f"exit_{mode_name}_u_9"
      elif 0.12 > current_profit >= 0.1:
        if last_rsi_14 > 52.0:
          return True, f"exit_{mode_name}_u_10"
      elif 0.2 > current_profit >= 0.12:
        if last_rsi_14 > 54.0:
          return True, f"exit_{mode_name}_u_11"
      elif current_profit >= 0.2:
        if last_rsi_14 > 56.0:
          return True, f"exit_{mode_name}_u_12"

    #  Here ends exit signal conditions for short_exit_main

    return False, None

  # Short Exit Williams R
  # ---------------------------------------------------------------------------------------------
  def short_exit_williams_r(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_willr_14 = last_candle["WILLR_14"]
    last_rsi_3 = last_candle["RSI_3"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_aroond_14_4h = last_candle["AROOND_14_4h"]
    last_rsi_14 = last_candle["RSI_14"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_stochrsi_k_1d = last_candle["STOCHRSIk_14_14_3_3_1d"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_willr_480 = last_candle["WILLR_480"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    last_aroonu_14_4h = last_candle["AROONU_14_4h"]
    last_cmf_20_1h = last_candle["CMF_20_1h"]
    last_cmf_20_4h = last_candle["CMF_20_4h"]
    last_cci_20_change_pct_4h = last_candle["CCI_20_change_pct_4h"]
    last_bot_wick_pct_1d = last_candle["bot_wick_pct_1d"]
    # Reused short Williams-R exit thresholds
    last_willr_14_lt_neg_98 = last_willr_14 < -98.0
    last_willr_14_lt_neg_99 = last_willr_14 < -99.0
    last_stochrsi_k_4h_lt_30 = last_stochrsi_k_4h < 30.0
    last_aroonu_14_4h_lt_50 = last_aroonu_14_4h < 50.0
    last_aroond_14_4h_gt_75 = last_aroond_14_4h > 75.0
    last_rsi_3_lt_10 = last_rsi_3 < 10.0
    last_willr_14_lt_neg_96 = last_willr_14 < -96.0
    last_willr_14_lt_neg_94 = last_willr_14 < -94.0
    last_willr_14_lt_neg_92 = last_willr_14 < -92.0
    last_rsi_3_lt_8 = last_rsi_3 < 8.0
    last_rsi_3_lt_12 = last_rsi_3 < 12.0
    last_willr_14_lte_neg_99 = last_willr_14 <= -99.0
    last_rsi_3_lt_6 = last_rsi_3 < 6.0
    last_rsi_3_lt_2 = last_rsi_3 < 2.0
    last_willr_14_lt_neg_80 = last_willr_14 < -80.0
    last_rsi_3_lt_14 = last_rsi_3 < 14.0
    last_rsi_3_lt_1 = last_rsi_3 < 1.0
    last_rsi_3_lt_16 = last_rsi_3 < 16.0
    last_willr_480_lt_neg_75 = last_willr_480 < -75.0
    last_willr_14_lte_neg_98 = last_willr_14 <= -98.0
    last_willr_14_lt_neg_90 = last_willr_14 < -90.0
    last_stochrsi_k_4h_lt_70 = last_stochrsi_k_4h < 70.0
    last_stochrsi_k_4h_lt_60 = last_stochrsi_k_4h < 60.0
    last_stochrsi_k_4h_lt_20 = last_stochrsi_k_4h < 20.0
    last_stochrsi_k_1h_lt_80 = last_stochrsi_k_1h < 80.0
    last_stochrsi_k_1h_lt_70 = last_stochrsi_k_1h < 70.0
    last_stochrsi_k_1h_lt_20 = last_stochrsi_k_1h < 20.0
    last_rsi_3_4h_gt_60 = last_rsi_3_4h > 60.0
    last_rsi_3_4h_gt_50 = last_rsi_3_4h > 50.0
    last_rsi_3_1h_gt_75 = last_rsi_3_1h > 75.0
    last_rsi_3_1h_gt_70 = last_rsi_3_1h > 70.0
    last_rsi_3_1h_gt_60 = last_rsi_3_1h > 60.0
    last_rsi_3_1h_gt_50 = last_rsi_3_1h > 50.0
    last_rsi_3_1h_gt_40 = last_rsi_3_1h > 40.0
    last_rsi_3_lt_4 = last_rsi_3 < 4.0
    last_rsi_3_lt_18 = last_rsi_3 < 18.0
    last_rsi_14_4h_lt_40 = last_rsi_14_4h < 40.0
    last_rsi_14_4h_lt_30 = last_rsi_14_4h < 30.0
    last_roc_9_1h_gt_5 = last_roc_9_1h > 5.0

    # Reused short Williams-R exit thresholds
    last_roc_9_4h_lt_neg_20 = last_roc_9_4h < -20.0
    last_roc_9_4h_lt_neg_10 = last_roc_9_4h < -10.0
    last_roc_9_1h_gt_0 = last_roc_9_1h > 0.0
    last_cmf_20_4h_gt_0 = last_cmf_20_4h > 0.0
    last_cmf_20_1h_gt_0 = last_cmf_20_1h > 0.0
    last_cci_20_change_pct_4h_gt_0 = last_cci_20_change_pct_4h > 0.0
    last_bot_wick_pct_1d_gt_20 = last_bot_wick_pct_1d > 20.0
    last_aroond_14_4h_gt_50 = last_aroond_14_4h > 50.0
    last_rsi_3_4h_gt_85 = last_rsi_3_4h > 85.0
    last_rsi_3_lt_20 = last_rsi_3 < 20.0
    last_willr_14_lt_neg_88 = last_willr_14 < -88.0
    last_rsi_14_lt_30 = last_rsi_14 < 30.0
    last_willr_14_lte_neg_85 = last_willr_14 <= -85.0
    last_rsi_14_lt_25 = last_rsi_14 < 25.0
    last_rsi_14_gt_52 = last_rsi_14 > 52.0
    last_rsi_14_gt_50 = last_rsi_14 > 50.0
    last_rsi_14_gt_48 = last_rsi_14 > 48.0
    last_willr_14_lte_neg_95 = last_willr_14 <= -95.0
    last_willr_14_lt_neg_86 = last_willr_14 < -86.0
    last_rsi_14_gt_54 = last_rsi_14 > 54.0
    last_rsi_14_gt_46 = last_rsi_14 > 46.0
    last_rsi_14_lt_22 = last_rsi_14 < 22.0
    last_rsi_14_lt_20 = last_rsi_14 < 20.0
    last_willr_14_lt_neg_84 = last_willr_14 < -84.0
    last_willr_14_lt_neg_82 = last_willr_14 < -82.0
    last_willr_14_lt_neg_78 = last_willr_14 < -78.0
    last_willr_14_lt_neg_76 = last_willr_14 < -76.0
    last_rsi_3_lt_56 = last_rsi_3 < 56.0
    last_rsi_3_lt_54 = last_rsi_3 < 54.0
    last_rsi_3_lt_52 = last_rsi_3 < 52.0
    last_rsi_3_lt_50 = last_rsi_3 < 50.0
    last_rsi_3_lt_5 = last_rsi_3 < 5.0
    last_rsi_3_lt_22 = last_rsi_3 < 22.0
    last_rsi_14_gt_60 = last_rsi_14 > 60.0
    last_rsi_14_gt_56 = last_rsi_14 > 56.0
    last_rsi_14_gt_44 = last_rsi_14 > 44.0
    last_rsi_14_lt_24 = last_rsi_14 < 24.0
    last_rsi_14_lt_23 = last_rsi_14 < 23.0

    if 0.01 > current_profit >= 0.001:
      if (last_willr_480 < -99.9) and (last_willr_14_lte_neg_99) and (last_rsi_14_lt_25):
        return True, f"exit_{mode_name}_w_0_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14 < 16.0):
        return True, f"exit_{mode_name}_w_0_2"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_gt_60):
        return True, f"exit_{mode_name}_w_0_3"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_20) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_0_4"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_96)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_0_5"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_99)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_0_6"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_0_7"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_0_8"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_99)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_0_9"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_84)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_0_10"
      elif (last_rsi_3_lt_2) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 75.0):
        return True, f"exit_{mode_name}_w_0_11"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_0_12"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_0_13"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_0_14"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_52)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_0_15"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_0_16"
      elif (
        (last_rsi_3_lt_2) and (last_willr_14_lt_neg_96) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_0_17"
      elif (
        (last_rsi_3_lt_10) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_0_18"
    elif 0.02 > current_profit >= 0.01:
      if last_willr_480 < -99.8:
        return True, f"exit_{mode_name}_w_1_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_22):
        return True, f"exit_{mode_name}_w_1_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_54):
        return True, f"exit_{mode_name}_w_1_3"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_lt_22) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_1_4"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_94)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_1_5"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_98)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_1_6"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_1_7"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_1_8"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_98)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_1_9"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_82)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_1_10"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_1_11"
      elif (last_rsi_3_lt_2) and (last_willr_14_lt_neg_98) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_1_12"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_1_13"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_1_14"
      elif (
        (last_rsi_3_lt_50)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_1_15"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_1_16"
      elif (
        (last_rsi_3_lt_4) and (last_willr_14_lt_neg_94) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_1_17"
      elif (
        (last_rsi_3_lt_12) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_1_18"
    elif 0.03 > current_profit >= 0.02:
      if last_willr_480 < -99.7:
        return True, f"exit_{mode_name}_w_2_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_23):
        return True, f"exit_{mode_name}_w_2_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_52):
        return True, f"exit_{mode_name}_w_2_3"
      elif (last_willr_14_lte_neg_95) and (last_rsi_14_lt_25) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_2_4"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_92)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_2_5"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_96)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_2_6"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_2_7"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_2_8"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_96)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_2_9"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_80)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_2_10"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_2_11"
      elif (last_rsi_3_lt_4) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_2_12"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_2_13"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_2_14"
      elif (
        (last_rsi_3_lt_52)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_48)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_2_15"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_2_16"
      elif (
        (last_rsi_3_lt_6) and (last_willr_14_lt_neg_92) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_2_17"
      elif (
        (last_rsi_3_lt_14) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_2_18"
    elif 0.04 > current_profit >= 0.03:
      if last_willr_480 < -99.6:
        return True, f"exit_{mode_name}_w_3_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_24):
        return True, f"exit_{mode_name}_w_3_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_50):
        return True, f"exit_{mode_name}_w_3_3"
      elif (last_willr_14_lte_neg_95) and (last_rsi_14_lt_25) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_3_4"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_90)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_3_5"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_94)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_3_6"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_3_7"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_3_8"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_94)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_3_9"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_78)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_3_10"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_3_11"
      elif (last_rsi_3_lt_6) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_3_12"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_3_13"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_3_14"
      elif (
        (last_rsi_3_lt_54)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_46)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_3_15"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_3_16"
      elif (
        (last_rsi_3_lt_8) and (last_willr_14_lt_neg_90) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_3_17"
      elif (
        (last_rsi_3_lt_16) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_3_18"
    elif 0.05 > current_profit >= 0.04:
      if last_willr_480 < -99.5:
        return True, f"exit_{mode_name}_w_4_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_25):
        return True, f"exit_{mode_name}_w_4_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_48):
        return True, f"exit_{mode_name}_w_4_3"
      elif (last_willr_14_lte_neg_95) and (last_rsi_14_lt_25) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_4_4"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_88)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_4_5"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_92)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_4_6"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_4_7"
      elif (last_rsi_3_lt_18) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_4_8"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_4_9"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_76)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_4_10"
      elif (last_rsi_3_lt_18) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_4_11"
      elif (last_rsi_3_lt_8) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_4_12"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_4_13"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_4_14"
      elif (
        (last_rsi_3_lt_56)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_44)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_4_15"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_4_16"
      elif (
        (last_rsi_3_lt_10) and (last_willr_14_lt_neg_88) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_4_17"
      elif (
        (last_rsi_3_lt_18) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_4_18"
    elif 0.06 > current_profit >= 0.05:
      if last_willr_480 < -99.4:
        return True, f"exit_{mode_name}_w_5_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14 < 26.0):
        return True, f"exit_{mode_name}_w_5_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_46):
        return True, f"exit_{mode_name}_w_5_3"
      elif (last_willr_14 <= -90.0) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_5_4"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_86)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_5_5"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_90)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_5_6"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_5_7"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_5_8"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_90)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_5_9"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14 < -74.0)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_5_10"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_5_11"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_5_12"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_5_13"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_5_14"
      elif (
        (last_rsi_3 < 58.0)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14 > 42.0)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_5_15"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_5_16"
      elif (
        (last_rsi_3_lt_12) and (last_willr_14_lt_neg_86) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_5_17"
      elif (
        (last_rsi_3_lt_20) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_5_18"
    elif 0.07 > current_profit >= 0.06:
      if last_willr_480 < -99.3:
        return True, f"exit_{mode_name}_w_6_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_25):
        return True, f"exit_{mode_name}_w_6_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_48):
        return True, f"exit_{mode_name}_w_6_3"
      elif (last_willr_14_lte_neg_85) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_6_4"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_88)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_6_5"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_92)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_6_6"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_6_7"
      elif (last_rsi_3_lt_18) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_6_8"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_6_9"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_76)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_6_10"
      elif (last_rsi_3_lt_18) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_6_11"
      elif (last_rsi_3_lt_8) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_6_12"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_6_13"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_6_14"
      elif (
        (last_rsi_3_lt_56)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_44)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_6_15"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_6_16"
      elif (
        (last_rsi_3_lt_10) and (last_willr_14_lt_neg_88) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_6_17"
      elif (
        (last_rsi_3_lt_18) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_6_18"
    elif 0.08 > current_profit >= 0.07:
      if last_willr_480 < -99.2:
        return True, f"exit_{mode_name}_w_7_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_24):
        return True, f"exit_{mode_name}_w_7_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_50):
        return True, f"exit_{mode_name}_w_7_3"
      elif (last_willr_14_lte_neg_85) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_7_4"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_90)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_7_5"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_94)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_7_6"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_7_7"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_7_8"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_94)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_7_9"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_78)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_7_10"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_7_11"
      elif (last_rsi_3_lt_6) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_7_12"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_7_13"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_7_14"
      elif (
        (last_rsi_3_lt_54)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_46)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_7_15"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_7_16"
      elif (
        (last_rsi_3_lt_8) and (last_willr_14_lt_neg_90) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_7_17"
      elif (
        (last_rsi_3_lt_16) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_7_18"
    elif 0.09 > current_profit >= 0.08:
      if last_willr_480 < -99.1:
        return True, f"exit_{mode_name}_w_8_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_23):
        return True, f"exit_{mode_name}_w_8_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_52):
        return True, f"exit_{mode_name}_w_8_3"
      elif (last_willr_14_lte_neg_85) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_8_4"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_92)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_8_5"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_96)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_8_6"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_8_7"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_8_8"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_96)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_8_9"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_80)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_8_10"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_8_11"
      elif (last_rsi_3_lt_4) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_8_12"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_8_13"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_8_14"
      elif (
        (last_rsi_3_lt_52)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_48)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_8_15"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_8_16"
      elif (
        (last_rsi_3_lt_6) and (last_willr_14_lt_neg_92) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_8_17"
      elif (
        (last_rsi_3_lt_14) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_8_18"
    elif 0.1 > current_profit >= 0.09:
      if last_willr_480 < -99.0:
        return True, f"exit_{mode_name}_w_9_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_22):
        return True, f"exit_{mode_name}_w_9_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_54):
        return True, f"exit_{mode_name}_w_9_3"
      elif (last_willr_14_lte_neg_85) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_9_4"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_94)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_9_5"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_98)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_9_6"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_9_7"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_9_8"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_98)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_9_9"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_82)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_9_10"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_9_11"
      elif (last_rsi_3_lt_2) and (last_willr_14_lt_neg_98) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_9_12"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_9_13"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_9_14"
      elif (
        (last_rsi_3_lt_50)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_9_15"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_9_16"
      elif (
        (last_rsi_3_lt_4) and (last_willr_14_lt_neg_94) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_9_17"
      elif (
        (last_rsi_3_lt_12) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_9_18"
    elif 0.12 > current_profit >= 0.1:
      if last_willr_480 < -98.9:
        return True, f"exit_{mode_name}_w_10_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14 < 21.0):
        return True, f"exit_{mode_name}_w_10_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_56):
        return True, f"exit_{mode_name}_w_10_3"
      elif (last_willr_14_lte_neg_85) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_10_4"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_96)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_10_5"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_99)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_10_6"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_10_7"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_10_8"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_99)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_10_9"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_84)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_10_10"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_10_11"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_10_12"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_10_13"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_10_14"
      elif (
        (last_rsi_3 < 48.0)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_52)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_10_15"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_10_16"
      elif (
        (last_rsi_3_lt_2) and (last_willr_14_lt_neg_96) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_10_17"
      elif (
        (last_rsi_3_lt_10) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_10_18"
    elif 0.2 > current_profit >= 0.12:
      if last_willr_480 < -99.6:
        return True, f"exit_{mode_name}_w_11_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_20):
        return True, f"exit_{mode_name}_w_11_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14 > 58.0):
        return True, f"exit_{mode_name}_w_11_3"
      elif (last_willr_14_lte_neg_85) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_11_4"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_98)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_11_5"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_11_6"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_11_7"
      elif (last_rsi_3_lt_8) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_11_8"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_99)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_11_9"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_86)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_11_10"
      elif (last_rsi_3_lt_8) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_11_11"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_11_12"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_11_13"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_11_14"
      elif (
        (last_rsi_3 < 46.0)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_54)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_11_15"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_11_16"
      elif (
        (last_rsi_3_lt_1) and (last_willr_14_lt_neg_98) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_11_17"
      elif (
        (last_rsi_3_lt_8) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_11_18"
    elif current_profit >= 0.2:
      if last_willr_480 < -99.8:
        return True, f"exit_{mode_name}_w_12_1"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14 < 19.0):
        return True, f"exit_{mode_name}_w_12_2"
      elif (last_willr_14_lte_neg_98) and (last_rsi_14_gt_60):
        return True, f"exit_{mode_name}_w_12_3"
      elif (last_willr_14_lte_neg_99) and (last_rsi_14_lt_20) and (last_roc_9_1h_gt_0) and (last_roc_9_4h_lt_neg_20):
        return True, f"exit_{mode_name}_w_12_4"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_12_5"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
        and (last_stochrsi_k_1h_lt_20)
      ):
        return True, f"exit_{mode_name}_w_12_6"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_14_4h_lt_40)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
      ):
        return True, f"exit_{mode_name}_w_12_7"
      elif (last_rsi_3_lt_6) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_w_12_8"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_99)
        and (last_roc_9_1h_gt_5)
        and (last_roc_9_4h_lt_neg_10)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_w_12_9"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_88)
        and (last_aroond_14_4h_gt_50)
        and (last_cci_20_change_pct_4h_gt_0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_w_12_10"
      elif (last_rsi_3_lt_6) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_w_12_11"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_w_12_12"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_w_12_13"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_40)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_w_12_14"
      elif (
        (last_rsi_3 < 44.0)
        and (last_willr_480_lt_neg_75)
        and (last_rsi_14_gt_56)
        and (last_rsi_14_4h_lt_30)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -100.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -100.0))
      ):
        return True, f"exit_{mode_name}_w_12_15"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_60)
        and (last_aroond_14_4h_gt_75)
        and (last_stochrsi_k_1h_lt_70)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_w_12_16"
      elif (
        (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_aroond_14_4h_gt_75) and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_w_12_17"
      elif (
        (last_rsi_3_lt_6) and (last_willr_14_lt_neg_80) and (last_aroonu_14_4h_lt_50) and (last_bot_wick_pct_1d_gt_20)
      ):
        return True, f"exit_{mode_name}_w_12_18"

    #  Here ends exit signal conditions for short_exit_williams_r

    return False, None

  # Short Exit Dec
  # ---------------------------------------------------------------------------------------------
  def short_exit_dec(
    self,
    mode_name: str,
    current_profit: float,
    max_profit: float,
    max_loss: float,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    last_rsi_3 = last_candle["RSI_3"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_aroond_14_4h = last_candle["AROOND_14_4h"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_aroond_14_1h = last_candle["AROOND_14_1h"]
    last_aroonu_14_4h = last_candle["AROONU_14_4h"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    last_ema_200_1h = last_candle["EMA_200_1h"]
    last_ema_200_4h = last_candle["EMA_200_4h"]
    last_change_pct_1d = last_candle["change_pct_1d"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_1d = last_candle["STOCHRSIk_14_14_3_3_1d"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_aroond_14_1d = last_candle["AROOND_14_1d"]
    last_cmf_20_1h = last_candle["CMF_20_1h"]
    last_cmf_20_4h = last_candle["CMF_20_4h"]
    last_ema_12_1h = last_candle["EMA_12_1h"]
    last_ema_12_4h = last_candle["EMA_12_4h"]
    last_change_pct_4h = last_candle["change_pct_4h"]
    last_roc_2_1d = last_candle["ROC_2_1d"]
    last_roc_2_1h = last_candle["ROC_2_1h"]
    last_roc_2_4h = last_candle["ROC_2_4h"]
    last_rsi_14_1d = last_candle["RSI_14_1d"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_aroond_14_15m = last_candle["AROOND_14_15m"]
    last_aroonu_14_1h = last_candle["AROONU_14_1h"]
    last_cci_20_change_pct_1h = last_candle["CCI_20_change_pct_1h"]
    last_kst_1h = last_candle["KST_10_15_20_30_10_10_10_15_1h"]
    last_kst_4h = last_candle["KST_10_15_20_30_10_10_10_15_4h"]
    last_ksts_9_1h = last_candle["KSTs_9_1h"]
    last_ksts_9_4h = last_candle["KSTs_9_4h"]
    last_roc_9_15m = last_candle["ROC_9_15m"]
    last_stochrsi_k_change_pct_4h = last_candle["STOCHRSIk_14_14_3_3_change_pct_4h"]
    last_stoch_k_4h = last_candle["STOCHk_14_3_3_4h"]
    last_change_pct_1h = last_candle["change_pct_1h"]
    last_close = last_candle["close"]
    last_low_min_30_1d = last_candle["low_min_30_1d"]
    # Reused short exit decision thresholds
    last_stochrsi_k_4h_lt_50 = last_stochrsi_k_4h < 50.0
    last_rsi_14_gt_50 = last_rsi_14 > 50.0
    last_rsi_3_1h_gt_70 = last_rsi_3_1h > 70.0
    last_stochrsi_k_1h_lt_50 = last_stochrsi_k_1h < 50.0
    last_rsi_3_4h_gt_70 = last_rsi_3_4h > 70.0

    # Reused short DEC exit thresholds
    last_willr_14_lt_neg_90 = last_willr_14 < -90.0
    last_willr_14_lt_neg_99 = last_willr_14 < -99.0
    last_willr_14_lt_neg_98 = last_willr_14 < -98.0
    last_willr_14_lt_neg_75 = last_willr_14 < -75.0
    last_willr_14_lt_neg_92 = last_willr_14 < -92.0
    last_willr_14_lt_neg_80 = last_willr_14 < -80.0
    last_willr_14_lt_neg_94 = last_willr_14 < -94.0
    last_willr_14_lt_neg_96 = last_willr_14 < -96.0
    last_roc_9_4h_gt_25 = last_roc_9_4h > 25.0
    last_roc_9_4h_gt_20 = last_roc_9_4h > 20.0
    last_stochrsi_k_4h_lt_90 = last_stochrsi_k_4h < 90.0
    last_stochrsi_k_4h_lt_30 = last_stochrsi_k_4h < 30.0
    last_stochrsi_k_4h_lt_20 = last_stochrsi_k_4h < 20.0
    last_stochrsi_k_1h_lt_80 = last_stochrsi_k_1h < 80.0
    last_stochrsi_k_1h_lt_75 = last_stochrsi_k_1h < 75.0
    last_rsi_3_4h_gt_95 = last_rsi_3_4h > 95.0
    last_rsi_3_4h_gt_65 = last_rsi_3_4h > 65.0
    last_rsi_3_1d_gt_60 = last_rsi_3_1d > 60.0
    last_rsi_3_15m_gt_70 = last_rsi_3_15m > 70.0
    last_roc_9_4h_gt_5 = last_roc_9_4h > 5.0
    last_roc_9_4h_gt_10 = last_roc_9_4h > 10.0
    last_roc_9_4h_lt_neg_40 = last_roc_9_4h < -40.0
    last_roc_9_4h_lt_neg_25 = last_roc_9_4h < -25.0
    last_roc_9_1h_gt_5 = last_roc_9_1h > 5.0
    last_roc_2_4h_gt_30 = last_roc_2_4h > 30.0
    last_cmf_20_4h_gt_0 = last_cmf_20_4h > 0.0
    last_cmf_20_1h_gt_0 = last_cmf_20_1h > 0.0
    last_willr_14_lt_neg_88 = last_willr_14 < -88.0
    last_stochrsi_k_lt_30 = last_stochrsi_k < 30.0
    last_willr_14_lt_neg_70 = last_willr_14 < -70.0
    last_willr_14_lt_neg_86 = last_willr_14 < -86.0
    last_willr_14_lt_neg_85 = last_willr_14 < -85.0
    last_willr_14_lt_neg_95 = last_willr_14 < -95.0
    last_willr_14_lt_neg_84 = last_willr_14 < -84.0
    last_rsi_3_lt_42 = last_rsi_3 < 42.0
    last_rsi_3_15m_lt_30 = last_rsi_3_15m < 30.0
    last_rsi_3_lt_44 = last_rsi_3 < 44.0
    last_willr_14_lt_neg_82 = last_willr_14 < -82.0
    last_stochrsi_k_change_pct_4h_gt_10 = last_stochrsi_k_change_pct_4h > 10.0
    last_stochrsi_k_4h_gt_70 = last_stochrsi_k_4h > 70.0
    last_stochrsi_k_1h_gt_50 = last_stochrsi_k_1h > 50.0
    last_stochrsi_k_1h_lt_25 = last_stochrsi_k_1h < 25.0
    last_stochrsi_k_1h_lt_10 = last_stochrsi_k_1h < 10.0
    last_stochrsi_k_1d_lt_50 = last_stochrsi_k_1d < 50.0
    last_stoch_k_4h_lt_60 = last_stoch_k_4h < 60.0

    if 0.01 > current_profit >= 0.001:
      # Reused short exit decision threshold checks for this profit bracket
      last_rsi_3_lt_5 = last_rsi_3 < 5.0
      last_rsi_3_lt_1 = last_rsi_3 < 1.0
      last_rsi_3_lt_2 = last_rsi_3 < 2.0
      last_rsi_14_gt_54 = last_rsi_14 > 54.0
      last_rsi_3_4h_gt_80 = last_rsi_3_4h > 80.0
      last_rsi_3_4h_gt_90 = last_rsi_3_4h > 90.0
      last_rsi_3_1h_gt_80 = last_rsi_3_1h > 80.0
      last_rsi_14_gt_56 = last_rsi_14 > 56.0
      last_rsi_14_lt_22 = last_rsi_14 < 22.0
      last_rsi_3_lt_10 = last_rsi_3 < 10.0
      last_rsi_3_1h_gt_85 = last_rsi_3_1h > 85.0
      last_rsi_3_1h_gt_50 = last_rsi_3_1h > 50.0
      last_rsi_3_1h_gt_90 = last_rsi_3_1h > 90.0
      last_rsi_3_1h_gt_75 = last_rsi_3_1h > 75.0
      last_rsi_3_4h_gt_60 = last_rsi_3_4h > 60.0
      last_rsi_3_4h_gt_75 = last_rsi_3_4h > 75.0
      last_rsi_14_gt_60 = last_rsi_14 > 60.0
      last_rsi_3_1h_gt_40 = last_rsi_3_1h > 40.0
      last_stochrsi_k_4h_lt_60 = last_stochrsi_k_4h < 60.0
      last_rsi_14_gt_58 = last_rsi_14 > 58.0
      last_stochrsi_k_4h_lt_80 = last_stochrsi_k_4h < 80.0
      last_change_pct_1d_gt_5 = last_change_pct_1d > 5.0
      last_stochrsi_k_4h_lt_10 = last_stochrsi_k_4h < 10.0
      last_rsi_3_4h_gt_85 = last_rsi_3_4h > 85.0
      last_stochrsi_k_1h_lt_30 = last_stochrsi_k_1h < 30.0
      last_stochrsi_k_4h_lt_70 = last_stochrsi_k_4h < 70.0
      last_rsi_3_1d_gt_75 = last_rsi_3_1d > 75.0
      last_rsi_3_lt_16 = last_rsi_3 < 16.0
      last_rsi_3_lt_4 = last_rsi_3 < 4.0
      last_stochrsi_k_1h_lt_20 = last_stochrsi_k_1h < 20.0
      last_rsi_14_gt_52 = last_rsi_14 > 52.0
      last_stochrsi_k_1h_lt_60 = last_stochrsi_k_1h < 60.0
      last_aroond_14_1h_gt_75 = last_aroond_14_1h > 75.0
      last_rsi_3_4h_gt_40 = last_rsi_3_4h > 40.0
      last_stochrsi_k_lt_5 = last_stochrsi_k < 5.0
      last_roc_9_1h_gt_10 = last_roc_9_1h > 10.0
      last_change_pct_4h_gt_5 = last_change_pct_4h > 5.0
      last_aroond_14_4h_gt_25 = last_aroond_14_4h > 25.0
      last_aroond_14_4h_gt_75 = last_aroond_14_4h > 75.0
      last_stochrsi_k_1h_lt_70 = last_stochrsi_k_1h < 70.0
      last_stochrsi_k_4h_lt_75 = last_stochrsi_k_4h < 75.0
      last_rsi_14_gt_62 = last_rsi_14 > 62.0
      last_rsi_3_1h_gt_60 = last_rsi_3_1h > 60.0
      last_rsi_3_1h_gt_55 = last_rsi_3_1h > 55.0
      last_aroonu_14_4h_lt_50 = last_aroonu_14_4h < 50.0
      last_aroond_14_4h_gt_50 = last_aroond_14_4h > 50.0
      last_rsi_3_1h_gt_65 = last_rsi_3_1h > 65.0
      last_rsi_3_lt_8 = last_rsi_3 < 8.0
      last_rsi_14_4h_lt_30 = last_rsi_14_4h < 30.0
      last_rsi_3_1d_gt_70 = last_rsi_3_1d > 70.0
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14_lt_22)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_0_1"
      elif (
        (last_willr_14 <= -99.0)
        and (last_rsi_14_lt_22)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_0_2"
      elif (
        (last_willr_14 <= -99.0)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h_lt_80) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_0_3"
      elif (
        (last_willr_14 <= -99.0)
        and (last_rsi_14_lt_22)
        and (last_stochrsi_k_lt_5)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_0_4"
      elif (last_willr_14 <= -99.0) and (last_rsi_14_lt_22) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_0_5"
      elif (
        (last_rsi_3_lt_5)
        and (last_stochrsi_k_lt_5)
        and (last_rsi_14_gt_60)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_0_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_5)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_0_7"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_0_8"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_3_lt_1)
        and (last_change_pct_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_0_9"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h_gt_10)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_0_10"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_0_11"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_0_12"
      elif (last_rsi_3_lt_1) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_0_13"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_0_14"
      elif (last_rsi_3_lt_1) and (last_rsi_14_lt_22) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_0_15"
      elif (
        (last_rsi_3_lt_1)
        and (last_aroond_14_4h_gt_25)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_0_16"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_90)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_0_17"
      elif (last_rsi_3_lt_5) and (last_rsi_14 < 25.0) and (last_rsi_3_4h_gt_80) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_0_18"
      elif (
        (last_rsi_3_lt_1)
        and (last_rsi_14_lt_22)
        and (last_rsi_3_4h_gt_90)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_19"
      elif (last_rsi_3_lt_10) and (last_rsi_14_gt_60) and (last_rsi_3_1h_gt_90) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_0_20"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_60) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_4h_lt_10):
        return True, f"exit_{mode_name}_d_0_21"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_99)
        and (last_change_pct_4h_gt_5)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_22"
      elif (last_rsi_3_lt_2) and (last_willr_14_lt_neg_95) and (last_rsi_3_1h_gt_85) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_0_23"
      elif (
        (last_rsi_3_lt_1)
        and (last_rsi_14_lt_22)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_0_24"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_25"
      elif (last_rsi_3_lt_5) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_85) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_0_26"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_4h_lt_80)
      ):
        return True, f"exit_{mode_name}_d_0_27"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_0_28"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_0_29"
      elif (last_rsi_3_lt_1) and (last_rsi_3_1h_gt_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_30):
        return True, f"exit_{mode_name}_d_0_30"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_85)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_0_31"
      elif (last_rsi_3_lt_5) and (last_rsi_3_1h_gt_85) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_0_32"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_99)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_0_34"
      elif (last_rsi_3_lt_5) and (last_willr_14_lt_neg_95) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_0_35"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_99)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_36"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_37"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_0_38"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_0_39"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h_lt_70)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_0_40"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h_lt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_0_41"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_98)
        and (last_stochrsi_k_4h_lt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_42"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_60)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_0_43"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_0_44"
      elif (last_rsi_3_lt_4) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h_gt_90):
        return True, f"exit_{mode_name}_d_0_45"
      elif (last_rsi_3_lt_2) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_90) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_0_46"
      elif (
        (last_rsi_3_lt_2)
        and (last_stochrsi_k_1h_lt_20)
        and (last_stochrsi_k_4h_lt_60)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_0_47"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_58)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_48"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h_gt_80)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_0_50"
      elif (last_rsi_3 < 32.0) and (last_rsi_14_gt_56) and (last_rsi_3_4h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_0_51"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14 < 38.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_0_52"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_1h_gt_80)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_53"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_56)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_0_54"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_88)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_55"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_0_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 66.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_0_57"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_58"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_0_59"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_62)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_60"
      elif (last_rsi_3_lt_2) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_70):
        return True, f"exit_{mode_name}_d_0_61"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d_gt_5)
      ):
        return True, f"exit_{mode_name}_d_0_62"
      elif (last_rsi_3_lt_2) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_20) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_0_63"
      elif (
        (last_rsi_3_lt_2)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_0_64"
      elif (last_rsi_3_lt_10) and (last_rsi_14_gt_60) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_d_0_65"
      elif (last_rsi_3_lt_16) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_0_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14_gt_60)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_0_67"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_75)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_0_68"
      elif (last_rsi_3 < 3.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h_gt_5):
        return True, f"exit_{mode_name}_d_0_69"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_62) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_0_70"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_58) and (last_rsi_3_4h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_0_71"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_60) and (last_rsi_3_1h_gt_90) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_0_72"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_85)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_0_73"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_75)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_0_74"
      elif (
        (last_rsi_3_lt_2)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_75"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_52) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_0_76"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_0_77"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_0_78"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_0_79"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_0_80"
      elif (
        (last_rsi_3_lt_4)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_81"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_0_82"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_0_83"
      elif (last_rsi_3_lt_1) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_0_84"
      elif (
        (last_rsi_3_lt_1)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_85"
      elif (
        (last_rsi_3_lt_4)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_86"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_58)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_87"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_98)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_0_88"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_gt_62)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_0_89"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_0_90"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_0_91"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_0_92"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h_gt_75)
        and (last_stochrsi_k_1h_lt_30)
        and (last_aroond_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_0_93"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_0_94"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_0_95"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_96"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_65)
        and (last_aroond_14_4h_gt_50)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_0_97"
      elif (
        (last_rsi_3_lt_8)
        and (last_rsi_3_15m < 26.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_98"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h_gt_40)
        and (last_aroond_14_4h_gt_50)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_0_99"
      elif (last_rsi_3_lt_1) and (last_rsi_14_lt_22) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_0_100"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_4h_lt_60)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_0_101"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_0_102"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_14_4h_lt_30)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_0_103"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_0_104"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_0_105"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_0_106"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_30)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_0_107"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_40) and (last_stochrsi_k_1h_lt_20):
        return True, f"exit_{mode_name}_d_0_108"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_0_109"
      elif (last_rsi_3_lt_5) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_0_110"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_58)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_aroond_14_1h_gt_75)
        and (last_aroond_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_0_111"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_0_112"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1d_gt_70)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_0_113"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d_gt_70)
      ):
        return True, f"exit_{mode_name}_d_0_114"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_0_115"
      elif (last_rsi_3_lt_8) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_d_0_116"
      elif (last_rsi_3_lt_5) and (last_rsi_3_1h_gt_50) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0):
        return True, f"exit_{mode_name}_d_0_117"
      elif (last_rsi_3_lt_8) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_40) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_0_118"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_0_119"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_60) and (last_aroond_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_0_120"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_56) and (last_rsi_3_1h_gt_50) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_0_121"
      elif (last_rsi_3_lt_5) and (last_rsi_14_gt_58) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_0_122"
      elif (last_rsi_3_lt_5) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_90) and (last_rsi_3_1d_gt_70):
        return True, f"exit_{mode_name}_d_0_123"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_3_1h_gt_85)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_0_124"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_90)
        and (last_rsi_3_4h_gt_60)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_0_125"
      elif (last_rsi_3_lt_5) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_0_126"
      elif (last_rsi_3_lt_5) and (last_rsi_3_1h_gt_90) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_0_127"
      elif (last_rsi_3_lt_4) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_0_128"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_0_129"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h_lt_20)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_0_130"
      elif (last_rsi_14 > 64.0) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_0_131"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_0_132"
      elif (
        (last_rsi_3_lt_5)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_0_133"
    elif 0.02 > current_profit >= 0.01:
      # Reused short exit decision threshold checks for this profit bracket
      last_rsi_3_lt_10 = last_rsi_3 < 10.0
      last_rsi_3_lt_20 = last_rsi_3 < 20.0
      last_rsi_14_gt_52 = last_rsi_14 > 52.0
      last_rsi_3_4h_gt_80 = last_rsi_3_4h > 80.0
      last_rsi_3_lt_5 = last_rsi_3 < 5.0
      last_rsi_3_4h_gt_90 = last_rsi_3_4h > 90.0
      last_rsi_3_1h_gt_80 = last_rsi_3_1h > 80.0
      last_rsi_14_gt_54 = last_rsi_14 > 54.0
      last_rsi_3_1h_gt_85 = last_rsi_3_1h > 85.0
      last_rsi_3_1h_gt_50 = last_rsi_3_1h > 50.0
      last_rsi_3_1h_gt_90 = last_rsi_3_1h > 90.0
      last_rsi_3_1h_gt_75 = last_rsi_3_1h > 75.0
      last_rsi_3_4h_gt_60 = last_rsi_3_4h > 60.0
      last_rsi_3_lt_22 = last_rsi_3 < 22.0
      last_rsi_3_4h_gt_75 = last_rsi_3_4h > 75.0
      last_rsi_3_lt_16 = last_rsi_3 < 16.0
      last_rsi_3_lt_12 = last_rsi_3 < 12.0
      last_rsi_3_lt_14 = last_rsi_3 < 14.0
      last_rsi_3_lt_28 = last_rsi_3 < 28.0
      last_rsi_3_1h_gt_40 = last_rsi_3_1h > 40.0
      last_rsi_14_gt_60 = last_rsi_14 > 60.0
      last_rsi_3_lt_15 = last_rsi_3 < 15.0
      last_rsi_3_lt_35 = last_rsi_3 < 35.0
      last_stochrsi_k_4h_lt_60 = last_stochrsi_k_4h < 60.0
      last_rsi_14_gt_56 = last_rsi_14 > 56.0
      last_stochrsi_k_4h_lt_80 = last_stochrsi_k_4h < 80.0
      last_rsi_3_lt_30 = last_rsi_3 < 30.0
      last_change_pct_1d_gt_5 = last_change_pct_1d > 5.0
      last_stochrsi_k_4h_lt_10 = last_stochrsi_k_4h < 10.0
      last_rsi_3_lt_50 = last_rsi_3 < 50.0
      last_rsi_3_4h_gt_85 = last_rsi_3_4h > 85.0
      last_stochrsi_k_1h_lt_30 = last_stochrsi_k_1h < 30.0
      last_stochrsi_k_4h_lt_70 = last_stochrsi_k_4h < 70.0
      last_rsi_3_1d_gt_75 = last_rsi_3_1d > 75.0
      last_rsi_3_lt_6 = last_rsi_3 < 6.0
      last_stochrsi_k_1h_lt_20 = last_stochrsi_k_1h < 20.0
      last_rsi_3_lt_32 = last_rsi_3 < 32.0
      last_stochrsi_k_1h_lt_60 = last_stochrsi_k_1h < 60.0
      last_aroond_14_1h_gt_75 = last_aroond_14_1h > 75.0
      last_rsi_3_4h_gt_40 = last_rsi_3_4h > 40.0
      last_roc_9_1h_gt_10 = last_roc_9_1h > 10.0
      last_change_pct_4h_gt_5 = last_change_pct_4h > 5.0
      last_aroond_14_4h_gt_25 = last_aroond_14_4h > 25.0
      last_rsi_3_lt_2 = last_rsi_3 < 2.0
      last_aroond_14_4h_gt_75 = last_aroond_14_4h > 75.0
      last_stochrsi_k_1h_lt_70 = last_stochrsi_k_1h < 70.0
      last_rsi_3_lt_18 = last_rsi_3 < 18.0
      last_stochrsi_k_4h_lt_75 = last_stochrsi_k_4h < 75.0
      last_rsi_3_lt_34 = last_rsi_3 < 34.0
      last_rsi_3_lt_40 = last_rsi_3 < 40.0
      last_rsi_14_gt_58 = last_rsi_14 > 58.0
      last_rsi_3_lt_24 = last_rsi_3 < 24.0
      last_rsi_3_1h_gt_60 = last_rsi_3_1h > 60.0
      last_rsi_3_1h_gt_55 = last_rsi_3_1h > 55.0
      last_aroonu_14_4h_lt_50 = last_aroonu_14_4h < 50.0
      last_aroond_14_4h_gt_50 = last_aroond_14_4h > 50.0
      last_rsi_3_1h_gt_65 = last_rsi_3_1h > 65.0
      last_rsi_14_4h_lt_30 = last_rsi_14_4h < 30.0
      last_rsi_3_1d_gt_70 = last_rsi_3_1d > 70.0
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_1_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 32.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_1_2"
      elif (
        (last_willr_14_lt_neg_92)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h_lt_80) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_1_3"
      elif (
        (last_willr_14_lt_neg_70)
        and (last_rsi_14 < 35.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_1_4"
      elif (last_willr_14_lt_neg_98) and (last_rsi_14 < 28.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_1_5"
      elif (
        (last_rsi_3_lt_30)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14_gt_60)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_1_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_1_7"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_1_8"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_rsi_3_lt_5)
        and (last_change_pct_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_1_9"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h_gt_10)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_1_10"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_1_11"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_1_12"
      elif (last_rsi_3_lt_20) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_1_13"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_1_14"
      elif (last_rsi_3_lt_5) and (last_rsi_14 < 25.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_1_15"
      elif (
        (last_rsi_3_lt_5)
        and (last_aroond_14_4h_gt_25)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_1_16"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_90)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_1_17"
      elif (last_rsi_3 < 25.0) and (last_rsi_14 < 40.0) and (last_rsi_3_4h_gt_80) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_1_18"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14 < 28.0)
        and (last_rsi_3_4h_gt_90)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_19"
      elif (last_rsi_3_lt_50) and (last_rsi_14_gt_60) and (last_rsi_3_1h_gt_90) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_1_20"
      elif (last_rsi_3_lt_20) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_4h_lt_10):
        return True, f"exit_{mode_name}_d_1_21"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_98)
        and (last_change_pct_4h_gt_5)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_22"
      elif (last_rsi_3_lt_5) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h_gt_85) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_1_23"
      elif (
        (last_rsi_3_lt_5)
        and (last_rsi_14 < 25.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_1_24"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_25"
      elif (last_rsi_3_lt_15) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_85) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_1_26"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_4h_lt_80)
      ):
        return True, f"exit_{mode_name}_d_1_27"
      elif (last_rsi_3_lt_20) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_1_28"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_1_29"
      elif (last_rsi_3_lt_10) and (last_rsi_3_1h_gt_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_30):
        return True, f"exit_{mode_name}_d_1_30"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_85)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_1_31"
      elif (last_rsi_3_lt_10) and (last_rsi_3_1h_gt_85) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_1_32"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_98)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_33"
      elif (last_rsi_3_lt_35) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_1_34"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_94) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_1_35"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_85)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_36"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_37"
      elif (last_rsi_3_lt_15) and (last_willr_14_lt_neg_85) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_1_38"
      elif (last_rsi_3_lt_5) and (last_willr_14_lt_neg_95) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_1_39"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h_lt_70)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_1_40"
      elif (
        (last_rsi_3_lt_5)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h_lt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_1_41"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_75)
        and (last_stochrsi_k_4h_lt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_42"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_60)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_1_43"
      elif (
        (last_rsi_3_lt_35)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_1_44"
      elif (last_rsi_3_lt_6) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h_gt_90):
        return True, f"exit_{mode_name}_d_1_45"
      elif (last_rsi_3_lt_30) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_90) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_1_46"
      elif (
        (last_rsi_3_lt_14)
        and (last_stochrsi_k_1h_lt_20)
        and (last_stochrsi_k_4h_lt_60)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_1_47"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_48"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_4h_gt_80)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_49"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_96) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_1_50"
      elif (last_rsi_3_lt_34) and (last_rsi_14_gt_54) and (last_rsi_3_4h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_1_51"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14 < 40.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_1_52"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_80)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_53"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_54)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_1_54"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_86)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_55"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_1_56"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14 > 64.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_1_57"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_58"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_1_59"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_60)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_60"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_70):
        return True, f"exit_{mode_name}_d_1_61"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d_gt_5)
      ):
        return True, f"exit_{mode_name}_d_1_62"
      elif (last_rsi_3_lt_32) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_20) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_1_63"
      elif (
        (last_rsi_3_lt_12)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_1_64"
      elif (last_rsi_3_lt_32) and (last_rsi_14_gt_58) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_d_1_65"
      elif (last_rsi_3_lt_18) and (last_rsi_14_gt_52) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_1_66"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14_gt_58)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_1_67"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_75)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_1_68"
      elif (last_rsi_3 < 4.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h_gt_5):
        return True, f"exit_{mode_name}_d_1_69"
      elif (last_rsi_3_lt_34) and (last_rsi_14_gt_60) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_1_70"
      elif (last_rsi_3 < 36.0) and (last_rsi_14_gt_56) and (last_rsi_3_4h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_1_71"
      elif (last_rsi_3_lt_22) and (last_rsi_14_gt_58) and (last_rsi_3_1h_gt_90) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_1_72"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_85)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_1_73"
      elif (
        (last_rsi_3_lt_2)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_75)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_1_74"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_75"
      elif (last_rsi_3_lt_32) and (last_rsi_14_gt_50) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_1_76"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_1_77"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_1_78"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_1_79"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_1_80"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_81"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_1_82"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_1_83"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_98) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_1_84"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_85"
      elif (
        (last_rsi_3_lt_6)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_86"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_87"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_80)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_1_88"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_60)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_1_89"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_1_90"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_1_91"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_1_92"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h_gt_75)
        and (last_stochrsi_k_1h_lt_30)
        and (last_aroond_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_1_93"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_1_94"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_1_95"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_96"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_65)
        and (last_aroond_14_4h_gt_50)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_1_97"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_3_15m < 28.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_98"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h_gt_40)
        and (last_aroond_14_4h_gt_50)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_1_99"
      elif (last_rsi_3_lt_2) and (last_rsi_14 < 24.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_1_100"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_4h_lt_60)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_1_101"
      elif (
        (last_rsi_3_lt_32)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_1_102"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_14_4h_lt_30)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_1_103"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_1_104"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_1_105"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_1_106"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_30)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_1_107"
      elif (last_rsi_3_lt_44) and (last_rsi_14_gt_52) and (last_rsi_3_1h_gt_40) and (last_stochrsi_k_1h_lt_20):
        return True, f"exit_{mode_name}_d_1_108"
      elif (
        (last_rsi_3_lt_24)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_1_109"
      elif (last_rsi_3_lt_28) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_1_110"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14_gt_56)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_aroond_14_1h_gt_75)
        and (last_aroond_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_1_111"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_1_112"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1d_gt_70)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_1_113"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d_gt_70)
      ):
        return True, f"exit_{mode_name}_d_1_114"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_1_115"
      elif (last_rsi_3_lt_10) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_d_1_116"
      elif (last_rsi_3_lt_14) and (last_rsi_3_1h_gt_50) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0):
        return True, f"exit_{mode_name}_d_1_117"
      elif (last_rsi_3_lt_10) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_40) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_1_118"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_1_119"
      elif (last_rsi_3 < 46.0) and (last_rsi_14_gt_52) and (last_rsi_3_1h_gt_60) and (last_aroond_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_1_120"
      elif (last_rsi_3_lt_40) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_50) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_1_121"
      elif (last_rsi_3_lt_42) and (last_rsi_14_gt_56) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_1_122"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h_gt_90) and (last_rsi_3_1d_gt_70):
        return True, f"exit_{mode_name}_d_1_123"
      elif (
        (last_rsi_3_lt_12)
        and (last_rsi_3_1h_gt_85)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_1_124"
      elif (
        (last_rsi_3_lt_24)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_90)
        and (last_rsi_3_4h_gt_60)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_1_125"
      elif (last_rsi_3_lt_10) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_1_126"
      elif (last_rsi_3_lt_10) and (last_rsi_3_1h_gt_90) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_1_127"
      elif (last_rsi_3_lt_6) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_1_128"
      elif (
        (last_rsi_3_lt_14)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_1_129"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h_lt_20)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_1_130"
      elif (last_rsi_14 > 62.0) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_1_131"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_1_132"
      elif (
        (last_rsi_3_lt_20)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_1_133"
    elif 0.03 > current_profit >= 0.02:
      # Reused short exit decision threshold checks for this profit bracket
      last_rsi_3_lt_30 = last_rsi_3 < 30.0
      last_rsi_3_lt_20 = last_rsi_3 < 20.0
      last_rsi_3_4h_gt_80 = last_rsi_3_4h > 80.0
      last_rsi_3_4h_gt_90 = last_rsi_3_4h > 90.0
      last_rsi_3_1h_gt_80 = last_rsi_3_1h > 80.0
      last_rsi_14_gt_52 = last_rsi_14 > 52.0
      last_rsi_3_lt_10 = last_rsi_3 < 10.0
      last_rsi_3_1h_gt_85 = last_rsi_3_1h > 85.0
      last_rsi_3_1h_gt_50 = last_rsi_3_1h > 50.0
      last_rsi_3_1h_gt_90 = last_rsi_3_1h > 90.0
      last_rsi_3_lt_15 = last_rsi_3 < 15.0
      last_rsi_3_1h_gt_75 = last_rsi_3_1h > 75.0
      last_rsi_3_4h_gt_60 = last_rsi_3_4h > 60.0
      last_rsi_3_lt_24 = last_rsi_3 < 24.0
      last_rsi_3_4h_gt_75 = last_rsi_3_4h > 75.0
      last_rsi_3_lt_18 = last_rsi_3 < 18.0
      last_rsi_3_lt_14 = last_rsi_3 < 14.0
      last_rsi_3_lt_16 = last_rsi_3 < 16.0
      last_rsi_3_lt_22 = last_rsi_3 < 22.0
      last_rsi_3_lt_12 = last_rsi_3 < 12.0
      last_rsi_3_1h_gt_40 = last_rsi_3_1h > 40.0
      last_rsi_3_lt_25 = last_rsi_3 < 25.0
      last_rsi_3_lt_8 = last_rsi_3 < 8.0
      last_stochrsi_k_4h_lt_60 = last_stochrsi_k_4h < 60.0
      last_rsi_14_gt_54 = last_rsi_14 > 54.0
      last_stochrsi_k_4h_lt_80 = last_stochrsi_k_4h < 80.0
      last_rsi_14_lt_30 = last_rsi_14 < 30.0
      last_change_pct_1d_gt_5 = last_change_pct_1d > 5.0
      last_stochrsi_k_4h_lt_10 = last_stochrsi_k_4h < 10.0
      last_rsi_14_gt_58 = last_rsi_14 > 58.0
      last_rsi_3_4h_gt_85 = last_rsi_3_4h > 85.0
      last_stochrsi_k_1h_lt_30 = last_stochrsi_k_1h < 30.0
      last_stochrsi_k_4h_lt_70 = last_stochrsi_k_4h < 70.0
      last_rsi_3_1d_gt_75 = last_rsi_3_1d > 75.0
      last_rsi_3_lt_40 = last_rsi_3 < 40.0
      last_stochrsi_k_1h_lt_20 = last_stochrsi_k_1h < 20.0
      last_rsi_3_lt_34 = last_rsi_3 < 34.0
      last_rsi_14_gt_48 = last_rsi_14 > 48.0
      last_stochrsi_k_1h_lt_60 = last_stochrsi_k_1h < 60.0
      last_aroond_14_1h_gt_75 = last_aroond_14_1h > 75.0
      last_rsi_3_4h_gt_40 = last_rsi_3_4h > 40.0
      last_roc_9_1h_gt_10 = last_roc_9_1h > 10.0
      last_change_pct_4h_gt_5 = last_change_pct_4h > 5.0
      last_aroond_14_4h_gt_25 = last_aroond_14_4h > 25.0
      last_aroond_14_4h_gt_75 = last_aroond_14_4h > 75.0
      last_rsi_3_lt_35 = last_rsi_3 < 35.0
      last_stochrsi_k_1h_lt_70 = last_stochrsi_k_1h < 70.0
      last_stochrsi_k_4h_lt_75 = last_stochrsi_k_4h < 75.0
      last_rsi_3_lt_36 = last_rsi_3 < 36.0
      last_rsi_14_gt_56 = last_rsi_14 > 56.0
      last_rsi_3_lt_26 = last_rsi_3 < 26.0
      last_rsi_3_1h_gt_60 = last_rsi_3_1h > 60.0
      last_rsi_3_1h_gt_55 = last_rsi_3_1h > 55.0
      last_aroonu_14_4h_lt_50 = last_aroonu_14_4h < 50.0
      last_aroond_14_4h_gt_50 = last_aroond_14_4h > 50.0
      last_rsi_3_1h_gt_65 = last_rsi_3_1h > 65.0
      last_rsi_14_4h_lt_30 = last_rsi_14_4h < 30.0
      last_rsi_3_1d_gt_70 = last_rsi_3_1d > 70.0
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_2_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 34.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_2_2"
      elif (
        (last_willr_14_lt_neg_90)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h_lt_80) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_2_3"
      elif (
        (last_willr_14_lt_neg_70)
        and (last_rsi_14 < 35.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_2_4"
      elif (last_willr_14_lt_neg_96) and (last_rsi_14_lt_30) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_2_5"
      elif (
        (last_rsi_3_lt_30)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_2_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_2_7"
      elif (
        (last_willr_14_lt_neg_96)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_2_8"
      elif (
        (last_willr_14_lt_neg_96)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_2_9"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h_gt_10)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_2_10"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_2_11"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_2_12"
      elif (last_rsi_3_lt_20) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_2_13"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_2_14"
      elif (last_rsi_3_lt_8) and (last_rsi_14_lt_30) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_2_15"
      elif (
        (last_rsi_3_lt_30)
        and (last_aroond_14_4h_gt_25)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_2_16"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_90)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_2_17"
      elif (last_rsi_3_lt_25) and (last_rsi_14 < 40.0) and (last_rsi_3_4h_gt_80) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_2_18"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_lt_30)
        and (last_rsi_3_4h_gt_90)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_19"
      elif (last_rsi_3 < 52.0) and (last_rsi_14_gt_58) and (last_rsi_3_1h_gt_90) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_2_20"
      elif (last_rsi_3_lt_30) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_4h_lt_10):
        return True, f"exit_{mode_name}_d_2_21"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_96)
        and (last_change_pct_4h_gt_5)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_22"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_85) and (last_rsi_3_1h_gt_85) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_2_23"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_lt_30)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_2_24"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_25"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_85) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_2_26"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_4h_lt_80)
      ):
        return True, f"exit_{mode_name}_d_2_27"
      elif (last_rsi_3_lt_25) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_2_28"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_2_29"
      elif (last_rsi_3_lt_15) and (last_rsi_3_1h_gt_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_30):
        return True, f"exit_{mode_name}_d_2_30"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_85)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_2_31"
      elif (last_rsi_3_lt_15) and (last_rsi_3_1h_gt_85) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_2_32"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_96)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_33"
      elif (last_rsi_3_lt_35) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_2_34"
      elif (last_rsi_3_lt_14) and (last_willr_14 < -93.0) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_2_35"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_80)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_36"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_37"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_80) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_2_38"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_94) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_2_39"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h_lt_70)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_2_40"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h_lt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_2_41"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_70)
        and (last_stochrsi_k_4h_lt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_42"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_60)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_2_43"
      elif (
        (last_rsi_3_lt_40)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_2_44"
      elif (last_rsi_3_lt_8) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h_gt_90):
        return True, f"exit_{mode_name}_d_2_45"
      elif (last_rsi_3_lt_30) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_90) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_2_46"
      elif (
        (last_rsi_3_lt_16)
        and (last_stochrsi_k_1h_lt_20)
        and (last_stochrsi_k_4h_lt_60)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_2_47"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_48"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_4h_gt_80)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_49"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_94) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_2_50"
      elif (last_rsi_3_lt_36) and (last_rsi_14_gt_52) and (last_rsi_3_4h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_2_51"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14 < 42.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_2_52"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_80)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_53"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_52)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_2_54"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_84)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_55"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_2_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 62.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_2_57"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_58"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_2_59"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_58)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_60"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_70):
        return True, f"exit_{mode_name}_d_2_61"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d_gt_5)
      ):
        return True, f"exit_{mode_name}_d_2_62"
      elif (last_rsi_3_lt_34) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_20) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_2_63"
      elif (
        (last_rsi_3_lt_14)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_2_64"
      elif (last_rsi_3_lt_34) and (last_rsi_14_gt_56) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_d_2_65"
      elif (last_rsi_3_lt_20) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_2_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14_gt_56)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_2_67"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_75)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_2_68"
      elif (last_rsi_3 < 5.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h_gt_5):
        return True, f"exit_{mode_name}_d_2_69"
      elif (last_rsi_3_lt_36) and (last_rsi_14_gt_58) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_2_70"
      elif (last_rsi_3 < 38.0) and (last_rsi_14_gt_54) and (last_rsi_3_4h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_2_71"
      elif (last_rsi_3_lt_24) and (last_rsi_14_gt_56) and (last_rsi_3_1h_gt_90) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_2_72"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_85)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_2_73"
      elif (
        (last_rsi_3 < 3.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_75)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_2_74"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_75"
      elif (last_rsi_3_lt_34) and (last_rsi_14_gt_48) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_2_76"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_2_77"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_2_78"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_2_79"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_2_80"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_81"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_2_82"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_2_83"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_2_84"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_85"
      elif (
        (last_rsi_3_lt_8)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_86"
      elif (
        (last_rsi_3_lt_36)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_87"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14 < -78.0)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_2_88"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_58)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_2_89"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_2_90"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_2_91"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_2_92"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h_gt_75)
        and (last_stochrsi_k_1h_lt_30)
        and (last_aroond_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_2_93"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_2_94"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_2_95"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_96"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_65)
        and (last_aroond_14_4h_gt_50)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_2_97"
      elif (
        (last_rsi_3_lt_12)
        and (last_rsi_3_15m_lt_30)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_98"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h_gt_40)
        and (last_aroond_14_4h_gt_50)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_2_99"
      elif (last_rsi_3 < 4.0) and (last_rsi_14 < 26.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_2_100"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_4h_lt_60)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_2_101"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_2_102"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_14_4h_lt_30)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_2_103"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_2_104"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_2_105"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_2_106"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_30)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_2_107"
      elif (last_rsi_3 < 46.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_40) and (last_stochrsi_k_1h_lt_20):
        return True, f"exit_{mode_name}_d_2_108"
      elif (
        (last_rsi_3_lt_26)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_2_109"
      elif (last_rsi_3_lt_30) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_2_110"
      elif (
        (last_rsi_3 < 52.0)
        and (last_rsi_14_gt_54)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_aroond_14_1h_gt_75)
        and (last_aroond_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_2_111"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_2_112"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1d_gt_70)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_2_113"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d_gt_70)
      ):
        return True, f"exit_{mode_name}_d_2_114"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_2_115"
      elif (last_rsi_3_lt_12) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_d_2_116"
      elif (last_rsi_3_lt_16) and (last_rsi_3_1h_gt_50) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0):
        return True, f"exit_{mode_name}_d_2_117"
      elif (last_rsi_3_lt_12) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_40) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_2_118"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_2_119"
      elif (last_rsi_3 < 48.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_60) and (last_aroond_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_2_120"
      elif (last_rsi_3_lt_42) and (last_rsi_14_gt_52) and (last_rsi_3_1h_gt_50) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_2_121"
      elif (last_rsi_3_lt_44) and (last_rsi_14_gt_54) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_2_122"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h_gt_90) and (last_rsi_3_1d_gt_70):
        return True, f"exit_{mode_name}_d_2_123"
      elif (
        (last_rsi_3_lt_14)
        and (last_rsi_3_1h_gt_85)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_2_124"
      elif (
        (last_rsi_3_lt_26)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_90)
        and (last_rsi_3_4h_gt_60)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_2_125"
      elif (last_rsi_3_lt_12) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_2_126"
      elif (last_rsi_3_lt_12) and (last_rsi_3_1h_gt_90) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_2_127"
      elif (last_rsi_3_lt_8) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_2_128"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_2_129"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h_lt_20)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_2_130"
      elif (last_rsi_14 > 60.0) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_2_131"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_2_132"
      elif (
        (last_rsi_3_lt_22)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_2_133"
    elif 0.04 > current_profit >= 0.03:
      # Reused short exit decision threshold checks for this profit bracket
      last_rsi_3_lt_20 = last_rsi_3 < 20.0
      last_rsi_14_gt_48 = last_rsi_14 > 48.0
      last_rsi_3_lt_30 = last_rsi_3 < 30.0
      last_rsi_3_4h_gt_80 = last_rsi_3_4h > 80.0
      last_rsi_3_4h_gt_90 = last_rsi_3_4h > 90.0
      last_rsi_3_1h_gt_80 = last_rsi_3_1h > 80.0
      last_rsi_3_1h_gt_85 = last_rsi_3_1h > 85.0
      last_rsi_3_1h_gt_50 = last_rsi_3_1h > 50.0
      last_rsi_3_lt_25 = last_rsi_3 < 25.0
      last_rsi_3_lt_10 = last_rsi_3 < 10.0
      last_rsi_3_1h_gt_90 = last_rsi_3_1h > 90.0
      last_rsi_3_1h_gt_75 = last_rsi_3_1h > 75.0
      last_rsi_3_4h_gt_60 = last_rsi_3_4h > 60.0
      last_rsi_3_lt_26 = last_rsi_3 < 26.0
      last_rsi_3_4h_gt_75 = last_rsi_3_4h > 75.0
      last_rsi_3_lt_16 = last_rsi_3 < 16.0
      last_rsi_3_lt_18 = last_rsi_3 < 18.0
      last_rsi_3_lt_24 = last_rsi_3 < 24.0
      last_rsi_3_lt_32 = last_rsi_3 < 32.0
      last_rsi_3_lt_14 = last_rsi_3 < 14.0
      last_rsi_3_1h_gt_40 = last_rsi_3_1h > 40.0
      last_stochrsi_k_4h_lt_60 = last_stochrsi_k_4h < 60.0
      last_rsi_14_gt_52 = last_rsi_14 > 52.0
      last_stochrsi_k_4h_lt_80 = last_stochrsi_k_4h < 80.0
      last_change_pct_1d_gt_5 = last_change_pct_1d > 5.0
      last_stochrsi_k_4h_lt_10 = last_stochrsi_k_4h < 10.0
      last_rsi_3_lt_12 = last_rsi_3 < 12.0
      last_rsi_14_gt_56 = last_rsi_14 > 56.0
      last_rsi_3_lt_40 = last_rsi_3 < 40.0
      last_rsi_3_4h_gt_85 = last_rsi_3_4h > 85.0
      last_stochrsi_k_1h_lt_30 = last_stochrsi_k_1h < 30.0
      last_stochrsi_k_4h_lt_70 = last_stochrsi_k_4h < 70.0
      last_rsi_3_1d_gt_75 = last_rsi_3_1d > 75.0
      last_stochrsi_k_1h_lt_20 = last_stochrsi_k_1h < 20.0
      last_rsi_3_lt_36 = last_rsi_3 < 36.0
      last_rsi_14_gt_46 = last_rsi_14 > 46.0
      last_stochrsi_k_1h_lt_60 = last_stochrsi_k_1h < 60.0
      last_aroond_14_1h_gt_75 = last_aroond_14_1h > 75.0
      last_rsi_3_4h_gt_40 = last_rsi_3_4h > 40.0
      last_stochrsi_k_lt_5 = last_stochrsi_k < 5.0
      last_rsi_14_lt_32 = last_rsi_14 < 32.0
      last_roc_9_1h_gt_10 = last_roc_9_1h > 10.0
      last_change_pct_4h_gt_5 = last_change_pct_4h > 5.0
      last_aroond_14_4h_gt_25 = last_aroond_14_4h > 25.0
      last_rsi_3_lt_6 = last_rsi_3 < 6.0
      last_rsi_3_lt_15 = last_rsi_3 < 15.0
      last_aroond_14_4h_gt_75 = last_aroond_14_4h > 75.0
      last_rsi_3_lt_35 = last_rsi_3 < 35.0
      last_stochrsi_k_1h_lt_70 = last_stochrsi_k_1h < 70.0
      last_rsi_3_lt_22 = last_rsi_3 < 22.0
      last_stochrsi_k_4h_lt_75 = last_stochrsi_k_4h < 75.0
      last_rsi_3_lt_38 = last_rsi_3 < 38.0
      last_rsi_3_lt_50 = last_rsi_3 < 50.0
      last_rsi_14_gt_54 = last_rsi_14 > 54.0
      last_rsi_3_lt_28 = last_rsi_3 < 28.0
      last_rsi_3_1h_gt_60 = last_rsi_3_1h > 60.0
      last_rsi_3_1h_gt_55 = last_rsi_3_1h > 55.0
      last_aroonu_14_4h_lt_50 = last_aroonu_14_4h < 50.0
      last_aroond_14_4h_gt_50 = last_aroond_14_4h > 50.0
      last_rsi_3_1h_gt_65 = last_rsi_3_1h > 65.0
      last_rsi_14_4h_lt_30 = last_rsi_14_4h < 30.0
      last_rsi_3_1d_gt_70 = last_rsi_3_1d > 70.0
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_3_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 36.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_3_2"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_stochrsi_k_lt_5)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h_lt_80) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_3_3"
      elif (
        (last_willr_14_lt_neg_70)
        and (last_rsi_14 < 35.0)
        and (last_stochrsi_k_lt_5)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_3_4"
      elif (last_willr_14_lt_neg_94) and (last_rsi_14_lt_32) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_3_5"
      elif (
        (last_rsi_3_lt_30)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_3_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_3_7"
      elif (
        (last_willr_14_lt_neg_94)
        and (last_stochrsi_k_lt_5)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_3_8"
      elif (
        (last_willr_14_lt_neg_94)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_3_9"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h_gt_10)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_3_10"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_3_11"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_3_12"
      elif (last_rsi_3_lt_20) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_3_13"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_3_14"
      elif (last_rsi_3_lt_10) and (last_rsi_14 < 35.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_3_15"
      elif (
        (last_rsi_3_lt_30)
        and (last_aroond_14_4h_gt_25)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_3_16"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_90)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_3_17"
      elif (last_rsi_3_lt_25) and (last_rsi_14 < 40.0) and (last_rsi_3_4h_gt_80) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_3_18"
      elif (
        (last_rsi_3_lt_12)
        and (last_rsi_14_lt_32)
        and (last_rsi_3_4h_gt_90)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_19"
      elif (last_rsi_3 < 54.0) and (last_rsi_14_gt_56) and (last_rsi_3_1h_gt_90) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_3_20"
      elif (last_rsi_3_lt_40) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_4h_lt_10):
        return True, f"exit_{mode_name}_d_3_21"
      elif (
        (last_rsi_3_lt_6)
        and (last_willr_14_lt_neg_94)
        and (last_change_pct_4h_gt_5)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_22"
      elif (last_rsi_3_lt_15) and (last_willr_14_lt_neg_80) and (last_rsi_3_1h_gt_85) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_3_23"
      elif (
        (last_rsi_3_lt_12)
        and (last_rsi_14_lt_32)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_3_24"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_25"
      elif (last_rsi_3_lt_25) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_85) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_3_26"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_4h_lt_80)
      ):
        return True, f"exit_{mode_name}_d_3_27"
      elif (last_rsi_3_lt_30) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_3_28"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_3_29"
      elif (last_rsi_3_lt_20) and (last_rsi_3_1h_gt_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_30):
        return True, f"exit_{mode_name}_d_3_30"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_85)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_3_31"
      elif (last_rsi_3_lt_20) and (last_rsi_3_1h_gt_85) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_3_32"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_94)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_33"
      elif (last_rsi_3_lt_35) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_3_34"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_92) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_3_35"
      elif (
        (last_rsi_3_lt_25)
        and (last_willr_14_lt_neg_75)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_36"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_37"
      elif (last_rsi_3_lt_25) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_3_38"
      elif (last_rsi_3 < 7.0) and (last_willr_14 < -93.0) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_3_39"
      elif (
        (last_rsi_3_lt_25)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h_lt_70)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_3_40"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h_lt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_3_41"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14 < -65.0)
        and (last_stochrsi_k_4h_lt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_42"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_60)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_3_43"
      elif (
        (last_rsi_3 < 45.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_3_44"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h_gt_90):
        return True, f"exit_{mode_name}_d_3_45"
      elif (last_rsi_3_lt_30) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_90) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_3_46"
      elif (
        (last_rsi_3_lt_18)
        and (last_stochrsi_k_1h_lt_20)
        and (last_stochrsi_k_4h_lt_60)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_3_47"
      elif (
        (last_rsi_3 < 45.0)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_48"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h_gt_80)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_49"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_92) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_3_50"
      elif (last_rsi_3_lt_38) and (last_rsi_14_gt_50) and (last_rsi_3_4h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_3_51"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14 < 44.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_3_52"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_80)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_53"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_3_54"
      elif (
        (last_rsi_3_lt_10)
        and (last_willr_14_lt_neg_82)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_55"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_3_56"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14 > 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_3_57"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_58"
      elif (
        (last_rsi_3_lt_15)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_3_59"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_56)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_60"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_70):
        return True, f"exit_{mode_name}_d_3_61"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d_gt_5)
      ):
        return True, f"exit_{mode_name}_d_3_62"
      elif (last_rsi_3_lt_36) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_20) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_3_63"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_3_64"
      elif (last_rsi_3_lt_36) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_d_3_65"
      elif (last_rsi_3_lt_22) and (last_rsi_14_gt_48) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_3_66"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14_gt_54)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_3_67"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_75)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_3_68"
      elif (last_rsi_3_lt_6) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h_gt_5):
        return True, f"exit_{mode_name}_d_3_69"
      elif (last_rsi_3_lt_38) and (last_rsi_14_gt_56) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_3_70"
      elif (last_rsi_3_lt_40) and (last_rsi_14_gt_52) and (last_rsi_3_4h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_3_71"
      elif (last_rsi_3_lt_26) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_90) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_3_72"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_85)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_3_73"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_75)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_3_74"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_75"
      elif (last_rsi_3_lt_36) and (last_rsi_14_gt_46) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_3_76"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_3_77"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_3_78"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_3_79"
      elif (
        (last_rsi_3_lt_32)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_3_80"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_81"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_3_82"
      elif (
        (last_rsi_3_lt_32)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_3_83"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_3_84"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_85"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_86"
      elif (
        (last_rsi_3_lt_38)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_87"
      elif (
        (last_rsi_3_lt_16)
        and (last_willr_14 < -76.0)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_3_88"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_56)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_3_89"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_3_90"
      elif (
        (last_rsi_3_lt_32)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_3_91"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_3_92"
      elif (
        (last_rsi_3_lt_32)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h_gt_75)
        and (last_stochrsi_k_1h_lt_30)
        and (last_aroond_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_3_93"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_3_94"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_3_95"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_96"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_65)
        and (last_aroond_14_4h_gt_50)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_3_97"
      elif (
        (last_rsi_3_lt_14)
        and (last_rsi_3_15m < 32.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_98"
      elif (
        (last_rsi_3_lt_44)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h_gt_40)
        and (last_aroond_14_4h_gt_50)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_3_99"
      elif (last_rsi_3_lt_6) and (last_rsi_14 < 28.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_3_100"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_4h_lt_60)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_3_101"
      elif (
        (last_rsi_3_lt_36)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_3_102"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14 > 40.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_14_4h_lt_30)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_3_103"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_3_104"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_3_105"
      elif (
        (last_rsi_3_lt_32)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_3_106"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_30)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_3_107"
      elif (last_rsi_3 < 48.0) and (last_rsi_14_gt_48) and (last_rsi_3_1h_gt_40) and (last_stochrsi_k_1h_lt_20):
        return True, f"exit_{mode_name}_d_3_108"
      elif (
        (last_rsi_3_lt_28)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_3_109"
      elif (last_rsi_3_lt_32) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_3_110"
      elif (
        (last_rsi_3 < 54.0)
        and (last_rsi_14_gt_52)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_aroond_14_1h_gt_75)
        and (last_aroond_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_3_111"
      elif (
        (last_rsi_3_lt_24)
        and (last_willr_14 < -65.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_3_112"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1d_gt_70)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_3_113"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d_gt_70)
      ):
        return True, f"exit_{mode_name}_d_3_114"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_3_115"
      elif (last_rsi_3_lt_14) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_d_3_116"
      elif (last_rsi_3_lt_18) and (last_rsi_3_1h_gt_50) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0):
        return True, f"exit_{mode_name}_d_3_117"
      elif (last_rsi_3_lt_14) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_40) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_3_118"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_3_119"
      elif (last_rsi_3_lt_50) and (last_rsi_14_gt_48) and (last_rsi_3_1h_gt_60) and (last_aroond_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_3_120"
      elif (last_rsi_3_lt_44) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_50) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_3_121"
      elif (last_rsi_3 < 46.0) and (last_rsi_14_gt_52) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_3_122"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h_gt_90) and (last_rsi_3_1d_gt_70):
        return True, f"exit_{mode_name}_d_3_123"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_3_1h_gt_85)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_3_124"
      elif (
        (last_rsi_3_lt_28)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_90)
        and (last_rsi_3_4h_gt_60)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_3_125"
      elif (last_rsi_3_lt_14) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_3_126"
      elif (last_rsi_3_lt_14) and (last_rsi_3_1h_gt_90) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_3_127"
      elif (last_rsi_3_lt_10) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_3_128"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_3_129"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h_lt_20)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_3_130"
      elif (last_rsi_14 > 58.0) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_3_131"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_3_132"
      elif (
        (last_rsi_3_lt_24)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_3_133"
    elif 0.05 > current_profit >= 0.04:
      # Reused short exit decision threshold checks for this profit bracket
      last_rsi_3_lt_30 = last_rsi_3 < 30.0
      last_rsi_3_lt_20 = last_rsi_3 < 20.0
      last_rsi_14_gt_46 = last_rsi_14 > 46.0
      last_rsi_3_4h_gt_80 = last_rsi_3_4h > 80.0
      last_rsi_3_lt_25 = last_rsi_3 < 25.0
      last_rsi_3_4h_gt_90 = last_rsi_3_4h > 90.0
      last_rsi_3_1h_gt_80 = last_rsi_3_1h > 80.0
      last_rsi_14_gt_48 = last_rsi_14 > 48.0
      last_rsi_3_1h_gt_85 = last_rsi_3_1h > 85.0
      last_rsi_3_1h_gt_50 = last_rsi_3_1h > 50.0
      last_rsi_3_1h_gt_90 = last_rsi_3_1h > 90.0
      last_rsi_3_1h_gt_75 = last_rsi_3_1h > 75.0
      last_rsi_3_4h_gt_60 = last_rsi_3_4h > 60.0
      last_rsi_3_lt_28 = last_rsi_3 < 28.0
      last_rsi_3_4h_gt_75 = last_rsi_3_4h > 75.0
      last_rsi_3_lt_22 = last_rsi_3 < 22.0
      last_rsi_3_lt_18 = last_rsi_3 < 18.0
      last_rsi_3_lt_26 = last_rsi_3 < 26.0
      last_rsi_3_lt_34 = last_rsi_3 < 34.0
      last_rsi_3_lt_16 = last_rsi_3 < 16.0
      last_rsi_3_1h_gt_40 = last_rsi_3_1h > 40.0
      last_rsi_3_lt_12 = last_rsi_3 < 12.0
      last_rsi_3_lt_35 = last_rsi_3 < 35.0
      last_rsi_3_lt_50 = last_rsi_3 < 50.0
      last_stochrsi_k_4h_lt_60 = last_stochrsi_k_4h < 60.0
      last_stochrsi_k_4h_lt_80 = last_stochrsi_k_4h < 80.0
      last_change_pct_1d_gt_5 = last_change_pct_1d > 5.0
      last_stochrsi_k_4h_lt_10 = last_stochrsi_k_4h < 10.0
      last_rsi_3_lt_14 = last_rsi_3 < 14.0
      last_rsi_14_gt_54 = last_rsi_14 > 54.0
      last_rsi_3_4h_gt_85 = last_rsi_3_4h > 85.0
      last_stochrsi_k_1h_lt_30 = last_stochrsi_k_1h < 30.0
      last_stochrsi_k_4h_lt_70 = last_stochrsi_k_4h < 70.0
      last_rsi_3_1d_gt_75 = last_rsi_3_1d > 75.0
      last_stochrsi_k_1h_lt_20 = last_stochrsi_k_1h < 20.0
      last_rsi_3_lt_40 = last_rsi_3 < 40.0
      last_rsi_3_lt_38 = last_rsi_3 < 38.0
      last_rsi_14_gt_44 = last_rsi_14 > 44.0
      last_stochrsi_k_1h_lt_60 = last_stochrsi_k_1h < 60.0
      last_aroond_14_1h_gt_75 = last_aroond_14_1h > 75.0
      last_rsi_3_4h_gt_40 = last_rsi_3_4h > 40.0
      last_stochrsi_k_lt_5 = last_stochrsi_k < 5.0
      last_rsi_14_lt_34 = last_rsi_14 < 34.0
      last_roc_9_1h_gt_10 = last_roc_9_1h > 10.0
      last_change_pct_4h_gt_5 = last_change_pct_4h > 5.0
      last_rsi_3_lt_10 = last_rsi_3 < 10.0
      last_aroond_14_4h_gt_25 = last_aroond_14_4h > 25.0
      last_rsi_3_lt_8 = last_rsi_3 < 8.0
      last_aroond_14_4h_gt_75 = last_aroond_14_4h > 75.0
      last_stochrsi_k_1h_lt_70 = last_stochrsi_k_1h < 70.0
      last_rsi_3_lt_24 = last_rsi_3 < 24.0
      last_stochrsi_k_4h_lt_75 = last_stochrsi_k_4h < 75.0
      last_rsi_14_gt_52 = last_rsi_14 > 52.0
      last_rsi_3_1h_gt_60 = last_rsi_3_1h > 60.0
      last_rsi_3_1h_gt_55 = last_rsi_3_1h > 55.0
      last_aroonu_14_4h_lt_50 = last_aroonu_14_4h < 50.0
      last_aroond_14_4h_gt_50 = last_aroond_14_4h > 50.0
      last_rsi_3_1h_gt_65 = last_rsi_3_1h > 65.0
      last_rsi_14_4h_lt_30 = last_rsi_14_4h < 30.0
      last_rsi_3_1d_gt_70 = last_rsi_3_1d > 70.0
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_4_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 38.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_4_2"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_stochrsi_k_lt_5)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h_lt_80) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_4_3"
      elif (
        (last_willr_14_lt_neg_70)
        and (last_rsi_14 < 35.0)
        and (last_stochrsi_k_lt_5)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_4_4"
      elif (last_willr_14_lt_neg_92) and (last_rsi_14_lt_34) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_4_5"
      elif (
        (last_rsi_3_lt_30)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_4_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_4_7"
      elif (
        (last_willr_14_lt_neg_92)
        and (last_stochrsi_k_lt_5)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_4_8"
      elif (
        (last_willr_14 < -93.0)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_4_9"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h_gt_10)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_4_10"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_4_11"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_4_12"
      elif (last_rsi_3_lt_20) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_4_13"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_4_14"
      elif (last_rsi_3_lt_12) and (last_rsi_14 < 40.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_4_15"
      elif (
        (last_rsi_3_lt_30)
        and (last_aroond_14_4h_gt_25)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_4_16"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_1h_gt_90)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_4_17"
      elif (last_rsi_3_lt_25) and (last_rsi_14 < 40.0) and (last_rsi_3_4h_gt_80) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_4_18"
      elif (
        (last_rsi_3_lt_14)
        and (last_rsi_14_lt_34)
        and (last_rsi_3_4h_gt_90)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_19"
      elif (last_rsi_3 < 56.0) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_90) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_4_20"
      elif (last_rsi_3 < 45.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_4h_lt_10):
        return True, f"exit_{mode_name}_d_4_21"
      elif (
        (last_rsi_3_lt_8)
        and (last_willr_14_lt_neg_92)
        and (last_change_pct_4h_gt_5)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_22"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_75) and (last_rsi_3_1h_gt_85) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_4_23"
      elif (
        (last_rsi_3_lt_14)
        and (last_rsi_14_lt_34)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h_gt_75)
      ):
        return True, f"exit_{mode_name}_d_4_24"
      elif (
        (last_rsi_3_lt_25)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_90)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_25"
      elif (last_rsi_3_lt_30) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h_gt_85) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_4_26"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_4h_lt_80)
      ):
        return True, f"exit_{mode_name}_d_4_27"
      elif (last_rsi_3_lt_35) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_4_28"
      elif (
        (last_rsi_3_lt_25)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_4_29"
      elif (last_rsi_3_lt_25) and (last_rsi_3_1h_gt_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_30):
        return True, f"exit_{mode_name}_d_4_30"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_85)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_4_31"
      elif (last_rsi_3_lt_25) and (last_rsi_3_1h_gt_85) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_4_32"
      elif (
        (last_rsi_3_lt_25)
        and (last_willr_14_lt_neg_92)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_33"
      elif (last_rsi_3_lt_35) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_4_34"
      elif (last_rsi_3_lt_18) and (last_willr_14 < -91.0) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_4_35"
      elif (
        (last_rsi_3_lt_30)
        and (last_willr_14_lt_neg_70)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_36"
      elif (
        (last_rsi_3_lt_24)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_37"
      elif (last_rsi_3_lt_30) and (last_willr_14_lt_neg_70) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_4_38"
      elif (last_rsi_3_lt_8) and (last_willr_14_lt_neg_92) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_4_39"
      elif (
        (last_rsi_3_lt_30)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h_lt_70)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_4_40"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h_lt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_4_41"
      elif (
        (last_rsi_3_lt_25)
        and (last_willr_14 < -60.0)
        and (last_stochrsi_k_4h_lt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_42"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_85)
        and (last_rsi_3_4h_gt_60)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_4_43"
      elif (
        (last_rsi_3_lt_50)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_4_44"
      elif (last_rsi_3_lt_12) and (last_willr_14_lt_neg_88) and (last_rsi_3_1h_gt_90):
        return True, f"exit_{mode_name}_d_4_45"
      elif (last_rsi_3_lt_30) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_90) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_4_46"
      elif (
        (last_rsi_3_lt_20)
        and (last_stochrsi_k_1h_lt_20)
        and (last_stochrsi_k_4h_lt_60)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_4_47"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_48"
      elif (
        (last_rsi_3_lt_25)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_80)
        and (last_change_pct_1d_gt_5)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_49"
      elif (last_rsi_3_lt_20) and (last_willr_14_lt_neg_90) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_4_50"
      elif (last_rsi_3_lt_40) and (last_rsi_14_gt_48) and (last_rsi_3_4h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_4_51"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14 < 46.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h_lt_30)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_4_52"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_80)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_53"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_48)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_4_54"
      elif (
        (last_rsi_3_lt_12)
        and (last_willr_14_lt_neg_80)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_55"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_4_56"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14 > 58.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_4_57"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_4_59"
      elif (
        (last_rsi_3_lt_35)
        and (last_rsi_14_gt_54)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_60"
      elif (last_rsi_3_lt_10) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h_gt_90) and (last_stochrsi_k_1h_lt_70):
        return True, f"exit_{mode_name}_d_4_61"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d_gt_5)
      ):
        return True, f"exit_{mode_name}_d_4_62"
      elif (last_rsi_3_lt_38) and (last_rsi_3_1d_gt_75) and (last_stochrsi_k_1h_lt_20) and (last_stochrsi_k_4h_lt_70):
        return True, f"exit_{mode_name}_d_4_63"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_4_64"
      elif (last_rsi_3_lt_38) and (last_rsi_14_gt_52) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_85):
        return True, f"exit_{mode_name}_d_4_65"
      elif (last_rsi_3_lt_24) and (last_rsi_14_gt_46) and (last_rsi_3_1h_gt_80) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_4_66"
      elif (
        (last_rsi_3_lt_50)
        and (last_rsi_14_gt_52)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_4_67"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_75)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_4_68"
      elif (last_rsi_3 < 7.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h_gt_5):
        return True, f"exit_{mode_name}_d_4_69"
      elif (last_rsi_3_lt_40) and (last_rsi_14_gt_54) and (last_rsi_3_1h_gt_75) and (last_stochrsi_k_4h_lt_80):
        return True, f"exit_{mode_name}_d_4_70"
      elif (last_rsi_3_lt_42) and (last_rsi_14_gt_50) and (last_rsi_3_4h_gt_75) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_4_71"
      elif (last_rsi_3_lt_28) and (last_rsi_14_gt_52) and (last_rsi_3_1h_gt_90) and (last_aroond_14_4h_gt_25):
        return True, f"exit_{mode_name}_d_4_72"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_85)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_4_73"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_75)
        and (last_rsi_3_1d_gt_75)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_4_74"
      elif (
        (last_rsi_3_lt_10)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_75"
      elif (last_rsi_3_lt_38) and (last_rsi_14_gt_44) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_4_76"
      elif (
        (last_rsi_3_lt_30)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_4_77"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14 < -78.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_80)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_4_78"
      elif (last_rsi_3_lt_14) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h_gt_90):
        return True, f"exit_{mode_name}_d_4_79"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_4_80"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_81"
      elif (
        (last_rsi_3_lt_24)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_4_82"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_4_83"
      elif (last_rsi_3_lt_16) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_4_84"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_85"
      elif (
        (last_rsi_3_lt_12)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_86"
      elif (
        (last_rsi_3_lt_40)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_87"
      elif (
        (last_rsi_3_lt_18)
        and (last_willr_14 < -74.0)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_4_88"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_54)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_4_89"
      elif (
        (last_rsi_3_lt_14)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_4_90"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h_gt_75)
        and (last_aroonu_14_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_4_91"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_60)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_4_92"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_44)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h_gt_75)
        and (last_stochrsi_k_1h_lt_30)
        and (last_aroond_14_4h_gt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_4_93"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_14_gt_44)
        and (last_rsi_3_1h_gt_75)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_4_94"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_4_95"
      elif (
        (last_rsi_3_lt_44)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_55)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_96"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_48)
        and (last_rsi_3_1h_gt_65)
        and (last_aroond_14_4h_gt_50)
        and (last_stochrsi_k_4h_lt_70)
      ):
        return True, f"exit_{mode_name}_d_4_97"
      elif (
        (last_rsi_3_lt_16)
        and (last_rsi_3_15m < 34.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_98"
      elif (
        (last_rsi_3 < 46.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h_gt_40)
        and (last_aroond_14_4h_gt_50)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_4_99"
      elif (last_rsi_3_lt_8) and (last_rsi_14 < 30.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_4_100"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14 < -78.0)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_4h_lt_60)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_4_101"
      elif (
        (last_rsi_3_lt_38)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_60)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_4_102"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14 > 38.0)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_14_4h_lt_30)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_4_103"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_4_104"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h_lt_10)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_4_105"
      elif (
        (last_rsi_3_lt_34)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_4_106"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_1h_gt_50)
        and (last_stochrsi_k_1h_lt_30)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_4_107"
      elif (last_rsi_3_lt_50) and (last_rsi_14_gt_46) and (last_rsi_3_1h_gt_40) and (last_stochrsi_k_1h_lt_20):
        return True, f"exit_{mode_name}_d_4_108"
      elif (
        (last_rsi_3_lt_30)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_3_4h_gt_80)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_4_109"
      elif (last_rsi_3_lt_34) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_4_110"
      elif (
        (last_rsi_3 < 56.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_50)
        and (last_rsi_14_4h_lt_30)
        and (last_aroond_14_1h_gt_75)
        and (last_aroond_14_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_4_111"
      elif (
        (last_rsi_3_lt_26)
        and (last_willr_14 < -60.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_4_112"
      elif (
        (last_rsi_3_lt_22)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1d_gt_70)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_4_113"
      elif (
        (last_rsi_3_lt_22)
        and (last_rsi_14_gt_44)
        and (last_rsi_3_1h_gt_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d_gt_70)
      ):
        return True, f"exit_{mode_name}_d_4_114"
      elif (
        (last_rsi_3_lt_28)
        and (last_rsi_14_gt_46)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_4_115"
      elif (last_rsi_3_lt_16) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_aroonu_14_4h_lt_50):
        return True, f"exit_{mode_name}_d_4_116"
      elif (last_rsi_3_lt_20) and (last_rsi_3_1h_gt_50) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0):
        return True, f"exit_{mode_name}_d_4_117"
      elif (last_rsi_3_lt_16) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_40) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_4_118"
      elif (
        (last_rsi_3_lt_20)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_40)
        and (last_rsi_3_4h_gt_40)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_4_119"
      elif (last_rsi_3 < 52.0) and (last_rsi_14_gt_46) and (last_rsi_3_1h_gt_60) and (last_aroond_14_4h_gt_75):
        return True, f"exit_{mode_name}_d_4_120"
      elif (last_rsi_3 < 46.0) and (last_rsi_14_gt_48) and (last_rsi_3_1h_gt_50) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_4_121"
      elif (last_rsi_3 < 48.0) and (last_rsi_14_gt_50) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_4_122"
      elif (last_rsi_3_lt_18) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h_gt_90) and (last_rsi_3_1d_gt_70):
        return True, f"exit_{mode_name}_d_4_123"
      elif (
        (last_rsi_3_lt_18)
        and (last_rsi_3_1h_gt_85)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_4_124"
      elif (
        (last_rsi_3_lt_30)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_90)
        and (last_rsi_3_4h_gt_60)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_4_125"
      elif (last_rsi_3_lt_16) and (last_rsi_3_1h_gt_85) and (last_rsi_3_4h_gt_60) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_4_126"
      elif (last_rsi_3_lt_16) and (last_rsi_3_1h_gt_90) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_4_127"
      elif (last_rsi_3_lt_12) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_4_128"
      elif (
        (last_rsi_3_lt_20)
        and (last_rsi_3_4h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_4_129"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h_lt_20)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_4_130"
      elif (last_rsi_14 > 56.0) and (last_rsi_3_1h_gt_80) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_4_131"
      elif (
        (last_rsi_3_lt_26)
        and (last_rsi_3_1h_gt_65)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h_lt_60)
      ):
        return True, f"exit_{mode_name}_d_4_132"
      elif (
        (last_rsi_3_lt_26)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h_gt_75)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_4_133"
    elif 0.06 > current_profit >= 0.05:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_5_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 40.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_5_2"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_5_3"
      elif (
        (last_willr_14_lt_neg_70)
        and (last_rsi_14 < 35.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_5_4"
      elif (last_willr_14_lt_neg_90) and (last_rsi_14 < 36.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_5_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_5_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_5_7"
      elif (
        (last_willr_14_lt_neg_90)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_5_8"
      elif (
        (last_willr_14_lt_neg_92)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_5_9"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_5_10"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_5_11"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_5_12"
      elif (last_rsi_3 < 20.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_5_13"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_88) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_5_14"
      elif (last_rsi_3 < 14.0) and (last_rsi_14 > 58.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_5_15"
      elif (
        (last_rsi_3 < 30.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_5_16"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14 < -65.0)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_5_17"
      elif (last_rsi_3 < 25.0) and (last_rsi_14 < 40.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_5_18"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 < 36.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_19"
      elif (last_rsi_3 < 58.0) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_5_20"
      elif (last_rsi_3 < 50.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_5_21"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_90)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_22"
      elif (last_rsi_3 < 25.0) and (last_willr_14_lt_neg_70) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_5_23"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 < 36.0)
        and (last_willr_14 < -65.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_5_24"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_25"
      elif (last_rsi_3 < 35.0) and (last_willr_14_lt_neg_88) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_5_26"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_5_27"
      elif (last_rsi_3 < 40.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_5_28"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_5_29"
      elif (last_rsi_3 < 30.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_5_30"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_5_31"
      elif (last_rsi_3 < 30.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_5_32"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_90)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_5_34"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_5_35"
      elif (
        (last_rsi_3 < 35.0)
        and (last_willr_14 < -65.0)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_36"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_37"
      elif (last_rsi_3 < 35.0) and (last_willr_14 < -65.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_5_38"
      elif (last_rsi_3 < 9.0) and (last_willr_14 < -91.0) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_5_39"
      elif (
        (last_rsi_3 < 35.0)
        and (last_willr_14 < -65.0)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_5_40"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_5_41"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14 < -55.0)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_42"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_5_43"
      elif (
        (last_rsi_3 < 50.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_5_44"
      elif (last_rsi_3 < 14.0) and (last_willr_14_lt_neg_86) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_5_45"
      elif (last_rsi_3 < 30.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_5_46"
      elif (
        (last_rsi_3 < 22.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_5_47"
      elif (
        (last_rsi_3 < 55.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_48"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_88) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_5_50"
      elif (last_rsi_3_lt_42) and (last_rsi_14 > 46.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_5_51"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 < 48.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_5_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_53"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 46.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_5_54"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14 < -78.0)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_55"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_5_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 56.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_5_57"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_5_59"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_60"
      elif (
        (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_5_61"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_5_62"
      elif (
        (last_rsi_3 < 40.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_5_63"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_5_64"
      elif (last_rsi_3 < 40.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_5_65"
      elif (last_rsi_3 < 26.0) and (last_rsi_14 > 44.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_5_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14_gt_50)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_5_67"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_5_68"
      elif (
        (last_rsi_3 < 8.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_5_69"
      elif (last_rsi_3_lt_42) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_5_70"
      elif (last_rsi_3_lt_44) and (last_rsi_14 > 48.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_5_71"
      elif (last_rsi_3 < 30.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_5_72"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_5_73"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_5_74"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_75"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 42.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_5_76"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_5_77"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14 < -76.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_5_78"
      elif (last_rsi_3 < 16.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_5_79"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_5_80"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_81"
      elif (
        (last_rsi_3 < 26.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_5_82"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_5_83"
      elif (last_rsi_3 < 18.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_5_84"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_85"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_86"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_87"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14 < -72.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_5_88"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 52.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_5_89"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_5_90"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_5_91"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_5_92"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_5_93"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_5_94"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_5_95"
      elif (
        (last_rsi_3 < 46.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_96"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_5_97"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_3_15m < 36.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_98"
      elif (
        (last_rsi_3 < 48.0)
        and (last_rsi_14 > 40.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_5_99"
      elif (last_rsi_3 < 10.0) and (last_rsi_14 < 32.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_5_100"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14 < -76.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_5_101"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_5_102"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 36.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_5_103"
      elif (
        (last_rsi_3_lt_44)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_5_104"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_5_105"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_5_106"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_5_107"
      elif (last_rsi_3 < 52.0) and (last_rsi_14 > 44.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_5_108"
      elif (
        (last_rsi_3 < 32.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_5_109"
      elif (last_rsi_3 < 36.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_5_110"
      elif (
        (last_rsi_3 < 58.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_5_111"
      elif (
        (last_rsi_3 < 28.0)
        and (last_willr_14 < -55.0)
        and (last_rsi_14 > 40.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_5_112"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_5_113"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_5_114"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_5_115"
      elif (last_rsi_3 < 18.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_5_116"
      elif (
        (last_rsi_3 < 22.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_5_117"
      elif (last_rsi_3 < 18.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_5_118"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_5_119"
      elif (last_rsi_3 < 54.0) and (last_rsi_14 > 44.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_5_120"
      elif (last_rsi_3 < 48.0) and (last_rsi_14 > 46.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_5_121"
      elif (last_rsi_3 < 50.0) and (last_rsi_14 > 48.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_5_122"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_88) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_5_123"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_5_124"
      elif (
        (last_rsi_3 < 32.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_5_125"
      elif (last_rsi_3 < 18.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_5_126"
      elif (last_rsi_3 < 18.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_5_127"
      elif (last_rsi_3 < 14.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_5_128"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_5_129"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_5_130"
      elif (last_rsi_14 > 54.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_5_131"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_5_132"
      elif (
        (last_rsi_3 < 28.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_5_133"
    elif 0.07 > current_profit >= 0.06:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_6_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 38.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_6_2"
      elif (
        (last_willr_14_lt_neg_85)
        and (last_stochrsi_k < 2.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_6_3"
      elif (
        (last_willr_14_lt_neg_75)
        and (last_rsi_14 < 32.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_6_4"
      elif (last_willr_14_lt_neg_92) and (last_rsi_14 < 34.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_6_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_6_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_6_7"
      elif (
        (last_willr_14_lt_neg_92)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_6_8"
      elif (
        (last_willr_14 < -93.0)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_6_9"
      elif (
        (last_willr_14_lt_neg_85)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_6_10"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_6_11"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_6_12"
      elif (last_rsi_3 < 15.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_6_13"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_6_14"
      elif (last_rsi_3 < 12.0) and (last_rsi_14 < 40.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_6_15"
      elif (
        (last_rsi_3 < 25.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_6_16"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_6_17"
      elif (last_rsi_3 < 20.0) and (last_rsi_14 < 35.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_6_18"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 < 34.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_19"
      elif (last_rsi_3 < 56.0) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_6_20"
      elif (last_rsi_3 < 40.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_6_21"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_92)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_22"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_75) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_6_23"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 < 34.0)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_6_24"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_25"
      elif (last_rsi_3 < 30.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_6_26"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_6_27"
      elif (last_rsi_3 < 35.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_6_28"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_6_29"
      elif (last_rsi_3 < 25.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_6_30"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_6_31"
      elif (last_rsi_3 < 25.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_6_32"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_92)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_6_34"
      elif (last_rsi_3 < 18.0) and (last_willr_14 < -91.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_6_35"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_70)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_36"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_37"
      elif (
        (last_rsi_3 < 30.0) and (last_willr_14_lt_neg_70) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_6_38"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_92) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_6_39"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_6_40"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_6_41"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14 < -60.0)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_42"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_6_43"
      elif (
        (last_rsi_3 < 45.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_6_44"
      elif (last_rsi_3 < 12.0) and (last_willr_14_lt_neg_88) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_6_45"
      elif (last_rsi_3 < 25.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_6_46"
      elif (
        (last_rsi_3 < 20.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_6_47"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_48"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_6_50"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 48.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_6_51"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 < 46.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_6_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_53"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 48.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_6_54"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_80)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_55"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_6_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 58.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_6_57"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_6_59"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_60"
      elif (
        (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_6_61"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_6_62"
      elif (
        (last_rsi_3 < 38.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_6_63"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_6_64"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_6_65"
      elif (last_rsi_3 < 24.0) and (last_rsi_14 > 46.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_6_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 52.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_6_67"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_6_68"
      elif (
        (last_rsi_3 < 7.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_6_69"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_6_70"
      elif (last_rsi_3_lt_42) and (last_rsi_14_gt_50) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_6_71"
      elif (last_rsi_3 < 28.0) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_6_72"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_6_73"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_6_74"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_75"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 44.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_6_76"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_6_77"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14 < -78.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_6_78"
      elif (last_rsi_3 < 14.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_6_79"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_6_80"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_81"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_6_82"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_6_83"
      elif (last_rsi_3 < 16.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_6_84"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_85"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_86"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_87"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14 < -74.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_6_88"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 54.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_6_89"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_6_90"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_6_91"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_6_92"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_6_93"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_6_94"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_6_95"
      elif (
        (last_rsi_3_lt_44)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_96"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_6_97"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_3_15m < 34.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_98"
      elif (
        (last_rsi_3 < 46.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_6_99"
      elif (last_rsi_3 < 8.0) and (last_rsi_14 < 30.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_6_100"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14 < -78.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_6_101"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_6_102"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 38.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_6_103"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_6_104"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_6_105"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_6_106"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_6_107"
      elif (last_rsi_3 < 50.0) and (last_rsi_14 > 46.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_6_108"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_6_109"
      elif (last_rsi_3 < 34.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_6_110"
      elif (
        (last_rsi_3 < 56.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_6_111"
      elif (
        (last_rsi_3 < 26.0)
        and (last_willr_14 < -60.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_6_112"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_6_113"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_6_114"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_6_115"
      elif (last_rsi_3 < 16.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_6_116"
      elif (
        (last_rsi_3 < 20.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_6_117"
      elif (last_rsi_3 < 16.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_6_118"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_6_119"
      elif (last_rsi_3 < 52.0) and (last_rsi_14 > 46.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_6_120"
      elif (last_rsi_3 < 46.0) and (last_rsi_14 > 48.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_6_121"
      elif (last_rsi_3 < 48.0) and (last_rsi_14_gt_50) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_6_122"
      elif (last_rsi_3 < 18.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_6_123"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_6_124"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_6_125"
      elif (last_rsi_3 < 16.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_6_126"
      elif (last_rsi_3 < 16.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_6_127"
      elif (last_rsi_3 < 12.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_6_128"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_6_129"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_6_130"
      elif (last_rsi_14 > 56.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_6_131"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_6_132"
      elif (
        (last_rsi_3 < 26.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_6_133"
    elif 0.08 > current_profit >= 0.07:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_7_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 36.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_7_2"
      elif (
        (last_willr_14_lt_neg_90)
        and (last_stochrsi_k < 2.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_7_3"
      elif (
        (last_willr_14_lt_neg_80)
        and (last_rsi_14 < 30.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_7_4"
      elif (last_willr_14_lt_neg_94) and (last_rsi_14 < 32.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_7_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_7_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_7_7"
      elif (
        (last_willr_14_lt_neg_94)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_7_8"
      elif (
        (last_willr_14_lt_neg_94)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_7_9"
      elif (
        (last_willr_14_lt_neg_90)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_7_10"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_7_11"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_7_12"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_7_13"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_7_14"
      elif (last_rsi_3 < 10.0) and (last_rsi_14 < 38.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_7_15"
      elif (
        (last_rsi_3 < 20.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_7_16"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_7_17"
      elif (last_rsi_3 < 15.0) and (last_rsi_14 < 30.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_7_18"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14 < 32.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_19"
      elif (last_rsi_3 < 54.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_7_20"
      elif (last_rsi_3 < 30.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_7_21"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_94)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_22"
      elif (last_rsi_3 < 15.0) and (last_willr_14_lt_neg_80) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_7_23"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14 < 32.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_7_24"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_25"
      elif (last_rsi_3 < 25.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_7_26"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_7_27"
      elif (last_rsi_3 < 30.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_7_28"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_7_29"
      elif (last_rsi_3 < 20.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_7_30"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_7_31"
      elif (last_rsi_3 < 20.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_7_32"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_94)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_7_34"
      elif (last_rsi_3 < 16.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_7_35"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_75)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_36"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_37"
      elif (
        (last_rsi_3 < 25.0) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_7_38"
      elif (last_rsi_3 < 7.0) and (last_willr_14 < -93.0) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_7_39"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_7_40"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_7_41"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14 < -65.0)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_42"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_7_43"
      elif (
        (last_rsi_3 < 40.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_7_44"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_7_45"
      elif (last_rsi_3 < 20.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_7_46"
      elif (
        (last_rsi_3 < 18.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_7_47"
      elif (
        (last_rsi_3 < 45.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_48"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_7_50"
      elif (last_rsi_3 < 38.0) and (last_rsi_14_gt_50) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_7_51"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 < 44.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_7_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_53"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14_gt_50)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_7_54"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_82)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_55"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_7_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 60.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_7_57"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_7_59"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_60"
      elif (
        (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_7_61"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_7_62"
      elif (
        (last_rsi_3 < 36.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_7_63"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_7_64"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_7_65"
      elif (last_rsi_3 < 22.0) and (last_rsi_14 > 48.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_7_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 54.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_7_67"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_7_68"
      elif (
        (last_rsi_3 < 6.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_7_69"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_7_70"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 52.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_7_71"
      elif (last_rsi_3 < 26.0) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_7_72"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_7_73"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_7_74"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_75"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 46.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_7_76"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_7_77"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_7_78"
      elif (last_rsi_3 < 12.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_7_79"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_7_80"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_81"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_7_82"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_7_83"
      elif (last_rsi_3 < 14.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_7_84"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_85"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_86"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_87"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14 < -76.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_7_88"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 56.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_7_89"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_7_90"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_7_91"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_7_92"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_7_93"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_7_94"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_7_95"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_96"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_7_97"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_3_15m < 32.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_98"
      elif (
        (last_rsi_3_lt_44)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_7_99"
      elif (last_rsi_3 < 6.0) and (last_rsi_14 < 28.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_7_100"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_7_101"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_7_102"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 40.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_7_103"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_7_104"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_7_105"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_7_106"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_7_107"
      elif (last_rsi_3 < 48.0) and (last_rsi_14 > 48.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_7_108"
      elif (
        (last_rsi_3 < 28.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_7_109"
      elif (last_rsi_3 < 32.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_7_110"
      elif (
        (last_rsi_3 < 54.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_7_111"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14 < -65.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_7_112"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_7_113"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_7_114"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_7_115"
      elif (last_rsi_3 < 14.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_7_116"
      elif (
        (last_rsi_3 < 18.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_7_117"
      elif (last_rsi_3 < 14.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_7_118"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_7_119"
      elif (last_rsi_3 < 50.0) and (last_rsi_14 > 48.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_7_120"
      elif (last_rsi_3_lt_44) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_7_121"
      elif (last_rsi_3 < 46.0) and (last_rsi_14 > 52.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_7_122"
      elif (last_rsi_3 < 16.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_7_123"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_7_124"
      elif (
        (last_rsi_3 < 28.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_7_125"
      elif (last_rsi_3 < 14.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_7_126"
      elif (last_rsi_3 < 14.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_7_127"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_7_128"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_7_129"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_7_130"
      elif (last_rsi_14 > 58.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_7_131"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_7_132"
      elif (
        (last_rsi_3 < 24.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_7_133"
    elif 0.09 > current_profit >= 0.08:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_8_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 34.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_8_2"
      elif (
        (last_willr_14_lt_neg_92)
        and (last_stochrsi_k < 2.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_8_3"
      elif (
        (last_willr_14_lt_neg_85)
        and (last_rsi_14 < 28.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_8_4"
      elif (last_willr_14_lt_neg_96) and (last_rsi_14 < 30.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_8_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_8_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_8_7"
      elif (
        (last_willr_14_lt_neg_96)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_8_8"
      elif (
        (last_willr_14_lt_neg_95)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_8_9"
      elif (
        (last_willr_14_lt_neg_92)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_8_10"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_8_11"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_8_12"
      elif (last_rsi_3 < 5.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_8_13"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_8_14"
      elif (last_rsi_3 < 8.0) and (last_rsi_14 < 36.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_8_15"
      elif (
        (last_rsi_3 < 15.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_8_16"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_8_17"
      elif (last_rsi_3 < 10.0) and (last_rsi_14 < 28.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_8_18"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 < 30.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_19"
      elif (last_rsi_3 < 52.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_8_20"
      elif (last_rsi_3 < 20.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_8_21"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_96)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_22"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_85) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_8_23"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 < 30.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_8_24"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_25"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_8_26"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_8_27"
      elif (last_rsi_3 < 25.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_8_28"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_8_29"
      elif (last_rsi_3 < 15.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_8_30"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_8_31"
      elif (last_rsi_3 < 15.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_8_32"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_96)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_8_34"
      elif (last_rsi_3 < 14.0) and (last_willr_14 < -93.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_8_35"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_80)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_36"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_37"
      elif (
        (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_80) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_8_38"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_94) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_8_39"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_8_40"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_8_41"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_70)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_42"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_8_43"
      elif (
        (last_rsi_3 < 35.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_8_44"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_92) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_8_45"
      elif (last_rsi_3 < 15.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_8_46"
      elif (
        (last_rsi_3 < 16.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_8_47"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_48"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_8_50"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 52.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_8_51"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 < 42.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_8_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_53"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 52.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_8_54"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_84)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_55"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_8_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 62.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_8_57"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_8_59"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_60"
      elif (
        (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_75) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_8_61"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_8_62"
      elif (
        (last_rsi_3 < 34.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_8_63"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_8_64"
      elif (last_rsi_3 < 34.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_8_65"
      elif (last_rsi_3 < 20.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_8_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 56.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_8_67"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_8_68"
      elif (
        (last_rsi_3 < 5.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_8_69"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_8_70"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 54.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_8_71"
      elif (last_rsi_3 < 24.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_8_72"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_8_73"
      elif (
        (last_rsi_3 < 3.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_8_74"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_75"
      elif (last_rsi_3 < 34.0) and (last_rsi_14 > 48.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_8_76"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_8_77"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_8_78"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_8_79"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_8_80"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_81"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_8_82"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_8_83"
      elif (last_rsi_3 < 12.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_8_84"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_85"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_86"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_87"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14 < -78.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_8_88"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 58.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_8_89"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_8_90"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_8_91"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_8_92"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_8_93"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_8_94"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_8_95"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_96"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_8_97"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_3_15m_lt_30)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_98"
      elif (
        (last_rsi_3_lt_42)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_8_99"
      elif (last_rsi_3 < 4.0) and (last_rsi_14 < 26.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_8_100"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_82)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_8_101"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_8_102"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 42.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_8_103"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_8_104"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_8_105"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_8_106"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_8_107"
      elif (last_rsi_3 < 46.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_8_108"
      elif (
        (last_rsi_3 < 26.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_8_109"
      elif (last_rsi_3 < 30.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_8_110"
      elif (
        (last_rsi_3 < 52.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_8_111"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_70)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_8_112"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_8_113"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_8_114"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_8_115"
      elif (last_rsi_3 < 12.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_8_116"
      elif (
        (last_rsi_3 < 16.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_8_117"
      elif (last_rsi_3 < 12.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_8_118"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_8_119"
      elif (last_rsi_3 < 48.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_8_120"
      elif (last_rsi_3_lt_42) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_8_121"
      elif (last_rsi_3_lt_44) and (last_rsi_14 > 54.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_8_122"
      elif (last_rsi_3 < 14.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_8_123"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_8_124"
      elif (
        (last_rsi_3 < 26.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_8_125"
      elif (last_rsi_3 < 12.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_8_126"
      elif (last_rsi_3 < 12.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_8_127"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_8_128"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_8_129"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_8_130"
      elif (last_rsi_14 > 60.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_8_131"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_8_132"
      elif (
        (last_rsi_3 < 22.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_8_133"
    elif 0.1 > current_profit >= 0.09:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_9_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 32.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_9_2"
      elif (
        (last_willr_14_lt_neg_94)
        and (last_stochrsi_k < 2.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_9_3"
      elif (
        (last_willr_14_lt_neg_90)
        and (last_rsi_14 < 26.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_9_4"
      elif (last_willr_14_lt_neg_98) and (last_rsi_14 < 28.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_9_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_9_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_9_7"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_9_8"
      elif (
        (last_willr_14_lt_neg_96)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_9_9"
      elif (
        (last_willr_14_lt_neg_94)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_9_10"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_9_11"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_9_12"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_9_13"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_9_14"
      elif (last_rsi_3 < 6.0) and (last_rsi_14 < 34.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_9_15"
      elif (
        (last_rsi_3 < 10.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_9_16"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_9_17"
      elif (last_rsi_3 < 8.0) and (last_rsi_14 < 26.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_9_18"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_14 < 28.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_19"
      elif (last_rsi_3 < 50.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_9_20"
      elif (last_rsi_3 < 10.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_9_21"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_98)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_22"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_9_23"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_14 < 28.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_9_24"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_25"
      elif (last_rsi_3 < 15.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_9_26"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_9_27"
      elif (last_rsi_3 < 20.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_9_28"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_9_29"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_9_30"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_9_31"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_9_32"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_98)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_9_34"
      elif (last_rsi_3 < 12.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_9_35"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_85)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_36"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_37"
      elif (
        (last_rsi_3 < 15.0) and (last_willr_14_lt_neg_85) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_9_38"
      elif (last_rsi_3 < 5.0) and (last_willr_14_lt_neg_95) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_9_39"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_9_40"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_9_41"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_75)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_42"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_9_43"
      elif (
        (last_rsi_3 < 30.0)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_9_44"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_94) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_9_45"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_9_46"
      elif (
        (last_rsi_3 < 14.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_9_47"
      elif (
        (last_rsi_3 < 35.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_48"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_9_50"
      elif (last_rsi_3 < 34.0) and (last_rsi_14 > 54.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_9_51"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 < 40.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_9_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_53"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 54.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_9_54"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_86)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_55"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_9_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 64.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_9_57"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_9_59"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_60"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_80) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0):
        return True, f"exit_{mode_name}_d_9_61"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_9_62"
      elif (
        (last_rsi_3 < 32.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_9_63"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_9_64"
      elif (last_rsi_3 < 32.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_9_65"
      elif (last_rsi_3 < 18.0) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_9_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 58.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_9_67"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_9_68"
      elif (
        (last_rsi_3 < 4.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_9_69"
      elif (last_rsi_3 < 34.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_9_70"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 56.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_9_71"
      elif (last_rsi_3 < 22.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_9_72"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_9_73"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_9_74"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_75"
      elif (last_rsi_3 < 32.0) and (last_rsi_14_gt_50) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_9_76"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_9_77"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_9_78"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_9_79"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_9_80"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_81"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_9_82"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_9_83"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_9_84"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_85"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_86"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_87"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_80)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_9_88"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_9_89"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_9_90"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_9_91"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_9_92"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_9_93"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_9_94"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_9_95"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_96"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_9_97"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_3_15m < 28.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_98"
      elif (
        (last_rsi_3 < 40.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_9_99"
      elif (last_rsi_3 < 2.0) and (last_rsi_14 < 24.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_9_100"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_84)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_9_101"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_9_102"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 44.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_9_103"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_9_104"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_9_105"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_9_106"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_9_107"
      elif (last_rsi_3_lt_44) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_9_108"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_9_109"
      elif (last_rsi_3 < 28.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_9_110"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_9_111"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_9_112"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_9_113"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_9_114"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_9_115"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_9_116"
      elif (
        (last_rsi_3 < 14.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_9_117"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_9_118"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_9_119"
      elif (last_rsi_3 < 46.0) and (last_rsi_14 > 52.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_9_120"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_9_121"
      elif (last_rsi_3_lt_42) and (last_rsi_14 > 56.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_9_122"
      elif (last_rsi_3 < 12.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_9_123"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_9_124"
      elif (
        (last_rsi_3 < 24.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_9_125"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_9_126"
      elif (last_rsi_3 < 10.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_9_127"
      elif (last_rsi_3 < 6.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_9_128"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_9_129"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_9_130"
      elif (last_rsi_14 > 62.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_9_131"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_9_132"
      elif (
        (last_rsi_3 < 20.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_9_133"
    elif 0.12 > current_profit >= 0.1:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_10_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 30.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_10_2"
      elif (
        (last_willr_14_lt_neg_96)
        and (last_stochrsi_k < 2.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_10_3"
      elif (
        (last_willr_14_lt_neg_95)
        and (last_rsi_14 < 24.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_10_4"
      elif (last_willr_14_lt_neg_99) and (last_rsi_14 < 26.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_10_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_10_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_10_7"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_stochrsi_k < 5.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_10_8"
      elif (
        (last_willr_14 < -97.0)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_10_9"
      elif (
        (last_willr_14_lt_neg_96)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_10_10"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_10_11"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_10_12"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_10_13"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_10_14"
      elif (last_rsi_3 < 4.0) and (last_rsi_14 < 32.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_10_15"
      elif (
        (last_rsi_3 < 5.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_10_16"
      elif (
        (last_rsi_3 < 3.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_10_17"
      elif (last_rsi_3 < 6.0) and (last_rsi_14 < 24.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_10_18"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_14 < 26.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_19"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_10_20"
      elif (last_rsi_3 < 5.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_10_21"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_22"
      elif (last_rsi_3 < 5.0) and (last_willr_14_lt_neg_95) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_10_23"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_14 < 26.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_10_24"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_25"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_10_26"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_10_27"
      elif (last_rsi_3 < 15.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_10_28"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_10_29"
      elif (last_rsi_3 < 5.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_10_30"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_10_31"
      elif (last_rsi_3 < 5.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_10_32"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_99)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_10_34"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_95) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_10_35"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_90)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_36"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_37"
      elif (
        (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_10_38"
      elif (last_rsi_3 < 4.0) and (last_willr_14_lt_neg_96) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_10_39"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_10_40"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_10_41"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_80)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_42"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_10_43"
      elif (
        (last_rsi_3 < 25.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_10_44"
      elif (last_rsi_3 < 4.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_10_45"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_10_46"
      elif (
        (last_rsi_3 < 12.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_10_47"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_48"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_49"
      elif (last_rsi_3 < 20.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_10_50"
      elif (last_rsi_3 < 32.0) and (last_rsi_14 > 56.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_10_51"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 < 38.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_10_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_53"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 56.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_10_54"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_88)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_55"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_10_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 66.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_10_57"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_58"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_10_59"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 62.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_60"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_85) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0):
        return True, f"exit_{mode_name}_d_10_61"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_10_62"
      elif (
        (last_rsi_3 < 30.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_10_63"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_10_64"
      elif (last_rsi_3 < 30.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_10_65"
      elif (last_rsi_3 < 16.0) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_10_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 60.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_10_67"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_10_68"
      elif (
        (last_rsi_3 < 3.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_10_69"
      elif (last_rsi_3 < 32.0) and (last_rsi_14 > 62.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_10_70"
      elif (last_rsi_3 < 34.0) and (last_rsi_14 > 58.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_10_71"
      elif (last_rsi_3 < 20.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_10_72"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_10_73"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_10_74"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_75"
      elif (last_rsi_3 < 30.0) and (last_rsi_14 > 52.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_10_76"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_10_77"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_10_78"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_10_79"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_10_80"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_81"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_10_82"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_10_83"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_10_84"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_85"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_86"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_87"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_82)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_10_88"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 62.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_10_89"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_10_90"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_10_91"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_10_92"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_10_93"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_10_94"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_10_95"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_96"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_10_97"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_3_15m < 26.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_98"
      elif (
        (last_rsi_3 < 38.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_10_99"
      elif (last_rsi_3 < 1.0) and (last_rsi_14 < 22.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_10_100"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_86)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_10_101"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_10_102"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 46.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_10_103"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_10_104"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_10_105"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_10_106"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_10_107"
      elif (last_rsi_3_lt_42) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_10_108"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_10_109"
      elif (last_rsi_3 < 26.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_10_110"
      elif (
        (last_rsi_3 < 48.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_10_111"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_10_112"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_10_113"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_10_114"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_10_115"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_10_116"
      elif (
        (last_rsi_3 < 12.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_10_117"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_10_118"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_10_119"
      elif (last_rsi_3_lt_44) and (last_rsi_14 > 54.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_10_120"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_10_121"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 58.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_10_122"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_10_123"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_10_124"
      elif (
        (last_rsi_3 < 22.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_10_125"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_10_126"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_10_127"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_10_128"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_10_129"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_10_130"
      elif (last_rsi_14 > 64.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_10_131"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_10_132"
      elif (
        (last_rsi_3 < 18.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_10_133"
    elif 0.2 > current_profit >= 0.12:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_11_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 26.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_11_2"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_11_3"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_rsi_14 < 22.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_11_4"
      elif (last_willr_14_lt_neg_99) and (last_rsi_14 < 24.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_11_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_11_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k_lt_30)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_11_7"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_stochrsi_k < 2.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_11_8"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_rsi_3 < 5.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_11_9"
      elif (
        (last_willr_14_lt_neg_98)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_11_10"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_11_11"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_11_12"
      elif (last_rsi_3 < 2.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_11_13"
      elif (last_rsi_3 < 5.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_11_14"
      elif (last_rsi_3 < 2.0) and (last_rsi_14 < 30.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_11_15"
      elif (
        (last_rsi_3 < 2.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_11_16"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_11_17"
      elif (last_rsi_3 < 4.0) and (last_rsi_14 < 22.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_11_18"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_14 < 24.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_19"
      elif (last_rsi_3 < 20.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_11_20"
      elif (last_rsi_3 < 2.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_11_21"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_22"
      elif (last_rsi_3 < 2.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_11_23"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_14 < 24.0)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_11_24"
      elif (
        (last_rsi_3 < 3.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_25"
      elif (last_rsi_3 < 5.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_11_26"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_11_27"
      elif (last_rsi_3 < 10.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_11_28"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_11_29"
      elif (last_rsi_3 < 2.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_11_30"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_11_31"
      elif (last_rsi_3 < 2.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_11_32"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_99)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_11_34"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_96) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_11_35"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_95)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_36"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_37"
      elif (last_rsi_3 < 5.0) and (last_willr_14_lt_neg_95) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_11_38"
      elif (last_rsi_3 < 3.0) and (last_willr_14 < -97.0) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_11_39"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_95)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_11_40"
      elif (
        (last_rsi_3 < 3.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_11_41"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_85)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_42"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_11_43"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_11_44"
      elif (last_rsi_3 < 2.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_11_45"
      elif (last_rsi_3 < 6.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_11_46"
      elif (
        (last_rsi_3 < 10.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_11_47"
      elif (
        (last_rsi_3 < 25.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_48"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_49"
      elif (last_rsi_3 < 15.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_11_50"
      elif (last_rsi_3 < 30.0) and (last_rsi_14 > 58.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_11_51"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 < 36.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_11_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_53"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 58.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_11_54"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_90)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_55"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_11_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 68.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_11_57"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_58"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_11_59"
      elif (
        (last_rsi_3 < 15.0)
        and (last_rsi_14 > 64.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_60"
      elif (last_rsi_3 < 4.0) and (last_willr_14_lt_neg_90) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0):
        return True, f"exit_{mode_name}_d_11_61"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_11_62"
      elif (
        (last_rsi_3 < 28.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_11_63"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_11_64"
      elif (last_rsi_3 < 28.0) and (last_rsi_14 > 62.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_11_65"
      elif (last_rsi_3 < 14.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_11_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 62.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_11_67"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_11_68"
      elif (
        (last_rsi_3 < 2.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_11_69"
      elif (last_rsi_3 < 30.0) and (last_rsi_14 > 64.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_11_70"
      elif (last_rsi_3 < 32.0) and (last_rsi_14 > 60.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_11_71"
      elif (last_rsi_3 < 18.0) and (last_rsi_14 > 62.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_11_72"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_11_73"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_11_74"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_75"
      elif (last_rsi_3 < 28.0) and (last_rsi_14 > 54.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_11_76"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_11_77"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_11_78"
      elif (last_rsi_3 < 4.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_11_79"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_11_80"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_81"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_11_82"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_11_83"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_11_84"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_85"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_86"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_87"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_84)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_11_88"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 64.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_11_89"
      elif (
        (last_rsi_3 < 4.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_11_90"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_11_91"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_11_92"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_11_93"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_11_94"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_92)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_11_95"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_96"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_11_97"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_3_15m < 24.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_98"
      elif (
        (last_rsi_3 < 36.0)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_11_99"
      elif (last_rsi_3 < 1.0) and (last_rsi_14 < 20.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_11_100"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_88)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_11_101"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_11_102"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 48.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_11_103"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_11_104"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_11_105"
      elif (
        (last_rsi_3 < 24.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_11_106"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_11_107"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_11_108"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_11_109"
      elif (last_rsi_3 < 24.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_11_110"
      elif (
        (last_rsi_3 < 46.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_11_111"
      elif (
        (last_rsi_3 < 16.0)
        and (last_willr_14_lt_neg_85)
        and (last_rsi_14 > 52.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_11_112"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_11_113"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_11_114"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_11_115"
      elif (last_rsi_3 < 6.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_11_116"
      elif (
        (last_rsi_3 < 10.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0)
      ):
        return True, f"exit_{mode_name}_d_11_117"
      elif (last_rsi_3 < 6.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_11_118"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_11_119"
      elif (last_rsi_3_lt_42) and (last_rsi_14 > 56.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_11_120"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_11_121"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 60.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_11_122"
      elif (last_rsi_3 < 8.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_11_123"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_11_124"
      elif (
        (last_rsi_3 < 20.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_11_125"
      elif (last_rsi_3 < 6.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_11_126"
      elif (last_rsi_3 < 6.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_11_127"
      elif (last_rsi_3 < 2.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_11_128"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_11_129"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_11_130"
      elif (last_rsi_14 > 66.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_11_131"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_11_132"
      elif (
        (last_rsi_3 < 16.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_11_133"
    elif current_profit >= 0.2:
      if (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
        and (last_kst_1h > last_ksts_9_1h)
        and (last_kst_4h > last_ksts_9_4h)
      ):
        return True, f"exit_{mode_name}_d_12_1"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 22.0)
        and (last_cmf_20_1h_gt_0)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_12_2"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h_gt_0)
        and (last_cmf_20_4h_gt_0)
        and ((last_stochrsi_k_4h < 80.0) and (last_stochrsi_k_change_pct_4h_gt_10))
      ):
        return True, f"exit_{mode_name}_d_12_3"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14 < 20.0)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_30)
        and (isinstance(last_ema_200_1h, np.float64) and (last_ema_12_1h > last_ema_200_1h))
        and (isinstance(last_ema_200_4h, np.float64) and (last_ema_12_4h > last_ema_200_4h))
      ):
        return True, f"exit_{mode_name}_d_12_4"
      elif (last_willr_14_lt_neg_99) and (last_rsi_14 < 22.0) and (last_roc_9_1h_gt_5) and (last_roc_9_4h_gt_5):
        return True, f"exit_{mode_name}_d_12_5"
      elif (
        (last_rsi_3 < 30.0)
        and (last_stochrsi_k_lt_30)
        and (last_rsi_14 > 60.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_12_6"
      elif (
        (last_rsi_14_gt_50)
        and (last_stochrsi_k < 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 40.0))
      ):
        return True, f"exit_{mode_name}_d_12_7"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_stochrsi_k < 1.0)
        and (last_cmf_20_1h > 0.1)
        and (last_cmf_20_4h > 0.1)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -15.0))
      ):
        return True, f"exit_{mode_name}_d_12_8"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_3 < 1.0)
        and (last_change_pct_4h > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_12_9"
      elif (
        (last_willr_14_lt_neg_99)
        and (last_rsi_14_gt_50)
        and (last_roc_9_1h > 10.0)
        and (last_roc_9_4h_gt_10)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
      ):
        return True, f"exit_{mode_name}_d_12_10"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_14 > 55.0)
        and (last_roc_9_15m > 10.0)
        and (last_roc_9_1h > 10.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 20.0))
      ):
        return True, f"exit_{mode_name}_d_12_11"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_1h > 20.0)
        and (last_roc_9_4h_gt_20)
      ):
        return True, f"exit_{mode_name}_d_12_12"
      elif (last_rsi_3 < 1.0) and (last_rsi_3_4h_gt_95) and (last_roc_9_4h_gt_25):
        return True, f"exit_{mode_name}_d_12_13"
      elif (last_rsi_3 < 1.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_95) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_12_14"
      elif (last_rsi_3 < 1.0) and (last_rsi_14 < 25.0) and (last_roc_9_4h > 30.0):
        return True, f"exit_{mode_name}_d_12_15"
      elif (
        (last_rsi_3 < 1.0)
        and (last_aroond_14_4h > 25.0)
        and (last_roc_9_4h_gt_25)
        and (last_aroond_14_1d > 50.0)
        and (last_change_pct_1d > 15.0)
      ):
        return True, f"exit_{mode_name}_d_12_16"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h > 90.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h < -30.0)
      ):
        return True, f"exit_{mode_name}_d_12_17"
      elif (last_rsi_3 < 1.0) and (last_rsi_14 < 20.0) and (last_rsi_3_4h > 80.0) and (last_roc_2_1d > 50.0):
        return True, f"exit_{mode_name}_d_12_18"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_14 < 22.0)
        and (last_rsi_3_4h > 90.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_19"
      elif (last_rsi_3 < 10.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_1h > 25.0):
        return True, f"exit_{mode_name}_d_12_20"
      elif (last_rsi_3 < 1.0) and (last_rsi_14_gt_50) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_4h < 10.0):
        return True, f"exit_{mode_name}_d_12_21"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_change_pct_4h > 5.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_22"
      elif (last_rsi_3 < 1.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h > 85.0) and (last_rsi_3_1d > 95.0):
        return True, f"exit_{mode_name}_d_12_23"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_14 < 22.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_4h_gt_70)
        and (last_aroond_14_4h > 75.0)
      ):
        return True, f"exit_{mode_name}_d_12_24"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_4h > 90.0)
        and (last_roc_9_4h > 15.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_25"
      elif (last_rsi_3 < 1.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h > 85.0) and (last_roc_9_4h_gt_20):
        return True, f"exit_{mode_name}_d_12_26"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_4h < 80.0)
      ):
        return True, f"exit_{mode_name}_d_12_27"
      elif (last_rsi_3 < 5.0) and (last_rsi_14_gt_50) and (last_rsi_3_15m > 90.0) and (last_roc_9_4h < -50.0):
        return True, f"exit_{mode_name}_d_12_28"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_12_29"
      elif (last_rsi_3 < 1.0) and (last_rsi_3_1h > 75.0) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 30.0):
        return True, f"exit_{mode_name}_d_12_30"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 85.0)
        and (last_stochrsi_k_1h_lt_75)
      ):
        return True, f"exit_{mode_name}_d_12_31"
      elif (last_rsi_3 < 1.0) and (last_rsi_3_1h > 85.0) and (last_roc_2_4h_gt_30) and (last_stochrsi_k_4h < 70.0):
        return True, f"exit_{mode_name}_d_12_32"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_roc_2_1h > 10.0)
        and (last_roc_9_1h < -30.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_33"
      elif (last_rsi_3 < 35.0) and (last_rsi_3_15m_gt_70) and (last_rsi_14_1h < 20.0) and (last_roc_9_1h < -40.0):
        return True, f"exit_{mode_name}_d_12_34"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h_lt_25):
        return True, f"exit_{mode_name}_d_12_35"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_99)
        and (last_roc_9_4h_gt_25)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_36"
      elif (
        (last_rsi_3 < 12.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_1d < 75.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_37"
      elif (last_rsi_3 < 1.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_12_38"
      elif (last_rsi_3 < 2.0) and (last_willr_14_lt_neg_98) and (last_cmf_20_4h_gt_0) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_12_39"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_1h < 70.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_12_40"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_stochrsi_k_4h < 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_12_41"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_4h < 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_42"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 85.0)
        and (last_rsi_3_4h > 60.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_12_43"
      elif (
        (last_rsi_3 < 15.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 25.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
      ):
        return True, f"exit_{mode_name}_d_12_44"
      elif (last_rsi_3 < 1.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h > 90.0):
        return True, f"exit_{mode_name}_d_12_45"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 90.0) and (last_roc_2_1d > 20.0):
        return True, f"exit_{mode_name}_d_12_46"
      elif (
        (last_rsi_3 < 2.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_stochrsi_k_4h < 60.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 5.0))
      ):
        return True, f"exit_{mode_name}_d_12_47"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 62.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_48"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_4h > 80.0)
        and (last_change_pct_1d > 5.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_49"
      elif (last_rsi_3 < 10.0) and (last_willr_14_lt_neg_98) and (last_rsi_3_1d > 90.0) and (last_stochrsi_k_1h_lt_10):
        return True, f"exit_{mode_name}_d_12_50"
      elif (last_rsi_3 < 28.0) and (last_rsi_14 > 60.0) and (last_rsi_3_4h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_12_51"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 < 34.0)
        and (last_willr_14_lt_neg_90)
        and (last_stochrsi_k_1h < 30.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
      ):
        return True, f"exit_{mode_name}_d_12_52"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14_gt_50)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 80.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_53"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_roc_9_4h_gt_10)
        and (last_change_pct_1d > 10.0)
      ):
        return True, f"exit_{mode_name}_d_12_54"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_92)
        and (last_roc_9_4h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -10.0))
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_55"
      elif (
        (last_rsi_3 < 5.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_90)
      ):
        return True, f"exit_{mode_name}_d_12_56"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 70.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 30.0))
        and (last_stochrsi_k_4h_lt_30)
      ):
        return True, f"exit_{mode_name}_d_12_57"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_58"
      elif (
        (last_rsi_3 < 5.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 15.0))
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_12_59"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 > 66.0)
        and (last_rsi_14_4h < 35.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_stochrsi_k_1d_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_60"
      elif (last_rsi_3 < 2.0) and (last_willr_14_lt_neg_95) and (last_rsi_3_4h > 90.0) and (last_stochrsi_k_1h < 70.0):
        return True, f"exit_{mode_name}_d_12_61"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
        and (last_change_pct_1d > 5.0)
      ):
        return True, f"exit_{mode_name}_d_12_62"
      elif (
        (last_rsi_3 < 26.0) and (last_rsi_3_1d > 75.0) and (last_stochrsi_k_1h < 20.0) and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_12_63"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_12_64"
      elif (last_rsi_3 < 26.0) and (last_rsi_14 > 64.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 85.0):
        return True, f"exit_{mode_name}_d_12_65"
      elif (last_rsi_3 < 12.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 80.0) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_12_66"
      elif (
        (last_rsi_3 < 50.0)
        and (last_rsi_14 > 64.0)
        and (last_stochrsi_k_4h_lt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_12_67"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 75.0)
        and (last_roc_2_4h_gt_30)
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_12_68"
      elif (
        (last_rsi_3 < 1.0) and (last_roc_9_4h < -20.0) and (last_stochrsi_k_4h_lt_50) and (last_change_pct_4h > 5.0)
      ):
        return True, f"exit_{mode_name}_d_12_69"
      elif (last_rsi_3 < 28.0) and (last_rsi_14 > 66.0) and (last_rsi_3_1h > 75.0) and (last_stochrsi_k_4h < 80.0):
        return True, f"exit_{mode_name}_d_12_70"
      elif (last_rsi_3 < 30.0) and (last_rsi_14 > 62.0) and (last_rsi_3_4h > 75.0) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_12_71"
      elif (last_rsi_3 < 16.0) and (last_rsi_14 > 64.0) and (last_rsi_3_1h > 90.0) and (last_aroond_14_4h > 25.0):
        return True, f"exit_{mode_name}_d_12_72"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 85.0)
        and (last_roc_9_4h_gt_20)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_12_73"
      elif (
        (last_rsi_3 < 1.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_4h > 75.0)
        and (last_rsi_3_1d > 75.0)
        and (last_stochrsi_k_1h_gt_50)
      ):
        return True, f"exit_{mode_name}_d_12_74"
      elif (
        (last_rsi_3 < 2.0)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_75"
      elif (last_rsi_3 < 26.0) and (last_rsi_14 > 56.0) and (last_roc_9_1h < -80.0) and (last_stochrsi_k_4h_lt_20):
        return True, f"exit_{mode_name}_d_12_76"
      elif (
        (last_rsi_3 < 18.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_12_77"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 80.0)
        and (last_rsi_3_1d > 80.0)
      ):
        return True, f"exit_{mode_name}_d_12_78"
      elif (last_rsi_3 < 2.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h_gt_70) and (last_rsi_3_4h > 90.0):
        return True, f"exit_{mode_name}_d_12_79"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
        and (last_stochrsi_k_4h < 75.0)
      ):
        return True, f"exit_{mode_name}_d_12_80"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_rsi_14_1d, np.float64) and (last_rsi_14_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_81"
      elif (
        (last_rsi_3 < 12.0)
        and (last_willr_14_lt_neg_96)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 85.0)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_12_82"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_12_83"
      elif (last_rsi_3 < 4.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_80):
        return True, f"exit_{mode_name}_d_12_84"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h_gt_70)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_85"
      elif (
        (last_rsi_3 < 1.0)
        and (last_rsi_14_4h < 20.0)
        and (last_roc_2_1h > 5.0)
        and (last_roc_9_1h < -5.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_86"
      elif (
        (last_rsi_3 < 28.0)
        and (last_rsi_14 > 62.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 50.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_87"
      elif (
        (last_rsi_3 < 6.0)
        and (last_willr_14_lt_neg_86)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h_lt_50)
        and (last_change_pct_1h > 2.0)
      ):
        return True, f"exit_{mode_name}_d_12_88"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 66.0)
        and (last_roc_9_1h_gt_5)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_12_89"
      elif (
        (last_rsi_3 < 2.0)
        and (last_willr_14_lt_neg_75)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h_gt_70)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_12_90"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 75.0)
        and (last_aroonu_14_4h < 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 50.0))
      ):
        return True, f"exit_{mode_name}_d_12_91"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 60.0)
        and (last_stochrsi_k_1h_lt_75)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 25.0))
      ):
        return True, f"exit_{mode_name}_d_12_92"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_15m > 50.0)
        and (last_aroond_14_1h > 75.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_aroond_14_4h > 50.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_12_93"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 75.0)
        and (last_rsi_3_4h > 55.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 10.0))
      ):
        return True, f"exit_{mode_name}_d_12_94"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_94)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_lt_90)
        and (isinstance(last_aroond_14_1d, np.float64) and (last_aroond_14_1d > 75.0))
      ):
        return True, f"exit_{mode_name}_d_12_95"
      elif (
        (last_rsi_3 < 32.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h > 55.0)
        and (last_rsi_3_1d > 55.0)
        and (last_stochrsi_k_1h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_96"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 > 60.0)
        and (last_rsi_3_1h > 65.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stochrsi_k_4h < 70.0)
      ):
        return True, f"exit_{mode_name}_d_12_97"
      elif (
        (last_rsi_3 < 4.0)
        and (last_rsi_3_15m < 22.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_rsi_3_1d < 20.0)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_98"
      elif (
        (last_rsi_3 < 34.0)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 35.0)
        and (last_rsi_3_4h > 40.0)
        and (last_aroond_14_4h > 50.0)
        and (last_stoch_k_4h_lt_60)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_12_99"
      elif (last_rsi_3 < 1.0) and (last_rsi_14 < 18.0) and (last_rsi_3_15m_lt_30) and (last_rsi_3_4h > 20.0):
        return True, f"exit_{mode_name}_d_12_100"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_4h < 60.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -40.0))
      ):
        return True, f"exit_{mode_name}_d_12_101"
      elif (
        (last_rsi_3 < 26.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 60.0)
        and (last_stochrsi_k_4h_gt_70)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -40.0))
      ):
        return True, f"exit_{mode_name}_d_12_102"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14_gt_50)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_14_4h < 30.0)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -80.0))
      ):
        return True, f"exit_{mode_name}_d_12_103"
      elif (
        (last_rsi_3 < 30.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_12_104"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_15m > 45.0)
        and (last_stochrsi_k_4h < 10.0)
        and (last_roc_9_4h_lt_neg_25)
      ):
        return True, f"exit_{mode_name}_d_12_105"
      elif (
        (last_rsi_3 < 22.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h_lt_50)
        and (last_rsi_14_4h < 30.0)
        and (last_roc_9_4h_lt_neg_40)
      ):
        return True, f"exit_{mode_name}_d_12_106"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_1h > 50.0)
        and (last_stochrsi_k_1h < 30.0)
        and (last_rsi_14_4h < 50.0)
      ):
        return True, f"exit_{mode_name}_d_12_107"
      elif (last_rsi_3 < 38.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 40.0) and (last_stochrsi_k_1h < 20.0):
        return True, f"exit_{mode_name}_d_12_108"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_98)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_3_4h > 80.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -50.0))
      ):
        return True, f"exit_{mode_name}_d_12_109"
      elif (last_rsi_3 < 22.0) and (last_rsi_3_4h > 35.0) and (last_stochrsi_k_4h_lt_50) and (last_roc_9_4h_lt_neg_25):
        return True, f"exit_{mode_name}_d_12_110"
      elif (
        (last_rsi_3_lt_44)
        and (last_rsi_14 > 62.0)
        and (last_rsi_3_1h > 50.0)
        and (last_rsi_14_4h < 30.0)
        and (last_aroond_14_1h > 75.0)
        and (last_aroond_14_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -20.0))
      ):
        return True, f"exit_{mode_name}_d_12_111"
      elif (
        (last_rsi_3 < 14.0)
        and (last_willr_14_lt_neg_90)
        and (last_rsi_14 > 54.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_rsi_3_1d > 40.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -30.0))
      ):
        return True, f"exit_{mode_name}_d_12_112"
      elif (
        (last_rsi_3 < 10.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1d > 70.0)
        and (last_stochrsi_k_4h_lt_50)
        and (isinstance(last_roc_9_4h, np.float64) and (last_roc_9_4h < -10.0))
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d > 10.0))
      ):
        return True, f"exit_{mode_name}_d_12_113"
      elif (
        (last_rsi_3 < 10.0)
        and (last_rsi_14 > 56.0)
        and (last_rsi_3_1h > 80.0)
        and (last_rsi_3_4h_gt_70)
        and (last_rsi_3_1d > 70.0)
      ):
        return True, f"exit_{mode_name}_d_12_114"
      elif (
        (last_rsi_3 < 16.0)
        and (last_rsi_14 > 58.0)
        and (last_rsi_3_15m_gt_70)
        and (last_stochrsi_k_1h_lt_50)
        and (last_stochrsi_k_4h_lt_50)
      ):
        return True, f"exit_{mode_name}_d_12_115"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_aroonu_14_4h < 50.0):
        return True, f"exit_{mode_name}_d_12_116"
      elif (last_rsi_3 < 8.0) and (last_rsi_3_1h > 50.0) and (last_aroonu_14_1h < 20.0) and (last_aroonu_14_4h < 20.0):
        return True, f"exit_{mode_name}_d_12_117"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h > 40.0) and (last_aroond_14_4h > 40.0):
        return True, f"exit_{mode_name}_d_12_118"
      elif (
        (last_rsi_3 < 8.0)
        and (last_willr_14_lt_neg_80)
        and (last_rsi_3_1h > 40.0)
        and (last_rsi_3_4h > 40.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_12_119"
      elif (last_rsi_3 < 40.0) and (last_rsi_14 > 58.0) and (last_rsi_3_1h > 60.0) and (last_aroond_14_4h > 75.0):
        return True, f"exit_{mode_name}_d_12_120"
      elif (last_rsi_3 < 34.0) and (last_rsi_14 > 60.0) and (last_rsi_3_1h > 50.0) and (last_rsi_14_4h < 15.0):
        return True, f"exit_{mode_name}_d_12_121"
      elif (last_rsi_3 < 36.0) and (last_rsi_14 > 62.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_1h_lt_50):
        return True, f"exit_{mode_name}_d_12_122"
      elif (last_rsi_3 < 6.0) and (last_willr_14_lt_neg_99) and (last_rsi_3_1h > 90.0) and (last_rsi_3_1d > 70.0):
        return True, f"exit_{mode_name}_d_12_123"
      elif (
        (last_rsi_3 < 6.0)
        and (last_rsi_3_1h > 85.0)
        and (isinstance(last_stochrsi_k_1d, np.float64) and (last_stochrsi_k_1d < 20.0))
      ):
        return True, f"exit_{mode_name}_d_12_124"
      elif (
        (last_rsi_3 < 18.0)
        and (last_willr_14_lt_neg_99)
        and (last_rsi_3_1h > 90.0)
        and (last_rsi_3_4h > 60.0)
        and (last_rsi_3_1d_gt_60)
        and (last_close > (last_low_min_30_1d * 2.0))
      ):
        return True, f"exit_{mode_name}_d_12_125"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_1h > 85.0) and (last_rsi_3_4h > 60.0) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_12_126"
      elif (last_rsi_3 < 4.0) and (last_rsi_3_1h > 90.0) and (last_rsi_3_4h_gt_70) and (last_rsi_3_1d_gt_60):
        return True, f"exit_{mode_name}_d_12_127"
      elif (last_rsi_3 < 1.0) and (last_rsi_3_4h_gt_70) and (last_aroond_14_4h > 85.0):
        return True, f"exit_{mode_name}_d_12_128"
      elif (
        (last_rsi_3 < 8.0)
        and (last_rsi_3_4h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -80.0))
      ):
        return True, f"exit_{mode_name}_d_12_129"
      elif (
        (last_rsi_3 < 20.0)
        and (last_rsi_14_1h < 35.0)
        and (last_stochrsi_k_1h < 20.0)
        and (last_cci_20_change_pct_1h > 0.0)
      ):
        return True, f"exit_{mode_name}_d_12_130"
      elif (last_rsi_14 > 68.0) and (last_rsi_3_1h > 80.0) and (last_rsi_3_4h_gt_70) and (last_stochrsi_k_4h_lt_50):
        return True, f"exit_{mode_name}_d_12_131"
      elif (
        (last_rsi_3 < 14.0)
        and (last_rsi_3_1h > 65.0)
        and (last_rsi_3_4h_gt_65)
        and (last_aroond_14_1h > 50.0)
        and (last_stochrsi_k_1h < 60.0)
      ):
        return True, f"exit_{mode_name}_d_12_132"
      elif (
        (last_rsi_3 < 14.0)
        and (last_aroond_14_15m > 75.0)
        and (last_aroond_14_1h > 75.0)
        and (isinstance(last_roc_9_1d, np.float64) and (last_roc_9_1d < -25.0))
      ):
        return True, f"exit_{mode_name}_d_12_133"

    #  Here ends exit signal conditions for short_exit_dec

    return False, None

  # Short Exit Stop Loss
  # ---------------------------------------------------------------------------------------------
  def short_exit_stoploss(
    self,
    mode_name: str,
    current_rate: float,
    profit_stake: float,
    profit_ratio: float,
    profit_current_stake_ratio: float,
    profit_init_ratio: float,
    max_profit: float,
    max_loss: float,
    filled_orders,
    filled_entries,
    filled_exits,
    last_candle,
    previous_candle_1,
    trade: "Trade",
    current_time: "datetime",
    buy_tag,
  ) -> tuple:
    is_futures_mode = self.is_futures_mode
    doom_stops_enable = self.doom_stops_enable
    trade_leverage = trade.leverage
    stoploss_doom = f"exit_{mode_name}_stoploss_doom"
    stoploss_u_e = f"exit_{mode_name}_stoploss_u_e"

    is_backtest = self.is_backtest_mode()
    trade_open_date = None if is_backtest else trade.open_date_utc.replace(tzinfo=None)
    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)
    if not self.stops_enable:
      return False, None

    entry_cost = filled_entries[0].safe_filled * filled_entries[0].safe_price
    if is_system_v3_2:
      # Stoploss doom
      if self.system_v3_2_stops_enable and (
        profit_stake
        < -(
          entry_cost
          * (
            self.system_v3_2_stop_threshold_doom_futures
            if is_futures_mode
            else self.system_v3_2_stop_threshold_doom_spot
          )
          / trade_leverage
        )
      ):
        return True, stoploss_doom
    elif is_system_v3_1:
      # Stoploss doom
      if doom_stops_enable and (
        profit_stake
        < -(
          entry_cost
          * (
            self.system_v3_1_stop_threshold_doom_futures
            if is_futures_mode
            else self.system_v3_1_stop_threshold_doom_spot
          )
          / trade_leverage
        )
      ):
        return True, stoploss_doom
    elif is_system_v3:
      # Stoploss doom
      if doom_stops_enable and (
        profit_stake
        < -(
          entry_cost
          * (
            self.system_v3_stop_threshold_doom_futures if is_futures_mode else self.system_v3_stop_threshold_doom_spot
          )
          / trade_leverage
        )
      ):
        return True, stoploss_doom
    else:
      # Stoploss doom
      if (
        doom_stops_enable
        and (
          profit_stake
          < -(entry_cost * (self.stop_threshold_doom_futures if is_futures_mode else self.stop_threshold_doom_spot))
        )
        and (
          self.has_valid_entry_conditions(trade, current_rate, last_candle, previous_candle_1, filled_orders) == False
        )
        # temporary
        and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
      ):
        return True, stoploss_doom

    last_close = last_candle["close"]
    last_ema_200 = last_candle["EMA_200"]
    last_rsi_14 = last_candle["RSI_14"]
    last_cmf_20 = last_candle["CMF_20"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    previous_rsi_14 = previous_candle_1["RSI_14"]

    # Stoploss u_e
    if (
      self.u_e_stops_enable
      and (
        profit_stake
        < -(
          entry_cost * (self.stop_threshold_futures if is_futures_mode else self.stop_threshold_spot)
          # / trade.leverage
        )
      )
      and (last_close > last_ema_200)
      and (last_cmf_20 > 0.0)
      and (((last_close - last_ema_200) / last_ema_200) < 0.010)
      and (last_rsi_14 < previous_rsi_14)
      and (last_rsi_14 < (last_rsi_14_1h - 24.0))
      # and (current_time - timedelta(minutes=720) > trade.open_date_utc)
      # temporary
      and (is_backtest or trade_open_date >= datetime(2025, 4, 3))
    ):
      return True, stoploss_u_e

    #  Here ends exit signal conditions for short_exit_stoploss

    return False, None

  ###############################################################################################

  # SHORT EXIT FUNCTIONS ENDS HERE

  ###############################################################################################

  # SHORT GRIND FUNCTIONS STARTS HERE

  ###############################################################################################

  #
  #   ______  __    __  ______  _______ ________         ______  _______  ______ __    __ _______
  #  /      \|  \  |  \/      \|       |        \       /      \|       \|      |  \  |  |       \
  # |  $$$$$$| $$  | $|  $$$$$$| $$$$$$$\$$$$$$$$      |  $$$$$$| $$$$$$$\\$$$$$| $$\ | $| $$$$$$$\
  # | $$___\$| $$__| $| $$  | $| $$__| $$ | $$         | $$ __\$| $$__| $$ | $$ | $$$\| $| $$  | $$
  #  \$$    \| $$    $| $$  | $| $$    $$ | $$         | $$|    | $$    $$ | $$ | $$$$\ $| $$  | $$
  #  _\$$$$$$| $$$$$$$| $$  | $| $$$$$$$\ | $$         | $$ \$$$| $$$$$$$\ | $$ | $$\$$ $| $$  | $$
  # |  \__| $| $$  | $| $$__/ $| $$  | $$ | $$         | $$__| $| $$  | $$_| $$_| $$ \$$$| $$__/ $$
  #  \$$    $| $$  | $$\$$    $| $$  | $$ | $$          \$$    $| $$  | $|   $$ | $$  \$$| $$    $$
  #   \$$$$$$ \$$   \$$ \$$$$$$ \$$   \$$  \$$           \$$$$$$ \$$   \$$\$$$$$$\$$   \$$\$$$$$$$
  #

  # Short Grinding Adjust Trade Position v2
  # ---------------------------------------------------------------------------------------------
  def short_grind_adjust_trade_position_v2(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    short_grind_exit_v2 = self.short_grind_exit_v2
    stake_currency = self.config["stake_currency"]
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    is_backtest = self.is_backtest_mode()
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    is_futures = self.is_futures_mode
    trade_leverage = trade.leverage
    trade_get_custom_data = trade.get_custom_data
    trade_set_custom_data = trade.set_custom_data
    trade_is_short = trade.is_short
    derisk_enable = self.derisk_enable
    short_rebuy_mode_tags = self.short_rebuy_mode_tags
    short_grind_mode_tags = self.short_grind_mode_tags

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    previous_candle = df.iloc[-2]

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_exits = trade.nr_of_successful_exits

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = self.config["exit_pricing"]["price_side"]
        if trade_is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]
    first_filled_entry = filled_entries[0]
    last_filled_entry = filled_entries[-1]

    current_stake_amount = trade_amount * exit_rate
    slice_amount = first_filled_entry.safe_filled * first_filled_entry.safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    is_rebuy_mode = all(c in short_rebuy_mode_tags for c in enter_tags) or (
      any(c in short_rebuy_mode_tags for c in enter_tags)
      and all(c in (short_rebuy_mode_tags + short_grind_mode_tags) for c in enter_tags)
    )

    has_order_tags = hasattr(first_filled_order, "ft_order_tag")

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate
    stake_scale_leverage = trade_leverage if is_futures else 1.0
    derisk_flag_timeout = None

    def get_derisk_flag_timeout():
      nonlocal derisk_flag_timeout
      if derisk_flag_timeout is None:
        derisk_flag_timeout = current_time - timedelta(hours=96)

      return derisk_flag_timeout

    grind_1_max_sub_grinds = 0
    grind_1_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_1_stakes_futures if is_futures else self.grinding_v2_grind_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_1_sub_thresholds = (
      self.grinding_v2_grind_1_thresholds_futures if is_futures else self.grinding_v2_grind_1_thresholds_spot
    )
    grind_1_max_sub_grinds = len(grind_1_stakes)
    grind_1_derisk_grinds = (
      self.grinding_v2_grind_1_derisk_futures if is_futures else self.grinding_v2_grind_1_derisk_spot
    )
    grind_1_profit_threshold = (
      self.grinding_v2_grind_1_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_1_profit_threshold_spot
    )

    grind_2_max_sub_grinds = 0
    grind_2_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_2_stakes_futures if is_futures else self.grinding_v2_grind_2_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_2_sub_thresholds = (
      self.grinding_v2_grind_2_thresholds_futures if is_futures else self.grinding_v2_grind_2_thresholds_spot
    )
    grind_2_max_sub_grinds = len(grind_2_stakes)
    grind_2_derisk_grinds = (
      self.grinding_v2_grind_2_derisk_futures if is_futures else self.grinding_v2_grind_2_derisk_spot
    )
    grind_2_profit_threshold = (
      self.grinding_v2_grind_2_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_2_profit_threshold_spot
    )

    grind_3_max_sub_grinds = 0
    grind_3_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_3_stakes_futures if is_futures else self.grinding_v2_grind_3_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_3_sub_thresholds = (
      self.grinding_v2_grind_3_thresholds_futures if is_futures else self.grinding_v2_grind_3_thresholds_spot
    )
    grind_3_max_sub_grinds = len(grind_3_stakes)
    grind_3_derisk_grinds = (
      self.grinding_v2_grind_3_derisk_futures if is_futures else self.grinding_v2_grind_3_derisk_spot
    )
    grind_3_profit_threshold = (
      self.grinding_v2_grind_3_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_3_profit_threshold_spot
    )

    grind_4_max_sub_grinds = 0
    grind_4_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_4_stakes_futures if is_futures else self.grinding_v2_grind_4_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_4_sub_thresholds = (
      self.grinding_v2_grind_4_thresholds_futures if is_futures else self.grinding_v2_grind_4_thresholds_spot
    )
    grind_4_max_sub_grinds = len(grind_4_stakes)
    grind_4_derisk_grinds = (
      self.grinding_v2_grind_4_derisk_futures if is_futures else self.grinding_v2_grind_4_derisk_spot
    )
    grind_4_profit_threshold = (
      self.grinding_v2_grind_4_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_4_profit_threshold_spot
    )

    grind_5_max_sub_grinds = 0
    grind_5_stakes = scale_stakes_for_min_stake(
      self.grinding_v2_grind_5_stakes_futures if is_futures else self.grinding_v2_grind_5_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_5_sub_thresholds = (
      self.grinding_v2_grind_5_thresholds_futures if is_futures else self.grinding_v2_grind_5_thresholds_spot
    )
    grind_5_max_sub_grinds = len(grind_5_stakes)
    grind_5_derisk_grinds = (
      self.grinding_v2_grind_5_derisk_futures if is_futures else self.grinding_v2_grind_5_derisk_spot
    )
    grind_5_profit_threshold = (
      self.grinding_v2_grind_5_profit_threshold_futures
      if is_futures
      else self.grinding_v2_grind_5_profit_threshold_spot
    )

    is_derisk_1 = False
    is_derisk_1_found = False  # derisk_level_1 de-risk exit
    derisk_1_order = None
    is_derisk_2 = False
    is_derisk_2_found = False  # derisk_level_2 de-risk exit
    derisk_2_order = None
    is_derisk_3 = False
    is_derisk_3_found = False  # derisk_level_3 de-risk exit
    derisk_3_order = None
    buyback_1_sub_grind_count = 0
    buyback_1_total_amount = 0.0
    buyback_1_total_cost = 0.0
    buyback_1_current_open_rate = 0.0
    buyback_1_current_grind_stake = 0.0
    buyback_1_current_grind_stake_profit = 0.0
    buyback_1_is_exit_found = False
    buyback_1_found = False
    buyback_1_buy_orders = []
    buyback_1_orders = []
    buyback_1_distance_ratio = 0.0
    buyback_1_exit_order = None
    buyback_1_exit_distance_ratio = 0.0
    buyback_2_sub_grind_count = 0
    buyback_2_total_amount = 0.0
    buyback_2_total_cost = 0.0
    buyback_2_current_open_rate = 0.0
    buyback_2_current_grind_stake = 0.0
    buyback_2_current_grind_stake_profit = 0.0
    buyback_2_is_exit_found = False
    buyback_2_found = False
    buyback_2_buy_orders = []
    buyback_2_orders = []
    buyback_2_distance_ratio = 0.0
    buyback_2_exit_order = None
    buyback_2_exit_distance_ratio = 0.0
    buyback_3_sub_grind_count = 0
    buyback_3_total_amount = 0.0
    buyback_3_total_cost = 0.0
    buyback_3_current_open_rate = 0.0
    buyback_3_current_grind_stake = 0.0
    buyback_3_current_grind_stake_profit = 0.0
    buyback_3_is_exit_found = False
    buyback_3_found = False
    buyback_3_buy_orders = []
    buyback_3_orders = []
    buyback_3_distance_ratio = 0.0
    buyback_3_exit_order = None
    buyback_3_exit_distance_ratio = 0.0
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_stake_profit = 0.0
    grind_1_is_exit_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_orders = []
    grind_1_distance_ratio = 0.0
    grind_1_exit_order = None
    grind_1_exit_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_stake_profit = 0.0
    grind_2_is_exit_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_orders = []
    grind_2_distance_ratio = 0.0
    grind_2_exit_order = None
    grind_2_exit_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_stake_profit = 0.0
    grind_3_is_exit_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_orders = []
    grind_3_distance_ratio = 0.0
    grind_3_exit_order = None
    grind_3_exit_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_stake_profit = 0.0
    grind_4_is_exit_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_orders = []
    grind_4_distance_ratio = 0.0
    grind_4_exit_order = None
    grind_4_exit_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_stake_profit = 0.0
    grind_5_is_exit_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_orders = []
    grind_5_distance_ratio = 0.0
    grind_5_exit_order = None
    grind_5_exit_distance_ratio = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "sell") and (order is not first_filled_order):
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        if not buyback_1_is_exit_found and order_tag == "buyback_1_entry":
          buyback_1_sub_grind_count += 1
          buyback_1_total_amount += order.safe_filled
          buyback_1_total_cost += order.safe_filled * order.safe_price
          buyback_1_buy_orders.append(order.id)
          buyback_1_orders.append(order)
          if not buyback_1_found:
            buyback_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_1_found = True
        elif not buyback_2_is_exit_found and order_tag == "buyback_2_entry":
          buyback_2_sub_grind_count += 1
          buyback_2_total_amount += order.safe_filled
          buyback_2_total_cost += order.safe_filled * order.safe_price
          buyback_2_buy_orders.append(order.id)
          buyback_2_orders.append(order)
          if not buyback_2_found:
            buyback_2_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_2_found = True
        elif not buyback_3_is_exit_found and order_tag == "buyback_3_entry":
          buyback_3_sub_grind_count += 1
          buyback_3_total_amount += order.safe_filled
          buyback_3_total_cost += order.safe_filled * order.safe_price
          buyback_3_buy_orders.append(order.id)
          buyback_3_orders.append(order)
          if not buyback_3_found:
            buyback_3_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            buyback_3_found = True
        elif not grind_1_is_exit_found and order_tag == "grind_1_entry":
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order.safe_filled
          grind_1_total_cost += order.safe_filled * order.safe_price
          grind_1_buy_orders.append(order.id)
          grind_1_orders.append(order)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_1_found = True
        elif not grind_2_is_exit_found and order_tag == "grind_2_entry":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order.safe_filled
          grind_2_total_cost += order.safe_filled * order.safe_price
          grind_2_buy_orders.append(order.id)
          grind_2_orders.append(order)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_2_found = True
        elif not grind_3_is_exit_found and order_tag == "grind_3_entry":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order.safe_filled
          grind_3_total_cost += order.safe_filled * order.safe_price
          grind_3_buy_orders.append(order.id)
          grind_3_orders.append(order)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_3_found = True
        elif not grind_4_is_exit_found and order_tag == "grind_4_entry":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order.safe_filled
          grind_4_total_cost += order.safe_filled * order.safe_price
          grind_4_buy_orders.append(order.id)
          grind_4_orders.append(order)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_4_found = True
        elif not grind_5_is_exit_found and order_tag == "grind_5_entry":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order.safe_filled
          grind_5_total_cost += order.safe_filled * order.safe_price
          grind_5_buy_orders.append(order.id)
          grind_5_orders.append(order)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_5_found = True
      elif order.ft_order_side == "buy":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          # break
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag.partition(" ")[0]
        if order_tag in ["derisk_level_1", "d"]:
          if not is_derisk_1_found:
            is_derisk_1_found = True
            is_derisk_1 = True
            derisk_1_order = order
        elif order_tag == "derisk_level_2":
          if not is_derisk_2_found:
            is_derisk_2_found = True
            is_derisk_2 = True
            derisk_2_order = order
        elif order_tag == "derisk_level_3":
          if not is_derisk_3_found:
            is_derisk_3_found = True
            is_derisk_3 = True
            derisk_3_order = order
        elif not buyback_1_is_exit_found and order_tag in ["buyback_1_exit", "buyback_1_derisk"]:
          buyback_1_is_exit_found = True
          buyback_1_exit_order = order
        elif not buyback_2_is_exit_found and order_tag in ["buyback_2_exit", "buyback_2_derisk"]:
          buyback_2_is_exit_found = True
          buyback_2_exit_order = order
        elif not buyback_3_is_exit_found and order_tag in ["buyback_3_exit", "buyback_3_derisk"]:
          buyback_3_is_exit_found = True
          buyback_3_exit_order = order
        elif not grind_1_is_exit_found and order_tag in ["grind_1_exit", "grind_1_derisk"]:
          grind_1_is_exit_found = True
          grind_1_exit_order = order
        elif not grind_2_is_exit_found and order_tag in ["grind_2_exit", "grind_2_derisk"]:
          grind_2_is_exit_found = True
          grind_2_exit_order = order
        elif not grind_3_is_exit_found and order_tag in ["grind_3_exit", "grind_3_derisk"]:
          grind_3_is_exit_found = True
          grind_3_exit_order = order
        elif not grind_4_is_exit_found and order_tag in ["grind_4_exit", "grind_4_derisk"]:
          grind_4_is_exit_found = True
          grind_4_exit_order = order
        elif not grind_5_is_exit_found and order_tag in ["grind_5_exit", "grind_5_derisk"]:
          grind_5_is_exit_found = True
          grind_5_exit_order = order
        elif order_tag == "derisk_global":
          if not buyback_1_is_exit_found:
            buyback_1_is_exit_found = True
            buyback_1_exit_order = order
          if not buyback_2_is_exit_found:
            buyback_2_is_exit_found = True
            buyback_2_exit_order = order
          if not buyback_3_is_exit_found:
            buyback_3_is_exit_found = True
            buyback_3_exit_order = order
          if not grind_1_is_exit_found:
            grind_1_is_exit_found = True
            grind_1_exit_order = order
          if not grind_2_is_exit_found:
            grind_2_is_exit_found = True
            grind_2_exit_order = order
          if not grind_3_is_exit_found:
            grind_3_is_exit_found = True
            grind_3_exit_order = order
          if not grind_4_is_exit_found:
            grind_4_is_exit_found = True
            grind_4_exit_order = order
          if not grind_5_is_exit_found:
            grind_5_is_exit_found = True
            grind_5_exit_order = order

    if buyback_1_sub_grind_count > 0:
      buyback_1_current_open_rate = buyback_1_total_cost / buyback_1_total_amount
      buyback_1_current_grind_stake = buyback_1_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_1_current_grind_stake_profit = buyback_1_total_cost - buyback_1_current_grind_stake
    if buyback_2_sub_grind_count > 0:
      buyback_2_current_open_rate = buyback_2_total_cost / buyback_2_total_amount
      buyback_2_current_grind_stake = buyback_2_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_2_current_grind_stake_profit = buyback_2_total_cost - buyback_2_current_grind_stake
    if buyback_3_sub_grind_count > 0:
      buyback_3_current_open_rate = buyback_3_total_cost / buyback_3_total_amount
      buyback_3_current_grind_stake = buyback_3_total_amount * exit_rate * (1 - trade_fee_close)
      buyback_3_current_grind_stake_profit = buyback_3_total_cost - buyback_3_current_grind_stake
    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_current_grind_stake_profit = grind_1_total_cost - grind_1_current_grind_stake
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_current_grind_stake_profit = grind_2_total_cost - grind_2_current_grind_stake
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 - trade_fee_close)
      grind_3_current_grind_stake_profit = grind_3_total_cost - grind_3_current_grind_stake
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 - trade_fee_close)
      grind_4_current_grind_stake_profit = grind_4_total_cost - grind_4_current_grind_stake
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 - trade_fee_close)
      grind_5_current_grind_stake_profit = grind_5_total_cost - grind_5_current_grind_stake

    if grind_1_is_exit_found:
      grind_1_exit_distance_ratio = (exit_rate - grind_1_exit_order.safe_price) / grind_1_exit_order.safe_price
    if grind_2_is_exit_found:
      grind_2_exit_distance_ratio = (exit_rate - grind_2_exit_order.safe_price) / grind_2_exit_order.safe_price
    if grind_3_is_exit_found:
      grind_3_exit_distance_ratio = (exit_rate - grind_3_exit_order.safe_price) / grind_3_exit_order.safe_price
    if grind_4_is_exit_found:
      grind_4_exit_distance_ratio = (exit_rate - grind_4_exit_order.safe_price) / grind_4_exit_order.safe_price
    if buyback_1_is_exit_found:
      buyback_1_exit_distance_ratio = (exit_rate - buyback_1_exit_order.safe_price) / buyback_1_exit_order.safe_price
    elif is_derisk_1_found:
      buyback_1_exit_distance_ratio = (exit_rate - derisk_1_order.safe_price) / derisk_1_order.safe_price
    if buyback_2_is_exit_found:
      buyback_2_exit_distance_ratio = (exit_rate - buyback_2_exit_order.safe_price) / buyback_2_exit_order.safe_price
    elif is_derisk_2_found:
      buyback_2_exit_distance_ratio = (exit_rate - derisk_2_order.safe_price) / derisk_2_order.safe_price
    if buyback_3_is_exit_found:
      buyback_3_exit_distance_ratio = (exit_rate - buyback_3_exit_order.safe_price) / buyback_3_exit_order.safe_price
    elif is_derisk_3_found:
      buyback_3_exit_distance_ratio = (exit_rate - derisk_3_order.safe_price) / derisk_3_order.safe_price

    # all buybacks & grinds
    current_open_grind_stake_profit = (
      buyback_1_current_grind_stake_profit
      + buyback_2_current_grind_stake_profit
      + buyback_3_current_grind_stake_profit
      + grind_1_current_grind_stake_profit
      + grind_2_current_grind_stake_profit
      + grind_3_current_grind_stake_profit
      + grind_4_current_grind_stake_profit
      + grind_5_current_grind_stake_profit
    )
    num_open_grinds_and_buybacks = (
      buyback_1_sub_grind_count
      + buyback_2_sub_grind_count
      + buyback_3_sub_grind_count
      + grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
    )

    # Rebuy mode, the first entry is lower than normal slot stake
    if is_rebuy_mode:
      slice_amount /= self.rebuy_mode_stake_multiplier
    # not reached the max allowed stake for all grinds
    is_not_trade_max_stake = (current_stake_amount < (slice_amount * self.grinding_v2_max_stake)) and (
      num_open_grinds_and_buybacks < self.grinding_v2_max_grinds_and_buybacks
    )
    slice_profit_gt_0_06 = slice_profit > 0.06

    is_short_extra_checks_entry = (
      (current_time - timedelta(minutes=5) > last_filled_entry.order_filled_utc)
      and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
      and (
        (current_stake_amount < ((first_filled_entry.safe_filled * first_filled_entry.safe_price) * 0.50))
        or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
        or slice_profit_gt_0_06
      )
    )
    is_short_buyback_entry = self.short_buyback_entry_v2(last_candle, previous_candle, slice_profit, True)
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_aroond_14 = last_candle["AROOND_14"]
    last_aroond_14_15m = last_candle["AROOND_14_15m"]
    is_short_grind_entry = (
      self.short_grind_entry_v2(last_candle, previous_candle, slice_profit, True)
      or (
        (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
        and (num_open_grinds_and_buybacks == 0)
        and (
          (last_rsi_3 < 90.0)
          and (last_rsi_3_15m < 80.0)
          and (last_rsi_3_1h < 80.0)
          and (last_rsi_3_1h < 80.0)
          and (last_aroond_14 < 50.0)
          and (last_aroond_14_15m < 50.0)
        )
      )
      or (
        is_futures
        and trade.liquidation_price is not None
        and (
          (trade_is_short and current_rate > trade.liquidation_price * 0.90)
          or (not trade_is_short and current_rate < trade.liquidation_price * 1.10)
        )
        and (slice_profit > 0.03)
        and (last_rsi_3 < 90.0)
        and (last_rsi_3_15m < 80.0)
        # and (last_candle["RSI_3_1h"] < 80.0)
        # and (last_candle["RSI_3_1h"] < 80.0)
        and (last_aroond_14 < 50.0)
        and (last_aroond_14_15m < 50.0)
      )
    )

    # De-risk level 1

    # flag it
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_1_enable
      and (not is_derisk_1_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_1_flag") is not True)
      and (
        profit_stake
        < (
          slice_amount
          * (self.grinding_v2_derisk_level_1_futures[0] if is_futures else self.grinding_v2_derisk_level_1_spot[0])
        )
        / trade_leverage
      )
    ):
      trade_set_custom_data(key="grinding_v2_derisk_level_1_flag", value=True)
      trade_set_custom_data(key="grinding_v2_derisk_level_1_profit", value=profit_stake)
      trade_set_custom_data(key="grinding_v2_derisk_level_1_time", value=current_time.isoformat())

    flag_is_derisk_level_1 = False
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_1_enable
      and (not is_derisk_1_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_1_flag") is True)
    ):
      flag_profit = trade_get_custom_data(key="grinding_v2_derisk_level_1_profit")
      flag_time = datetime.fromisoformat(trade_get_custom_data(key="grinding_v2_derisk_level_1_time"))
      if get_derisk_flag_timeout() > flag_time:
        if profit_stake > flag_profit:
          trade_set_custom_data(key="grinding_v2_derisk_level_1_flag", value=False)
        else:
          flag_is_derisk_level_1 = True

    if (
      derisk_enable
      and self.grinding_v2_derisk_level_1_enable
      and (not is_derisk_1_found)
      and not is_rebuy_mode
      and (
        flag_is_derisk_level_1
        or (
          profit_stake
          < (
            slice_amount
            * (self.grinding_v2_derisk_level_1_futures[1] if is_futures else self.grinding_v2_derisk_level_1_spot[1])
          )
          / trade_leverage
        )
      )
    ):
      sell_amount = (
        (
          first_filled_entry.safe_filled
          * (
            self.grinding_v2_derisk_level_1_stake_futures if is_futures else self.grinding_v2_derisk_level_1_stake_spot
          )
        )
        * exit_rate
        / trade_leverage
      )
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Level 1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Level 1 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_1"

    # De-risk level 2

    # flag it
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_2_enable
      and (not is_derisk_2_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_2_flag") is not True)
      and (
        profit_stake
        < (
          slice_amount
          * (self.grinding_v2_derisk_level_2_futures[0] if is_futures else self.grinding_v2_derisk_level_2_spot[0])
        )
        / trade_leverage
      )
    ):
      trade_set_custom_data(key="grinding_v2_derisk_level_2_flag", value=True)
      trade_set_custom_data(key="grinding_v2_derisk_level_2_profit", value=profit_stake)
      trade_set_custom_data(key="grinding_v2_derisk_level_2_time", value=current_time.isoformat())

    flag_is_derisk_level_2 = False
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_2_enable
      and (not is_derisk_2_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_2_flag") is True)
    ):
      flag_profit = trade_get_custom_data(key="grinding_v2_derisk_level_2_profit")
      flag_time = datetime.fromisoformat(trade_get_custom_data(key="grinding_v2_derisk_level_2_time"))
      if get_derisk_flag_timeout() > flag_time:
        if profit_stake > flag_profit:
          trade_set_custom_data(key="grinding_v2_derisk_level_2_flag", value=False)
        else:
          flag_is_derisk_level_2 = True

    if (
      derisk_enable
      and self.grinding_v2_derisk_level_2_enable
      and (not is_derisk_2_found)
      and not is_rebuy_mode
      and (
        flag_is_derisk_level_2
        or (
          profit_stake
          < (
            slice_amount
            * (self.grinding_v2_derisk_level_2_futures[1] if is_futures else self.grinding_v2_derisk_level_2_spot[1])
          )
          / trade_leverage
        )
      )
    ):
      sell_amount = (
        (
          first_filled_entry.safe_filled
          * (
            self.grinding_v2_derisk_level_2_stake_futures if is_futures else self.grinding_v2_derisk_level_2_stake_spot
          )
        )
        * exit_rate
        / trade_leverage
      )
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Level 2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Level 2 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_2"

    # De-risk level 3

    # flag it
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_3_enable
      and (not is_derisk_3_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_3_flag") is not True)
      and (
        profit_stake
        < (
          slice_amount
          * (self.grinding_v2_derisk_level_3_futures[0] if is_futures else self.grinding_v2_derisk_level_3_spot[0])
        )
        / trade_leverage
      )
    ):
      trade_set_custom_data(key="grinding_v2_derisk_level_3_flag", value=True)
      trade_set_custom_data(key="grinding_v2_derisk_level_3_profit", value=profit_stake)
      trade_set_custom_data(key="grinding_v2_derisk_level_3_time", value=current_time.isoformat())

    flag_is_derisk_level_3 = False
    if (
      derisk_enable
      and self.grinding_v2_derisk_level_3_enable
      and (not is_derisk_3_found)
      and not is_rebuy_mode
      and (trade_get_custom_data(key="grinding_v2_derisk_level_3_flag") is True)
    ):
      flag_profit = trade_get_custom_data(key="grinding_v2_derisk_level_3_profit")
      flag_time = datetime.fromisoformat(trade_get_custom_data(key="grinding_v2_derisk_level_3_time"))
      if get_derisk_flag_timeout() > flag_time:
        if profit_stake > flag_profit:
          trade_set_custom_data(key="grinding_v2_derisk_level_3_flag", value=False)
        else:
          flag_is_derisk_level_3 = True

    if (
      derisk_enable
      and self.grinding_v2_derisk_level_3_enable
      and (not is_derisk_3_found)
      and not is_rebuy_mode
      and (
        flag_is_derisk_level_3
        or (
          profit_stake
          < (
            slice_amount
            * (self.grinding_v2_derisk_level_3_futures[1] if is_futures else self.grinding_v2_derisk_level_3_spot[1])
          )
          / trade_leverage
        )
      )
    ):
      sell_amount = (
        (
          first_filled_entry.safe_filled
          * (
            self.grinding_v2_derisk_level_3_stake_futures if is_futures else self.grinding_v2_derisk_level_3_stake_spot
          )
        )
        * exit_rate
        / trade_leverage
      )
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Level 3",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_3"

    # De-risk global
    if (
      self.grinding_v2_derisk_global_enable
      and is_derisk_1_found
      and (
        current_open_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_derisk_global_futures if is_futures else self.grinding_v2_derisk_global_spot)
        )
        / trade_leverage
      )
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="Global",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk Global [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_global"

    # Grinding 1

    if (
      (self.grinding_v2_grind_1_enable)
      and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and is_short_grind_entry
      and is_short_extra_checks_entry
      and (grind_1_sub_grind_count < grind_1_max_sub_grinds)
      and (grind_1_sub_grind_count == 0 or (-grind_1_distance_ratio < grind_1_sub_thresholds[grind_1_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_1_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_1_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
      if (grind_profit > (grind_1_profit_threshold + fee_open_rate + fee_close_rate)) and short_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_1_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_1_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_1_exit"
          for grind_entry_id in grind_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_1_use_derisk
    #   and (grind_1_sub_grind_count > 0)
    #   and ((-(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < grind_1_derisk_grinds)
    #   and (grind_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_1_use_derisk
      and (grind_1_sub_grind_count > 0)
      and (grind_1_current_grind_stake_profit < (slice_amount * grind_1_derisk_grinds))
      and (is_backtest or grind_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_1_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "grind_1_derisk"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 2

    if (
      (self.grinding_v2_grind_2_enable)
      # and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and is_short_grind_entry
      and is_short_extra_checks_entry
      and (grind_2_sub_grind_count < grind_2_max_sub_grinds)
      and (grind_2_sub_grind_count == 0 or (-grind_2_distance_ratio < grind_2_sub_thresholds[grind_2_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_2_stakes[grind_2_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_2_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_2_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_2_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_2_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
      if (grind_profit > (grind_2_profit_threshold + fee_open_rate + fee_close_rate)) and short_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_2_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_2_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_2_exit"
          for grind_entry_id in grind_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_2_use_derisk
    #   and (grind_2_sub_grind_count > 0)
    #   and ((-(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < grind_2_derisk_grinds)
    #   and (grind_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_2_use_derisk
      and (grind_2_sub_grind_count > 0)
      and (grind_2_current_grind_stake_profit < (slice_amount * grind_2_derisk_grinds))
      and (is_backtest or grind_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_2_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_2_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "grind_2_derisk"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 3

    if (
      (self.grinding_v2_grind_3_enable)
      # and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and is_short_grind_entry
      and is_short_extra_checks_entry
      and (grind_3_sub_grind_count < grind_3_max_sub_grinds)
      and (grind_3_sub_grind_count == 0 or (-grind_3_distance_ratio < grind_3_sub_thresholds[grind_3_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_3_stakes[grind_3_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_3_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_3_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_3_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_3_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
      if (grind_profit > (grind_3_profit_threshold + fee_open_rate + fee_close_rate)) and short_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_3_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_3_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_3_exit"
          for grind_entry_id in grind_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_3_use_derisk
    #   and (grind_3_sub_grind_count > 0)
    #   and ((-(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < grind_3_derisk_grinds)
    #   and (grind_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_3_use_derisk
      and (grind_3_sub_grind_count > 0)
      and (grind_3_current_grind_stake_profit < (slice_amount * grind_3_derisk_grinds))
      and (is_backtest or grind_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_3_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_3_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "grind_3_derisk"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 4

    if (
      (self.grinding_v2_grind_4_enable)
      # and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and (
        is_short_grind_entry
        # or (
        #   is_derisk_1_found
        #   # only queue 4 grinds open
        #   and (num_open_grinds_and_buybacks == grind_4_sub_grind_count)
        #   and (last_candle["protections_short_global"] == True)
        #   and (
        #     (slice_profit > 0.04)
        #     and (last_candle["RSI_3"] < 90.0)
        #     and (last_candle["RSI_3_15m"] < 80.0)
        #     and (last_candle["AROOND_14"] < 50.0)
        #     and (last_candle["AROOND_14_15m"] < 50.0)
        #   )
        # )
      )
      and is_short_extra_checks_entry
      and (grind_4_sub_grind_count < grind_4_max_sub_grinds)
      and (grind_4_sub_grind_count == 0 or (-grind_4_distance_ratio < grind_4_sub_thresholds[grind_4_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_4_stakes[grind_4_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_4_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_4_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_4_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_4_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
      if (grind_profit > (grind_4_profit_threshold + fee_open_rate + fee_close_rate)) and short_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_4_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_4_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_4_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_4_exit"
          for grind_entry_id in grind_4_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_4_use_derisk
    #   and (grind_4_sub_grind_count > 0)
    #   and ((-(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < grind_4_derisk_grinds)
    #   and (grind_4_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_4_use_derisk
      and (grind_4_sub_grind_count > 0)
      and (grind_4_current_grind_stake_profit < (slice_amount * grind_4_derisk_grinds))
      and (is_backtest or grind_4_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_4_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_4_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "grind_4_derisk"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 5

    if (
      (self.grinding_v2_grind_5_enable)
      and (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
      and (
        is_short_grind_entry
        or (
          is_derisk_1_found
          and (slice_profit_entry > 0.10)
          and (slice_profit_exit > 0.04)
          and (last_candle["protections_short_global"] == True)
          # and (
          #   (slice_profit > 0.04)
          #   and (last_candle["RSI_3"] < 90.0)
          #   and (last_candle["RSI_3_15m"] < 80.0)
          #   and (last_candle["AROOND_14"] < 50.0)
          #   and (last_candle["AROOND_14_15m"] < 50.0)
          # )
        )
      )
      and is_short_extra_checks_entry
      and (grind_5_sub_grind_count < grind_5_max_sub_grinds)
      and (grind_5_sub_grind_count == 0 or (-grind_5_distance_ratio < grind_5_sub_thresholds[grind_5_sub_grind_count]))
      and is_not_trade_max_stake
    ):
      buy_amount = slice_amount * grind_5_stakes[grind_5_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_5_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_5_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "grind_5_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_5_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
      if (grind_profit > (grind_5_profit_threshold + fee_open_rate + fee_close_rate)) and short_grind_exit_v2(
        last_candle, previous_candle, slice_profit, True
      ):
        sell_amount = grind_5_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="grind_5_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
          log.info(
            f"Grinding exit (grind_5_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "grind_5_exit"
          for grind_entry_id in grind_5_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_grind_5_use_derisk
    #   and (grind_5_sub_grind_count > 0)
    #   and ((-(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < grind_5_derisk_grinds)
    #   and (grind_5_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_grind_5_use_derisk
      and (grind_5_sub_grind_count > 0)
      and (grind_5_current_grind_stake_profit < (slice_amount * grind_5_derisk_grinds))
      and (is_backtest or grind_5_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_5_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_5_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "grind_5_derisk"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Buyback 1

    if (
      self.grinding_v2_buyback_1_enable
      and is_derisk_1_found
      and is_short_buyback_entry
      and is_short_extra_checks_entry
      and (buyback_1_current_open_rate == 0)
      and (
        -buyback_1_exit_distance_ratio
        < (
          self.grinding_v2_buyback_1_distance_ratio_futures
          if is_futures
          else self.grinding_v2_buyback_1_distance_ratio_spot
        )
      )
      and is_not_trade_max_stake
    ):
      buy_amount = (
        slice_amount
        * (self.grinding_v2_buyback_1_stake_futures if is_futures else self.grinding_v2_buyback_1_stake_spot)
        / trade_leverage
      )
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "buyback-entry",
          tag="buyback_1_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Buyback entry (buyback_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if buyback_1_sub_grind_count > 0:
      grind_profit = -(exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate
      if (
        grind_profit
        > (
          (
            self.grinding_v2_buyback_1_profit_threshold_futures
            if is_futures
            else self.grinding_v2_buyback_1_profit_threshold_spot
          )
          + fee_open_rate
          + fee_close_rate
        )
      ) and short_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
        sell_amount = buyback_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "buyback-exit",
              tag="buyback_1_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_1_total_amount,
            )
          )
          log.info(
            f"Buyback exit (buyback_1_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "buyback_1_exit"
          for grind_entry_id in buyback_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_1_use_derisk
    #   and (buyback_1_sub_grind_count > 0)
    #   and (
    #     (-(exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_1_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_1_derisk_spot
    #     )
    #   )
    #   and (buyback_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_buyback_1_use_derisk
      and (buyback_1_sub_grind_count > 0)
      and (
        buyback_1_current_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_buyback_1_derisk_futures if is_futures else self.grinding_v2_buyback_1_derisk_spot)
        )
      )
      and (is_backtest or buyback_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = buyback_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_1_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - buyback_1_current_open_rate) / buyback_1_current_open_rate)
            if buyback_1_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "buyback-derisk",
            tag="buyback_1_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            coin_amount=buyback_1_total_amount,
          )
        )
        log.info(
          f"Buyback de-risk (buyback_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "buyback_1_derisk"
        for grind_entry_id in buyback_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # # Buyback 2

    if (
      self.grinding_v2_buyback_2_enable
      and is_derisk_2_found
      and is_short_buyback_entry
      and is_short_extra_checks_entry
      and (buyback_2_current_open_rate == 0)
      and (
        -buyback_2_exit_distance_ratio
        < (
          self.grinding_v2_buyback_2_distance_ratio_futures
          if is_futures
          else self.grinding_v2_buyback_2_distance_ratio_spot
        )
      )
      and is_not_trade_max_stake
    ):
      buy_amount = (
        slice_amount
        * (self.grinding_v2_buyback_2_stake_futures if is_futures else self.grinding_v2_buyback_2_stake_spot)
        / trade_leverage
      )
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "buyback-entry",
          tag="buyback_2_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Buyback entry (buyback_2_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_2_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if buyback_2_sub_grind_count > 0:
      grind_profit = -(exit_rate - buyback_2_current_open_rate) / buyback_2_current_open_rate
      if (
        grind_profit
        > (
          (
            self.grinding_v2_buyback_2_profit_threshold_futures
            if is_futures
            else self.grinding_v2_buyback_2_profit_threshold_spot
          )
          + fee_open_rate
          + fee_close_rate
        )
      ) and short_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
        sell_amount = buyback_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "buyback-exit",
              tag="buyback_2_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_2_total_amount,
            )
          )
          log.info(
            f"Buyback exit (buyback_2_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "buyback_2_exit"
          for grind_entry_id in buyback_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_2_use_derisk
    #   and (buyback_2_sub_grind_count > 0)
    #   and (
    #     (-(exit_rate - buyback_2_current_open_rate) / buyback_2_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_2_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_2_derisk_spot
    #     )
    #   )
    #   and (buyback_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_buyback_2_use_derisk
      and (buyback_2_sub_grind_count > 0)
      and (
        buyback_2_current_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_buyback_2_derisk_futures if is_futures else self.grinding_v2_buyback_2_derisk_spot)
        )
      )
      and (is_backtest or buyback_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = buyback_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_2_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - buyback_2_current_open_rate) / buyback_2_current_open_rate)
            if buyback_2_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "buyback-derisk",
            tag="buyback_2_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            coin_amount=buyback_2_total_amount,
          )
        )
        log.info(
          f"Buyback de-risk (buyback_2_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "buyback_2_derisk"
        for grind_entry_id in buyback_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # # Buyback 3

    if (
      self.grinding_v2_buyback_3_enable
      and is_derisk_3_found
      and is_short_buyback_entry
      and is_short_extra_checks_entry
      and (buyback_3_current_open_rate == 0)
      and (
        -buyback_3_exit_distance_ratio
        < (
          self.grinding_v2_buyback_3_distance_ratio_futures
          if is_futures
          else self.grinding_v2_buyback_3_distance_ratio_spot
        )
      )
      and is_not_trade_max_stake
    ):
      buy_amount = (
        slice_amount
        * (self.grinding_v2_buyback_3_stake_futures if is_futures else self.grinding_v2_buyback_3_stake_spot)
        / trade_leverage
      )
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "buyback-entry",
          tag="buyback_3_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Buyback entry (buyback_3_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      order_tag = "buyback_3_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if buyback_3_sub_grind_count > 0:
      grind_profit = -(exit_rate - buyback_3_current_open_rate) / buyback_3_current_open_rate
      if (
        grind_profit
        > (
          (
            self.grinding_v2_buyback_3_profit_threshold_futures
            if is_futures
            else self.grinding_v2_buyback_3_profit_threshold_spot
          )
          + fee_open_rate
          + fee_close_rate
        )
      ) and short_grind_exit_v2(last_candle, previous_candle, slice_profit, True):
        sell_amount = buyback_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "buyback-exit",
              tag="buyback_3_exit",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=buyback_3_total_amount,
            )
          )
          log.info(
            f"Buyback exit (buyback_3_exit) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "buyback_3_exit"
          for grind_entry_id in buyback_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # if (
    #   self.grinding_v2_buyback_3_use_derisk
    #   and (buyback_3_sub_grind_count > 0)
    #   and (
    #     (-(exit_rate - buyback_3_current_open_rate) / buyback_3_current_open_rate)
    #     < (
    #       self.grinding_v2_buyback_3_derisk_futures if self.is_futures_mode else self.grinding_v2_buyback_3_derisk_spot
    #     )
    #   )
    #   and (buyback_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
    # ):
    if (
      self.grinding_v2_buyback_3_use_derisk
      and (buyback_3_sub_grind_count > 0)
      and (
        buyback_3_current_grind_stake_profit
        < (
          slice_amount
          * (self.grinding_v2_buyback_3_derisk_futures if is_futures else self.grinding_v2_buyback_3_derisk_spot)
        )
      )
      and (is_backtest or buyback_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3))
    ):
      sell_amount = buyback_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if buyback_3_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - buyback_3_current_open_rate) / buyback_3_current_open_rate)
            if buyback_3_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "buyback-derisk",
            tag="buyback_3_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            coin_amount=buyback_3_total_amount,
          )
        )
        log.info(
          f"Buyback de-risk (buyback_3_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {buyback_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "buyback_3_derisk"
        for grind_entry_id in buyback_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    return None

  def short_buyback_entry_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    previous_ema_12 = previous_candle["EMA_12"]
    previous_ema_26 = previous_candle["EMA_26"]

    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_close_min_48 = last_candle["close_min_48"]
    last_low_min_6_1h = last_candle["low_min_6_1h"]
    last_low_min_12_1h = last_candle["low_min_12_1h"]
    last_open = last_candle["open"]

    last_ema_12 = last_candle["EMA_12"]
    last_ema_26 = last_candle["EMA_26"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_rsi_3 = last_candle["RSI_3"]

    last_close = last_candle["close"]
    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_roc_2_1h = last_candle["ROC_2_1h"]
    last_roc_2_4h = last_candle["ROC_2_4h"]
    last_protections_short_global = last_candle["protections_short_global"]
    last_enter_short = last_candle["enter_short"]
    last_aroond_14 = last_candle["AROOND_14"]
    last_aroond_14_15m = last_candle["AROOND_14_15m"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_stochrsi_k_15m = last_candle["STOCHRSIk_14_14_3_3_15m"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_roc_2_1d = last_candle["ROC_2_1d"]
    last_ema_16 = last_candle["EMA_16"]
    last_bbu_20 = last_candle["BBU_20_2.0"]

    # Reused short buyback entry v2 thresholds
    last_roc_2_4h_lt_5 = last_roc_2_4h < 5.0
    last_roc_2_1h_lt_5 = last_roc_2_1h < 5.0
    last_rsi_14_gt_64 = last_rsi_14 > 64.0
    last_rsi_3_4h_lt_90 = last_rsi_3_4h < 90.0
    last_rsi_3_1h_lt_90 = last_rsi_3_1h < 90.0
    last_rsi_3_1d_lt_90 = last_rsi_3_1d < 90.0
    last_rsi_3_15m_lt_90 = last_rsi_3_15m < 90.0
    last_roc_9_4h_lt_5 = last_roc_9_4h < 5.0
    last_roc_9_1h_lt_5 = last_roc_9_1h < 5.0
    last_roc_9_1d_lt_5 = last_roc_9_1d < 5.0

    if (last_protections_short_global == True) and (
      (last_enter_short == True)
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3 < 80.0)
        and (last_rsi_3_15m < 70.0)
        and (last_rsi_3_1h < 70.0)
        and (last_rsi_3_4h < 70.0)
        and (last_aroond_14 < 25.0)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        # and (last_candle["ROC_9_4h"] > -20.0)
        # and (last_candle["ROC_9_4h"] < 40.0)
        # and (last_candle["ROC_9_1d"] > -20.0)
        # and (last_candle["ROC_9_1d"] < 50.0)
        and (last_stochrsi_k > 80.0)
        and (last_stochrsi_k_15m > 80.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 30.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_4h"] < 30.0)
        and (last_close < (last_close_min_48 * 1.10))
        and (last_close < (last_low_min_6_1h * 1.18))
        and (last_close < (last_low_min_12_1h * 1.25))
        # and (last_candle["close"] < (last_candle["low_min_24_4h"] * 1.20))
        and (last_close > (last_ema_16 * 1.120))
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3 < 95.0)
        and (last_rsi_3_15m < 85.0)
        and (last_rsi_3_1h < 85.0)
        and (last_rsi_3_4h < 85.0)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        # and (last_candle["ROC_2_1d"] > -10.0)
        # and (last_candle["ROC_9_1h"] > -10.0)
        # and (last_candle["ROC_9_4h"] > -10.0)
        and (last_roc_9_1d_lt_5)
        and (last_ema_12 > last_ema_26)
        and ((last_ema_12 - last_ema_26) > (last_open * 0.020))
        and ((previous_ema_12 - previous_ema_26) > (last_open / 100.0))
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3 < 90.0)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_rsi_3_1d_lt_90)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        and (last_roc_2_1d < 5.0)
        and (last_roc_9_1h_lt_5)
        and (last_roc_9_4h_lt_5)
        and (last_roc_9_1d < 10.0)
        # and (last_candle["ROC_9_4h"] < 40.0)
        # and (last_candle["ROC_9_1d"] < 50.0)
        and (last_aroond_14_15m < 25.0)
        and (last_close < (last_close_min_48 * 1.10))
        and (last_close < (last_low_min_6_1h * 1.18))
        and (last_close < (last_low_min_12_1h * 1.25))
        # and (last_candle["close"] < (last_candle["low_min_24_4h"] * 1.20))
        and (last_close > (last_ema_12 * 1.020))
      )
      or (
        (last_rsi_14 < 64.0)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_rsi_3_1d_lt_90)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        # and (last_candle["ROC_2_1d"] > -5.0)
        and (last_roc_9_1h_lt_5)
        and (last_roc_9_4h_lt_5)
        and (last_roc_9_1d_lt_5)
        and (last_stochrsi_k_1h > 20.0)
        and (last_stochrsi_k_4h > 30.0)
        # and (last_candle["close"] > (last_candle["close_max_48"] * 0.90))
        # and (last_candle["close"] < (last_candle["low_min_6_1h"] * 1.18))
        # and (last_candle["close"] < (last_candle["low_min_12_1h"] * 1.25))
        and (last_close > (last_ema_26 * 1.040))
        and (last_close > (last_bbu_20 * 1.001))
      )
    ):
      return True

    return False

  def short_grind_entry_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    previous_ema_12 = previous_candle["EMA_12"]
    previous_ema_26 = previous_candle["EMA_26"]
    last_aroond_14_15m = last_candle["AROOND_14_15m"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_high_max_24_4h = last_candle["high_max_24_4h"]
    last_bbu_20_2_0 = last_candle["BBU_20_2.0"]
    last_high_max_12_4h = last_candle["high_max_12_4h"]

    last_ema_12 = last_candle["EMA_12"]
    last_ema_26 = last_candle["EMA_26"]
    last_stochrsik_14_14_3_3 = last_candle["STOCHRSIk_14_14_3_3"]
    last_close_min_48 = last_candle["close_min_48"]
    last_open = last_candle["open"]
    last_aroond_14 = last_candle["AROOND_14"]
    last_roc_2_1d = last_candle["ROC_2_1d"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_low_min_12_1h = last_candle["low_min_12_1h"]
    last_low_min_6_1h = last_candle["low_min_6_1h"]

    last_close = last_candle["close"]
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_rsi_14 = last_candle["RSI_14"]
    last_roc_2_1h = last_candle["ROC_2_1h"]
    last_roc_2_4h = last_candle["ROC_2_4h"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_protections_short_global = last_candle["protections_short_global"]
    last_enter_short = last_candle["enter_short"]
    last_stochrsi_k_15m = last_candle["STOCHRSIk_14_14_3_3_15m"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_low_min_24_4h = last_candle["low_min_24_4h"]
    last_ema_16 = last_candle["EMA_16"]

    # Reused short grind entry v2 thresholds
    last_rsi_3_lt_95 = last_rsi_3 < 95.0
    last_rsi_3_4h_lt_90 = last_rsi_3_4h < 90.0
    last_rsi_3_1h_lt_90 = last_rsi_3_1h < 90.0
    last_rsi_3_15m_lt_90 = last_rsi_3_15m < 90.0
    last_rsi_3_lt_90 = last_rsi_3 < 90.0
    last_rsi_14_gt_64 = last_rsi_14 > 64.0
    last_aroond_14_lt_25 = last_aroond_14 < 25.0
    last_stochrsik_14_14_3_3_gt_80 = last_stochrsik_14_14_3_3 > 80.0
    last_rsi_3_1d_lt_90 = last_rsi_3_1d < 90.0
    last_roc_9_4h_lt_10 = last_roc_9_4h < 10.0
    last_roc_9_1h_lt_10 = last_roc_9_1h < 10.0
    last_roc_2_4h_lt_10 = last_roc_2_4h < 10.0
    last_roc_2_1h_lt_10 = last_roc_2_1h < 10.0
    last_rsi_3_15m_lt_85 = last_rsi_3_15m < 85.0
    last_roc_2_4h_lt_5 = last_roc_2_4h < 5.0
    last_roc_2_1h_lt_5 = last_roc_2_1h < 5.0
    last_roc_2_1d_lt_10 = last_roc_2_1d < 10.0
    last_rsi_3_4h_lt_85 = last_rsi_3_4h < 85.0
    last_rsi_3_1h_lt_85 = last_rsi_3_1h < 85.0
    last_rsi_3_15m_lt_95 = last_rsi_3_15m < 95.0
    last_rsi_14_gt_65 = last_rsi_14 > 65.0
    last_roc_9_1d_lt_30 = last_roc_9_1d < 30.0

    if (last_protections_short_global == True) and (
      (last_enter_short == True)
      or (
        (last_rsi_14 > 54.0)
        and (last_rsi_3_lt_90)
        and (last_rsi_3_15m_lt_85)
        and (last_rsi_3_1h_lt_85)
        and (last_rsi_3_4h_lt_85)
        and (last_roc_2_1h_lt_10)
        and (last_roc_2_4h_lt_10)
        and (last_roc_2_1d_lt_10)
        and (last_roc_9_1h < 25.0)
        and (last_roc_9_4h < 25.0)
        and (last_roc_9_1d < 25.0)
        # and (last_candle["ROC_9_1d"] < 40.0)
        and (last_aroond_14_lt_25)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 30.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_4h"] < 30.0)
        and (last_close < (last_close_min_48 * 1.10))
        and (last_close < (last_low_min_6_1h * 1.18))
        and (last_close < (last_low_min_12_1h * 1.25))
        and (last_close > (last_high_max_24_4h * 0.85))
        and (last_close > (last_ema_16 * 1.032))
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3_lt_95)
        and (last_rsi_3_15m_lt_85)
        and (last_rsi_3_1h_lt_85)
        and (last_rsi_3_4h_lt_85)
        # and (last_candle["RSI_3_1d"] > 15.0)
        and (last_roc_2_1h_lt_10)
        and (last_roc_2_4h_lt_10)
        # and (last_candle["ROC_2_1d"] > -10.0)
        and (last_roc_9_1h_lt_10)
        and (last_roc_9_4h_lt_10)
        and (last_roc_9_1d_lt_30)
        and (last_stochrsik_14_14_3_3 > 50.0)
        and (last_ema_12 > last_ema_26)
        and ((last_ema_12 - last_ema_26) > (last_open * 0.020))
        and ((previous_ema_12 - previous_ema_26) > (last_open / 100.0))
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3_lt_90)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_rsi_3_1d_lt_90)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        and (last_roc_2_1d < 5.0)
        and (last_roc_9_1h_lt_10)
        and (last_roc_9_4h_lt_10)
        and (last_roc_9_1d < 10.0)
        # and (last_roc_9_4h < 40.0)
        # and (last_candle["ROC_9_1d"] < 50.0)
        and (last_aroond_14_15m < 25.0)
        and (last_close < (last_close_min_48 * 1.10))
        and (last_close < (last_low_min_6_1h * 1.18))
        and (last_close < (last_low_min_12_1h * 1.25))
        # and (last_close < (last_candle["low_min_24_4h"] * 1.20))
        and (last_close > (last_ema_12 * 1.020))
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3_lt_90)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_rsi_3_1d_lt_90)
        and (last_roc_2_1h_lt_10)
        and (last_roc_2_4h_lt_10)
        and (last_roc_2_1d_lt_10)
        # and (last_roc_9_1h > -10.0)
        # and (last_roc_9_4h > -10.0)
        # and (last_candle["ROC_9_1d"] > -10.0)
        and (last_aroond_14_lt_25)
        and (last_close < (last_close_min_48 * 1.10))
        and (last_close < (last_low_min_6_1h * 1.18))
        and (last_close < (last_low_min_12_1h * 1.25))
        and (last_close > (last_ema_26 * 1.038))
        and (last_close > (last_bbu_20_2_0 * 1.0))
      )
      or (
        (last_rsi_14_gt_65)
        and (last_rsi_3_lt_90)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        # and (last_candle["RSI_3_1d"] > 10.0)
        and (last_roc_2_1h_lt_10)
        and (last_roc_2_4h_lt_10)
        and (last_roc_2_1d_lt_10)
        and (last_roc_9_1h_lt_10)
        and (last_roc_9_4h_lt_10)
        # and (last_candle["ROC_9_1d"] > -10.0)
        and (last_aroond_14_lt_25)
        # and (last_candle["AROONU_14_15m"] < 25.0)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 20.0)
        # and (last_close > (last_candle["close_max_48"] * 0.90))
        # and (last_close < (last_candle["low_min_6_1h"] * 1.18))
        # and (last_close < (last_candle["low_min_12_1h"] * 1.25))
        and (last_close > (last_high_max_12_4h * 0.80))
        and (last_close > (last_candle["EMA_9"] * 1.032))
        and (last_close > (last_candle["EMA_20"] * 1.020))
      )
      or (
        (last_rsi_14_gt_65)
        and (last_rsi_3_lt_90)
        and (last_rsi_3 > 60.0)
        # and (last_candle["RSI_4"] < 40.0)
        and (last_rsi_3_15m_lt_85)
        # and (last_rsi_3_1h > 20.0)
        # and (last_rsi_3_4h > 20.0)
        # and (last_candle["RSI_3_1d"] > 20.0)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        # and (last_candle["ROC_2_1d"] > -5.0)
        and (last_roc_9_1h_lt_10)
        and (last_roc_9_4h_lt_10)
        # and (last_candle["ROC_9_1d"] > -10.0)
        and (last_aroond_14_lt_25)
        # and (last_candle["AROONU_14_15m"] < 25.0)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_15m"] < 20.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 50.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_4h"] < 50.0)
        # and (last_close > (last_candle["close_max_48"] * 0.90))
        # and (last_close < (last_candle["low_min_6_1h"] * 1.18))
        # and (last_close < (last_candle["low_min_12_1h"] * 1.25))
        and (last_candle["RSI_20"] > previous_candle["RSI_20"])
        and (last_close > (last_candle["SMA_16"] * 1.045))
        # and (last_close < (last_candle["EMA_20"] * 0.980))
      )
      or (
        (last_rsi_3_lt_95)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_roc_2_1h_lt_5)
        and (last_roc_2_4h_lt_5)
        and (last_roc_9_1h < 5.0)
        and (last_roc_9_4h < 5.0)
        and (last_candle["WILLR_14"] > -50.0)
        # and (last_candle["AROONU_14"] < 25.0)
        and (last_stochrsik_14_14_3_3_gt_80)
        and (last_candle["WILLR_84_1h"] > -30.0)
        # and (last_candle["STOCHRSIk_14_14_3_3_1h"] < 40.0)
        and (last_close < (last_high_max_24_4h * 0.77))
        and (last_candle["BBB_20_2.0_1h"] > 12.0)
        and (last_close_min_48 <= (last_close * 0.90))
      )
      or (
        (last_rsi_3 > 70.0)
        and (last_rsi_3_lt_95)
        and (last_rsi_3_15m_lt_95)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        # and (last_roc_2_1h > -5.0)
        # and (last_roc_2_4h > -5.0)
        # and (last_roc_9_1h > -5.0)
        # and (last_roc_9_4h > -5.0)
        and (last_roc_9_1d_lt_30)
        # and (last_candle["STOCHRSIk_14_14_3_3"] < 20.0)
        # and (last_close < (last_candle["low_min_24_4h"] * 1.50))
        and (last_ema_12 > last_ema_26)
        and ((last_ema_12 - last_ema_26) > (last_open * 0.034))
        and ((previous_ema_12 - previous_ema_26) > (last_open / 100.0))
      )
      or (
        (last_rsi_3_lt_95)
        and (last_rsi_3_15m < 75.0)
        and (last_rsi_3_1h < 70.0)
        and (last_close > (last_low_min_24_4h * 1.10))
        and (last_close > (last_close_min_48 * 1.10))
        and (last_close < (last_candle["close_max_12"] * 0.92))
      )
      or (
        (last_rsi_3_lt_95)
        and (last_rsi_3_15m_lt_95)
        and (last_stochrsik_14_14_3_3_gt_80)
        and (last_rsi_14 > (last_rsi_14_1h + 45.0))
      )
      or (
        (last_rsi_3_lt_90)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_rsi_3_1d_lt_90)
        and (last_stochrsik_14_14_3_3_gt_80)
        and (last_close > (last_candle["SMA_30"] * 1.022))
        and (last_close > (last_bbu_20_2_0 * 1.0))
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3_lt_95)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_rsi_3_1d_lt_90)
        and (last_stochrsik_14_14_3_3 > 70.0)
        and (last_close < (last_close_min_48 * 1.15))
        and (last_close < (last_low_min_6_1h * 1.20))
        and (last_close < (last_low_min_12_1h * 1.33))
        and (last_close > (last_high_max_12_4h * 0.75))
        and (last_ema_12 > last_ema_26)
        and ((last_ema_12 - last_ema_26) > (last_open * 0.018))
        and ((previous_ema_12 - previous_ema_26) > (last_open / 100.0))
      )
      or (
        (last_rsi_3_lt_95)
        and (previous_candle["SMA_9"] > previous_candle["SMA_21"])
        and (last_candle["SMA_9"] < last_candle["SMA_21"])
        and (last_close > (last_candle["EMA_100"] * 1.016))
        and (last_rsi_3_1h < 80.0)
        and (last_rsi_3_4h < 80.0)
      )
      or (
        (slice_profit > 0.12)
        and (last_rsi_3_lt_95)
        and (last_rsi_3_15m_lt_90)
        and (last_rsi_14 > 60.0)
        and (last_aroond_14_lt_25)
        and (last_aroond_14_15m < 30.0)
        and (last_stochrsik_14_14_3_3_gt_80)
        and (last_stochrsi_k_15m > 70.0)
        and (last_rsi_14_1h > 50.0)
        and (last_candle["RSI_14_4h"] > 50.0)
      )
      or (
        (last_rsi_14_gt_64)
        and (last_rsi_3_lt_95)
        and (last_rsi_3_1h_lt_90)
        and (last_rsi_3_4h_lt_90)
        and (last_close > (last_ema_12 * 1.001))
        and (last_close > (last_candle["BBL_20_2.0"] * 1.004))
      )
    ):
      return True

    return False

  def short_buyback_exit_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_14 = last_candle["RSI_14"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_close = last_candle["close"]
    last_bbl_20 = last_candle["BBL_20_2.0"]

    if (
      (last_rsi_3 < 1.0)
      or (last_rsi_14 < 30.0)
      or (last_willr_14 < -99.9)
      or (last_stochrsi_k > 5.0)
      or (last_close < (last_bbl_20 * 0.99))
      or ((last_rsi_3 < 10.0) and (last_rsi_14 > 50.0))
    ):
      return True

    return False

  def short_grind_exit_v2(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_14 = last_candle["RSI_14"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_close = last_candle["close"]
    last_bbl_20 = last_candle["BBL_20_2.0"]

    if (
      (last_rsi_3 < 1.0)
      or (last_rsi_14 < 30.0)
      or (last_willr_14 < -99.9)
      or (last_stochrsi_k < 5.0)
      or (last_close < (last_bbl_20 * 0.99))
      or ((last_rsi_3 < 10.0) and (last_rsi_14 > 50.0))
    ):
      return True

    return False

  # Short Grinding Exit v3 (mirror of long_grind_exit_v3)
  # ---------------------------------------------------------------------------------------------
  def short_grind_exit_v3(
    self,
    last_candle: Series,
    previous_candle: Series,
    slice_profit: float,
    current_time: datetime,
    min_stake: float,
    current_stake_amount: float,
    exit_rate: float,
    profit_stake: float,
    profit_ratio: float,
    name: str,
    tag: str,
    fee_open_rate: float,
    fee_close_rate: float,
    # max_profit: float,
    # max_profit_rate: float,
    grind_profit_stake: float,
    grind_profit_rate: float,
    grind_total_amount: float,
    grind_exit_profit_threshold: float,
    grind_open_orders,
    trade: Trade,
  ) -> tuple:
    # Normalize so profit is always positive when the short is profitable.
    profit = -grind_profit_rate

    # Not enough profit after fees.
    if profit < (grind_exit_profit_threshold + fee_open_rate + fee_close_rate):
      return None, None

    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_14 = last_candle["RSI_14"]
    last_willr_14 = last_candle["WILLR_14"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_close = last_candle["close"]
    last_bbl_20 = last_candle["BBL_20_2.0"]

    is_normal_exit = False
    if (
      (last_rsi_3 < 1.0)
      or (last_rsi_14 < 30.0)
      or (last_willr_14 < -99.9)
      or (last_stochrsi_k < 5.0)
      or (last_close < (last_bbl_20 * 0.99))
      or ((last_rsi_3 < 10.0) and (last_rsi_14 > 50.0))
      or (
        (last_rsi_3 < 20.0)
        and (last_candle["RSI_3_1h"] > 80.0)
        and (last_candle["RSI_3_4h"] > 80.0)
        and (last_candle["ROC_9_1d"] < 10.0)
        and (last_candle["BTC_RSI_14_4h"] > 65.0)
      )
    ):
      is_normal_exit = True

    is_trailing_exit = False
    # max_profit = -max_profit_rate
    # drawdown = max_profit - profit
    # if 0.01 <= -grind_profit_rate < 0.02:
    #   if -grind_profit_rate < (-max_profit_rate - 0.025):
    #     is_trailing_exit = True
    # elif 0.02 <= -grind_profit_rate <= 0.05:
    #   if -grind_profit_rate < (-max_profit_rate - 0.035):
    #     is_trailing_exit = True
    # elif 0.05 <= -grind_profit_rate <= 0.08:
    #   if -grind_profit_rate < (-max_profit_rate - 0.045):
    #     is_trailing_exit = True
    # elif 0.08 <= -grind_profit_rate <= 0.12:
    #   if -grind_profit_rate < (-max_profit_rate - 0.050):
    #     is_trailing_exit = True
    # elif 0.12 <= -grind_profit_rate:
    #   if -grind_profit_rate < (-max_profit_rate - 0.055):
    #     is_trailing_exit = True
    # is_trailing_exit = -grind_profit_rate > 0.04
    if is_normal_exit or is_trailing_exit:
      stake_currency = self.config["stake_currency"]
      stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
      trade_pair = trade.pair
      trade_leverage = trade.leverage
      trade_amount = trade.amount
      trade_stake_amount = trade.stake_amount
      exit_amount = grind_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - exit_amount) < (min_stake * 1.55):
        exit_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_exit_amount = exit_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if exit_amount > min_stake and ft_exit_amount > min_stake:
        self.dp.send_msg(
          self.notification_msg(
            "grinding-exit",
            tag=name,
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=exit_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit_stake,
            grind_profit_pct=profit,
            coin_amount=grind_total_amount,
          )
        )
        log.info(
          f"Grinding exit ({name}) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {exit_amount:{stake_fmt}} | Coin amount: {grind_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(profit * 100.0):.2f}% ({grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = tag
        for grind_entry in grind_open_orders:
          order_tag += " " + str(grind_entry.id)
        return -ft_exit_amount, order_tag

    return None, None

  # Short Grinding Adjust Trade Position v3
  # ---------------------------------------------------------------------------------------------
  def short_grind_adjust_trade_position_v3(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    config = self.config
    stake_currency = config["stake_currency"]
    is_futures_mode = self.is_futures_mode
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_leverage = trade.leverage
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    is_backtest = self.is_backtest_mode()
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    previous_candle = df.iloc[-2]

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_exits = trade.nr_of_successful_exits

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    current_stake_amount = trade_amount * exit_rate
    slice_amount = filled_entries[0].safe_filled * filled_entries[0].safe_price
    slice_profit = (exit_rate - filled_orders[-1].safe_price) / filled_orders[-1].safe_price
    slice_profit_entry = (exit_rate - filled_entries[-1].safe_price) / filled_entries[-1].safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    is_rebuy_mode = all(c in self.short_rebuy_mode_tags for c in enter_tags) or (
      any(c in self.short_rebuy_mode_tags for c in enter_tags)
      and all(c in (self.short_rebuy_mode_tags + self.short_grind_mode_tags) for c in enter_tags)
    )
    # Rebuy mode, the first entry is lower than normal slot stake
    if is_rebuy_mode:
      slice_amount /= self.system_v3_rebuy_mode_stake_multiplier

    is_system_v3, is_system_v3_1, is_system_v3_2 = self.get_system_version_flags(trade)

    has_order_tags = hasattr(filled_orders[0], "ft_order_tag")

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate
    fee_rate = fee_open_rate + fee_close_rate
    stake_scale_leverage = trade_leverage if is_futures_mode else 1.0
    grind_entry_retry_time = current_time - timedelta(minutes=5)

    # =========================================================================
    # GRINDING CONFIGURATION
    # =========================================================================
    if is_futures_mode:
      grind_1_stakes = self.system_v3_grind_1_stakes_futures
      grind_1_sub_thresholds = self.system_v3_grind_1_thresholds_futures
      grind_1_derisk_grinds = self.system_v3_grind_1_derisk_futures
      grind_1_profit_threshold = self.system_v3_grind_1_profit_threshold_futures

      grind_2_stakes = self.system_v3_grind_2_stakes_futures
      grind_2_sub_thresholds = self.system_v3_grind_2_thresholds_futures
      grind_2_derisk_grinds = self.system_v3_grind_2_derisk_futures
      grind_2_profit_threshold = self.system_v3_grind_2_profit_threshold_futures

      grind_3_stakes = self.system_v3_grind_3_stakes_futures
      grind_3_sub_thresholds = self.system_v3_grind_3_thresholds_futures
      grind_3_derisk_grinds = self.system_v3_grind_3_derisk_futures
      grind_3_profit_threshold = self.system_v3_grind_3_profit_threshold_futures

      grind_4_stakes = self.system_v3_grind_4_stakes_futures
      grind_4_sub_thresholds = self.system_v3_grind_4_thresholds_futures
      grind_4_derisk_grinds = self.system_v3_grind_4_derisk_futures
      grind_4_profit_threshold = self.system_v3_grind_4_profit_threshold_futures

      grind_5_stakes = self.system_v3_grind_5_stakes_futures
      grind_5_sub_thresholds = self.system_v3_grind_5_thresholds_futures
      grind_5_derisk_grinds = self.system_v3_grind_5_derisk_futures
      grind_5_profit_threshold = self.system_v3_grind_5_profit_threshold_futures

      rebuy_stakes = self.system_v3_1_rebuy_stakes_futures
      rebuy_sub_thresholds = self.system_v3_1_rebuy_thresholds_futures
    else:
      grind_1_stakes = self.system_v3_grind_1_stakes_spot
      grind_1_sub_thresholds = self.system_v3_grind_1_thresholds_spot
      grind_1_derisk_grinds = self.system_v3_grind_1_derisk_spot
      grind_1_profit_threshold = self.system_v3_grind_1_profit_threshold_spot

      grind_2_stakes = self.system_v3_grind_2_stakes_spot
      grind_2_sub_thresholds = self.system_v3_grind_2_thresholds_spot
      grind_2_derisk_grinds = self.system_v3_grind_2_derisk_spot
      grind_2_profit_threshold = self.system_v3_grind_2_profit_threshold_spot

      grind_3_stakes = self.system_v3_grind_3_stakes_spot
      grind_3_sub_thresholds = self.system_v3_grind_3_thresholds_spot
      grind_3_derisk_grinds = self.system_v3_grind_3_derisk_spot
      grind_3_profit_threshold = self.system_v3_grind_3_profit_threshold_spot

      grind_4_stakes = self.system_v3_grind_4_stakes_spot
      grind_4_sub_thresholds = self.system_v3_grind_4_thresholds_spot
      grind_4_derisk_grinds = self.system_v3_grind_4_derisk_spot
      grind_4_profit_threshold = self.system_v3_grind_4_profit_threshold_spot

      grind_5_stakes = self.system_v3_grind_5_stakes_spot
      grind_5_sub_thresholds = self.system_v3_grind_5_thresholds_spot
      grind_5_derisk_grinds = self.system_v3_grind_5_derisk_spot
      grind_5_profit_threshold = self.system_v3_grind_5_profit_threshold_spot

      rebuy_stakes = self.system_v3_1_rebuy_stakes_spot
      rebuy_sub_thresholds = self.system_v3_1_rebuy_thresholds_spot
    grind_1_max_sub_grinds = 0
    grind_1_stakes = scale_stakes_for_min_stake(
      grind_1_stakes, slice_amount, min_stake, trade_leverage, trade_leverage
    )
    grind_1_max_sub_grinds = len(grind_1_stakes)

    grind_2_max_sub_grinds = 0
    grind_2_stakes = scale_stakes_for_min_stake(
      grind_2_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_2_max_sub_grinds = len(grind_2_stakes)

    grind_3_max_sub_grinds = 0
    grind_3_stakes = scale_stakes_for_min_stake(
      grind_3_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_3_max_sub_grinds = len(grind_3_stakes)

    grind_4_max_sub_grinds = 0
    grind_4_stakes = scale_stakes_for_min_stake(
      grind_4_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_4_max_sub_grinds = len(grind_4_stakes)

    grind_5_max_sub_grinds = 0
    grind_5_stakes = scale_stakes_for_min_stake(
      grind_5_stakes, slice_amount, min_stake, stake_scale_leverage, trade_leverage
    )
    grind_5_max_sub_grinds = len(grind_5_stakes)

    rebuy_max_sub_grinds = len(rebuy_stakes)

    is_derisk_1 = False
    is_derisk_1_found = False  # derisk_level_1 de-risk exit
    derisk_1_order = None
    is_derisk_2 = False
    is_derisk_2_found = False  # derisk_level_2 de-risk exit
    derisk_2_order = None
    is_derisk_3 = False
    is_derisk_3_found = False  # derisk_level_3 de-risk exit
    derisk_3_order = None
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_profit_stake = 0.0
    grind_1_current_grind_profit_rate = 0.0
    grind_1_is_exit_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_orders = []
    grind_1_distance_ratio = 0.0
    grind_1_exit_order = None
    grind_1_exit_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_profit_stake = 0.0
    grind_2_current_grind_profit_rate = 0.0
    grind_2_is_exit_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_orders = []
    grind_2_distance_ratio = 0.0
    grind_2_exit_order = None
    grind_2_exit_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_profit_stake = 0.0
    grind_3_current_grind_profit_rate = 0.0
    grind_3_is_exit_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_orders = []
    grind_3_distance_ratio = 0.0
    grind_3_exit_order = None
    grind_3_exit_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_profit_stake = 0.0
    grind_4_current_grind_profit_rate = 0.0
    grind_4_is_exit_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_orders = []
    grind_4_distance_ratio = 0.0
    grind_4_exit_order = None
    grind_4_exit_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_profit_stake = 0.0
    grind_5_current_grind_profit_rate = 0.0
    grind_5_is_exit_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_orders = []
    grind_5_distance_ratio = 0.0
    grind_5_exit_order = None
    grind_5_exit_distance_ratio = 0.0
    rebuy_sub_grind_count = 0
    rebuy_total_amount = 0.0
    rebuy_total_cost = 0.0
    rebuy_current_open_rate = 0.0
    rebuy_current_grind_stake = 0.0
    rebuy_current_grind_stake_profit = 0.0
    rebuy_is_exit_found = False
    rebuy_found = False
    rebuy_buy_orders = []
    rebuy_orders = []
    rebuy_distance_ratio = 0.0
    rebuy_exit_order = None
    rebuy_exit_distance_ratio = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "sell") and (order is not filled_orders[0]):
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        if not grind_1_is_exit_found and order_tag == "grind_1_entry":
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order.safe_filled
          grind_1_total_cost += order.safe_filled * order.safe_price
          grind_1_buy_orders.append(order.id)
          grind_1_orders.append(order)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_1_found = True
        elif not grind_2_is_exit_found and order_tag == "grind_2_entry":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order.safe_filled
          grind_2_total_cost += order.safe_filled * order.safe_price
          grind_2_buy_orders.append(order.id)
          grind_2_orders.append(order)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_2_found = True
        elif not grind_3_is_exit_found and order_tag == "grind_3_entry":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order.safe_filled
          grind_3_total_cost += order.safe_filled * order.safe_price
          grind_3_buy_orders.append(order.id)
          grind_3_orders.append(order)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_3_found = True
        elif not grind_4_is_exit_found and order_tag == "grind_4_entry":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order.safe_filled
          grind_4_total_cost += order.safe_filled * order.safe_price
          grind_4_buy_orders.append(order.id)
          grind_4_orders.append(order)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_4_found = True
        elif not grind_5_is_exit_found and order_tag == "grind_5_entry":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order.safe_filled
          grind_5_total_cost += order.safe_filled * order.safe_price
          grind_5_buy_orders.append(order.id)
          grind_5_orders.append(order)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            grind_5_found = True
        elif not rebuy_is_exit_found and order_tag == "rebuy_entry":
          rebuy_sub_grind_count += 1
          rebuy_total_amount += order.safe_filled
          rebuy_total_cost += order.safe_filled * order.safe_price
          rebuy_buy_orders.append(order.id)
          rebuy_orders.append(order)
          if not rebuy_found:
            rebuy_distance_ratio = (exit_rate - order.safe_price) / order.safe_price
            rebuy_found = True
      elif order.ft_order_side == "buy":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          # break
        order_tag = ""
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag.partition(" ")[0]
        if order_tag == "derisk_level_1":
          if not is_derisk_1_found:
            is_derisk_1_found = True
            is_derisk_1 = True
            derisk_1_order = order
        elif order_tag == "derisk_level_2":
          if not is_derisk_2_found:
            is_derisk_2_found = True
            is_derisk_2 = True
            derisk_2_order = order
        elif order_tag == "derisk_level_3":
          if not is_derisk_3_found:
            is_derisk_3_found = True
            is_derisk_3 = True
            derisk_3_order = order
        elif not grind_1_is_exit_found and order_tag in ["grind_1_exit", "grind_1_derisk"]:
          grind_1_is_exit_found = True
          grind_1_exit_order = order
        elif not grind_2_is_exit_found and order_tag in ["grind_2_exit", "grind_2_derisk"]:
          grind_2_is_exit_found = True
          grind_2_exit_order = order
        elif not grind_3_is_exit_found and order_tag in ["grind_3_exit", "grind_3_derisk"]:
          grind_3_is_exit_found = True
          grind_3_exit_order = order
        elif not grind_4_is_exit_found and order_tag in ["grind_4_exit", "grind_4_derisk"]:
          grind_4_is_exit_found = True
          grind_4_exit_order = order
        elif not grind_5_is_exit_found and order_tag in ["grind_5_exit", "grind_5_derisk"]:
          grind_5_is_exit_found = True
          grind_5_exit_order = order
        elif not rebuy_is_exit_found and order_tag in ["rebuy_exit", "rebuy_derisk"]:
          rebuy_is_exit_found = True
          rebuy_exit_order = order
        elif order_tag == "derisk_global":
          if not grind_1_is_exit_found:
            grind_1_is_exit_found = True
            grind_1_exit_order = order
          if not grind_2_is_exit_found:
            grind_2_is_exit_found = True
            grind_2_exit_order = order
          if not grind_3_is_exit_found:
            grind_3_is_exit_found = True
            grind_3_exit_order = order
          if not grind_4_is_exit_found:
            grind_4_is_exit_found = True
            grind_4_exit_order = order
          if not grind_5_is_exit_found:
            grind_5_is_exit_found = True
            grind_5_exit_order = order
          if not rebuy_is_exit_found:
            rebuy_is_exit_found = True
            rebuy_exit_order = order

    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 - trade_fee_close)
      grind_1_current_grind_profit_stake = grind_1_total_cost - grind_1_current_grind_stake
      grind_1_current_grind_profit_rate = (exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 - trade_fee_close)
      grind_2_current_grind_profit_stake = grind_2_total_cost - grind_2_current_grind_stake
      grind_2_current_grind_profit_rate = (exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 - trade_fee_close)
      grind_3_current_grind_profit_stake = grind_3_total_cost - grind_3_current_grind_stake
      grind_3_current_grind_profit_rate = (exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 - trade_fee_close)
      grind_4_current_grind_profit_stake = grind_4_total_cost - grind_4_current_grind_stake
      grind_4_current_grind_profit_rate = (exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 - trade_fee_close)
      grind_5_current_grind_profit_stake = grind_5_total_cost - grind_5_current_grind_stake
      grind_5_current_grind_profit_rate = (exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
    if rebuy_sub_grind_count > 0:
      rebuy_current_open_rate = rebuy_total_cost / rebuy_total_amount
      rebuy_current_grind_stake = rebuy_total_amount * exit_rate * (1 - trade_fee_close)
      rebuy_current_grind_stake_profit = rebuy_total_cost - rebuy_current_grind_stake

    if grind_1_is_exit_found:
      grind_1_exit_distance_ratio = (exit_rate - grind_1_exit_order.safe_price) / grind_1_exit_order.safe_price
    if grind_2_is_exit_found:
      grind_2_exit_distance_ratio = (exit_rate - grind_2_exit_order.safe_price) / grind_2_exit_order.safe_price
    if grind_3_is_exit_found:
      grind_3_exit_distance_ratio = (exit_rate - grind_3_exit_order.safe_price) / grind_3_exit_order.safe_price
    if grind_4_is_exit_found:
      grind_4_exit_distance_ratio = (exit_rate - grind_4_exit_order.safe_price) / grind_4_exit_order.safe_price
    if grind_5_is_exit_found:
      grind_5_exit_distance_ratio = (exit_rate - grind_5_exit_order.safe_price) / grind_5_exit_order.safe_price
    if rebuy_is_exit_found:
      rebuy_exit_distance_ratio = (exit_rate - rebuy_exit_order.safe_price) / rebuy_exit_order.safe_price

    # all buybacks & grinds
    current_open_grind_stake_profit = (
      grind_1_current_grind_profit_stake
      + grind_2_current_grind_profit_stake
      + grind_3_current_grind_profit_stake
      + grind_4_current_grind_profit_stake
      + grind_5_current_grind_profit_stake
      + rebuy_current_grind_stake_profit
    )
    num_open_grinds_and_buybacks = (
      grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
      + rebuy_sub_grind_count
    )

    # not reached the max allowed stake for all grinds
    is_not_trade_max_stake_v3 = current_stake_amount < (slice_amount * self.system_v3_max_stake)
    is_not_trade_max_stake_v3_1 = current_stake_amount < (slice_amount * self.system_v3_1_max_stake)

    # grind_1_cluster_max_profit_stake = trade.get_custom_data(key="grind_1_cluster_max_profit_stake") or 0.0
    # grind_1_cluster_max_profit_rate = trade.get_custom_data(key="grind_1_cluster_max_profit_rate") or 0.0
    # if grind_1_current_grind_profit_stake > grind_1_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_1_cluster_max_profit_stake", value=grind_1_current_grind_profit_stake)
    # if grind_1_current_grind_profit_rate < grind_1_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_1_cluster_max_profit_rate", value=grind_1_current_grind_profit_rate)

    # grind_2_cluster_max_profit_stake = trade.get_custom_data(key="grind_2_cluster_max_profit_stake") or 0.0
    # grind_2_cluster_max_profit_rate = trade.get_custom_data(key="grind_2_cluster_max_profit_rate") or 0.0
    # if grind_2_current_grind_profit_stake > grind_2_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_2_cluster_max_profit_stake", value=grind_2_current_grind_profit_stake)
    # if grind_2_current_grind_profit_rate < grind_2_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_2_cluster_max_profit_rate", value=grind_2_current_grind_profit_rate)

    # grind_3_cluster_max_profit_stake = trade.get_custom_data(key="grind_3_cluster_max_profit_stake") or 0.0
    # grind_3_cluster_max_profit_rate = trade.get_custom_data(key="grind_3_cluster_max_profit_rate") or 0.0
    # if grind_3_current_grind_profit_stake > grind_3_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_3_cluster_max_profit_stake", value=grind_3_current_grind_profit_stake)
    # if grind_3_current_grind_profit_rate < grind_3_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_3_cluster_max_profit_rate", value=grind_3_current_grind_profit_rate)

    # grind_4_cluster_max_profit_stake = trade.get_custom_data(key="grind_4_cluster_max_profit_stake") or 0.0
    # grind_4_cluster_max_profit_rate = trade.get_custom_data(key="grind_4_cluster_max_profit_rate") or 0.0
    # if grind_4_current_grind_profit_stake > grind_4_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_4_cluster_max_profit_stake", value=grind_4_current_grind_profit_stake)
    # if grind_4_current_grind_profit_rate < grind_4_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_4_cluster_max_profit_rate", value=grind_4_current_grind_profit_rate)

    # grind_5_cluster_max_profit_stake = trade.get_custom_data(key="grind_5_cluster_max_profit_stake") or 0.0
    # grind_5_cluster_max_profit_rate = trade.get_custom_data(key="grind_5_cluster_max_profit_rate") or 0.0
    # if grind_5_current_grind_profit_stake > grind_5_cluster_max_profit_stake:
    #  trade.set_custom_data(key="grind_5_cluster_max_profit_stake", value=grind_5_current_grind_profit_stake)
    # if grind_5_current_grind_profit_rate < grind_5_cluster_max_profit_rate:
    #  trade.set_custom_data(key="grind_5_cluster_max_profit_rate", value=grind_5_current_grind_profit_rate)

    is_short_extra_checks_entry = (
      grind_entry_retry_time > filled_entries[-1].order_filled_utc
      # and ((current_time - timedelta(hours=6) > filled_orders[-1].order_filled_utc) or (slice_profit > 0.02))
      and (
        (current_time - timedelta(hours=6) > filled_orders[-1].order_filled_utc)
        or (slice_profit > 0.06)
        or (is_derisk_3)
      )
      # and (
      #   (current_stake_amount < (filled_entries[0].cost * 0.50))
      #   or (current_time - timedelta(hours=6) > filled_orders[-1].order_filled_utc)
      #   or (slice_profit > 0.06)
      # )
    )
    # is_short_extra_checks_entry = True
    is_short_grind_entry = (
      self.short_grind_entry_v3(
        last_candle,
        previous_candle,
        slice_profit,
        slice_profit_entry,
        True,
      )
      if is_short_extra_checks_entry
      else False
    )
    is_short_rebuy_entry = (
      self.short_rebuy_entry_v3(
        last_candle,
        previous_candle,
        slice_profit,
        True,
      )
      if is_system_v3_1
      else False
    )
    stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
    send_notifications = not is_backtest
    # =========================================================================
    # DE-RISK CONFIGURATION
    # =========================================================================

    if is_system_v3:
      derisk_1_enable = self.system_v3_derisk_level_1_enable
      derisk_2_enable = self.system_v3_derisk_level_2_enable
      derisk_3_enable = self.system_v3_derisk_level_3_enable
      if is_futures_mode:
        derisk_1_threshold = self.system_v3_derisk_level_1_futures[1]
        derisk_1_stake = self.system_v3_derisk_level_1_stake_futures
        derisk_2_threshold = self.system_v3_derisk_level_2_futures[1]
        derisk_2_stake = self.system_v3_derisk_level_2_stake_futures
        derisk_3_threshold = self.system_v3_derisk_level_3_futures[1]
        derisk_3_stake = self.system_v3_derisk_level_3_stake_futures
      else:
        derisk_1_threshold = self.system_v3_derisk_level_1_spot[1]
        derisk_1_stake = self.system_v3_derisk_level_1_stake_spot
        derisk_2_threshold = self.system_v3_derisk_level_2_spot[1]
        derisk_2_stake = self.system_v3_derisk_level_2_stake_spot
        derisk_3_threshold = self.system_v3_derisk_level_3_spot[1]
        derisk_3_stake = self.system_v3_derisk_level_3_stake_spot
    elif is_system_v3_1:
      derisk_1_enable = False
      derisk_2_enable = False
      derisk_3_enable = False
    elif is_system_v3_2:
      derisk_1_enable = self.system_v3_2_derisk_level_1_enable
      derisk_2_enable = self.system_v3_2_derisk_level_2_enable
      derisk_3_enable = self.system_v3_2_derisk_level_3_enable
      if is_futures_mode:
        derisk_1_threshold = self.system_v3_2_derisk_level_1_futures[1]
        derisk_1_stake = self.system_v3_2_derisk_level_1_stake_futures
        derisk_2_threshold = self.system_v3_2_derisk_level_2_futures[1]
        derisk_2_stake = self.system_v3_2_derisk_level_2_stake_futures
        derisk_3_threshold = self.system_v3_2_derisk_level_3_futures[1]
        derisk_3_stake = self.system_v3_2_derisk_level_3_stake_futures
      else:
        derisk_1_threshold = self.system_v3_2_derisk_level_1_spot[1]
        derisk_1_stake = self.system_v3_2_derisk_level_1_stake_spot
        derisk_2_threshold = self.system_v3_2_derisk_level_2_spot[1]
        derisk_2_stake = self.system_v3_2_derisk_level_2_stake_spot
        derisk_3_threshold = self.system_v3_2_derisk_level_3_spot[1]
        derisk_3_stake = self.system_v3_2_derisk_level_3_stake_spot
    derisk_enable = self.derisk_enable
    # ---------------------------------------------------------------------
    # De-risk level 1
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_1_enable
      and not is_derisk_1_found
      and not is_rebuy_mode
      and profit_stake < slice_amount * derisk_1_threshold / trade_leverage
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_1_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 1 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_1"
    # ---------------------------------------------------------------------
    # De-risk level 2
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_2_enable
      and not is_derisk_2_found
      and not is_rebuy_mode
      and profit_stake < slice_amount * derisk_2_threshold / trade_leverage
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_2_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 2 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_2"
    # ---------------------------------------------------------------------
    # De-risk level 3
    # ---------------------------------------------------------------------
    if (
      derisk_enable
      and derisk_3_enable
      and not is_derisk_3_found
      and not is_rebuy_mode
      and profit_stake < slice_amount * derisk_3_threshold / trade_leverage
    ):
      sell_amount = filled_entries[0].safe_filled * derisk_3_stake * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if send_notifications:
          send_msg(
            notification_msg(
              "de-risk",
              tag="Level 3",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
            )
          )
        log.info(
          f"De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "derisk_level_3"

    # Grinding 1

    if (
      (self.system_v3_grind_1_enable)
      # and is_derisk_1_found
      and is_short_extra_checks_entry
      and (grind_1_sub_grind_count < grind_1_max_sub_grinds)
      and (grind_1_sub_grind_count == 0 or (-grind_1_distance_ratio < grind_1_sub_thresholds[grind_1_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and is_short_grind_entry
    ):
      buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_1_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_1_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_1_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_1_sub_grind_count > 0:
      ft_exit_amount, tag = self.short_grind_exit_v3(
        last_candle,
        previous_candle,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_1_exit",
        "grind_1_exit",
        fee_open_rate,
        fee_close_rate,
        # grind_1_cluster_max_profit_stake,
        # grind_1_cluster_max_profit_rate,
        grind_1_current_grind_profit_stake,
        grind_1_current_grind_profit_rate,
        grind_1_total_amount,
        grind_1_profit_threshold,
        grind_1_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      self.system_v3_grind_1_use_derisk
      and (grind_1_sub_grind_count > 0)
      and ((-(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < grind_1_derisk_grinds)
    ):
      # if (
      #   self.system_v3_grind_1_use_derisk
      #   and (grind_1_sub_grind_count > 0)
      #   and (grind_1_current_grind_profit_stake < (slice_amount * grind_1_derisk_grinds))
      #   and (grind_1_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_1_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_current_grind_profit_stake,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_1_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_1_derisk"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 2

    if (
      (self.system_v3_grind_2_enable)
      # and is_derisk_1_found
      and is_short_extra_checks_entry
      and (grind_2_sub_grind_count < grind_2_max_sub_grinds)
      and (grind_2_sub_grind_count == 0 or (-grind_2_distance_ratio < grind_2_sub_thresholds[grind_2_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and is_short_grind_entry
    ):
      buy_amount = slice_amount * grind_2_stakes[grind_2_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_2_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_2_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_2_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_2_sub_grind_count > 0:
      ft_exit_amount, tag = self.short_grind_exit_v3(
        last_candle,
        previous_candle,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_2_exit",
        "grind_2_exit",
        fee_open_rate,
        fee_close_rate,
        # grind_2_cluster_max_profit_stake,
        # grind_2_cluster_max_profit_rate,
        grind_2_current_grind_profit_stake,
        grind_2_current_grind_profit_rate,
        grind_2_total_amount,
        grind_2_profit_threshold,
        grind_2_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      self.system_v3_grind_2_use_derisk
      and (grind_2_sub_grind_count > 0)
      and ((-(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < grind_2_derisk_grinds)
    ):
      # if (
      #   self.system_v3_grind_2_use_derisk
      #   and (grind_2_sub_grind_count > 0)
      #   and (grind_2_current_grind_profit_stake < (slice_amount * grind_2_derisk_grinds))
      #   and (grind_2_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_2_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_current_grind_profit_stake,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_2_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_2_derisk"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 3

    if (
      (self.system_v3_grind_3_enable)
      # and is_derisk_1_found
      and is_short_extra_checks_entry
      and (grind_3_sub_grind_count < grind_3_max_sub_grinds)
      and (grind_3_sub_grind_count == 0 or (-grind_3_distance_ratio < grind_3_sub_thresholds[grind_3_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and is_short_grind_entry
    ):
      buy_amount = slice_amount * grind_3_stakes[grind_3_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_3_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_3_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_3_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_3_sub_grind_count > 0:
      ft_exit_amount, tag = self.short_grind_exit_v3(
        last_candle,
        previous_candle,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_3_exit",
        "grind_3_exit",
        fee_open_rate,
        fee_close_rate,
        # grind_3_cluster_max_profit_stake,
        # grind_3_cluster_max_profit_rate,
        grind_3_current_grind_profit_stake,
        grind_3_current_grind_profit_rate,
        grind_3_total_amount,
        grind_3_profit_threshold,
        grind_3_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      self.system_v3_grind_3_use_derisk
      and (grind_3_sub_grind_count > 0)
      and ((-(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < grind_3_derisk_grinds)
    ):
      # if (
      #   self.system_v3_grind_3_use_derisk
      #   and (grind_3_sub_grind_count > 0)
      #   and (grind_3_current_grind_profit_stake < (slice_amount * grind_3_derisk_grinds))
      #   and (grind_3_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_3_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_3_current_grind_profit_stake,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_3_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_3_derisk"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 4

    if (
      (self.system_v3_grind_4_enable)
      # and is_derisk_1_found
      # and is_short_grind_entry
      and is_short_extra_checks_entry
      and (grind_4_sub_grind_count < grind_4_max_sub_grinds)
      and (grind_4_sub_grind_count == 0 or (-grind_4_distance_ratio < grind_4_sub_thresholds[grind_4_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and (
        is_short_grind_entry
        or (
          (slice_profit_entry > 0.04)
          and (last_candle["RSI_3"] < 95.0)
          and (last_candle["RSI_3_15m"] < 90.0)
          and (last_candle["RSI_14"] > 65.0)
          and (last_candle["close"] > (last_candle["EMA_20"] * 1.015))
        )
        or (
          (slice_profit_entry > 0.06)
          and (num_open_grinds_and_buybacks == 0)
          and (last_candle["RSI_14"] > 70.0)
          and (last_candle["close"] > (last_candle["EMA_20"] * 1.020))
        )
      )
    ):
      buy_amount = slice_amount * grind_4_stakes[grind_4_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_4_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_4_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_4_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_4_sub_grind_count > 0:
      ft_exit_amount, tag = self.short_grind_exit_v3(
        last_candle,
        previous_candle,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_4_exit",
        "grind_4_exit",
        fee_open_rate,
        fee_close_rate,
        # grind_4_cluster_max_profit_stake,
        # grind_4_cluster_max_profit_rate,
        grind_4_current_grind_profit_stake,
        grind_4_current_grind_profit_rate,
        grind_4_total_amount,
        grind_4_profit_threshold,
        grind_4_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      self.system_v3_grind_4_use_derisk
      and (grind_4_sub_grind_count > 0)
      and ((-(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < grind_4_derisk_grinds)
    ):
      # if (
      #   self.system_v3_grind_4_use_derisk
      #   and (grind_4_sub_grind_count > 0)
      #   and (grind_4_current_grind_profit_stake < (slice_amount * grind_4_derisk_grinds))
      #   and (grind_4_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_4_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_4_current_grind_profit_stake,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_4_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_4_derisk"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 5

    if (
      (self.system_v3_grind_5_enable)
      # and is_derisk_1_found
      # and is_short_grind_entry
      and is_short_extra_checks_entry
      and (grind_5_sub_grind_count < grind_5_max_sub_grinds)
      and (grind_5_sub_grind_count == 0 or (-grind_5_distance_ratio < grind_5_sub_thresholds[grind_5_sub_grind_count]))
      and is_not_trade_max_stake_v3
      and (
        is_short_grind_entry
        or (
          (is_derisk_1_found or is_derisk_2_found or is_derisk_3_found)
          and (slice_profit_entry > 0.06)
          and (last_candle["RSI_3"] < 90.0)
          and (last_candle["RSI_3_15m"] < 80.0)
          and (last_candle["AROOND_14"] < 50.0)
        )
        or (
          (self.is_futures_mode)
          and (slice_profit_entry > 0.15)
          and (trade.liquidation_price is not None)
          and (
            (trade.is_short and current_rate > trade.liquidation_price * 0.80)
            or (not trade.is_short and current_rate < trade.liquidation_price * 1.20)
          )
        )
      )
    ):
      buy_amount = slice_amount * grind_5_stakes[grind_5_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="grind_5_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Grinding entry (grind_5_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Tag: {self._grind_entry_tag}"
      )
      order_tag = "grind_5_entry"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    if grind_5_sub_grind_count > 0:
      ft_exit_amount, tag = self.short_grind_exit_v3(
        last_candle,
        previous_candle,
        slice_profit,
        current_time,
        min_stake,
        current_stake_amount,
        exit_rate,
        profit_stake,
        profit_ratio,
        "grind_5_exit",
        "grind_5_exit",
        fee_open_rate,
        fee_close_rate,
        # grind_5_cluster_max_profit_stake,
        # grind_5_cluster_max_profit_rate,
        grind_5_current_grind_profit_stake,
        grind_5_current_grind_profit_rate,
        grind_5_total_amount,
        grind_5_profit_threshold,
        grind_5_orders,
        trade,
      )
      if ft_exit_amount is not None and tag is not None:
        return ft_exit_amount, tag

    if (
      self.system_v3_grind_5_use_derisk
      and (grind_5_sub_grind_count > 0)
      and ((-(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < grind_5_derisk_grinds)
    ):
      # if (
      #   self.system_v3_grind_5_use_derisk
      #   and (grind_5_sub_grind_count > 0)
      #   and (grind_5_current_grind_profit_stake < (slice_amount * grind_5_derisk_grinds))
      #   and (grind_5_orders[-1].order_date_utc.replace(tzinfo=None) >= datetime(2025, 8, 3) or is_backtest)
      # ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            -((exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_exit_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-derisk",
            tag="grind_5_derisk",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_5_current_grind_profit_stake,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding de-risk (grind_5_derisk) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_profit_stake:{stake_fmt}} {stake_currency})"
        )
        order_tag = "grind_5_derisk"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Rebuy

    if (
      is_system_v3_1
      and (
        (0 <= rebuy_sub_grind_count < rebuy_max_sub_grinds)
        and (slice_profit_entry < rebuy_sub_thresholds[rebuy_sub_grind_count])
      )
      and is_not_trade_max_stake_v3_1
      and is_short_rebuy_entry
    ):
      buy_amount = slice_amount * rebuy_stakes[rebuy_sub_grind_count] / trade_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      send_msg(
        notification_msg(
          "rebuy",
          tag="rebuy_entry",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
        )
      )
      log.info(
        f"Rebuy (rebuy_entry) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
      )
      if has_order_tags:
        return buy_amount, "rebuy_entry"
      else:
        return buy_amount

    return None

  def short_grind_entry_v3(
    self,
    last_candle: Series,
    previous_candle: Series,
    slice_profit: float,
    slice_profit_entry: float,
    is_derisk: bool,
  ) -> float:
    if last_candle["protections_short_global"] != True:
      return False
    # g0 — signal entry
    if last_candle["enter_short"] == True:
      self._grind_entry_tag = "g0"
      return True
    last_close = last_candle["close"]
    last_open = last_candle["open"]
    last_close_max_12 = last_candle["close_max_12"]
    last_close_min_48 = last_candle["close_min_48"]
    last_low_min_24_1h = last_candle["low_min_24_1h"]
    last_high_max_12_4h = last_candle["high_max_12_4h"]
    last_high_max_24_4h = last_candle["high_max_24_4h"]
    last_rsi_3 = last_candle["RSI_3"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_rsi_3_1d = last_candle["RSI_3_1d"]
    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    last_rsi_20 = last_candle["RSI_20"]
    last_sma_9 = last_candle["SMA_9"]
    last_sma_16 = last_candle["SMA_16"]
    last_sma_21 = last_candle["SMA_21"]
    last_sma_30 = last_candle["SMA_30"]
    last_ema_9 = last_candle["EMA_9"]
    last_ema_12 = last_candle["EMA_12"]
    last_ema_16 = last_candle["EMA_16"]
    last_ema_20 = last_candle["EMA_20"]
    last_ema_26 = last_candle["EMA_26"]
    last_ema_100 = last_candle["EMA_100"]
    last_ema_12_4h = last_candle["EMA_12_4h"]
    last_ema_50_4h = last_candle["EMA_50_4h"]
    last_ema_100_4h = last_candle["EMA_100_4h"]
    last_ema_200_4h = last_candle["EMA_200_4h"]
    last_roc_9_1h = last_candle["ROC_9_1h"]
    last_roc_9_4h = last_candle["ROC_9_4h"]
    last_roc_9_1d = last_candle["ROC_9_1d"]
    last_stochrsi_k = last_candle["STOCHRSIk_14_14_3_3"]
    last_stochrsi_k_1h = last_candle["STOCHRSIk_14_14_3_3_1h"]
    last_stochrsi_k_4h = last_candle["STOCHRSIk_14_14_3_3_4h"]
    last_stochrsi_k_1d = last_candle["STOCHRSIk_14_14_3_3_1d"]
    last_willr_14 = last_candle["WILLR_14"]
    last_willr_84_1h = last_candle["WILLR_84_1h"]
    last_bbu = last_candle["BBU_20_2.0"]
    last_bbb_1h = last_candle["BBB_20_2.0_1h"]
    last_cmf_20 = last_candle["CMF_20"]
    last_aroonu_14 = last_candle["AROONU_14"]
    last_aroonu_14_15m = last_candle["AROONU_14_15m"]
    last_aroonu_14_1d = last_candle["AROONU_14_1d"]
    last_aroonu_14_1h = last_candle["AROONU_14_1h"]
    last_aroonu_14_4h = last_candle["AROONU_14_4h"]
    last_stochrsi_k_15m = last_candle["STOCHRSIk_14_14_3_3_15m"]
    prev_rsi_20 = previous_candle["RSI_20"]
    prev_sma_9 = previous_candle["SMA_9"]
    prev_sma_21 = previous_candle["SMA_21"]
    prev_ema_12 = previous_candle["EMA_12"]
    prev_ema_26 = previous_candle["EMA_26"]
    # g1 — AROONU rally + EMA_16 rise (mirror long g1)
    if (
      (last_rsi_3 < 90.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_3_1h < 85.0)
      and (last_rsi_3_4h < 85.0)
      and (last_rsi_14 > 55.0)
      and (last_aroonu_14 > 75.0)
      and (last_aroonu_14_4h > 0.0)
      and (last_roc_9_1h > -20.0)
      and (last_close < (last_close_min_48 * 1.10))
      and (last_close > (last_high_max_24_4h * 0.40))
      and (last_close > (last_ema_16 * 1.025))
      and ((last_rsi_3_1h < 65.0) or (last_aroonu_14_1h > 0.0))
      and ((last_aroonu_14_1h > 0.0) or (last_aroonu_14_1d > 0.0))
      and ((last_aroonu_14_1d > 0.0) or (last_stochrsi_k_1h > 10.0))
    ):
      self._grind_entry_tag = "g1"
      return True
    # g2 — EMA_12 > EMA_26 divergence + BBU (mirror long g2)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 85.0)
      and (last_rsi_3_4h < 85.0)
      and (last_rsi_14 > 70.0)
      and (last_stochrsi_k > 70.0)
      and (last_ema_12 > last_ema_26)
      and ((last_ema_12 - last_ema_26) > (last_open * 0.020))
      and ((prev_ema_12 - prev_ema_26) > (last_open / 100.0))
      and (last_close > (last_bbu * 0.990))
    ):
      self._grind_entry_tag = "g2"
      return True
    # g3 — AROONU_15m rally + EMA_12 rise (mirror long g3)
    if (
      (last_rsi_3 < 90.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 90.0)
      and (last_rsi_3_4h < 85.0)
      and (last_rsi_14 > 65.0)
      and (last_aroonu_14_15m > 75.0)
      and (last_stochrsi_k_15m > 30.0)
      and (last_stochrsi_k_1h > 10.0)
      and (last_roc_9_1h < 15.0)
      and (last_roc_9_4h < 15.0)
      and (last_close < (last_close_min_48 * 1.15))
      and (last_close > (last_ema_12 * 1.020))
      and ((last_rsi_3_1h < 80.0) or (last_rsi_3_1d < 80.0))
      and ((last_rsi_3_1h < 80.0) or (last_stochrsi_k_1d > 30.0))
      and ((last_rsi_3_1h < 75.0) or (last_stochrsi_k_1h > 30.0))
      and ((last_rsi_3_4h < 70.0) or (last_stochrsi_k_4h > 40.0))
    ):
      self._grind_entry_tag = "g3"
      return True
    # g4 — multi-TF RSI + EMA_26 + BBU (mirror long g4)
    if (
      (last_rsi_3 < 90.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 90.0)
      and (last_rsi_3_4h < 90.0)
      and (last_rsi_3_1d < 90.0)
      and (last_rsi_14 > 65.0)
      and (last_aroonu_14 > 75.0)
      and (last_roc_9_1h < 20.0)
      and (last_roc_9_4h < 20.0)
      # and (last_close < (last_close_min_48 * 1.10))
      and (last_close > (last_ema_26 * 1.030))
      and (last_close > (last_bbu * 1.001))
    ):
      self._grind_entry_tag = "g4"
      return True
    # g5 — rally top + EMA_9/20 (mirror long g5)
    if (
      (last_rsi_3 < 90.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 85.0)
      and (last_rsi_3_4h < 85.0)
      and (last_rsi_14 > 65.0)
      and (last_aroonu_14 > 70.0)
      and (last_roc_9_4h < 20.0)
      and (last_close < (last_low_min_24_1h * 1.20))
      and (last_close > (last_high_max_12_4h * 0.50))
      and (last_close > (last_ema_9 * 1.025))
      and (last_close > (last_ema_20 * 1.030))
    ):
      self._grind_entry_tag = "g5"
      return True
    # g6 — RSI_20 rising + SMA_16 rise (mirror long g6)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3 > 60.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_14 < 65.0)
      and (last_roc_9_1h < 20.0)
      and (last_roc_9_4h < 20.0)
      and (last_aroonu_14 > 75.0)
      and (last_close > (last_high_max_12_4h * 0.40))
      and (last_rsi_20 > prev_rsi_20)
      and (last_close > (last_sma_16 * 1.040))
      and ((last_aroonu_14_1d > 0.0) or (last_roc_9_1d > -50.0))
    ):
      self._grind_entry_tag = "g6"
      return True
    # g7 — WILLR overbought + BBB wide (mirror long g7)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 80.0)
      and (last_rsi_3_1h < 80.0)
      and (last_rsi_3_4h < 80.0)
      and (last_willr_14 > -50.0)
      and (last_willr_84_1h > -30.0)
      and (last_stochrsi_k > 70.0)
      and (last_stochrsi_k_1h > 10.0)
      and (last_roc_9_1h < 10.0)
      and (last_roc_9_1h > -20.0)
      and (last_roc_9_4h < 10.0)
      and (last_close > (last_high_max_24_4h * 0.50))
      and (last_bbb_1h > 12.0)
      and (last_close_min_48 <= (last_close * 0.90))
    ):
      self._grind_entry_tag = "g7"
      return True
    # g8 — EMA_12/26 gap wide + high_max_24_1h (mirror long g8)
    if (
      (last_rsi_3 > 70.0)
      and (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 90.0)
      and (last_rsi_3_4h < 90.0)
      and (last_roc_9_1h < 10.0)
      and (last_roc_9_4h < 25.0)
      # and (last_close > (last_candle["high_max_24_1h"] * 0.70))
      and (last_ema_12 > last_ema_26)
      and ((last_ema_12 - last_ema_26) > (last_open * 0.030))
      and ((prev_ema_12 - prev_ema_26) > (last_open / 100.0))
    ):
      self._grind_entry_tag = "g8"
      return True
    # g9 — pullback fade (mirror long g9)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_3_1h < 80.0)
      and (last_rsi_3_4h < 80.0)
      and (last_stochrsi_k > 50.0)
      and (last_close > (last_close_min_48 * 1.10))
      and (last_close < (last_close_max_12 * 0.97))
    ):
      self._grind_entry_tag = "g9"
      return True
    # g10 — RSI_14 divergence vs 1h (mirror long g10)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 80.0)
      and (last_stochrsi_k > 80.0)
      and (last_rsi_14 > (last_rsi_14_1h + 45.0))
    ):
      self._grind_entry_tag = "g10"
      return True
    # g11 — multi-TF RSI + SMA_30 + BBU (mirror long g11)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 90.0)
      and (last_cmf_20 < 0.0)
      and (last_close > (last_sma_30 * 1.035))
      and (last_close > (last_bbu * 1.000))
    ):
      self._grind_entry_tag = "g11"
      return True
    # g12 — EMA_12/26 divergence + close_min_48 (mirror long g12)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_3_1h < 90.0)
      and (last_stochrsi_k > 70.0)
      and (last_close < (last_close_min_48 * 1.10))
      and (last_close > (last_high_max_12_4h * 0.40))
      and (last_ema_12 > last_ema_26)
      and ((last_ema_12 - last_ema_26) > (last_open * 0.025))
      and ((prev_ema_12 - prev_ema_26) > (last_open / 100.0))
    ):
      self._grind_entry_tag = "g12"
      return True
    # g13 — SMA_9 cross SMA_21 down + EMA_100 rise (mirror long g13)
    if (
      (last_rsi_3 < 95.0)
      and (last_rsi_3_1h < 80.0)
      and (last_rsi_14_1h < 60.0)
      and (last_stochrsi_k_15m > 20.0)
      and (last_roc_9_1h < 15.0)
      and (last_roc_9_4h < 15.0)
      and (prev_sma_9 > prev_sma_21)
      and (last_sma_9 < last_sma_21)
      and (last_close > (last_ema_100 * 1.025))
      and ((last_rsi_3_4h < 70.0) or (last_aroonu_14_4h > 0.0))
      and ((last_rsi_3_4h < 60.0) or (last_roc_9_4h > -30.0))
    ):
      self._grind_entry_tag = "g13"
      return True
    # g14 — SMA_9 cross down + 4h downtrend (trend follower) (mirror long g14)
    if (
      (last_rsi_3 < 95.0)
      and (last_aroonu_14_15m > 50.0)
      and (last_stochrsi_k > 60.0)
      and (last_stochrsi_k_15m > 30.0)
      and (prev_sma_9 > prev_sma_21)
      and (last_sma_9 < last_sma_21)
      and (last_ema_12_4h < last_ema_200_4h)
      and (last_close < (last_close_min_48 * 1.10))
      and ((last_rsi_3_1h < 70.0) or (last_stochrsi_k_1h > 30.0))
      and ((last_rsi_3_1h < 60.0) or (last_aroonu_14_1h > 20.0))
      and ((last_rsi_3_1d < 75.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_stochrsi_k_1h > 20.0) or (last_stochrsi_k_1d > 10.0))
    ):
      self._grind_entry_tag = "g14"
      return True
    # g15 — deep loss recovery (slice_profit > 0.16, positive = adverse move for a short) (mirror long g15)
    if (
      (slice_profit > 0.16)
      and (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 90.0)
      and (last_rsi_14 > 60.0)
      and (last_aroonu_14 > 75.0)
      and (last_aroonu_14_15m > 70.0)
      and (last_stochrsi_k > 70.0)
      and (last_stochrsi_k_15m > 70.0)
      and ((last_rsi_3_1h < 70.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_rsi_3_4h < 70.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1d < 70.0) or (last_stochrsi_k_1d > 20.0))
    ):
      self._grind_entry_tag = "g15"
      return True
    # g16 — EMA_12 rise + BBU (mirror long g16)
    if (
      (last_rsi_3 < 92.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_3_1h < 85.0)
      and (last_rsi_3_4h < 85.0)
      and (last_rsi_14 > 65.0)
      and (last_close > (last_ema_12 * 1.035))
      and (last_close > (last_bbu * 1.001))
    ):
      self._grind_entry_tag = "g16"
      return True
    # g17 — StochRSI + EMA_20 rise (mirror long g17)
    if (
      (last_rsi_3 < 85.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_3_1h < 85.0)
      and (last_rsi_3_4h < 85.0)
      and (last_rsi_14 > 70.0)
      and (last_stochrsi_k > 70.0)
      and (last_close > (last_ema_20 * 1.025))
      and ((last_aroonu_14_4h > 0.0) or (last_aroonu_14_1d > 0.0))
    ):
      self._grind_entry_tag = "g17"
      return True
    # g18 — moderate loss recovery (slice_profit > 0.10, positive = adverse move for a short) (mirror long g18)
    if (
      (slice_profit > 0.10)
      and (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_3_1h < 80.0)
      and (last_rsi_3_4h < 80.0)
      and (last_rsi_14 > 60.0)
      and (last_close > (last_ema_26 * 1.030))
      and (last_close > (last_bbu * 1.001))
    ):
      self._grind_entry_tag = "g18"
      return True
    # g19 — EMA_12/26 wide gap (slice_profit > 0.06, positive = adverse move for a short) (mirror long g19)
    if (
      (slice_profit > 0.06)
      and (last_rsi_3 > 70.0)
      and (last_rsi_3 < 95.0)
      and (last_rsi_3_15m < 90.0)
      and (last_ema_12 > last_ema_26)
      and ((last_ema_12 - last_ema_26) > (last_open * 0.035))
      and ((prev_ema_12 - prev_ema_26) > (last_open / 100.0))
    ):
      self._grind_entry_tag = "g19"
      return True
    # g20 — AROONU 4h downtrend bounce fade (mirror long g20)
    if (
      (last_rsi_3 < 90.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_3_1h < 80.0)
      and (last_rsi_14 > 58.0)
      and (last_rsi_14_4h < 50.0)
      and (last_aroonu_14 > 70.0)
      and (last_aroonu_14_4h < 50.0)
      and (last_roc_9_1d < 15.0)
      and (last_ema_50_4h < last_ema_100_4h)
      and (last_close > (last_close_min_48 * 1.05))
      and ((last_rsi_3_15m < 80.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1h < 70.0) or (last_roc_9_4h > -30.0) or (last_roc_9_1d > -30.0))
      and ((last_rsi_3_1h < 50.0) or (last_roc_9_1d > -60.0))
      and ((last_rsi_3_4h < 60.0) or (last_aroonu_14_4h > 10.0))
      and ((last_rsi_3_4h < 55.0) or (last_aroonu_14_4h > 0.0))
      and ((last_rsi_3_4h < 40.0) or (last_roc_9_4h > -40.0))
      and ((last_aroonu_14_4h > 0.0) or (last_stochrsi_k_1d > 20.0))
      and ((last_aroonu_14_4h > 0.0) or (last_aroonu_14_1d > 0.0))
      and ((last_stochrsi_k_4h > 10.0) or (last_roc_9_4h > -30.0))
    ):
      self._grind_entry_tag = "g20"
      return True
    # g21 — EMA_20 rise (slice_profit_entry > 0.02, positive = adverse move for a short) (mirror long g21)
    if (
      (slice_profit_entry > 0.02)
      and (last_rsi_3 < 90.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_14 > 65.0)
      and (last_aroonu_14_15m > 50.0)
      and (last_close > (last_ema_20 * 1.045))
    ):
      self._grind_entry_tag = "g21"
      return True
    # g22 — early breakdown rebuild: rejecting off the high BEFORE the 4h trend confirms (g14 needs
    #        EMA_12_4h < EMA_200_4h and fires too late for a deep-derisk rejection). Anti-fake-drop gating via
    #        multi-TF RSI weakness + rejection off the 4h high + not-extended. (mirror long g22)
    if (
      (last_rsi_3 < 70.0)
      and (last_rsi_3_15m < 70.0)
      and (last_rsi_14 < 55.0)
      and (last_rsi_14_1h < 55.0)
      and (last_roc_9_1h < 0.0)
      and (last_roc_9_4h < 10.0)
      # anti-capitulative: even at a formed top, a capitulative 4h overshoot reverses (dead-bounce).
      # cross-coin (SFP/CELR/DYDX/APE): cuts 17 severe at ~1% good cost within breakdown-starts.
      and (last_roc_9_4h > -25.0)
      # breakdown-started gate: only rebuild once the 4h top is IN (not still making new highs).
      # g22's job is the breakdown rebuild — NOT entering mid-pump (that's g1..g21). AROOND low =
      # a fresh 4h high was just made = still pumping; require it high = top formed = breakdown start.
      and (last_aroonu_14_4h > 50.0)
      # aggressive risk-free: g22 fires ONLY deep above the 4h 200-EMA (fresh breakdown zone). The
      # near/below-EMA overextended-pullback zone is where dead-cats live AND where g22's late-breakdown
      # adds sit — we sacrifice those wins on purpose, because g23 (extended-continuation, ~0.2% severe)
      # backstops the real breakdowns below. So g22 stays clean, g23 captures the continuation.
      and (last_close > last_ema_200_4h)
      and (last_close < (last_high_max_12_4h * 0.90))
      and (last_close < (last_ema_20 * 1.03))
      and (last_close > (last_ema_20 * 0.98))
      and ((last_rsi_3_1h < 70.0) or (last_stochrsi_k_1d > 20.0))
      and ((last_rsi_3_1h < 65.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_4h < 50.0) or (last_aroonu_14_1h > 0.0))
      and ((last_rsi_3_1d < 90.0) or (last_aroonu_14_1d > 30.0))
      and ((last_rsi_3_1d < 90.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1d < 85.0) or (last_aroonu_14_1h > 30.0))
      and ((last_rsi_3_1d < 60.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_rsi_3_1d < 60.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1d < 55.0) or (last_aroonu_14_1h > 0.0))
      and ((last_rsi_3_1d < 55.0) or (last_aroonu_14_4h > 0.0))
      and ((last_rsi_3_1d < 55.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_rsi_3_1d < 55.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1d < 50.0) or (last_aroonu_14_15m > 0.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1d < 35.0) or (last_aroonu_14_1h > 30.0) or (last_aroonu_14_1d > 10.0))
      and ((last_aroonu_14_15m > 30.0) or (last_aroonu_14_1h > 0.0))
      and ((last_aroonu_14_15m > 20.0) or (last_stochrsi_k_15m > 20.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1h > 20.0) or (last_stochrsi_k_1h > 20.0) or (last_stochrsi_k_1d > 10.0))
      and ((last_aroonu_14_1h > 0.0) or (last_stochrsi_k_1d > 20.0))
      and ((last_stochrsi_k_1h > 50.0) or (last_roc_9_1d < 40.0))
      and ((last_roc_9_1d < 20.0) or (last_aroonu_14_4h > 0.0))
      and ((last_roc_9_1d < 20.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_roc_9_1d < 30.0) or (last_stochrsi_k_1h > 10.0))
    ):
      self._grind_entry_tag = "g22"
      return True
    # g23 — breakdown-continuation scalp: extended zone BELOW g22's EMA_20*0.98 cap. Only rides a CONFIRMED
    # continuation (price already declining past the rejection), so dead-bounces (which roll over before
    # reaching the extended zone) are structurally avoided. Complements g22: g22 = early breakdown-start,
    # g23 = confirmed continuation. (mirror long g23)
    if (
      (last_rsi_3 < 70.0)
      and (last_rsi_3_15m < 70.0)
      and (last_rsi_14 < 50.0)
      and (last_rsi_14_1h < 50.0)
      and (last_roc_9_1h < 0.0)
      and (last_roc_9_4h < 0.0)
      # anti-capitulative blow-off + anti-exhaustion bottom
      and (last_roc_9_4h > -25.0)
      and ((last_stochrsi_k > 3.0) or (last_rsi_14 > 20.0))
      and (last_close < (last_high_max_12_4h * 0.90))
      # extended zone: below g22's 0.98*EMA cap = continuation confirmed, not a rejection
      and (last_close <= (last_ema_20 * 0.98))
      and (last_close > (last_ema_20 * 0.88))
      and ((last_rsi_3_1h < 55.0) or (last_aroonu_14_4h > 20.0))
      and ((last_rsi_3_1h < 35.0) or (last_aroonu_14_15m > 40.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 35.0) or (last_stochrsi_k_15m > 40.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_4h < 60.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_rsi_3_4h < 50.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_1d < 85.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_rsi_3_1d < 70.0) or (last_aroonu_14_1h > 0.0))
      and ((last_rsi_3_1d < 70.0) or (last_aroonu_14_4h > 0.0))
      and ((last_rsi_3_1d < 50.0) or (last_stochrsi_k_1h > 20.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1d < 45.0) or (last_aroonu_14_15m > 0.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_aroonu_14_15m > 20.0) or (last_aroonu_14_1h > 0.0) or (last_roc_9_1d > -10.0))
      and ((last_aroonu_14_15m > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_1h > 0.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_4h > 0.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_1d > 10.0) or (last_roc_9_1d > -20.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_1d > 0.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_15m > 10.0) or (last_stochrsi_k_1d > 30.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_aroonu_14_1h > 20.0) or (last_aroonu_14_4h > 0.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_aroonu_14_1h > 0.0) or (last_aroonu_14_4h > 0.0))
      and ((last_aroonu_14_4h > 30.0) or (last_aroonu_14_1d > 0.0) or (last_roc_9_4h > -10.0))
      and ((last_aroonu_14_4h > 30.0) or (last_roc_9_1d > -50.0))
      and ((last_aroonu_14_4h > 0.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_aroonu_14_4h > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1d > 0.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_stochrsi_k_15m > 20.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_stochrsi_k_15m > 10.0) or (last_aroonu_14_1h > 0.0))
      and ((last_stochrsi_k_15m > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_stochrsi_k_1h > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_stochrsi_k_1h > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_stochrsi_k_1h > 10.0) or (last_stochrsi_k_1d > 10.0))
    ):
      self._grind_entry_tag = "g23"
      return True

    # g24 — downtrend-bounce continuation add: the zone BELOW the 4h 200-EMA that g22 explicitly sacrifices.
    # (mirror long g24)
    if (
      # momentum healthy on the bounce: RSI holds up (a real reversal cracks RSI hard)
      (last_rsi_3 < 80.0)
      and (last_rsi_3_15m < 80.0)
      and (last_rsi_14 < 60.0)
      # trend intact + this is a BOUNCE not a reversal: 4h still falling, 1h not in melt-up
      and (last_roc_9_1h < 10.0)
      and (last_roc_9_4h < 0.0)
      and (last_roc_9_4h > -25.0)  # anti-parabolic blow-off top
      # bear scope-gate: confirmed 4h downtrend + price below the 200-EMA regime (complements g22's <200EMA)
      and (last_ema_12_4h < last_ema_200_4h)
      and (last_close < last_ema_200_4h)
      # shallow bounce to the short EMA — sell the dip WITHIN the trend, never the bottom nor a deep pump
      and (last_close > (last_ema_20 * 0.99))
      and (last_close < (last_ema_20 * 1.06))
      and ((last_rsi_3_15m < 60.0) or (last_stochrsi_k_15m > 30.0))
      and ((last_rsi_3_1h < 90.0) or (last_rsi_3_4h < 70.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1h < 85.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_1h < 75.0) or (last_aroonu_14_1h > 30.0))
      and ((last_rsi_3_1h < 75.0) or (last_rsi_3_1d < 55.0) or (last_aroonu_14_1d > 30.0))
      and ((last_rsi_3_1h < 75.0) or (last_aroonu_14_1h > 20.0))
      and ((last_rsi_3_1h < 70.0) or (last_rsi_3_4h < 40.0) or (last_aroonu_14_1d > 30.0))
      and ((last_rsi_3_1h < 70.0) or (last_rsi_3_4h < 40.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1h < 70.0) or (last_stochrsi_k_1d > 20.0) or (last_roc_9_1d > -10.0))
      and ((last_rsi_3_1h < 65.0) or (last_rsi_3_4h < 55.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1h < 65.0) or (last_aroonu_14_1h > 40.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_1h < 65.0) or (last_stochrsi_k_1d > 10.0) or (last_roc_9_1d > -20.0))
      and ((last_rsi_3_1h < 60.0) or (last_rsi_3_4h < 60.0) or (last_aroonu_14_1d > 10.0))
      and ((last_rsi_3_1h < 60.0) or (last_rsi_3_4h < 35.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 60.0) or (last_rsi_3_1d < 40.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_1h < 60.0) or (last_aroonu_14_1h > 0.0))
      and ((last_rsi_3_1h < 60.0) or (last_aroonu_14_4h > 0.0))
      and ((last_rsi_3_1h < 60.0) or (last_aroonu_14_1d > 0.0) or (last_roc_9_1d > -20.0))
      and ((last_rsi_3_1h < 60.0) or (last_stochrsi_k_1d > 20.0) or (last_roc_9_1d > -50.0))
      and ((last_rsi_3_1h < 65.0) or (last_rsi_3_4h < 50.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 60.0) or (last_rsi_3_4h < 45.0) or (last_aroonu_14_4h > 10.0))
      and ((last_rsi_3_1h < 55.0) or (last_aroonu_14_4h > 20.0) or (last_roc_9_1d > -10.0))
      and ((last_rsi_3_1h < 50.0) or (last_aroonu_14_1h > 20.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1h < 50.0) or (last_rsi_3_4h < 45.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1h < 50.0) or (last_aroonu_14_1h > 30.0) or (last_aroonu_14_1d > 30.0))
      and ((last_rsi_3_1h < 50.0) or (last_aroonu_14_4h > 20.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_1h < 50.0) or (last_aroonu_14_4h > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1h < 45.0) or (last_rsi_3_4h < 45.0) or (last_stochrsi_k_15m > 30.0))
      and ((last_rsi_3_1h < 45.0) or (last_aroonu_14_1h > 20.0) or (last_aroonu_14_4h > 20.0))
      and ((last_rsi_3_1h < 45.0) or (last_stochrsi_k_4h > 10.0) or (last_roc_9_1d > -10.0))
      and ((last_rsi_3_1h < 40.0) or (last_aroonu_14_15m > 30.0) or (last_aroonu_14_4h > 20.0))
      and ((last_rsi_3_1h < 40.0) or (last_stochrsi_k_1h > 40.0) or (last_stochrsi_k_1d > 10.0))
      and ((last_rsi_3_1h < 35.0) or (last_aroonu_14_15m > 30.0) or (last_aroonu_14_1h > 0.0))
      and ((last_rsi_3_1h < 35.0) or (last_aroonu_14_1h > 30.0) or (last_aroonu_14_1d > 10.0))
      and ((last_rsi_3_1h < 35.0) or (last_aroonu_14_1h > 0.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_4h < 75.0) or (last_roc_9_1d > -30.0))
      and ((last_rsi_3_4h < 60.0) or (last_rsi_3_1d < 40.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_4h < 60.0) or (last_aroonu_14_15m > 30.0) or (last_aroonu_14_1d > 10.0))
      and ((last_rsi_3_4h < 60.0) or (last_aroonu_14_1d > 10.0) or (last_roc_9_1d > -10.0))
      and ((last_rsi_3_4h < 60.0) or (last_stochrsi_k_15m > 40.0) or (last_aroonu_14_1d > 10.0))
      and ((last_rsi_3_4h < 55.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_4h < 50.0) or (last_aroonu_14_4h > 30.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_4h < 50.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_4h < 45.0) or (last_aroonu_14_15m > 30.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_4h < 40.0) or (last_rsi_3_1d < 35.0) or (last_aroonu_14_15m > 30.0))
      and ((last_rsi_3_4h < 40.0) or (last_aroonu_14_15m > 10.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_rsi_3_4h < 40.0) or (last_aroonu_14_15m > 0.0) or (last_stochrsi_k_15m > 20.0))
      and ((last_rsi_3_4h < 40.0) or (last_stochrsi_k_15m > 30.0) or (last_stochrsi_k_1h > 30.0))
      and ((last_rsi_3_1d < 70.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1d < 65.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_rsi_3_1d < 65.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_rsi_3_1d < 65.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1d < 55.0) or (last_stochrsi_k_1h > 30.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1d < 50.0) or (last_stochrsi_k_15m > 10.0) or (last_roc_9_1d > -10.0))
      and ((last_rsi_3_1d < 40.0) or (last_aroonu_14_1h > 20.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_14_1h > 30.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_15m > 20.0) or (last_aroonu_14_1h > 20.0) or (last_aroonu_14_4h > 20.0))
      and ((last_aroonu_14_15m > 20.0) or (last_stochrsi_k_15m > 30.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_aroonu_14_15m > 20.0) or (last_aroonu_14_1d > 0.0))
      and ((last_aroonu_14_15m > 20.0) or (last_stochrsi_k_15m > 20.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_aroonu_14_15m > 10.0) or (last_aroonu_14_1h > 20.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_aroonu_14_15m > 10.0) or (last_aroonu_14_1h > 0.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_1h > 0.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_4h > 0.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_1d > 20.0) or (last_roc_9_1d > -10.0))
      and ((last_aroonu_14_1h > 30.0) or (last_aroonu_14_4h > 0.0))
      and ((last_aroonu_14_1h > 30.0) or (last_aroonu_14_1d > 10.0) or (last_roc_9_1d > -10.0))
      and ((last_aroonu_14_1h > 20.0) or (last_aroonu_14_4h > 0.0))
      and ((last_aroonu_14_1h > 10.0) or (last_stochrsi_k_1h > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1h > 10.0) or (last_stochrsi_k_1h > 10.0) or (last_roc_9_1d > -10.0))
      and ((last_aroonu_14_1h > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1h > 0.0) or (last_stochrsi_k_1d > 10.0))
      and ((last_aroonu_14_4h > 30.0) or (last_aroonu_14_1d > 0.0) or (last_roc_9_1d > -20.0))
      and ((last_aroonu_14_4h > 10.0) or (last_stochrsi_k_4h > 10.0) or (last_roc_9_1d > -10.0))
      and ((last_aroonu_14_4h > 10.0) or (last_roc_9_1d > -30.0))
      and ((last_aroonu_14_4h > 0.0) or (last_aroonu_14_1d > 0.0))
      and ((last_aroonu_14_4h > 0.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_aroonu_14_4h > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1d > 0.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_aroonu_14_1d > 0.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_aroonu_14_1d > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1d > 0.0) or (last_roc_9_4h > -15.0) or (last_roc_9_1d > -50.0))
      # do not sell an oversold bottom on the pullback
      and ((last_stochrsi_k > 10.0) or (last_rsi_14 > 30.0))
      and ((last_stochrsi_k_15m > 20.0) or (last_stochrsi_k_1h > 20.0) or (last_roc_9_1d > -10.0))
      and ((last_stochrsi_k_15m > 20.0) or (last_aroonu_14_1d > 0.0))
      and ((last_stochrsi_k_15m > 20.0) or (last_stochrsi_k_1d > 10.0) or (last_roc_9_1d > -20.0))
      and ((last_stochrsi_k_15m > 10.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_stochrsi_k_15m > 10.0) or (last_stochrsi_k_1d > 10.0))
      and ((last_stochrsi_k_1h > 20.0) or (last_stochrsi_k_1d > 10.0))
      and ((last_stochrsi_k_1h > 20.0) or (last_roc_9_1d < 20.0))
      and ((last_stochrsi_k_1h > 10.0) or (last_roc_9_4h > -15.0))
      and ((last_stochrsi_k_4h > 10.0) or (last_roc_9_4h > -15.0))
      and ((last_stochrsi_k_4h > 10.0) or (last_roc_9_1d < 15.0))
      and ((last_stochrsi_k_1d > 10.0) or (last_roc_9_4h > -20.0))
    ):
      self._grind_entry_tag = "g24"
      return True

    # g27 — coil (mirror of long g27)
    if (
      (last_rsi_3 < 85.0)
      and (last_rsi_3_15m < 85.0)
      and (last_rsi_14 < 60.0)
      and (last_rsi_14_1h < 60.0)
      # the coil signature: 1h momentum negative-to-flat under a flat price
      and (last_roc_9_1h < 15.0)
      and (last_roc_9_1h > -2.0)
      and (last_close < (last_ema_20 * 1.02))
      and (last_close > (last_ema_20 * 0.98))
      # squeeze integrity: regime still broken, 4h rejection HELD, not dripping to new highs
      and (last_close > last_ema_200_4h)
      and (last_close < (last_high_max_12_4h * 0.90))
      and (last_close < (last_close_max_12 * 0.995))
      # general protections first
      and ((last_rsi_3_15m < 80.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1h < 85.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_1h < 80.0) or (last_rsi_3_4h < 80.0) or (last_aroonu_14_1d > 10.0))
      and ((last_rsi_3_1h < 80.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_rsi_3_1h < 70.0) or (last_rsi_3_1d < 70.0) or (last_stochrsi_k_1h > 30.0))
      and ((last_rsi_3_1h < 65.0) or (last_aroonu_14_1h > 30.0))
      and ((last_rsi_3_1h < 65.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_1h < 60.0) or (last_aroonu_14_4h > 20.0))
      and ((last_rsi_3_1h < 55.0) or (last_aroonu_14_1h > 10.0) or (last_stochrsi_k_1h > 30.0))
      and ((last_rsi_3_1h < 60.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 55.0) or (last_aroonu_14_1h > 10.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 55.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_1h < 50.0) or (last_aroonu_14_1h > 30.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_1h < 45.0) or (last_rsi_3_4h < 40.0) or (last_aroonu_14_4h > 40.0))
      and ((last_rsi_3_1h < 50.0) or (last_aroonu_14_4h > 20.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 50.0) or (last_stochrsi_k_1d > 10.0) or (last_roc_9_1d > -30.0))
      and ((last_rsi_3_1h < 45.0) or (last_aroonu_14_4h > 20.0) or (last_aroonu_14_1d > 0.0))
      and ((last_rsi_3_1h < 45.0) or (last_aroonu_14_4h > 10.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_rsi_3_1h < 40.0) or (last_rsi_3_1d < 40.0) or (last_aroonu_14_1h > 20.0))
      and ((last_rsi_3_1h < 40.0) or (last_stochrsi_k_4h > 30.0) or (last_stochrsi_k_1d > 20.0))
      and ((last_rsi_3_1h < 40.0) or (last_stochrsi_k_4h > 20.0) or (last_roc_9_4h > -10.0))
      and ((last_rsi_3_4h < 90.0) or (last_rsi_3_1d < 60.0) or (last_stochrsi_k_15m > 20.0))
      and ((last_rsi_3_4h < 75.0) or (last_stochrsi_k_4h > 50.0) or (last_roc_9_4h > -10.0))
      and ((last_rsi_3_4h < 65.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_4h < 60.0) or (last_rsi_3_1d < 60.0) or (last_aroonu_14_15m > 30.0))
      and ((last_rsi_3_4h < 60.0) or (last_aroonu_14_15m > 0.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_rsi_3_4h < 60.0) or (last_aroonu_14_4h > 30.0))
      and ((last_rsi_3_4h < 50.0) or (last_aroonu_14_15m > 20.0) or (last_aroonu_14_4h > 20.0))
      and ((last_rsi_3_4h < 50.0) or (last_stochrsi_k_15m > 30.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_4h < 45.0) or (last_aroonu_14_1h > 0.0) or (last_aroonu_14_1d > 20.0))
      and ((last_rsi_3_4h < 40.0) or (last_rsi_3_1d < 40.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_rsi_3_4h < 40.0) or (last_aroonu_14_15m > 30.0) or (last_aroonu_14_1h > 30.0))
      and ((last_rsi_3_4h < 40.0) or (last_aroonu_14_1h > 0.0) or (last_stochrsi_k_1d > 20.0))
      and ((last_rsi_3_4h < 40.0) or (last_aroonu_14_4h > 30.0) or (last_roc_9_1d > -20.0))
      and ((last_rsi_3_4h < 35.0) or (last_aroonu_14_1h > 30.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_rsi_3_4h < 35.0) or (last_aroonu_14_4h > 20.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_4h < 35.0) or (last_stochrsi_k_4h > 10.0) or (last_roc_9_4h > -10.0))
      and ((last_rsi_3_1d < 90.0) or (last_stochrsi_k_4h > 30.0))
      and ((last_rsi_3_1d < 80.0) or (last_aroonu_14_1d > 10.0))
      and ((last_rsi_3_1d < 75.0) or (last_stochrsi_k_15m > 30.0))
      and ((last_rsi_3_1d < 75.0) or (last_aroonu_14_1h > 30.0))
      and ((last_rsi_3_1d < 75.0) or (last_stochrsi_k_1h > 10.0))
      and ((last_rsi_3_1d < 70.0) or (last_aroonu_14_15m > 0.0))
      and ((last_rsi_3_1d < 70.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_15m > 30.0) or (last_aroonu_14_1h > 0.0) or (last_stochrsi_k_1d > 20.0))
      and ((last_aroonu_14_15m > 30.0) or (last_aroonu_14_4h > 30.0) or (last_roc_9_4h > -10.0))
      and ((last_aroonu_14_15m > 20.0) or (last_stochrsi_k_15m > 30.0))
      and ((last_aroonu_14_15m > 20.0) or (last_aroonu_14_1h > 0.0))
      and ((last_aroonu_14_15m > 0.0) or (last_aroonu_14_4h > 10.0))
      and ((last_aroonu_14_15m > 0.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_1h > 20.0) or (last_aroonu_14_4h > 0.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_aroonu_14_1h > 20.0) or (last_stochrsi_k_4h > 0.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_aroonu_14_1h > 20.0) or (last_stochrsi_k_4h > 10.0) or (last_roc_9_4h > -10.0))
      and ((last_aroonu_14_1h > 0.0) or (last_aroonu_14_1d > 0.0))
      and ((last_aroonu_14_1h > 0.0) or (last_stochrsi_k_15m > 20.0))
      and ((last_aroonu_14_1h > 0.0) or (last_stochrsi_k_4h > 20.0) or (last_roc_9_4h > -10.0))
      and ((last_aroonu_14_1h > 0.0) or (last_stochrsi_k_1d > 10.0) or (last_roc_9_1d > -20.0))
      and ((last_aroonu_14_4h > 30.0) or (last_roc_9_1d < 25.0))
      and ((last_aroonu_14_4h > 30.0) or (last_roc_9_1d > -50.0))
      and ((last_aroonu_14_4h > 20.0) or (last_stochrsi_k_4h > 20.0) or (last_roc_9_4h > -10.0))
      and ((last_aroonu_14_4h > 20.0) or (last_stochrsi_k_1d > 20.0) or (last_roc_9_1d > -10.0))
      and ((last_aroonu_14_4h > 10.0) or (last_stochrsi_k_4h > 10.0))
      and ((last_aroonu_14_4h > 10.0) or (last_roc_9_4h > -10.0))
      and ((last_stochrsi_k_15m > 40.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_stochrsi_k_1h > 30.0) or (last_stochrsi_k_4h > 20.0))
      and ((last_stochrsi_k_1h > 10.0) or (last_roc_9_4h < 20.0))
      and ((last_stochrsi_k_4h > 30.0) or (last_roc_9_1d < 25.0))
      and ((last_stochrsi_k_4h > 20.0) or (last_stochrsi_k_1d > 10.0) or (last_roc_9_1d > -20.0))
      and ((last_roc_9_1d < 40.0) or (last_aroonu_14_1h > 10.0))
      and ((last_roc_9_1d < 40.0) or (last_stochrsi_k_1h > 20.0))
      and ((last_roc_9_1d < 25.0) or (last_stochrsi_k_15m > 10.0))
      and ((last_roc_9_1d < 25.0) or (last_aroonu_14_4h > 20.0))
      and ((last_roc_9_1d < 15.0) or (last_stochrsi_k_4h > 20.0))
    ):
      self._grind_entry_tag = "g27"
      return True

    self._grind_entry_tag = ""
    return False

  def short_rebuy_entry_v3(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    if (last_candle["protections_short_global"] == True) and (
      (last_candle["enter_short"] == True)
      or (
        (last_candle["RSI_3"] < 90.0)
        and (last_candle["RSI_3_15m"] < 90.0)
        and (last_candle["AROOND_14"] < 30.0)
        and (last_candle["AROOND_14_15m"] < 30.0)
        and (last_candle["close"] > (last_candle["EMA_26"] * 1.012))
      )
    ):
      return True

    return False

  # Short Grinding Adjust Trade Position
  # ---------------------------------------------------------------------------------------------
  def short_grind_adjust_trade_position(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ):
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    stake_currency = self.config["stake_currency"]
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    runmode_value = dp.runmode.value
    is_backtest = runmode_value in ["backtest", "hyperopt"]
    trade_open_date = None if is_backtest else trade.open_date_utc.replace(tzinfo=None)
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    is_futures = self.is_futures_mode
    derisk_use_grind_stops = self.derisk_use_grind_stops
    short_rebuy_mode_tags = self.short_rebuy_mode_tags
    short_grind_mode_tags = self.short_grind_mode_tags
    trade_leverage = trade.leverage

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
    if len(df) < 2:
      return None
    last_candle = df.iloc[-1]
    previous_candle = df.iloc[-2]

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_entries = trade.nr_of_successful_entries
    count_of_exits = trade.nr_of_successful_exits

    if count_of_entries == 0:
      return None

    first_filled_entry = filled_entries[0]
    last_filled_entry = filled_entries[-1]
    last_filled_order = filled_orders[-1]

    has_order_tags = hasattr(filled_orders[0], "ft_order_tag")

    if runmode_value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = self.config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    slice_amount = first_filled_entry.safe_filled * first_filled_entry.safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    current_stake_amount = trade_amount * current_rate
    is_derisk = trade_amount < (first_filled_entry.safe_filled * 0.95)
    is_derisk_calc = False
    is_rebuy_mode = all(c in short_rebuy_mode_tags for c in enter_tags) or (
      any(c in short_rebuy_mode_tags for c in enter_tags)
      and all(c in (short_rebuy_mode_tags + short_grind_mode_tags) for c in enter_tags)
    )
    is_grind_mode = all(c in short_grind_mode_tags for c in enter_tags)

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate
    stake_scale_leverage = trade_leverage if is_futures else 1.0
    grind_mode_stake_multipliers = (
      self.grind_mode_stake_multiplier_futures if is_futures else self.grind_mode_stake_multiplier_spot
    )
    regular_mode_stake_multipliers = (
      self.regular_mode_stake_multiplier_futures if is_futures else self.regular_mode_stake_multiplier_spot
    )
    grind_entry_retry_time = current_time - timedelta(minutes=10)
    grind_order_age_time = current_time - timedelta(hours=6)
    grind_force_order_age_time = current_time - timedelta(hours=24)

    # Rebuy mode
    if is_rebuy_mode:
      slice_amount /= self.rebuy_mode_stake_multiplier
    # Grind mode
    elif is_grind_mode:
      slice_amount /= grind_mode_stake_multipliers[0]
    elif not is_derisk and (is_backtest or trade_open_date >= datetime(2024, 2, 5)):
      rebuy_stake, order_tag, is_derisk_calc = self.short_adjust_trade_position_no_derisk(
        trade,
        enter_tags,
        current_time,
        current_rate,
        current_profit,
        min_stake,
        max_stake,
        current_entry_rate,
        current_exit_rate,
        current_entry_profit,
        current_exit_profit,
        last_candle,
        previous_candle,
        filled_orders,
        filled_entries,
        filled_exits,
        exit_rate,
        slice_amount,
        slice_profit_entry,
        slice_profit,
        profit_ratio,
        profit_stake,
        profit_init_ratio,
        current_stake_amount,
        has_order_tags,
        count_of_exits,
      )
      if rebuy_stake is not None:
        if has_order_tags:
          return rebuy_stake, order_tag
        else:
          return rebuy_stake
      elif count_of_exits == 0:
        return None
      elif not is_derisk_calc:
        return None

    if not is_rebuy_mode and not is_grind_mode:
      # First entry is lower now, therefore the grinds must adjust
      if is_backtest or trade_open_date >= datetime(2024, 4, 16):
        slice_amount /= regular_mode_stake_multipliers[0]

    is_not_trade_max_stake = current_stake_amount < (
      ((first_filled_entry.safe_filled * first_filled_entry.safe_price) * self.grinding_v1_max_stake)
      / (grind_mode_stake_multipliers[0] if is_grind_mode else 1.0)
    )

    grind_1_max_sub_grinds = 0
    grind_1_stakes = scale_stakes_for_min_stake(
      self.grind_1_stakes_futures if is_futures else self.grind_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_1_sub_thresholds = self.grind_1_sub_thresholds_futures if is_futures else self.grind_1_sub_thresholds_spot
    grind_1_max_sub_grinds = len(grind_1_stakes)
    grind_1_stop_grinds = self.grind_1_stop_grinds_futures if is_futures else self.grind_1_stop_grinds_spot
    grind_1_profit_threshold = (
      self.grind_1_profit_threshold_futures if is_futures else self.grind_1_profit_threshold_spot
    )

    grind_2_max_sub_grinds = 0
    grind_2_stakes = scale_stakes_for_min_stake(
      self.grind_2_stakes_futures if is_futures else self.grind_2_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_2_sub_thresholds = self.grind_2_sub_thresholds_futures if is_futures else self.grind_2_sub_thresholds_spot
    grind_2_max_sub_grinds = len(grind_2_stakes)
    grind_2_stop_grinds = self.grind_2_stop_grinds_futures if is_futures else self.grind_2_stop_grinds_spot
    grind_2_profit_threshold = (
      self.grind_2_profit_threshold_futures if is_futures else self.grind_2_profit_threshold_spot
    )

    grind_3_max_sub_grinds = 0
    grind_3_stakes = scale_stakes_for_min_stake(
      self.grind_3_stakes_futures if is_futures else self.grind_3_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_3_sub_thresholds = self.grind_3_sub_thresholds_futures if is_futures else self.grind_3_sub_thresholds_spot
    grind_3_max_sub_grinds = len(grind_3_stakes)
    grind_3_stop_grinds = self.grind_3_stop_grinds_futures if is_futures else self.grind_3_stop_grinds_spot
    grind_3_profit_threshold = (
      self.grind_3_profit_threshold_futures if is_futures else self.grind_3_profit_threshold_spot
    )

    grind_4_max_sub_grinds = 0
    grind_4_stakes = scale_stakes_for_min_stake(
      self.grind_4_stakes_futures if is_futures else self.grind_4_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_4_sub_thresholds = self.grind_4_sub_thresholds_futures if is_futures else self.grind_4_sub_thresholds_spot
    grind_4_max_sub_grinds = len(grind_4_stakes)
    grind_4_stop_grinds = self.grind_4_stop_grinds_futures if is_futures else self.grind_4_stop_grinds_spot
    grind_4_profit_threshold = (
      self.grind_4_profit_threshold_futures if is_futures else self.grind_4_profit_threshold_spot
    )

    grind_5_max_sub_grinds = 0
    grind_5_stakes = scale_stakes_for_min_stake(
      self.grind_5_stakes_futures if is_futures else self.grind_5_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_5_sub_thresholds = self.grind_5_sub_thresholds_futures if is_futures else self.grind_5_sub_thresholds_spot
    grind_5_max_sub_grinds = len(grind_5_stakes)
    grind_5_stop_grinds = self.grind_5_stop_grinds_futures if is_futures else self.grind_5_stop_grinds_spot
    grind_5_profit_threshold = (
      self.grind_5_profit_threshold_futures if is_futures else self.grind_5_profit_threshold_spot
    )

    grind_6_max_sub_grinds = 0
    grind_6_stakes = scale_stakes_for_min_stake(
      self.grind_6_stakes_futures if is_futures else self.grind_6_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_6_sub_thresholds = self.grind_6_sub_thresholds_futures if is_futures else self.grind_6_sub_thresholds_spot
    grind_6_max_sub_grinds = len(grind_6_stakes)
    grind_6_stop_grinds = self.grind_6_stop_grinds_futures if is_futures else self.grind_6_stop_grinds_spot
    grind_6_profit_threshold = (
      self.grind_6_profit_threshold_futures if is_futures else self.grind_6_profit_threshold_spot
    )

    grind_1_derisk_1_max_sub_grinds = 0
    grind_1_derisk_1_stakes = scale_stakes_for_min_stake(
      self.grind_1_derisk_1_stakes_futures if is_futures else self.grind_1_derisk_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_1_derisk_1_sub_thresholds = (
      self.grind_1_derisk_1_sub_thresholds_futures if is_futures else self.grind_1_derisk_1_sub_thresholds_spot
    )
    grind_1_derisk_1_max_sub_grinds = len(grind_1_derisk_1_stakes)
    grind_1_derisk_1_stop_grinds = (
      self.grind_1_derisk_1_stop_grinds_futures if is_futures else self.grind_1_derisk_1_stop_grinds_spot
    )
    grind_1_derisk_1_profit_threshold = (
      self.grind_1_derisk_1_profit_threshold_futures if is_futures else self.grind_1_derisk_1_profit_threshold_spot
    )

    grind_2_derisk_1_max_sub_grinds = 0
    grind_2_derisk_1_stakes = scale_stakes_for_min_stake(
      self.grind_2_derisk_1_stakes_futures if is_futures else self.grind_2_derisk_1_stakes_spot,
      slice_amount,
      min_stake,
      stake_scale_leverage,
      trade_leverage,
    )
    grind_2_derisk_1_sub_thresholds = (
      self.grind_2_derisk_1_sub_thresholds_futures if is_futures else self.grind_2_derisk_1_sub_thresholds_spot
    )
    grind_2_derisk_1_max_sub_grinds = len(grind_2_derisk_1_stakes)
    grind_2_derisk_1_stop_grinds = (
      self.grind_2_derisk_1_stop_grinds_futures if is_futures else self.grind_2_derisk_1_stop_grinds_spot
    )
    grind_2_derisk_1_profit_threshold = (
      self.grind_2_derisk_1_profit_threshold_futures if is_futures else self.grind_2_derisk_1_profit_threshold_spot
    )

    partial_sell = False
    is_derisk_found = False  # d de-risk
    is_derisk_1 = False
    is_derisk_1_found = False  # d1 de-risk exit
    derisk_1_order = None
    derisk_1_reentry_order = None
    derisk_1_sub_grind_count = 0
    derisk_1_total_amount = 0.0
    derisk_1_total_cost = 0.0
    derisk_1_current_open_rate = 0.0
    derisk_1_current_grind_stake = 0.0
    derisk_1_current_grind_stake_profit = 0.0
    derisk_1_is_sell_found = False
    derisk_1_reentry_found = False
    derisk_1_buy_orders = []
    derisk_1_distance_ratio = 0.0
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_stake_profit = 0.0
    grind_1_is_sell_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_stake_profit = 0.0
    grind_2_is_sell_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_stake_profit = 0.0
    grind_3_is_sell_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_stake_profit = 0.0
    grind_4_is_sell_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_stake_profit = 0.0
    grind_5_is_sell_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_distance_ratio = 0.0
    grind_6_sub_grind_count = 0
    grind_6_total_amount = 0.0
    grind_6_total_cost = 0.0
    grind_6_current_open_rate = 0.0
    grind_6_current_grind_stake = 0.0
    grind_6_current_grind_stake_profit = 0.0
    grind_6_is_sell_found = False
    grind_6_found = False
    grind_6_buy_orders = []
    grind_6_distance_ratio = 0.0
    grind_1_derisk_1_sub_grind_count = 0
    grind_1_derisk_1_total_amount = 0.0
    grind_1_derisk_1_total_cost = 0.0
    grind_1_derisk_1_current_open_rate = 0.0
    grind_1_derisk_1_current_grind_stake = 0.0
    grind_1_derisk_1_current_grind_stake_profit = 0.0
    grind_1_derisk_1_is_sell_found = False
    grind_1_derisk_1_found = False
    grind_1_derisk_1_buy_orders = []
    grind_1_derisk_1_distance_ratio = 0.0
    grind_2_derisk_1_sub_grind_count = 0
    grind_2_derisk_1_total_amount = 0.0
    grind_2_derisk_1_total_cost = 0.0
    grind_2_derisk_1_current_open_rate = 0.0
    grind_2_derisk_1_current_grind_stake = 0.0
    grind_2_derisk_1_current_grind_stake_profit = 0.0
    grind_2_derisk_1_is_sell_found = False
    grind_2_derisk_1_found = False
    grind_2_derisk_1_buy_orders = []
    grind_2_derisk_1_distance_ratio = 0.0
    for order in reversed(filled_orders):
      order_side = order.ft_order_side
      if (order_side == "sell") and (order is not filled_orders[0]):
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag
        order_safe_filled = order.safe_filled
        order_safe_price = order.safe_price
        order_id = order.id
        if not is_derisk_1 and order_tag == "d1":
          derisk_1_sub_grind_count += 1
          derisk_1_total_amount += order_safe_filled
          derisk_1_total_cost += order_safe_filled * order_safe_price
          derisk_1_buy_orders.append(order_id)
          if not derisk_1_reentry_found and not is_derisk_1:
            derisk_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            derisk_1_reentry_found = True
            derisk_1_reentry_order = order
        elif not grind_1_derisk_1_is_sell_found and order_tag == "dl1":
          grind_1_derisk_1_sub_grind_count += 1
          grind_1_derisk_1_total_amount += order_safe_filled
          grind_1_derisk_1_total_cost += order_safe_filled * order_safe_price
          grind_1_derisk_1_buy_orders.append(order_id)
          if not grind_1_derisk_1_found:
            grind_1_derisk_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_1_derisk_1_found = True
        elif not grind_2_derisk_1_is_sell_found and order_tag == "dl2":
          grind_2_derisk_1_sub_grind_count += 1
          grind_2_derisk_1_total_amount += order_safe_filled
          grind_2_derisk_1_total_cost += order_safe_filled * order_safe_price
          grind_2_derisk_1_buy_orders.append(order_id)
          if not grind_2_derisk_1_found:
            grind_2_derisk_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_2_derisk_1_found = True
        elif not grind_6_is_sell_found and order_tag == "gd6":
          grind_6_sub_grind_count += 1
          grind_6_total_amount += order_safe_filled
          grind_6_total_cost += order_safe_filled * order_safe_price
          grind_6_buy_orders.append(order_id)
          if not grind_6_found:
            grind_6_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_6_found = True
        elif not grind_5_is_sell_found and order_tag == "gd5":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order_safe_filled
          grind_5_total_cost += order_safe_filled * order_safe_price
          grind_5_buy_orders.append(order_id)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_5_found = True
        elif not grind_4_is_sell_found and order_tag == "gd4":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order_safe_filled
          grind_4_total_cost += order_safe_filled * order_safe_price
          grind_4_buy_orders.append(order_id)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_4_found = True
        elif not grind_3_is_sell_found and order_tag == "gd3":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order_safe_filled
          grind_3_total_cost += order_safe_filled * order_safe_price
          grind_3_buy_orders.append(order_id)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_3_found = True
        elif not grind_2_is_sell_found and order_tag == "gd2":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order_safe_filled
          grind_2_total_cost += order_safe_filled * order_safe_price
          grind_2_buy_orders.append(order_id)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_2_found = True
        elif not grind_1_is_sell_found and order_tag not in [
          "r",
          "d1",
          "dl1",
          "dl2",
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "gm0",
          "gmd0",
          "gdr",
        ]:
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order_safe_filled
          grind_1_total_cost += order_safe_filled * order_safe_price
          grind_1_buy_orders.append(order_id)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_1_found = True
      elif order_side == "buy":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          break
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag.partition(" ")[0]
        if order_tag in ["dl1", "ddl1"]:
          grind_1_derisk_1_is_sell_found = True
        elif order_tag in ["dl2", "ddl2"]:
          grind_2_derisk_1_is_sell_found = True
        elif order_tag in ["gd6", "dd6"]:
          grind_6_is_sell_found = True
        elif order_tag in ["gd5", "dd5"]:
          grind_5_is_sell_found = True
        if order_tag in ["gd4", "dd4"]:
          grind_4_is_sell_found = True
        elif order_tag in ["gd3", "dd3"]:
          grind_3_is_sell_found = True
        elif order_tag in ["gd2", "dd2"]:
          grind_2_is_sell_found = True
        elif order_tag == "d1":
          if not is_derisk_1_found:
            is_derisk_1_found = True
            is_derisk_1 = True
            derisk_1_order = order
        elif order_tag in ["p", "r", "d", "dd0", "partial_exit", "force_exit", ""]:
          if order_tag == "d":
            is_derisk_found = True
            is_derisk = True
          grind_1_is_sell_found = True
          grind_2_is_sell_found = True
          grind_3_is_sell_found = True
          grind_4_is_sell_found = True
          grind_5_is_sell_found = True
          grind_6_is_sell_found = True
          grind_1_derisk_1_is_sell_found = True
          grind_2_derisk_1_is_sell_found = True
        elif order_tag not in [
          "dl1",
          "ddl1",
          "dl2",
          "ddl2",
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "dd2",
          "dd3",
          "dd4",
          "dd5",
          "dd6",
          "gm0",
          "gmd0",
          "gdr",
        ]:
          grind_1_is_sell_found = True

    if derisk_1_sub_grind_count > 0:
      derisk_1_current_open_rate = derisk_1_total_cost / derisk_1_total_amount
      derisk_1_current_grind_stake = derisk_1_total_amount * exit_rate * (1 + trade_fee_close)
      derisk_1_current_grind_stake_profit = derisk_1_total_cost - derisk_1_current_grind_stake
    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 + trade_fee_close)
      grind_1_current_grind_stake_profit = grind_1_total_cost - grind_1_current_grind_stake
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 + trade_fee_close)
      grind_2_current_grind_stake_profit = grind_2_total_cost - grind_2_current_grind_stake
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 + trade_fee_close)
      grind_3_current_grind_stake_profit = grind_3_total_cost - grind_3_current_grind_stake
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 + trade_fee_close)
      grind_4_current_grind_stake_profit = grind_4_total_cost - grind_4_current_grind_stake
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 + trade_fee_close)
      grind_5_current_grind_stake_profit = grind_5_total_cost - grind_5_current_grind_stake
    if grind_6_sub_grind_count > 0:
      grind_6_current_open_rate = grind_6_total_cost / grind_6_total_amount
      grind_6_current_grind_stake = grind_6_total_amount * exit_rate * (1 + trade_fee_close)
      grind_6_current_grind_stake_profit = grind_6_total_cost - grind_6_current_grind_stake
    if grind_1_derisk_1_sub_grind_count > 0:
      grind_1_derisk_1_current_open_rate = grind_1_derisk_1_total_cost / grind_1_derisk_1_total_amount
      grind_1_derisk_1_current_grind_stake = grind_1_derisk_1_total_amount * exit_rate * (1 + trade_fee_close)
      grind_1_derisk_1_current_grind_stake_profit = grind_1_derisk_1_total_cost - grind_1_derisk_1_current_grind_stake
    if grind_2_derisk_1_sub_grind_count > 0:
      grind_2_derisk_1_current_open_rate = grind_2_derisk_1_total_cost / grind_2_derisk_1_total_amount
      grind_2_derisk_1_current_grind_stake = grind_2_derisk_1_total_amount * exit_rate * (1 + trade_fee_close)
      grind_2_derisk_1_current_grind_stake_profit = grind_2_derisk_1_total_cost - grind_2_derisk_1_current_grind_stake

    num_open_grinds = (
      grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
      + grind_6_sub_grind_count
      + grind_1_derisk_1_sub_grind_count
      + grind_2_derisk_1_sub_grind_count
    )
    grinds_total_stake_profit = (
      derisk_1_current_grind_stake_profit
      + grind_1_derisk_1_current_grind_stake_profit
      + grind_2_derisk_1_current_grind_stake_profit
      + grind_1_current_grind_stake_profit
      + grind_2_current_grind_stake_profit
      + grind_3_current_grind_stake_profit
      + grind_4_current_grind_stake_profit
      + grind_5_current_grind_stake_profit
      + grind_6_current_grind_stake_profit
    )
    grinds_total_amount = (
      derisk_1_total_amount
      + grind_1_derisk_1_total_amount
      + grind_2_derisk_1_total_amount
      + grind_1_total_amount
      + grind_2_total_amount
      + grind_3_total_amount
      + grind_4_total_amount
      + grind_5_total_amount
      + grind_6_total_amount
    )
    stake_fmt = ".8f" if self.config["stake_currency"] in ("BTC", "ETH", "BNB", "SOL") else ".3f"
    # Sell remaining if partial fill on exit
    if partial_sell:
      order = filled_exits[-1]
      sell_amount = order.safe_remaining * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        send_msg(
          f"Exit (remaining) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {order.safe_remaining} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        order_tag = "p"
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    if is_grind_mode and (
      (first_filled_entry.safe_filled * (trade_stake_amount / trade_amount) - (min_stake * 1.5)) > min_stake
    ):
      is_first_entry_exit_found = False
      for order in filled_orders:
        if order.ft_order_side == "buy":
          order_tag = ""
          if has_order_tags:
            if order.ft_order_tag is not None:
              order_tag = order.ft_order_tag.partition(" ")[0]
          else:
            # no order tag support, assume the first exit is for the first buy
            is_first_entry_exit_found = True
          if order_tag in ["gm0", "gmd0"]:
            is_first_entry_exit_found = True
            break
      if not is_first_entry_exit_found:
        first_entry = first_filled_entry
        first_entry_distance_ratio = -(exit_rate - first_entry.safe_price) / first_entry.safe_price
        # First entry exit
        if first_entry_distance_ratio > (
          (self.grind_mode_first_entry_profit_threshold_spot + fee_open_rate + fee_close_rate)
          if is_futures
          else (self.grind_mode_first_entry_profit_threshold_spot + fee_open_rate + fee_close_rate)
        ):
          sell_amount = first_entry.safe_filled * exit_rate / trade_leverage
          if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
            sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
          ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
          if sell_amount > min_stake and ft_sell_amount > min_stake:
            grind_profit = -(exit_rate - first_entry.safe_price) / first_entry.safe_price
            coin_amount = sell_amount / exit_rate
            send_msg(
              notification_msg(
                "grinding-exit",
                tag="gm0",
                pair=trade_pair,
                rate=exit_rate,
                stake_amount=sell_amount,
                profit_stake=profit_stake,
                profit_ratio=profit_ratio,
                stake_currency=stake_currency,
                grind_profit_stake=grind_profit * sell_amount * trade_leverage,
                grind_profit_pct=grind_profit,
                coin_amount=coin_amount,
              )
            )
            log.info(
              f"Grinding exit (gm0) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {coin_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
            )
            order_tag = "gm0"
            for grind_entry_id in grind_1_buy_orders:
              order_tag += " " + str(grind_entry_id)
            if has_order_tags:
              return -ft_sell_amount, order_tag
            else:
              return -ft_sell_amount
        # First entry de-risk
        if derisk_use_grind_stops and (
          first_entry_distance_ratio
          < (
            self.grind_mode_first_entry_stop_threshold_spot
            if is_futures
            else self.grind_mode_first_entry_stop_threshold_spot
          )
        ):
          sell_amount = first_entry.safe_filled * exit_rate / trade_leverage
          if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
            sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
          ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
          if sell_amount > min_stake and ft_sell_amount > min_stake:
            grind_profit = -(exit_rate - first_entry.safe_price) / first_entry.safe_price
            coin_amount = sell_amount / exit_rate
            send_msg(
              notification_msg(
                "grinding-derisk",
                tag="gmd0",
                pair=trade_pair,
                rate=exit_rate,
                stake_amount=sell_amount,
                profit_stake=profit_stake,
                profit_ratio=profit_ratio,
                stake_currency=stake_currency,
                grind_profit_stake=grind_profit * sell_amount * trade_leverage,
                grind_profit_pct=grind_profit,
                coin_amount=coin_amount,
              )
            )
            log.info(
              f"Grinding de-risk (gmd0) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {coin_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
            )
            order_tag = "gmd0"
            for grind_entry_id in grind_1_buy_orders:
              order_tag += " " + str(grind_entry_id)
            if has_order_tags:
              return -ft_sell_amount, order_tag
            else:
              return -ft_sell_amount

    is_short_grind_entry = self.short_grind_entry(last_candle, previous_candle, slice_profit, True)
    slice_profit_gt_0_06 = slice_profit > 0.06
    num_open_grinds_eq_0 = num_open_grinds == 0

    # Grinding derisk 1
    # Buy
    if (
      has_order_tags
      and is_derisk_1
      and not derisk_1_reentry_found
      and (not partial_sell)
      and (grind_1_derisk_1_sub_grind_count < grind_1_derisk_1_max_sub_grinds)
      and is_not_trade_max_stake
    ):
      if (
        (
          (
            (grind_1_derisk_1_sub_grind_count > 0)
            and -grind_1_derisk_1_distance_ratio < grind_1_derisk_1_sub_thresholds[grind_1_derisk_1_sub_grind_count]
          )
          or ((is_derisk or is_derisk_calc) and grind_1_derisk_1_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * grind_1_derisk_1_stakes[grind_1_derisk_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_1_derisk_1_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate
          grind_profit_stake = grind_1_derisk_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="dl1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_derisk_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (dl1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_derisk_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "dl1"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_1_derisk_1_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate
      if grind_profit > (grind_1_derisk_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_1_derisk_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="dl1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_derisk_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (dl1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "dl1"
          for grind_entry_id in grind_1_derisk_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (grind_1_derisk_1_sub_grind_count > 0)
      # and (
      #   (-(exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate)
      #   < grind_1_derisk_1_stop_grinds
      # )
      and (grind_1_derisk_1_current_grind_stake_profit < (slice_amount * grind_1_derisk_1_stop_grinds))
      and (is_derisk or is_derisk_calc)
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_1_derisk_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_derisk_1_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_1_derisk_1_current_open_rate) / grind_1_derisk_1_current_open_rate)
            if grind_1_derisk_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="ddl1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_derisk_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (ddl1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "ddl1"
        for grind_entry_id in grind_1_derisk_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding derisk 2
    # Buy
    if (
      has_order_tags
      and is_derisk_1
      and not derisk_1_reentry_found
      and (not partial_sell)
      and (grind_2_derisk_1_sub_grind_count < grind_2_derisk_1_max_sub_grinds)
      and is_not_trade_max_stake
    ):
      if (
        (
          (
            (grind_2_derisk_1_sub_grind_count > 0)
            and -grind_2_derisk_1_distance_ratio < grind_2_derisk_1_sub_thresholds[grind_2_derisk_1_sub_grind_count]
          )
          or ((is_derisk or is_derisk_calc) and grind_2_derisk_1_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * grind_2_derisk_1_stakes[grind_2_derisk_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_2_derisk_1_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate
          grind_profit_stake = grind_2_derisk_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="dl2",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_derisk_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (dl2) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_derisk_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "dl2"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_2_derisk_1_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate
      if grind_profit > (grind_2_derisk_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_2_derisk_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="dl2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_derisk_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (dl2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "dl2"
          for grind_entry_id in grind_2_derisk_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (grind_2_derisk_1_sub_grind_count > 0)
      # and (
      #   (-(exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate)
      #   < grind_2_derisk_1_stop_grinds
      # )
      and (grind_2_derisk_1_current_grind_stake_profit < (slice_amount * grind_2_derisk_1_stop_grinds))
      and (is_derisk or is_derisk_calc)
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_2_derisk_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_derisk_1_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_2_derisk_1_current_open_rate) / grind_2_derisk_1_current_open_rate)
            if grind_2_derisk_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="ddl2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_derisk_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (ddl2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_derisk_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "ddl2"
        for grind_entry_id in grind_2_derisk_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 1
    # Buy
    if (not partial_sell) and (grind_1_sub_grind_count < grind_1_max_sub_grinds):
      if (
        (
          ((grind_1_sub_grind_count > 0) and -grind_1_distance_ratio < grind_1_sub_thresholds[grind_1_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_1_sub_grind_count == 0)
          or (is_grind_mode and grind_1_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_1_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
          grind_profit_stake = grind_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd1"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    if (
      is_futures
      and has_order_tags
      and (not partial_sell)
      and slice_profit > (0.65 / trade_leverage)
      and (is_derisk or is_derisk_calc or is_grind_mode)
      and (grind_1_sub_grind_count < grind_1_max_sub_grinds)
    ):
      buy_amount = slice_amount * grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None
      grind_profit = 0.0
      grind_profit_stake = 0.0
      if grind_1_sub_grind_count > 0:
        grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
        grind_profit_stake = grind_1_current_grind_stake_profit
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="gd1",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
          grind_profit_stake=grind_1_current_grind_stake_profit,
          grind_profit_pct=grind_profit,
        )
      )
      log.info(
        f"Grinding entry (gd1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
      )
      order_tag = "gd1"
      if has_order_tags:
        return buy_amount, order_tag
      else:
        return buy_amount

    # Sell
    if grind_1_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
      if grind_profit > (grind_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd1"
          for grind_entry_id in grind_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_1_sub_grind_count > 0)
        # and ((-(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < grind_1_stop_grinds)
        and (grind_1_current_grind_stake_profit < (slice_amount * grind_1_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd1"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 2
    # Buy
    if has_order_tags and (not partial_sell) and (grind_2_sub_grind_count < grind_2_max_sub_grinds):
      if (
        (
          ((grind_2_sub_grind_count > 0) and -grind_2_distance_ratio < grind_2_sub_thresholds[grind_2_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_2_sub_grind_count == 0)
          or (is_grind_mode and grind_2_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_2_stakes[grind_2_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_2_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
          grind_profit_stake = grind_2_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd2",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd2) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd2"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_2_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
      if grind_profit > (grind_2_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd2"
          for grind_entry_id in grind_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_2_sub_grind_count > 0)
        # and ((-(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < grind_2_stop_grinds)
        and (grind_2_current_grind_stake_profit < (slice_amount * grind_2_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd2"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 3
    # Buy
    if has_order_tags and (not partial_sell) and (grind_3_sub_grind_count < grind_3_max_sub_grinds):
      if (
        (
          ((grind_3_sub_grind_count > 0) and -grind_3_distance_ratio < grind_3_sub_thresholds[grind_3_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_3_sub_grind_count == 0)
          or (is_grind_mode and grind_3_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_3_stakes[grind_3_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_3_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
          grind_profit_stake = grind_3_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd3",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_3_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd3) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd3"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_3_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
      if grind_profit > (grind_3_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd3",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd3"
          for grind_entry_id in grind_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_3_sub_grind_count > 0)
        # and ((-(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < grind_3_stop_grinds)
        and (grind_3_current_grind_stake_profit < (slice_amount * grind_3_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd3",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd3"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 4
    # Buy
    if has_order_tags and (not partial_sell) and (grind_4_sub_grind_count < grind_4_max_sub_grinds):
      if (
        (
          ((grind_4_sub_grind_count > 0) and -grind_4_distance_ratio < grind_4_sub_thresholds[grind_4_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_4_sub_grind_count == 0)
          or (is_grind_mode and grind_4_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_4_stakes[grind_4_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_4_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
          grind_profit_stake = grind_4_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd4",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_4_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd4) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd4"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_4_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
      if grind_profit > (grind_4_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_4_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd4",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd4"
          for grind_entry_id in grind_4_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_4_sub_grind_count > 0)
        # and ((-(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < grind_4_stop_grinds)
        and (grind_4_current_grind_stake_profit < (slice_amount * grind_4_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd4",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd4"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    gd5_liquidation_rescue_eligible = (
      is_futures
      and (slice_profit_entry > 0.12)
      and (trade.liquidation_price is not None)
      and (current_rate > trade.liquidation_price * 0.80)
      and (trade.get_custom_data(key="gd5_liquidation_rescue_used") is None)
    )

    # Grinding 5
    # Buy
    if has_order_tags and (not partial_sell) and (grind_5_sub_grind_count < grind_5_max_sub_grinds):
      if (
        (
          ((grind_5_sub_grind_count > 0) and -grind_5_distance_ratio < grind_5_sub_thresholds[grind_5_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_5_sub_grind_count == 0)
          or (is_grind_mode and grind_5_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and (is_short_grind_entry or gd5_liquidation_rescue_eligible)
        and is_not_trade_max_stake
      ):
        if gd5_liquidation_rescue_eligible:
          trade.set_custom_data(key="gd5_liquidation_rescue_used", value=True)

        buy_amount = slice_amount * grind_5_stakes[grind_5_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_5_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
          grind_profit_stake = grind_5_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd5",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_5_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd5) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd5"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_5_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
      if grind_profit > (grind_5_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_5_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd5",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd5"
          for grind_entry_id in grind_5_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_5_sub_grind_count > 0)
        # and ((-(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < grind_5_stop_grinds)
        and (grind_5_current_grind_stake_profit < (slice_amount * grind_5_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd5",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd5"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # Grinding 6
    # Buy
    if has_order_tags and (not partial_sell) and (grind_6_sub_grind_count < grind_6_max_sub_grinds):
      if (
        (
          ((grind_6_sub_grind_count > 0) and -grind_6_distance_ratio < grind_6_sub_thresholds[grind_6_sub_grind_count])
          or ((is_derisk or is_derisk_calc) and grind_6_sub_grind_count == 0)
          or (is_grind_mode and grind_6_sub_grind_count == 0)
        )
        and (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and is_short_grind_entry
        and is_not_trade_max_stake
      ):
        buy_amount = slice_amount * grind_6_stakes[grind_6_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_6_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
          grind_profit_stake = grind_6_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="gd6",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_6_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (gd6) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_6_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "gd6"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # Sell
    if grind_6_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
      if grind_profit > (grind_6_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_6_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="gd6",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_6_total_amount,
            )
          )
          log.info(
            f"Grinding exit (gd6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage:{stake_fmt}} {stake_currency})"
          )
          order_tag = "gd6"
          for grind_entry_id in grind_6_buy_orders:
            order_tag += " " + str(grind_entry_id)
          if has_order_tags:
            return -ft_sell_amount, order_tag
          else:
            return -ft_sell_amount

    # Grind stop
    if (
      derisk_use_grind_stops
      and (
        (grind_6_sub_grind_count > 0)
        # and ((-(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate) < grind_6_stop_grinds)
        and (grind_6_current_grind_stake_profit < (slice_amount * grind_6_stop_grinds))
        and (is_derisk or is_derisk_calc or is_grind_mode)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = grind_6_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_6_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate)
            if grind_6_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="dd6",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_6_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (dd6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "dd6"
        for grind_entry_id in grind_6_buy_orders:
          order_tag += " " + str(grind_entry_id)
        if has_order_tags:
          return -ft_sell_amount, order_tag
        else:
          return -ft_sell_amount

    # De-risk 1 reentry
    if (
      is_derisk_1
      and not derisk_1_reentry_found
      and derisk_1_order is not None
      and (
        (-(current_rate - derisk_1_order.safe_price) / derisk_1_order.safe_price)
        < (self.regular_mode_derisk_1_reentry_futures if is_futures else self.regular_mode_derisk_1_reentry_spot)
      )
    ):
      if (
        (grind_entry_retry_time > last_filled_entry.order_filled_utc)
        and ((grind_force_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06)
        and (
          num_open_grinds_eq_0 or (grind_order_age_time > last_filled_order.order_filled_utc) or slice_profit_gt_0_06
        )
        # and ((num_open_grinds == 0) or (slice_profit > 0.03))
        and (
          # (last_candle["protections_short_rebuy"] == True)
          # and (last_candle["protections_short_global"] == True)
          (last_candle["global_protections_short_pump"] == True)
          and (last_candle["global_protections_short_dump"] == True)
        )
        and is_short_grind_entry
      ):
        buy_amount = derisk_1_order.safe_filled * derisk_1_order.safe_price
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if derisk_1_sub_grind_count > 0:
          grind_profit = -(exit_rate - derisk_1_current_open_rate) / derisk_1_current_open_rate
          grind_profit_stake = derisk_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "re-entry",
            tag="d1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=derisk_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Re-entry (d1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({derisk_1_current_grind_stake_profit:{stake_fmt}} {stake_currency})"
        )
        order_tag = "d1"
        if has_order_tags:
          return buy_amount, order_tag
        else:
          return buy_amount

    # De-risk level 1
    if (
      has_order_tags
      # and not is_derisk_1
      and derisk_1_reentry_found
      and derisk_1_reentry_order is not None
      # and (trade.open_date_utc.replace(tzinfo=None) >= datetime(2024, 4, 5) or is_backtest)
      and -derisk_1_distance_ratio
      < (
        (self.regular_mode_derisk_1_reentry_futures if is_futures else self.regular_mode_derisk_1_reentry_spot)
        / stake_scale_leverage
      )
    ):
      sell_amount = derisk_1_reentry_order.safe_filled * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="d1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk (d1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "d1"

    return None

  # Short Grinding Entry
  # ---------------------------------------------------------------------------------------------
  def short_grind_entry(
    self, last_candle: Series, previous_candle: Series, slice_profit: float, is_derisk: bool
  ) -> float:
    last_aroond_14 = last_candle["AROOND_14"]
    last_aroond_14_15m = last_candle["AROOND_14_15m"]
    last_rsi_14_1h = last_candle["RSI_14_1h"]
    last_rsi_14_4h = last_candle["RSI_14_4h"]
    previous_ema_12 = previous_candle["EMA_12"]
    previous_ema_26 = previous_candle["EMA_26"]

    last_rsi_14 = last_candle["RSI_14"]
    last_rsi_3_15m = last_candle["RSI_3_15m"]
    last_rsi_3_1h = last_candle["RSI_3_1h"]
    last_rsi_3_4h = last_candle["RSI_3_4h"]
    last_close = last_candle["close"]
    last_ema_12 = last_candle["EMA_12"]
    last_ema_26 = last_candle["EMA_26"]
    last_rsi_3 = last_candle["RSI_3"]
    last_open = last_candle["open"]

    # Reused short regular grind-entry thresholds
    last_rsi_14_gt_64 = last_rsi_14 > 64.0
    last_rsi_3_4h_lt_80 = last_rsi_3_4h < 80.0
    last_rsi_3_1h_lt_80 = last_rsi_3_1h < 80.0
    last_rsi_3_15m_lt_90 = last_rsi_3_15m < 90.0
    last_rsi_3_4h_lt_90 = last_rsi_3_4h < 90.0
    last_rsi_3_1h_lt_90 = last_rsi_3_1h < 90.0
    last_rsi_14_4h_gt_40 = last_rsi_14_4h > 40.0
    last_rsi_14_1h_gt_20 = last_rsi_14_1h > 20.0
    last_aroond_14_15m_lt_25 = last_aroond_14_15m < 25.0
    last_aroond_14_lt_25 = last_aroond_14 < 25.0

    if (
      (last_candle["protections_short_global"] == True)
      and (last_candle["protections_short_rebuy"] == True)
      and (last_candle["global_protections_short_pump"] == True)
      and (last_candle["global_protections_short_dump"] == True)
      and (
        (last_candle["enter_short"] == True)
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3 < 90.0)
          and (last_rsi_3_15m_lt_90)
          and (last_aroond_14_lt_25)
          and (last_candle["STOCHRSIk_14_14_3_3_1h"] > 30.0)
          and (last_candle["STOCHRSIk_14_14_3_3_4h"] > 30.0)
          and (last_close > (last_candle["EMA_16"] * 1.020))
        )
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3_15m < 95.0)
          and (last_rsi_3_1h < 95.0)
          and (last_rsi_3_4h < 95.0)
          and (last_ema_12 > last_ema_26)
          and ((last_ema_12 - last_ema_26) > (last_open * 0.030))
          and ((previous_ema_12 - previous_ema_26) > (last_open / 100.0))
        )
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3 < 95.0)
          and (last_rsi_3_15m_lt_90)
          and (last_rsi_3_1h_lt_90)
          and (last_rsi_3_4h_lt_90)
          and (last_ema_12 > last_ema_26)
          and ((last_ema_12 - last_ema_26) > (last_open * 0.020))
          and ((previous_ema_12 - previous_ema_26) > (last_open / 100.0))
        )
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3 < 84.0)
          and (last_aroond_14_15m_lt_25)
          and (last_close > (last_ema_12 * 1.016))
        )
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3_15m_lt_90)
          and (last_rsi_3_1h_lt_90)
          and (last_rsi_3_4h_lt_90)
          and (last_candle["AROONU_14_1h"] < last_candle["AROOND_14_1h"])
          and (last_candle["AROONU_14_4h"] < last_candle["AROOND_14_4h"])
          and (last_close > (last_ema_26 * 1.022))
          and (last_close > (last_candle["BBL_20_2.0"] * 1.001))
        )
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3_1h_lt_80)
          and (last_rsi_3_4h_lt_80)
          and (last_rsi_14_1h_gt_20)
          and (last_rsi_14_4h_gt_40)
          and (last_candle["AROONU_14"] < last_aroond_14)
          and (previous_candle["AROONU_14"] > previous_candle["AROOND_14"])
        )
        or (
          (last_rsi_14_gt_64)
          and (last_rsi_3_15m < 85.0)
          and (last_rsi_3_1h_lt_80)
          and (last_rsi_3_4h_lt_80)
          and (last_rsi_14_1h_gt_20)
          and (last_rsi_14_4h_gt_40)
          and (last_candle["KST_10_15_20_30_10_10_10_15"] < last_candle["KSTs_9"])
          and (previous_candle["KST_10_15_20_30_10_10_10_15"] > previous_candle["KSTs_9"])
        )
        or (
          is_derisk
          and (last_rsi_3 < 80.0)
          and (last_rsi_3_15m < 80.0)
          and (last_rsi_3_1h_lt_80)
          and (last_rsi_3_4h_lt_80)
          and (last_rsi_14_gt_64)
          and (last_aroond_14_lt_25)
          and (last_aroond_14_15m_lt_25)
          and (last_candle["STOCHRSIk_14_14_3_3_15m"] > 50.0)
          and (last_close > (last_candle["EMA_20"] * 1.020))
        )
      )
    ):
      return True

    return False

  # Short Grinding Adjust Trade Position No De-Risk
  # ---------------------------------------------------------------------------------------------
  def short_adjust_trade_position_no_derisk(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    last_candle: Series,
    previous_candle: Series,
    filled_orders: "Orders",
    filled_entries: "Orders",
    filled_exits: "Orders",
    exit_rate: float,
    slice_amount: float,
    slice_profit_entry: float,
    slice_profit: float,
    profit_ratio: float,
    profit_stake: float,
    profit_init_ratio: float,
    current_stake_amount: float,
    has_order_tags: bool,
    count_of_exits: int,
    **kwargs,
  ) -> tuple[Optional[float], str, bool]:
    dp = self.dp
    send_msg = self.dp.send_msg
    notification_msg = self.notification_msg
    scale_stakes_for_min_stake = self.scale_stakes_for_min_stake
    stake_currency = self.config["stake_currency"]
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_stake_amount = trade.stake_amount
    trade_fee_open = trade.fee_open
    trade_fee_close = trade.fee_close

    is_backtest = dp.runmode.value in ["backtest", "hyperopt"]
    trade_open_date = None if is_backtest else trade.open_date_utc.replace(tzinfo=None)
    is_futures = self.is_futures_mode
    trade_leverage = trade.leverage
    stake_scale_leverage = trade_leverage if is_futures else 1.0
    regular_mode_use_grind_stops = self.regular_mode_use_grind_stops

    # Reused no-derisk slice-profit gates
    slice_profit_gt_0_02 = slice_profit > 0.02
    slice_profit_gt_0_03 = slice_profit > 0.03
    slice_profit_gt_0_06 = slice_profit > 0.06

    last_filled_entry = filled_entries[-1]
    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]

    max_rebuy_sub_grinds = 0
    regular_mode_rebuy_stakes = scale_stakes_for_min_stake(
      self.regular_mode_rebuy_stakes_futures if is_futures else self.regular_mode_rebuy_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_rebuy_sub_thresholds = (
      self.regular_mode_rebuy_thresholds_futures if is_futures else self.regular_mode_rebuy_thresholds_spot
    )
    max_rebuy_sub_grinds = len(regular_mode_rebuy_stakes)

    max_grind_1_sub_grinds = 0
    regular_mode_grind_1_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_1_stakes_futures if is_futures else self.regular_mode_grind_1_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_1_sub_thresholds = (
      self.regular_mode_grind_1_thresholds_futures if is_futures else self.regular_mode_grind_1_thresholds_spot
    )
    max_grind_1_sub_grinds = len(regular_mode_grind_1_stakes)
    regular_mode_grind_1_stop_grinds = (
      self.regular_mode_grind_1_stop_grinds_futures if is_futures else self.regular_mode_grind_1_stop_grinds_spot
    )
    regular_mode_grind_1_profit_threshold = (
      self.regular_mode_grind_1_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_1_profit_threshold_spot
    )

    max_grind_2_sub_grinds = 0
    regular_mode_grind_2_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_2_stakes_futures if is_futures else self.regular_mode_grind_2_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_2_sub_thresholds = (
      self.regular_mode_grind_2_thresholds_futures if is_futures else self.regular_mode_grind_2_thresholds_spot
    )
    max_grind_2_sub_grinds = len(regular_mode_grind_2_stakes)
    regular_mode_grind_2_stop_grinds = (
      self.regular_mode_grind_2_stop_grinds_futures if is_futures else self.regular_mode_grind_2_stop_grinds_spot
    )
    regular_mode_grind_2_profit_threshold = (
      self.regular_mode_grind_2_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_2_profit_threshold_spot
    )

    max_grind_3_sub_grinds = 0
    regular_mode_grind_3_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_3_stakes_futures if is_futures else self.regular_mode_grind_3_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_3_sub_thresholds = (
      self.regular_mode_grind_3_thresholds_futures if is_futures else self.regular_mode_grind_3_thresholds_spot
    )
    max_grind_3_sub_grinds = len(regular_mode_grind_3_stakes)
    regular_mode_grind_3_stop_grinds = (
      self.regular_mode_grind_3_stop_grinds_futures if is_futures else self.regular_mode_grind_3_stop_grinds_spot
    )
    regular_mode_grind_3_profit_threshold = (
      self.regular_mode_grind_3_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_3_profit_threshold_spot
    )

    max_grind_4_sub_grinds = 0
    regular_mode_grind_4_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_4_stakes_futures if is_futures else self.regular_mode_grind_4_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_4_sub_thresholds = (
      self.regular_mode_grind_4_thresholds_futures if is_futures else self.regular_mode_grind_4_thresholds_spot
    )
    max_grind_4_sub_grinds = len(regular_mode_grind_4_stakes)
    regular_mode_grind_4_stop_grinds = (
      self.regular_mode_grind_4_stop_grinds_futures if is_futures else self.regular_mode_grind_4_stop_grinds_spot
    )
    regular_mode_grind_4_profit_threshold = (
      self.regular_mode_grind_4_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_4_profit_threshold_spot
    )

    max_grind_5_sub_grinds = 0
    regular_mode_grind_5_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_5_stakes_futures if is_futures else self.regular_mode_grind_5_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_5_sub_thresholds = (
      self.regular_mode_grind_5_thresholds_futures if is_futures else self.regular_mode_grind_5_thresholds_spot
    )
    max_grind_5_sub_grinds = len(regular_mode_grind_5_stakes)
    regular_mode_grind_5_stop_grinds = (
      self.regular_mode_grind_5_stop_grinds_futures if is_futures else self.regular_mode_grind_5_stop_grinds_spot
    )
    regular_mode_grind_5_profit_threshold = (
      self.regular_mode_grind_5_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_5_profit_threshold_spot
    )

    max_grind_6_sub_grinds = 0
    regular_mode_grind_6_stakes = scale_stakes_for_min_stake(
      self.regular_mode_grind_6_stakes_futures if is_futures else self.regular_mode_grind_6_stakes_spot,
      slice_amount,
      min_stake,
      trade_leverage,
      trade_leverage,
    )
    regular_mode_grind_6_sub_thresholds = (
      self.regular_mode_grind_6_thresholds_futures if is_futures else self.regular_mode_grind_6_thresholds_spot
    )
    max_grind_6_sub_grinds = len(regular_mode_grind_6_stakes)
    regular_mode_grind_6_stop_grinds = (
      self.regular_mode_grind_6_stop_grinds_futures if is_futures else self.regular_mode_grind_6_stop_grinds_spot
    )
    regular_mode_grind_6_profit_threshold = (
      self.regular_mode_grind_6_profit_threshold_futures
      if is_futures
      else self.regular_mode_grind_6_profit_threshold_spot
    )

    partial_sell = False
    is_derisk = False
    is_derisk_1 = False
    rebuy_sub_grind_count = 0
    rebuy_total_amount = 0.0
    rebuy_total_cost = 0.0
    rebuy_current_open_rate = 0.0
    rebuy_current_grind_stake = 0.0
    rebuy_current_grind_stake_profit = 0.0
    rebuy_is_sell_found = False
    rebuy_found = False
    rebuy_buy_orders = []
    rebuy_distance_ratio = 0.0
    grind_1_sub_grind_count = 0
    grind_1_total_amount = 0.0
    grind_1_total_cost = 0.0
    grind_1_current_open_rate = 0.0
    grind_1_current_grind_stake = 0.0
    grind_1_current_grind_stake_profit = 0.0
    grind_1_is_sell_found = False
    grind_1_found = False
    grind_1_buy_orders = []
    grind_1_distance_ratio = 0.0
    grind_2_sub_grind_count = 0
    grind_2_total_amount = 0.0
    grind_2_total_cost = 0.0
    grind_2_current_open_rate = 0.0
    grind_2_current_grind_stake = 0.0
    grind_2_current_grind_stake_profit = 0.0
    grind_2_is_sell_found = False
    grind_2_found = False
    grind_2_buy_orders = []
    grind_2_distance_ratio = 0.0
    grind_3_sub_grind_count = 0
    grind_3_total_amount = 0.0
    grind_3_total_cost = 0.0
    grind_3_current_open_rate = 0.0
    grind_3_current_grind_stake = 0.0
    grind_3_current_grind_stake_profit = 0.0
    grind_3_is_sell_found = False
    grind_3_found = False
    grind_3_buy_orders = []
    grind_3_distance_ratio = 0.0
    grind_4_sub_grind_count = 0
    grind_4_total_amount = 0.0
    grind_4_total_cost = 0.0
    grind_4_current_open_rate = 0.0
    grind_4_current_grind_stake = 0.0
    grind_4_current_grind_stake_profit = 0.0
    grind_4_is_sell_found = False
    grind_4_found = False
    grind_4_buy_orders = []
    grind_4_distance_ratio = 0.0
    grind_5_sub_grind_count = 0
    grind_5_total_amount = 0.0
    grind_5_total_cost = 0.0
    grind_5_current_open_rate = 0.0
    grind_5_current_grind_stake = 0.0
    grind_5_current_grind_stake_profit = 0.0
    grind_5_is_sell_found = False
    grind_5_found = False
    grind_5_buy_orders = []
    grind_5_distance_ratio = 0.0
    grind_6_sub_grind_count = 0
    grind_6_total_amount = 0.0
    grind_6_total_cost = 0.0
    grind_6_current_open_rate = 0.0
    grind_6_current_grind_stake = 0.0
    grind_6_current_grind_stake_profit = 0.0
    grind_6_is_sell_found = False
    grind_6_found = False
    grind_6_buy_orders = []
    grind_6_distance_ratio = 0.0
    for order in reversed(filled_orders):
      order_side = order.ft_order_side
      if (order_side == "sell") and (order is not first_filled_order):
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag
        order_safe_filled = order.safe_filled
        order_safe_price = order.safe_price
        order_id = order.id
        if not grind_1_is_sell_found and order_tag == "g1":
          grind_1_sub_grind_count += 1
          grind_1_total_amount += order_safe_filled
          grind_1_total_cost += order_safe_filled * order_safe_price
          grind_1_buy_orders.append(order_id)
          if not grind_1_found:
            grind_1_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_1_found = True
        elif not grind_2_is_sell_found and order_tag == "g2":
          grind_2_sub_grind_count += 1
          grind_2_total_amount += order_safe_filled
          grind_2_total_cost += order_safe_filled * order_safe_price
          grind_2_buy_orders.append(order_id)
          if not grind_2_found:
            grind_2_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_2_found = True
        elif not grind_3_is_sell_found and order_tag == "g3":
          grind_3_sub_grind_count += 1
          grind_3_total_amount += order_safe_filled
          grind_3_total_cost += order_safe_filled * order_safe_price
          grind_3_buy_orders.append(order_id)
          if not grind_3_found:
            grind_3_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_3_found = True
        elif not grind_4_is_sell_found and order_tag == "g4":
          grind_4_sub_grind_count += 1
          grind_4_total_amount += order_safe_filled
          grind_4_total_cost += order_safe_filled * order_safe_price
          grind_4_buy_orders.append(order_id)
          if not grind_4_found:
            grind_4_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_4_found = True
        elif not grind_5_is_sell_found and order_tag == "g5":
          grind_5_sub_grind_count += 1
          grind_5_total_amount += order_safe_filled
          grind_5_total_cost += order_safe_filled * order_safe_price
          grind_5_buy_orders.append(order_id)
          if not grind_5_found:
            grind_5_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_5_found = True
        elif not grind_6_is_sell_found and order_tag == "g6":
          grind_6_sub_grind_count += 1
          grind_6_total_amount += order_safe_filled
          grind_6_total_cost += order_safe_filled * order_safe_price
          grind_6_buy_orders.append(order_id)
          if not grind_6_found:
            grind_6_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            grind_6_found = True
        elif not rebuy_is_sell_found and order_tag not in [
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "dl1",
          "dl2",
          "gd1",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "gm0",
          "gmd0",
        ]:
          rebuy_sub_grind_count += 1
          rebuy_total_amount += order_safe_filled
          rebuy_total_cost += order_safe_filled * order_safe_price
          rebuy_buy_orders.append(order_id)
          if not rebuy_found:
            rebuy_distance_ratio = (exit_rate - order_safe_price) / order_safe_price
            rebuy_found = True
      elif order_side == "buy":
        if order is filled_exits[-1] and (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
          break
        order_tag = ""
        if has_order_tags:
          order_ft_tag = order.ft_order_tag
          if order_ft_tag is not None:
            order_tag = order_ft_tag.partition(" ")[0]
        if order_tag in ["g1", "sg1"]:
          grind_1_is_sell_found = True
        elif order_tag in ["g2", "sg2"]:
          grind_2_is_sell_found = True
        elif order_tag in ["g3", "sg3"]:
          grind_3_is_sell_found = True
        elif order_tag in ["g4", "sg4"]:
          grind_4_is_sell_found = True
        elif order_tag in ["g5", "sg5"]:
          grind_5_is_sell_found = True
        elif order_tag in ["g6", "sg6"]:
          grind_6_is_sell_found = True
        elif order_tag in ["d", "d1", "dd0", "ddl1", "ddl2", "dd1", "dd2", "dd3", "dd4", "dd5", "dd6"]:
          is_derisk = True
          if order_tag == "d1":
            is_derisk_1 = True
          grind_1_is_sell_found = True
          grind_2_is_sell_found = True
          grind_3_is_sell_found = True
          grind_4_is_sell_found = True
          grind_5_is_sell_found = True
          grind_6_is_sell_found = True
          rebuy_is_sell_found = True
        elif order_tag not in [
          "p",
          "g1",
          "g2",
          "g3",
          "g4",
          "g5",
          "g6",
          "sg1",
          "sg2",
          "sg3",
          "sg4",
          "sg5",
          "sg6",
          "dl1",
          "dl2",
          "gd1",
          "gd2",
          "gd3",
          "gd4",
          "gd5",
          "gd6",
          "gm0",
          "gmd0",
        ]:
          rebuy_is_sell_found = True
        if not is_derisk:
          start_amount = first_filled_order.safe_filled
          current_amount = 0.0
          for order2 in filled_orders:
            if order2.ft_order_side == "sell":
              current_amount += order2.safe_filled
            elif order2.ft_order_side == "buy":
              current_amount -= order2.safe_filled
            if order2 is order:
              if current_amount < (start_amount * 0.95):
                is_derisk = True
        # found sells for all modes
        if (
          rebuy_is_sell_found
          and grind_1_is_sell_found
          and grind_2_is_sell_found
          and grind_3_is_sell_found
          and grind_4_is_sell_found
          and grind_5_is_sell_found
          and grind_6_is_sell_found
        ):
          break

    # The trade already de-risked
    if is_derisk:
      return None, "", is_derisk
    if not has_order_tags and count_of_exits > 0:
      return None, "", is_derisk

    if rebuy_sub_grind_count > 0:
      rebuy_current_open_rate = rebuy_total_cost / rebuy_total_amount
      rebuy_current_grind_stake = rebuy_total_amount * exit_rate * (1 + trade_fee_close)
      rebuy_current_grind_stake_profit = rebuy_total_cost - rebuy_current_grind_stake
    if grind_1_sub_grind_count > 0:
      grind_1_current_open_rate = grind_1_total_cost / grind_1_total_amount
      grind_1_current_grind_stake = grind_1_total_amount * exit_rate * (1 + trade_fee_close)
      grind_1_current_grind_stake_profit = grind_1_total_cost - grind_1_current_grind_stake
    if grind_2_sub_grind_count > 0:
      grind_2_current_open_rate = grind_2_total_cost / grind_2_total_amount
      grind_2_current_grind_stake = grind_2_total_amount * exit_rate * (1 + trade_fee_close)
      grind_2_current_grind_stake_profit = grind_2_total_cost - grind_2_current_grind_stake
    if grind_3_sub_grind_count > 0:
      grind_3_current_open_rate = grind_3_total_cost / grind_3_total_amount
      grind_3_current_grind_stake = grind_3_total_amount * exit_rate * (1 + trade_fee_close)
      grind_3_current_grind_stake_profit = grind_3_total_cost - grind_3_current_grind_stake
    if grind_4_sub_grind_count > 0:
      grind_4_current_open_rate = grind_4_total_cost / grind_4_total_amount
      grind_4_current_grind_stake = grind_4_total_amount * exit_rate * (1 + trade_fee_close)
      grind_4_current_grind_stake_profit = grind_4_total_cost - grind_4_current_grind_stake
    if grind_5_sub_grind_count > 0:
      grind_5_current_open_rate = grind_5_total_cost / grind_5_total_amount
      grind_5_current_grind_stake = grind_5_total_amount * exit_rate * (1 + trade_fee_close)
      grind_5_current_grind_stake_profit = grind_5_total_cost - grind_5_current_grind_stake
    if grind_6_sub_grind_count > 0:
      grind_6_current_open_rate = grind_6_total_cost / grind_6_total_amount
      grind_6_current_grind_stake = grind_6_total_amount * exit_rate * (1 + trade_fee_close)
      grind_6_current_grind_stake_profit = grind_6_current_grind_stake - grind_6_total_cost

    num_open_grinds = (
      grind_1_sub_grind_count
      + grind_2_sub_grind_count
      + grind_3_sub_grind_count
      + grind_4_sub_grind_count
      + grind_5_sub_grind_count
      + grind_6_sub_grind_count
    )

    is_scalp_mode = all(c in self.short_scalp_mode_tags for c in enter_tags)

    fee_open_rate = trade_fee_open if self.custom_fee_open_rate is None else self.custom_fee_open_rate
    fee_close_rate = trade_fee_close if self.custom_fee_close_rate is None else self.custom_fee_close_rate

    # Sell remaining if partial fill on exit
    if partial_sell:
      order = filled_exits[-1]
      sell_amount = order.safe_remaining * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        send_msg(
          f"Exit (remaining) [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {order.safe_remaining} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        order_tag = "p"
        if has_order_tags:
          if order.ft_order_tag is not None:
            order_tag = order.ft_order_tag
        return -ft_sell_amount, order_tag, is_derisk

    is_short_grind_entry = self.short_grind_entry(last_candle, previous_candle, slice_profit, False)

    # Rebuy
    if (not partial_sell) and (not rebuy_is_sell_found) and (rebuy_sub_grind_count < max_rebuy_sub_grinds):
      if (
        (0 <= rebuy_sub_grind_count < max_rebuy_sub_grinds)
        and (slice_profit_entry < regular_mode_rebuy_sub_thresholds[rebuy_sub_grind_count])
        and (
          (-rebuy_distance_ratio if (rebuy_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_rebuy_sub_thresholds[rebuy_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=12) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_06))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_rebuy_stakes[rebuy_sub_grind_count] / stake_scale_leverage
        if buy_amount > max_stake:
          buy_amount = max_stake
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        send_msg(
          notification_msg(
            "rebuy",
            tag="r",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"Rebuy (r) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        order_tag = "r"
        return buy_amount, order_tag, is_derisk

    # Grinding g1
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_1_sub_grind_count < max_grind_1_sub_grinds):
      if (
        (
          (-grind_1_distance_ratio if (grind_1_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_1_sub_thresholds[grind_1_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_gt_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_gt_0_03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_1_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
          grind_profit_stake = grind_1_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g1",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_1_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g1"
        return buy_amount, order_tag, is_derisk

    if (
      is_futures
      and has_order_tags
      and (not partial_sell)
      and slice_profit > (0.65 / trade_leverage)
      and (grind_1_sub_grind_count < max_grind_1_sub_grinds)
    ):
      buy_amount = slice_amount * regular_mode_grind_1_stakes[grind_1_sub_grind_count] / stake_scale_leverage
      if buy_amount < (min_stake * 1.5):
        buy_amount = min_stake * 1.5
      if buy_amount > max_stake:
        return None, "", is_derisk
      grind_profit = 0.0
      grind_profit_stake = 0.0
      if grind_1_sub_grind_count > 0:
        grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
        grind_profit_stake = grind_1_current_grind_stake_profit
      send_msg(
        notification_msg(
          "grinding-entry",
          tag="g1",
          pair=trade_pair,
          rate=current_rate,
          stake_amount=buy_amount,
          profit_stake=profit_stake,
          profit_ratio=profit_ratio,
          stake_currency=stake_currency,
          grind_profit_stake=grind_1_current_grind_stake_profit,
          grind_profit_pct=grind_profit,
        )
      )
      log.info(
        f"Grinding entry (g1) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_1_current_grind_stake_profit} {stake_currency})"
      )
      order_tag = "g1"
      return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_1_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate
      if grind_profit > (regular_mode_grind_1_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_1_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g1",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_1_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g1"
          for grind_entry_id in grind_1_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_1_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and ((-(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate) < regular_mode_grind_1_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_1_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_1_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_1_current_open_rate) / grind_1_current_open_rate)
            if grind_1_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_1_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_1_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg1"
        for grind_entry_id in grind_1_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g2
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_2_sub_grind_count < max_grind_2_sub_grinds):
      if (
        (
          (-grind_2_distance_ratio if (grind_2_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_2_sub_thresholds[grind_2_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_gt_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_gt_0_03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_2_stakes[grind_2_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_2_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
          grind_profit_stake = grind_2_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g2",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_2_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g2) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_2_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g2"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_2_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate
      if grind_profit > (regular_mode_grind_2_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_2_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g2",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_2_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g2"
          for grind_entry_id in grind_2_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_2_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and ((-(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate) < regular_mode_grind_2_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_2_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_2_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_2_current_open_rate) / grind_2_current_open_rate)
            if grind_2_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg2",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_2_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg2) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_2_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg2"
        for grind_entry_id in grind_2_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g3
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_3_sub_grind_count < max_grind_3_sub_grinds):
      if (
        (
          (-grind_3_distance_ratio if (grind_3_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_3_sub_thresholds[grind_3_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_gt_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_gt_0_03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_3_stakes[grind_3_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_3_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
          grind_profit_stake = grind_3_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g3",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_3_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g3) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_3_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g3"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_3_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate
      if grind_profit > (regular_mode_grind_3_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_3_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g3",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_3_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g3"
          for grind_entry_id in grind_3_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_3_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and ((-(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate) < regular_mode_grind_3_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_3_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_3_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_3_current_open_rate) / grind_3_current_open_rate)
            if grind_3_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg3",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_3_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg3) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_3_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg3"
        for grind_entry_id in grind_3_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g4
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_4_sub_grind_count < max_grind_4_sub_grinds):
      if (
        (
          (-grind_4_distance_ratio if (grind_4_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_4_sub_thresholds[grind_4_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_gt_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_gt_0_03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_4_stakes[grind_4_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_4_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
          grind_profit_stake = grind_4_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g4",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_4_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g4) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_4_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g4"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_4_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate
      if grind_profit > (regular_mode_grind_4_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_4_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g4",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_4_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g4"
          for grind_entry_id in grind_4_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_4_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and ((-(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate) < regular_mode_grind_4_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_4_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_4_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_4_current_open_rate) / grind_4_current_open_rate)
            if grind_4_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg4",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_4_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg4) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_4_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg4"
        for grind_entry_id in grind_4_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g5
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_5_sub_grind_count < max_grind_5_sub_grinds):
      if (
        (
          (-grind_5_distance_ratio if (grind_5_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_5_sub_thresholds[grind_5_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_gt_0_06)
        )
        and ((num_open_grinds == 0) or (slice_profit_gt_0_03))
        and is_short_grind_entry
      ):
        buy_amount = slice_amount * regular_mode_grind_5_stakes[grind_5_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_5_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
          grind_profit_stake = grind_5_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g5",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_5_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g5) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_5_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g5"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_5_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate
      if grind_profit > (regular_mode_grind_5_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_5_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g5",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_5_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g5"
          for grind_entry_id in grind_5_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_5_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and ((-(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate) < regular_mode_grind_5_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_5_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_5_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_5_current_open_rate) / grind_5_current_open_rate)
            if grind_5_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg5",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_5_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg5) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_5_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg5"
        for grind_entry_id in grind_5_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # Grinding g6
    # Grinding entry
    if has_order_tags and (not partial_sell) and (grind_6_sub_grind_count < max_grind_6_sub_grinds):
      if (
        (
          (-grind_6_distance_ratio if (grind_6_sub_grind_count > 0) else profit_init_ratio)
          < (regular_mode_grind_6_sub_thresholds[grind_6_sub_grind_count])
        )
        and (current_time - timedelta(minutes=10) > last_filled_entry.order_filled_utc)
        and ((current_time - timedelta(hours=2) > last_filled_order.order_filled_utc) or (slice_profit_gt_0_02))
        and (
          (num_open_grinds == 0)
          or (current_time - timedelta(hours=6) > last_filled_order.order_filled_utc)
          or (slice_profit_gt_0_06)
        )
        # and ((num_open_grinds == 0) or (slice_profit_gt_0_03))
        and (is_short_grind_entry)
      ):
        buy_amount = slice_amount * regular_mode_grind_6_stakes[grind_6_sub_grind_count] / stake_scale_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount > max_stake:
          return None, "", is_derisk
        grind_profit = 0.0
        grind_profit_stake = 0.0
        if grind_6_sub_grind_count > 0:
          grind_profit = -(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
          grind_profit_stake = grind_6_current_grind_stake_profit
        send_msg(
          notification_msg(
            "grinding-entry",
            tag="g6",
            pair=trade_pair,
            rate=current_rate,
            stake_amount=buy_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_6_current_grind_stake_profit,
            grind_profit_pct=grind_profit,
          )
        )
        log.info(
          f"Grinding entry (g6) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_6_current_grind_stake_profit} {stake_currency})"
        )
        order_tag = "g6"
        return buy_amount, order_tag, is_derisk

    # Grinding Exit
    if has_order_tags and grind_6_sub_grind_count > 0:
      grind_profit = -(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate
      if grind_profit > (regular_mode_grind_6_profit_threshold + fee_open_rate + fee_close_rate):
        sell_amount = grind_6_total_amount * exit_rate / trade_leverage
        if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
          sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
        ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
        if sell_amount > min_stake and ft_sell_amount > min_stake:
          send_msg(
            notification_msg(
              "grinding-exit",
              tag="g6",
              pair=trade_pair,
              rate=exit_rate,
              stake_amount=sell_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=stake_currency,
              grind_profit_stake=grind_profit * sell_amount * trade_leverage,
              grind_profit_pct=grind_profit,
              coin_amount=grind_6_total_amount,
            )
          )
          log.info(
            f"Grinding exit (g6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}% ({grind_profit * sell_amount * trade_leverage} {stake_currency})"
          )
          order_tag = "g6"
          for grind_entry_id in grind_6_buy_orders:
            order_tag += " " + str(grind_entry_id)
          return -ft_sell_amount, order_tag, is_derisk

    # Grind stop
    if (
      (
        (grind_6_sub_grind_count > 0)
        and regular_mode_use_grind_stops
        and ((-(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate) < regular_mode_grind_6_stop_grinds)
      )
      # temporary
      and (is_backtest or trade_open_date >= datetime(2024, 4, 16))
    ):
      sell_amount = grind_6_total_amount * exit_rate / trade_leverage
      if ((current_stake_amount / trade_leverage) - sell_amount) < (min_stake * 1.55):
        sell_amount = (trade_amount * exit_rate / trade_leverage) - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        if grind_6_current_open_rate > 0.0:
          grind_profit = (
            (-(exit_rate - grind_6_current_open_rate) / grind_6_current_open_rate)
            if grind_6_is_sell_found
            else profit_ratio
          )
        send_msg(
          notification_msg(
            "grinding-stop",
            tag="sg6",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
            grind_profit_stake=grind_profit * sell_amount * trade_leverage,
            grind_profit_pct=grind_profit,
            coin_amount=grind_6_total_amount,
          )
        )
        log.info(
          f"Grinding stop exit (sg6) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Coin amount: {grind_6_total_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}% | Grind profit: {(grind_profit * 100.0):.2f}%"
        )
        order_tag = "sg6"
        for grind_entry_id in grind_6_buy_orders:
          order_tag += " " + str(grind_entry_id)
        return -ft_sell_amount, order_tag, is_derisk

    # De-risk
    if (
      self.derisk_enable
      and (
        profit_stake
        < (
          slice_amount
          * (
            (self.regular_mode_derisk_futures if is_futures else self.regular_mode_derisk_spot)
            if (is_backtest or trade_open_date >= datetime(2024, 9, 13))
            else (self.regular_mode_derisk_futures_old if is_futures else self.regular_mode_derisk_spot_old)
          )
          / trade_leverage
        )
      )
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="d",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "d", is_derisk

    # De-risk level 1
    if (
      self.derisk_enable
      and has_order_tags
      and not is_derisk_1
      and (is_backtest or trade_open_date >= datetime(2024, 9, 13))
      and profit_stake
      < (
        slice_amount
        * (
          (self.regular_mode_derisk_1_scalp_mode_futures if is_futures else self.regular_mode_derisk_1_scalp_mode_spot)
          if is_scalp_mode
          else (
            (self.regular_mode_derisk_1_futures if is_futures else self.regular_mode_derisk_1_spot)
            if (is_backtest or trade_open_date >= datetime(2024, 9, 13))
            else (self.regular_mode_derisk_1_futures_old if is_futures else self.regular_mode_derisk_1_spot_old)
          )
        )
        / trade_leverage
      )
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade_stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        send_msg(
          notification_msg(
            "de-risk",
            tag="d1",
            pair=trade_pair,
            rate=exit_rate,
            stake_amount=sell_amount,
            profit_stake=profit_stake,
            profit_ratio=profit_ratio,
            stake_currency=stake_currency,
          )
        )
        log.info(
          f"De-risk (d1) [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        return -ft_sell_amount, "d1", is_derisk

    return None, "", is_derisk

  # Short Rebuy Adjust Trade Position
  # ---------------------------------------------------------------------------------------------
  def short_rebuy_adjust_trade_position(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ) -> Optional[float]:
    # Stake limits and rebuy amounts are margin, before leverage.
    config = self.config

    dp = self.dp
    is_futures_mode = self.is_futures_mode
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_leverage = trade.leverage

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)

    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_entries = trade.nr_of_successful_entries
    count_of_exits = trade.nr_of_successful_exits

    if count_of_entries == 0:
      return None

    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]
    last_filled_entry = filled_entries[-1]

    has_order_tags = hasattr(first_filled_order, "ft_order_tag")

    # The first exit is de-risk (providing the trade is still open)
    # Preserve the existing grind handoff budget after de-risk.
    if (count_of_exits > 0) and (filled_exits[0].ft_order_tag == "derisk_level_3"):
      if len(df) < 2:
        return None
      return self.short_grind_adjust_trade_position_v2(
        trade,
        enter_tags,
        current_time,
        current_rate,
        current_profit,
        min_stake,
        max_stake / trade_leverage,
        current_entry_rate,
        current_exit_rate,
        current_entry_profit,
        current_exit_profit,
      )

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    slice_amount = filled_entries[0].safe_filled * filled_entries[0].safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    if count_of_exits > 0:
      last_filled_exit_price = filled_exits[-1].safe_price
      slice_profit_exit = (exit_rate - last_filled_exit_price) / last_filled_exit_price
    else:
      slice_profit_exit = 0.0

    current_stake_amount = trade_amount * current_rate
    stake_scale_leverage = trade_leverage if is_futures_mode else 1.0

    rebuy_mode_stakes = self.rebuy_mode_stakes_futures if is_futures_mode else self.rebuy_mode_stakes_spot
    max_sub_grinds = len(rebuy_mode_stakes)
    rebuy_mode_sub_thresholds = (
      self.rebuy_mode_thresholds_futures if is_futures_mode else self.rebuy_mode_thresholds_spot
    )
    partial_sell = False
    sub_grind_count = 0
    total_amount = 0.0
    total_cost = 0.0
    current_open_rate = 0.0
    current_grind_stake = 0.0
    current_grind_stake_profit = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "sell") and (order is not first_filled_order):
        sub_grind_count += 1
        total_amount += order.safe_filled
        total_cost += order.safe_filled * order.safe_price
      elif order.ft_order_side == "buy":
        if (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
        break
    if sub_grind_count > 0:
      current_open_rate = total_cost / total_amount
      current_grind_stake = total_amount * exit_rate * (1 - trade.fee_close)
      current_grind_stake_profit = current_grind_stake - total_cost

    if (len(df) >= 2) and (not partial_sell) and (sub_grind_count < max_sub_grinds):
      last_candle = df.iloc[-1]
      previous_candle = df.iloc[-2]
      if (
        (0 <= sub_grind_count < max_sub_grinds) and (-slice_profit_entry < rebuy_mode_sub_thresholds[sub_grind_count])
      ) and (
        (last_candle["RSI_3"] < 90.0)
        and (last_candle["RSI_3_15m"] < 90.0)
        # and (last_candle["RSI_3_1h"] < 90.0)
        # and (last_candle["RSI_3_4h"] < 90.0)
        and (last_candle["RSI_14"] > 60.0)
        and (last_candle["ROC_2"] < 0.0)
        and (last_candle["close"] > (last_candle["EMA_26"] * 1.012))
      ):
        buy_amount = slice_amount * rebuy_mode_stakes[sub_grind_count] / trade_leverage
        if buy_amount < (min_stake * 1.5):
          buy_amount = min_stake * 1.5
        if buy_amount <= max_stake:
          dp.send_msg(
            self.notification_msg(
              "rebuy",
              tag="r",
              pair=trade_pair,
              rate=current_rate,
              stake_amount=buy_amount,
              profit_stake=profit_stake,
              profit_ratio=profit_ratio,
              stake_currency=config["stake_currency"],
            )
          )
          log.info(
            f"Rebuy (r) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
          )
          if has_order_tags:
            return buy_amount, "r"
          else:
            return buy_amount

    if self.derisk_enable and (
      profit_stake
      < (
        slice_amount * (self.rebuy_mode_derisk_futures if is_futures_mode else self.rebuy_mode_derisk_spot)
        # / (trade.leverage if self.is_futures_mode else 1.0)
      )
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade.stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        grind_profit = 0.0
        dp.send_msg(
          f"❌​​ ​**Rebuy De-risk:** `Level 3`\n"
          f"🪙​ **Pair:** `{trade_pair}`\n"
          f"〽️​ **Rate:** `{exit_rate}`\n"
          f"💰 **Stake amount:** `{sell_amount}`\n"
          f"💵​ **Profit (stake):** `{profit_stake}`\n"
          f"💸 **Profit (percent):** `{(profit_ratio * 100.0):.2f}%`"
        )
        log.info(
          f"Rebuy De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount} | Profit (stake): {profit_stake} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        if has_order_tags:
          return -ft_sell_amount, "derisk_level_3"
        else:
          return -ft_sell_amount

    return None

  # Short Rebuy Adjust Trade Position v3
  # ---------------------------------------------------------------------------------------------
  def short_rebuy_adjust_trade_position_v3(
    self,
    trade: Trade,
    enter_tags,
    current_time: datetime,
    current_rate: float,
    current_profit: float,
    min_stake: Optional[float],
    max_stake: float,
    current_entry_rate: float,
    current_exit_rate: float,
    current_entry_profit: float,
    current_exit_profit: float,
    **kwargs,
  ) -> Optional[float]:
    # Stake limits and rebuy amounts are margin, before leverage.
    dp = self.dp
    is_futures_mode = self.is_futures_mode
    config = self.config
    trade_pair = trade.pair
    trade_amount = trade.amount
    trade_leverage = trade.leverage

    # we already waiting for an order to get filled
    if trade.has_open_orders:
      return None

    min_stake = self.correct_min_stake(min_stake, trade_leverage)
    exit_rate = current_rate
    filled_orders, filled_entries, filled_exits, profit_values = self.profit_or_order_snapshot(
      trade, current_time, exit_rate
    )
    count_of_entries = trade.nr_of_successful_entries
    count_of_exits = trade.nr_of_successful_exits

    if count_of_entries == 0:
      return None

    first_filled_order = filled_orders[0]
    last_filled_order = filled_orders[-1]
    last_filled_entry = filled_entries[-1]

    has_order_tags = hasattr(first_filled_order, "ft_order_tag")

    # The first exit is de-risk (providing the trade is still open)
    # Preserve the existing grind handoff budget after de-risk.
    if (count_of_exits > 0) and (filled_exits[0].ft_order_tag == "derisk_level_3"):
      return self.short_grind_adjust_trade_position_v3(
        trade,
        enter_tags,
        current_time,
        current_rate,
        current_profit,
        min_stake,
        max_stake / trade_leverage,
        current_entry_rate,
        current_exit_rate,
        current_entry_profit,
        current_exit_profit,
      )

    if dp.runmode.value in ("live", "dry_run"):
      ticker = dp.ticker(trade_pair)
      if ("bid" in ticker) and ("ask" in ticker):
        exit_price_side = config["exit_pricing"]["price_side"]
        if trade.is_short:
          if exit_price_side in ["ask", "other"]:
            if ticker["ask"] is not None:
              exit_rate = ticker["ask"]
        else:
          if exit_price_side in ["bid", "other"]:
            if ticker["bid"] is not None:
              exit_rate = ticker["bid"]

    if profit_values is None:
      profit_values = self.calc_total_profit(trade, filled_entries, filled_exits, exit_rate)
    profit_stake, profit_ratio, profit_current_stake_ratio, profit_init_ratio = profit_values

    slice_amount = filled_entries[0].safe_filled * filled_entries[0].safe_price
    slice_profit = (exit_rate - last_filled_order.safe_price) / last_filled_order.safe_price
    slice_profit_entry = (exit_rate - last_filled_entry.safe_price) / last_filled_entry.safe_price
    slice_profit_exit = (
      ((exit_rate - filled_exits[-1].safe_price) / filled_exits[-1].safe_price) if count_of_exits > 0 else 0.0
    )

    current_stake_amount = trade_amount * current_rate
    stake_scale_leverage = trade_leverage if is_futures_mode else 1.0

    if is_futures_mode:
      rebuy_mode_stakes = self.system_v3_rebuy_mode_stakes_futures
      rebuy_mode_sub_thresholds = self.system_v3_rebuy_mode_thresholds_futures
    else:
      rebuy_mode_stakes = self.system_v3_rebuy_mode_stakes_spot
      rebuy_mode_sub_thresholds = self.system_v3_rebuy_mode_thresholds_spot
    max_sub_grinds = len(rebuy_mode_stakes)
    partial_sell = False
    sub_grind_count = 0
    total_amount = 0.0
    total_cost = 0.0
    current_open_rate = 0.0
    current_grind_stake = 0.0
    current_grind_stake_profit = 0.0
    for order in reversed(filled_orders):
      if (order.ft_order_side == "sell") and (order is not first_filled_order):
        sub_grind_count += 1
        total_amount += order.safe_filled
        total_cost += order.safe_filled * order.safe_price
      elif order.ft_order_side == "buy":
        if (order.safe_remaining * exit_rate / stake_scale_leverage) > min_stake:
          partial_sell = True
        break
    if sub_grind_count > 0:
      current_open_rate = total_cost / total_amount
      current_grind_stake = total_amount * exit_rate * (1 - trade.fee_close)
      current_grind_stake_profit = current_grind_stake - total_cost
    if (not partial_sell) and (sub_grind_count < max_sub_grinds):
      df, _ = dp.get_analyzed_dataframe(trade_pair, self.timeframe)
      if len(df) >= 1:
        last_candle = df.iloc[-1]
        if (
          (
            (0 <= sub_grind_count < max_sub_grinds)
            and (-slice_profit_entry < rebuy_mode_sub_thresholds[sub_grind_count])
          )
          and (last_candle["protections_short_global"] == True)
          and (
            (last_candle["RSI_3"] < 90.0)
            and (last_candle["RSI_3_15m"] < 90.0)
            and (last_candle["AROOND_14"] < 30.0)
            and (last_candle["AROOND_14_15m"] < 30.0)
            and (last_candle["close"] < (last_candle["EMA_26"] * 1.012))
          )
        ):
          buy_amount = slice_amount * rebuy_mode_stakes[sub_grind_count] / trade_leverage
          if buy_amount < (min_stake * 1.5):
            buy_amount = min_stake * 1.5
          if buy_amount <= max_stake:
            stake_currency = config["stake_currency"]
            stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
            send_notifications = not self.is_backtest_mode()
            if send_notifications:
              dp.send_msg(
                self.notification_msg(
                  "rebuy",
                  tag="r",
                  pair=trade_pair,
                  rate=current_rate,
                  stake_amount=buy_amount,
                  profit_stake=profit_stake,
                  profit_ratio=profit_ratio,
                  stake_currency=stake_currency,
                )
              )
            log.info(
              f"Rebuy (r) [{current_time}] [{trade_pair}] | Rate: {current_rate} | Stake amount: {buy_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
            )
            if has_order_tags:
              return buy_amount, "r"
            else:
              return buy_amount

    if self.derisk_enable and (
      profit_stake
      < (
        slice_amount
        * (self.system_v3_rebuy_mode_derisk_futures if is_futures_mode else self.system_v3_rebuy_mode_derisk_spot)
      )
      / trade_leverage
    ):
      sell_amount = trade_amount * exit_rate / trade_leverage - (min_stake * 1.55)
      ft_sell_amount = sell_amount * trade_leverage * (trade.stake_amount / trade_amount) / exit_rate
      if sell_amount > min_stake and ft_sell_amount > min_stake:
        stake_currency = config["stake_currency"]
        stake_fmt = ".8f" if stake_currency in ("BTC", "ETH", "BNB", "SOL") else ".3f"
        send_notifications = not self.is_backtest_mode()
        grind_profit = 0.0
        if send_notifications:
          dp.send_msg(
            f"❌​​ ​**Rebuy De-risk:** `Level 3`\n"
            f"🪙​ **Pair:** `{trade_pair}`\n"
            f"〽️​ **Rate:** `{exit_rate}`\n"
            f"💰 **Stake amount:** `{sell_amount:{stake_fmt}}`\n"
            f"💵​ **Profit (stake):** `{profit_stake:{stake_fmt}}`\n"
            f"💸 **Profit (percent):** `{(profit_ratio * 100.0):.2f}%`"
          )
        log.info(
          f"Rebuy De-risk Level 3 [{current_time}] [{trade_pair}] | Rate: {exit_rate} | Stake amount: {sell_amount:{stake_fmt}} | Profit (stake): {profit_stake:{stake_fmt}} | Profit: {(profit_ratio * 100.0):.2f}%"
        )
        if has_order_tags:
          return -ft_sell_amount, "derisk_level_3"
        else:
          return -ft_sell_amount

    return None

  ###############################################################################################

  # SHORT GRIND FUNCTIONS ENDS HERE

  ###############################################################################################


# +---------------------------------------------------------------------------+
# |                              Custom Indicators                            |
# +---------------------------------------------------------------------------+


# Range midpoint acts as Support
# ---------------------------------------------------------------------------------------------
def is_support(row_data) -> bool:
  conditions = []
  for row in range(len(row_data) - 1):
    if row < len(row_data) // 2:
      conditions.append(row_data[row] > row_data[row + 1])
    else:
      conditions.append(row_data[row] < row_data[row + 1])
  result = reduce(lambda x, y: x & y, conditions)
  return result


# Range midpoint acts as Resistance
# ---------------------------------------------------------------------------------------------
def is_resistance(row_data) -> bool:
  conditions = []
  for row in range(len(row_data) - 1):
    if row < len(row_data) // 2:
      conditions.append(row_data[row] < row_data[row + 1])
    else:
      conditions.append(row_data[row] > row_data[row + 1])
  result = reduce(lambda x, y: x & y, conditions)
  return result


# Elliot Wave Oscillator
# ---------------------------------------------------------------------------------------------
def ewo(df, ema1_length=5, ema2_length=35):
  ema1 = ta.EMA(df, timeperiod=ema1_length)
  ema2 = ta.EMA(df, timeperiod=ema2_length)
  emadiff = (ema1 - ema2) / df["close"] * 100.0
  return emadiff


# Pivot Points - 3 variants - daily recommended
# ---------------------------------------------------------------------------------------------
def pivot_points(df: DataFrame, mode="fibonacci") -> Series:
  df_high = df["high"]
  df_low = df["low"]
  df_close = df["close"]
  df_open = df["open"]

  if mode == "simple":
    hlc3_pivot = (df_high + df_low + df_close).shift(1) / 3
    res1 = hlc3_pivot * 2 - df_low.shift(1)
    sup1 = hlc3_pivot * 2 - df_high.shift(1)
    high_low_range = df_high - df_low
    res2 = hlc3_pivot + high_low_range.shift()
    sup2 = hlc3_pivot - high_low_range.shift()
    res3 = hlc3_pivot * 2 + (df_high - 2 * df_low).shift()
    sup3 = hlc3_pivot * 2 - (2 * df_high - df_low).shift()
    return hlc3_pivot, res1, res2, res3, sup1, sup2, sup3
  elif mode == "fibonacci":
    hlc3_pivot = (df_high + df_low + df_close).shift(1) / 3
    hl_range = (df_high - df_low).shift(1)
    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
  elif mode == "DeMark":
    demark_pivot_lt = df_low * 2 + df_high + df_close
    demark_pivot_eq = df_close * 2 + df_low + df_high
    demark_pivot_gt = df_high * 2 + df_low + df_close
    demark_pivot = np.where(
      (df_close < df_open),
      demark_pivot_lt,
      np.where((df_close > df_open), demark_pivot_gt, demark_pivot_eq),
    )
    dm_pivot = demark_pivot / 4
    dm_res = demark_pivot / 2 - df_low
    dm_sup = demark_pivot / 2 - df_high
    return dm_pivot, dm_res, dm_sup


# Heikin Ashi candles
# ---------------------------------------------------------------------------------------------
def heikin_ashi(df, smooth_inputs=False, smooth_outputs=False, length=10):
  df = df[["open", "close", "high", "low"]].copy().fillna(0)
  df_open = df["open"]
  df_high = df["high"]
  df_low = df["low"]
  df_close = df["close"]

  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)

    df_open_s = df["open_s"]
    df_high_s = df["high_s"]
    df_low_s = df["low_s"]
    df_close_s = df["close_s"]

    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


# Peak Percentage Change
# ---------------------------------------------------------------------------------------------
def range_percent_change(self, df: DataFrame, method, length: int) -> float:
  """
  Rolling Percentage Change Maximum across interval.

  :param df: DataFrame The original OHLC df
  :param method: High to Low / Open to Close
  :param length: int The length to look back
  """
  df_high = df["high"]
  df_low = df["low"]
  df_open = df["open"]
  df_close = df["close"]

  if method == "HL":
    low_min = df_low.rolling(length).min()
    return (df_high.rolling(length).max() - low_min) / low_min
  elif method == "OC":
    close_min = df_close.rolling(length).min()
    return (df_open.rolling(length).max() - close_min) / close_min
  else:
    raise ValueError(f"Method {method} not defined!")


# Percentage distance to top peak
# ---------------------------------------------------------------------------------------------
def top_percent_change(self, df: DataFrame, length: int) -> float:
  """
  Percentage change of the current close from the range maximum Open price

  :param df: DataFrame The original OHLC df
  :param length: int The length to look back
  """
  df_open = df["open"]
  df_close = df["close"]

  if length == 0:
    return (df_open - df_close) / df_close
  else:
    return (df_open.rolling(length).max() - df_close) / df_close


def _is_entry_bool_scalar(condition) -> bool:
  return isinstance(condition, (bool, np.bool_))


def _entry_bool_array(condition):
  if isinstance(condition, np.ndarray):
    return condition.astype(bool, copy=False)
  if isinstance(condition, (pd.Series, pd.Index)):
    return condition.to_numpy(dtype=bool, copy=False)
  return np.asarray(condition, dtype=bool)


def _and_entry_conditions(conditions):
  arrays = []
  has_false = False
  for condition in conditions:
    if _is_entry_bool_scalar(condition):
      if not condition:
        has_false = True
      continue
    arrays.append(_entry_bool_array(condition))
  if not arrays:
    return not has_false
  if has_false:
    return np.zeros_like(arrays[0], dtype=bool)
  if len(arrays) == 1:
    return arrays[0]
  return np.logical_and.reduce(arrays)


def _or_entry_conditions(conditions):
  arrays = []
  has_true = False
  for condition in conditions:
    if _is_entry_bool_scalar(condition):
      if condition:
        has_true = True
      continue
    arrays.append(_entry_bool_array(condition))
  if not arrays:
    return has_true
  if has_true:
    return np.ones_like(arrays[0], dtype=bool)
  if len(arrays) == 1:
    return arrays[0]
  return np.logical_or.reduce(arrays)


def _append_entry_tag(entry_tags, mask, tag: str) -> None:
  if _is_entry_bool_scalar(mask):
    if mask:
      entry_tags[:] = entry_tags + tag
    return
  entry_tags[mask] = entry_tags[mask] + tag


# +---------------------------------------------------------------------------+
# |                              Classes                                      |
# +---------------------------------------------------------------------------+


# Cache Class
# ---------------------------------------------------------------------------------------------
class Cache:
  def __init__(self, path):
    self.path = path
    self.data = {}
    self._mtime = None
    self._previous_data = {}
    try:
      self.load()
    except FileNotFoundError:
      pass

  @staticmethod
  def rapidjson_load_kwargs():
    return {"number_mode": rapidjson.NM_NATIVE, "parse_mode": rapidjson.PM_COMMENTS | rapidjson.PM_TRAILING_COMMAS}

  @staticmethod
  def rapidjson_dump_kwargs():
    return {"number_mode": rapidjson.NM_NATIVE}

  def load(self):
    if not self._mtime or self.path.stat().st_mtime_ns != self._mtime:
      self._load()

  def save(self):
    if self.data != self._previous_data:
      self._save()

  def process_loaded_data(self, data):
    return data

  def _load(self):
    # This method only exists to simplify unit testing
    cache_path = self.path
    rapidjson_load_kwargs = self.rapidjson_load_kwargs
    process_loaded_data = self.process_loaded_data

    with cache_path.open("r") as rfh:
      try:
        data = rapidjson.load(rfh, **rapidjson_load_kwargs())
      except rapidjson.JSONDecodeError as exc:
        log.error("Failed to load JSON from %s: %s", cache_path, exc)
      else:
        self.data = process_loaded_data(data)
        self._previous_data = copy.deepcopy(self.data)
        self._mtime = cache_path.stat().st_mtime_ns

  def _save(self):
    # This method only exists to simplify unit testing
    cache_path = self.path
    cache_data = self.data
    rapidjson_dump_kwargs = self.rapidjson_dump_kwargs

    rapidjson.dump(cache_data, cache_path.open("w"), **rapidjson_dump_kwargs())
    self._mtime = cache_path.stat().st_mtime
    self._previous_data = copy.deepcopy(cache_data)


class HoldsCache(Cache):
  @staticmethod
  def rapidjson_load_kwargs():
    return {
      "number_mode": rapidjson.NM_NATIVE,
      "parse_mode": rapidjson.PM_COMMENTS | rapidjson.PM_TRAILING_COMMAS,
      "object_hook": HoldsCache._object_hook,
    }

  @staticmethod
  def rapidjson_dump_kwargs():
    return {
      "number_mode": rapidjson.NM_NATIVE,
      "mapping_mode": rapidjson.MM_COERCE_KEYS_TO_STRINGS,
    }

  def save(self):
    raise RuntimeError("The holds cache does not allow programatical save")

  def process_loaded_data(self, data):
    cache_path = self.path

    trade_ids = data.get("trade_ids")
    trade_pairs = data.get("trade_pairs")

    if not trade_ids and not trade_pairs:
      return data

    open_trades = {}
    for trade in Trade.get_trades_proxy(is_open=True):
      open_trades[trade.id] = open_trades[trade.pair] = trade

    r_trade_ids = {}
    if trade_ids:
      if isinstance(trade_ids, dict):
        # New syntax
        for trade_id, profit_ratio in trade_ids.items():
          if not isinstance(trade_id, int):
            log.error("The trade_id(%s) defined under 'trade_ids' in %s is not an integer", trade_id, cache_path)
            continue
          if not isinstance(profit_ratio, float):
            log.error(
              "The 'profit_ratio' config value(%s) for trade_id %s in %s is not a float",
              profit_ratio,
              trade_id,
              cache_path,
            )
          if trade_id in open_trades:
            formatted_profit_ratio = f"{profit_ratio * 100}%"
            log.warning(
              "The trade %s is configured to HOLD until the profit ratio of %s is met",
              open_trades[trade_id],
              formatted_profit_ratio,
            )
            r_trade_ids[trade_id] = profit_ratio
          else:
            log.warning(
              "The trade_id(%s) is no longer open. Please remove it from 'trade_ids' in %s",
              trade_id,
              cache_path,
            )
      else:
        # Initial Syntax
        profit_ratio = data.get("profit_ratio")
        if profit_ratio:
          if not isinstance(profit_ratio, float):
            log.error("The 'profit_ratio' config value(%s) in %s is not a float", profit_ratio, cache_path)
        else:
          profit_ratio = 0.005
        formatted_profit_ratio = f"{profit_ratio * 100}%"
        for trade_id in trade_ids:
          if not isinstance(trade_id, int):
            log.error("The trade_id(%s) defined under 'trade_ids' in %s is not an integer", trade_id, cache_path)
            continue
          if trade_id in open_trades:
            log.warning(
              "The trade %s is configured to HOLD until the profit ratio of %s is met",
              open_trades[trade_id],
              formatted_profit_ratio,
            )
            r_trade_ids[trade_id] = profit_ratio
          else:
            log.warning(
              "The trade_id(%s) is no longer open. Please remove it from 'trade_ids' in %s",
              trade_id,
              cache_path,
            )

    r_trade_pairs = {}
    if trade_pairs:
      for trade_pair, profit_ratio in trade_pairs.items():
        if not isinstance(trade_pair, str):
          log.error("The trade_pair(%s) defined under 'trade_pairs' in %s is not a string", trade_pair, cache_path)
          continue
        if "/" not in trade_pair:
          log.error(
            "The trade_pair(%s) defined under 'trade_pairs' in %s does not look like "
            "a valid '<TOKEN_NAME>/<STAKE_CURRENCY>' formatted pair.",
            trade_pair,
            cache_path,
          )
          continue
        if not isinstance(profit_ratio, float):
          log.error(
            "The 'profit_ratio' config value(%s) for trade_pair %s in %s is not a float",
            profit_ratio,
            trade_pair,
            cache_path,
          )
        formatted_profit_ratio = f"{profit_ratio * 100}%"
        if trade_pair in open_trades:
          log.warning(
            "The trade %s is configured to HOLD until the profit ratio of %s is met",
            open_trades[trade_pair],
            formatted_profit_ratio,
          )
        else:
          log.warning(
            "The trade pair %s is configured to HOLD until the profit ratio of %s is met",
            trade_pair,
            formatted_profit_ratio,
          )
        r_trade_pairs[trade_pair] = profit_ratio

    r_data = {}
    if r_trade_ids:
      r_data["trade_ids"] = r_trade_ids
    if r_trade_pairs:
      r_data["trade_pairs"] = r_trade_pairs
    return r_data

  @staticmethod
  def _object_hook(data):
    _data = {}
    for key, value in data.items():
      try:
        key = int(key)
      except ValueError:
        pass
      _data[key] = value
    return _data
