💬 Forum

BasicFuturesStrategy

🏆 League #878 / 1939

markelayan/hhec-dois-bull-manager/1strategies1/backtest/TestDeployedStrategy.py · first seen 2026-07-16 · repo updated 2025-08-10 · ⬇ 1 download

Basics mode: futures timeframe: 1h interface version: 3
Settings stoploss: -0.02 has minimal roi
Indicators Bollinger_Bands MACD RSI talib
15 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
"""
Basic Futures Strategy Template
"""
import talib.abstract as ta
from freqtrade.strategy import IStrategy, informative
from pandas import DataFrame


class BasicFuturesStrategy(IStrategy):
    """
    Basic futures trading strategy template
    """
    
    # Strategy settings
    INTERFACE_VERSION = 3
    can_short = True
    
    # ROI table
    minimal_roi = {
        "0": 0.05,
        "30": 0.03,
        "60": 0.01,
        "120": 0
    }
    
    # Stoploss
    stoploss = -0.02
    
    # Timeframe
    timeframe = '1h'
    
    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Populate indicators
        """
        # RSI
        dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
        
        # MACD
        macd = ta.MACD(dataframe)
        dataframe['macd'] = macd['macd']
        dataframe['macdsignal'] = macd['macdsignal']
        dataframe['macdhist'] = macd['macdhist']
        
        # Bollinger Bands
        bollinger = ta.BBANDS(dataframe, timeperiod=20)
        dataframe['bb_lowerband'] = bollinger['lowerband']
        dataframe['bb_middleband'] = bollinger['middleband']
        dataframe['bb_upperband'] = bollinger['upperband']
        
        return dataframe
    
    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Entry trend logic
        """
        # Long entry conditions
        dataframe.loc[
            (
                (dataframe['rsi'] < 30) &
                (dataframe['macd'] > dataframe['macdsignal']) &
                (dataframe['close'] < dataframe['bb_lowerband'])
            ),
            'enter_long'] = 1
        
        # Short entry conditions (for futures)
        dataframe.loc[
            (
                (dataframe['rsi'] > 70) &
                (dataframe['macd'] < dataframe['macdsignal']) &
                (dataframe['close'] > dataframe['bb_upperband'])
            ),
            'enter_short'] = 1
        
        return dataframe
    
    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        """
        Exit trend logic
        """
        # Long exit conditions
        dataframe.loc[
            (
                (dataframe['rsi'] > 70) |
                (dataframe['macd'] < dataframe['macdsignal'])
            ),
            'exit_long'] = 1
        
        # Short exit conditions
        dataframe.loc[
            (
                (dataframe['rsi'] < 30) |
                (dataframe['macd'] > dataframe['macdsignal'])
            ),
            'exit_short'] = 1
        
        return dataframe