💬 Forum

LiquidationHuntStrategy

uploads/LiquidationHuntStrategy.py · uploaded by 🐋 Ron · first seen 2026-07-18 · ⬇ 1 download

Basics mode: spot timeframe: 15m interface version: 3
Settings stoploss: -0.02 has minimal roi trailing process only new candles startup candle count: 100
Indicators Bollinger_Bands EMA RSI Stochastic talib
Concepts mean_reversion trailing
Methods leverage
13 related strategies ( identical code, similar name)

Each tile is a different kind of check — from an instant code lint to full sandboxed backtests and forward tests on recent data. Not sure what a check actually proves? See the FAQ →

Source

Download Raw
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# flake8: noqa: F401

import pandas as pd
from pandas import DataFrame
from typing import Optional
from freqtrade.strategy import IStrategy, DecimalParameter, IntParameter
import talib.abstract as ta


class LiquidationHuntStrategy(IStrategy):
    """
    Liquidation Hunt Strategy - Fixed version
    """
    
    INTERFACE_VERSION = 3
    timeframe = "15m"
    can_short = False

    # ROI configuration
    minimal_roi = {
        "0": 0.02,
        "30": 0.015,
        "60": 0.01,
        "120": 0.005
    }

    # Stoploss
    stoploss = -0.02

    # Trailing stop
    trailing_stop = True
    trailing_only_offset_is_reached = True
    trailing_stop_positive = 0.01
    trailing_stop_positive_offset = 0.02

    process_only_new_candles = True
    use_exit_signal = True
    exit_profit_only = False
    ignore_roi_if_entry_signal = False
    startup_candle_count = 100

    order_types = {
        "entry": "limit",
        "exit": "limit",
        "stoploss": "market",
        "stoploss_on_exchange": False
    }

    order_time_in_force = {
        "entry": "GTC",
        "exit": "GTC"
    }

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        # Volume analysis
        dataframe['volume_mean'] = dataframe['volume'].rolling(window=20).mean()
        dataframe['volume_ratio'] = dataframe['volume'] / dataframe['volume_mean']
        
        # Price movements
        dataframe['price_change_3'] = (dataframe['close'] - dataframe['close'].shift(3)) / dataframe['close'].shift(3) * 100
        dataframe['price_change_6'] = (dataframe['close'] - dataframe['close'].shift(6)) / dataframe['close'].shift(6) * 100
        
        # Recovery detection
        dataframe['recovery_signal'] = (
            (dataframe['close'] > dataframe['open']) &  # Green candle
            (dataframe['close'] > dataframe['close'].shift(1))  # Higher than previous close
        )
        
        # RSI
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        dataframe['rsi_7'] = ta.RSI(dataframe, timeperiod=7)
        
        # Bollinger Bands
        bb = ta.BBANDS(dataframe, timeperiod=20, nbdevup=2, nbdevdn=2)
        dataframe['bb_lower'] = bb['lowerband']
        dataframe['bb_upper'] = bb['upperband']
        
        # EMA for trend
        dataframe['ema_50'] = ta.EMA(dataframe, timeperiod=50)
        
        # Stochastic
        stoch = ta.STOCH(dataframe, fastk_period=14, slowk_period=3, slowd_period=3)
        dataframe['stoch_k'] = stoch['slowk']
        dataframe['stoch_d'] = stoch['slowd']
        
        # Candle patterns
        dataframe['lower_wick'] = (dataframe[['open', 'close']].min(axis=1) - dataframe['low']) / dataframe['close'] * 100
        
        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Wait for recovery confirmation after drop
        """
        dataframe.loc[
            (
                # Price drop condition
                (dataframe['price_change_3'] < -1.5) &
                (dataframe['price_change_6'] < -2.5) &
                
                # Volume spike
                (dataframe['volume_ratio'] > 2.0) &
                
                # Oversold but not extreme
                (dataframe['rsi'] < 30) &
                (dataframe['rsi'] > 15) &
                (dataframe['stoch_k'] < 25) &
                
                # RECOVERY CONFIRMATION - MOST IMPORTANT
                (dataframe['recovery_signal']) &
                
                # Trend filter
                (dataframe['close'] > dataframe['ema_50'] * 0.9) &
                
                # Bollinger band position
                (dataframe['close'] <= dataframe['bb_lower'] * 1.02) &
                
                # Volume confirmation
                (dataframe['volume'] > 0)
            ),
            'enter_long'
        ] = 1

        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe['rsi'] > 60) |
                (dataframe['close'] >= dataframe['bb_upper'] * 0.98) |
                (dataframe['stoch_k'] > 80)
            ),
            'exit_long'
        ] = 1

        return dataframe

    def leverage(self, pair: str, current_time: pd.Timestamp, current_rate: float,
                 proposed_leverage: float, max_leverage: float, entry_tag: Optional[str], 
                 side: str, **kwargs) -> float:
        return 1.0