Skip to content
All library documents

Daily Candlestick Pattern Recognition Entries with Freqtrade

Article Strategy library · Author: freqtrade

Summary

This Freqtrade strategy calculates the full set of TA-Lib candlestick pattern recognition indicators on daily candles, then uses a configurable pattern and signal value as its long-entry condition. The published configuration selects the high-wave pattern and a bearish signal value. There is no active exit rule in the strategy code; position management instead relies on a return-on-investment schedule, a fixed stop, and a trailing stop. The document also reports one hyperparameter-search result, including trade counts, average and median returns, total return, and average holding time.

That result is presented as a single optimization outcome, not as independent validation. The entry is based on matching one pattern output to a chosen value, and the code does not add market, volatility, or trend filters. The reported performance therefore does not establish robustness across assets or periods. Daily signals and multi-day holds also mean the approach is not designed for intraday execution.

Key ideas

  • The strategy computes TA-Lib candlestick pattern indicators on daily market data.
  • A selected pattern and output value trigger long entries.
  • The published configuration uses the high-wave pattern with a bearish signal value.
  • No explicit exit signal is implemented; ROI, stop-loss, and trailing-stop settings manage exits.
  • The reported optimization result is a single run and does not demonstrate out-of-sample robustness.

Tags

Full text
# PatternRecognition


# PatternRecognition









## Source (GPL-3.0)

```python
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# flake8: noqa: F401

# --- Do not remove these libs ---
import numpy as np  # noqa
import pandas as pd  # noqa
from pandas import DataFrame

from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter,
                                IStrategy, IntParameter)

# --------------------------------
# Add your lib to import here
import talib
import talib.abstract as ta
import pandas_ta as pta
import freqtrade.vendor.qtpylib.indicators as qtpylib
from technical.util import resample_to_interval, resampled_merge


class PatternRecognition(IStrategy):
    # Pattern Recognition Strategy
    # By: @Mablue
    # freqtrade hyperopt -s PatternRecognition --hyperopt-loss SharpeHyperOptLossDaily -e 1000
    #

    # 173/1000:    510 trades. 408/14/88 Wins/Draws/Losses. Avg profit   2.35%. Median profit   5.60%. Total profit 5421.34509618 USDT ( 542.13%). Avg duration 7 days, 11:54:00 min. Objective: -1.60426


    INTERFACE_VERSION: int = 3
    # Buy hyperspace params:
    buy_params = {
        "buy_pr1": "CDLHIGHWAVE",
        "buy_vol1": -100,
    }

    # ROI table:
    minimal_roi = {
        "0": 0.936,
        "5271": 0.332,
        "18147": 0.086,
        "48152": 0
    }

    # Stoploss:
    stoploss = -0.288

    # Trailing stop:
    trailing_stop = True
    trailing_stop_positive = 0.032
    trailing_stop_positive_offset = 0.084
    trailing_only_offset_is_reached = True

    # Optimal timeframe for the strategy.
    timeframe = '1d'
    prs = talib.get_function_groups()['Pattern Recognition']

    # # Strategy parameters
    buy_pr1 = CategoricalParameter(prs, default=prs[0], space="buy")
    buy_vol1 = CategoricalParameter([-100,100], default=0, space="buy")



    def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        for pr in self.prs:
            dataframe[pr] = getattr(ta, pr)(dataframe)

        return dataframe

    def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
                (dataframe[self.buy_pr1.value]==self.buy_vol1.value)
                # |(dataframe[self.buy_pr2.value]==self.buy_vol2.value)
            ),
            'enter_long'] = 1

        return dataframe

    def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
        dataframe.loc[
            (
            #     (dataframe[self.sell_pr1.value]==self.sell_vol1.value)|
            #     (dataframe[self.sell_pr2.value]==self.sell_vol2.value)
            ),
            'exit_long'] = 1

        return dataframe

```

Shown in full with attribution under the source's licence. Licence: GPL-3.0

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.