💬 Forum

TestStrat_1781099171

🏆 League #1127 / 1962

4tie/fortiesr/user_data/strategies/TestStrat_1781099171.py · first seen 2026-07-16 · repo updated 2026-07-09 · ⬇ 1 download

Basics mode: spot timeframe: 5m interface version: 3
Settings stoploss: -0.05 has minimal roi hyperopt hyperopt params: 1
Indicators Bollinger_Bands MACD RSI talib
7 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 →

 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
# Auto-generated by Strategy Lab — Auto-Quant Factory
# Entry logic is controlled by the CategoricalParameter `entry_logic`.
# Optimise it with: freqtrade hyperopt --strategy TestStrat_1781099171 --spaces buy

from freqtrade.strategy import CategoricalParameter, IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib


class TestStrat_1781099171(IStrategy):
    INTERFACE_VERSION: int = 3

    # --- ROI / stoploss / timeframe defaults ----------------------------
    minimal_roi = {
        "0": 0.10,
        "30": 0.05,
        "60": 0.02,
        "120": 0,
    }

    stoploss = -0.05
    timeframe = "5m"

    trailing_stop = False

    # --- Categorical entry-logic selector --------------------------------
    # Hyperopt will search this space when --spaces buy is used.
    entry_logic = CategoricalParameter(
        ["macd_cross", "rsi_oversold", "bb_breakout"],
        default="macd_cross",
        space="buy",
        optimize=True,
    )

    # --- Indicator computation -------------------------------------------

    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        # MACD (fast=12, slow=26, signal=9)
        macd = ta.MACD(dataframe, fastperiod=12, slowperiod=26, signalperiod=9)
        dataframe["macd"] = macd["macd"]
        dataframe["macdsignal"] = macd["macdsignal"]
        dataframe["macdhist"] = macd["macdhist"]

        # RSI (period=14)
        dataframe["rsi"] = ta.RSI(dataframe, timeperiod=14)

        # Bollinger Bands (period=20, stddev=2)
        bollinger = qtpylib.bollinger_bands(
            qtpylib.typical_price(dataframe), window=20, stds=2
        )
        dataframe["bb_lowerband"] = bollinger["lower"]
        dataframe["bb_middleband"] = bollinger["mid"]
        dataframe["bb_upperband"] = bollinger["upper"]

        return dataframe

    # --- Entry logic router ----------------------------------------------

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        logic = self.entry_logic.value

        if logic == "macd_cross":
            dataframe.loc[
                (
                    qtpylib.crossed_above(dataframe["macd"], dataframe["macdsignal"])
                    & (dataframe["volume"] > 0)
                ),
                "enter_long",
            ] = 1

        elif logic == "rsi_oversold":
            dataframe.loc[
                (
                    (dataframe["rsi"] < 30)
                    & (dataframe["volume"] > 0)
                ),
                "enter_long",
            ] = 1

        elif logic == "bb_breakout":
            dataframe.loc[
                (
                    (dataframe["close"] < dataframe["bb_lowerband"])
                    & (dataframe["volume"] > 0)
                ),
                "enter_long",
            ] = 1

        return dataframe

    # --- Exit logic stub (relies on ROI / stoploss) ----------------------

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        return dataframe