💬 Forum

hansencandlepatternV1

🏆 League #1894 / 1922

Ysertysert2/freqtrade-strategies/strategies/hansencandlepatternV1/hansencandlepatternV1.py · ★3 · ⑂2 · first seen 2026-07-24 · repo updated 2025-09-23

Basics mode: spot timeframe: 1h interface version: 3
Settings stoploss: -0.1 has minimal roi
Indicators SMA talib
8 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
# --- Do not remove these libs --- freqtrade backtesting --strategy SmoothScalp --timerange 20210110-20210410
from freqtrade.strategy.interface import IStrategy
from typing import Dict, List
from functools import reduce
from pandas import DataFrame
# --------------------------------
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
from typing import Dict, List
from functools import reduce
from pandas import DataFrame, DatetimeIndex, merge
# --------------------------------
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
import numpy  # noqa


class hansencandlepatternV1(IStrategy):
    INTERFACE_VERSION = 3
    """
        This strategy is only an experiment using candlestick pattern to be used as buy or sell indicator. Do not use this strategy live.
    """

    timeframe = '1h'
    minimal_roi = {
        "0": 10,
    }
    stoploss = -0.1
    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:   
        dataframe['3LINESTRIKE'] = ta.CDL3LINESTRIKE(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close'])
        dataframe['EVENINGSTAR'] = ta.CDLEVENINGSTAR(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close'])
        dataframe['ABANDONEDBABY'] = ta.CDLEVENINGSTAR(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close'])
        dataframe['HARAMI'] = ta.CDLHARAMI(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close'])
        dataframe['INVERTEDHAMMER'] = ta.CDLINVERTEDHAMMER(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close'])
        dataframe['ENGULFING'] = ta.CDLENGULFING(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close'])
        dataframe['hclose']=(dataframe['open'] + dataframe['high'] + dataframe['low'] + dataframe['close']) / 4
        dataframe['hopen']= ((dataframe['open'].shift(2) + dataframe['close'].shift(2))/ 2)
        dataframe['hhigh']=dataframe[['open','close','high']].max(axis=1)
        dataframe['hlow']=dataframe[['open','close','low']].min(axis=1)
        dataframe['emac'] = ta.SMA(dataframe['hclose'], timeperiod=6)
        dataframe['emao'] = ta.SMA(dataframe['hopen'], timeperiod=6)
        return dataframe
        

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                ((dataframe['3LINESTRIKE'] < 0)|(dataframe['EVENINGSTAR'] > 0)|(dataframe['ABANDONEDBABY'] > 0)|(dataframe['HARAMI'] > 0)|(dataframe['ENGULFING'] > 0))&
                (dataframe['emao'] < dataframe['emac'])
                
            ),
            'buy'] = 1
        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe['emao'] > dataframe['emac'])
            ),
            'sell'] = 1
        return dataframe