HPStrategyV7Ultra
♡
Basics
mode: spot
timeframe: 5m
interface version: 3
Settings
has minimal roi
trailing
process only new candles
startup candle count: 50
Indicators
pandas_ta
talib
Concepts
trailing
15 related strategies (⧉ identical code, ≈ similar name)
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 | import logging import os import sys from functools import reduce import numpy import numpy as np # noqa import pandas as pd # noqa from pandas import DataFrame from typing import Optional, Union, List from pandas_ta import stdev from freqtrade.enums import ExitCheckTuple from freqtrade.persistence import Trade, Order from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter, IStrategy, IntParameter, informative) import datetime import talib.abstract as ta import freqtrade.vendor.qtpylib.indicators as qtpylib import pandas_ta as pta class HPStrategyV7Ultra(IStrategy): INTERFACE_VERSION = 3 timeframe = '5m' leverage_value = 3 stoploss = -0.02 * leverage_value minimal_roi = { "0": 0.01 * leverage_value } process_only_new_candles = True startup_candle_count = 50 position_adjustment_enable = False trailing_stop = True trailing_only_offset_is_reached = False trailing_stop_positive = 0.001 * leverage_value trailing_stop_positive_offset = 0.003 * leverage_value use_exit_signal = True ignore_roi_if_entry_signal = True exit_profit_offset = 0.001 * leverage_value exit_profit_only = True order_types = { 'entry': 'market', 'exit': 'market', 'stoploss': 'market', 'stoploss_on_exchange': False } def calc_donchian_channels(self, dataframe, period: int): dataframe["upperDon"] = dataframe["high"].rolling(period).max() dataframe["lowerDon"] = dataframe["low"].rolling(period).min() dataframe["midDon"] = (dataframe["upperDon"] + dataframe["lowerDon"]) / 2 return dataframe def mid_don_cross_over(self, dataframe, period: int = 20, shorts: bool = True): dataframe["position_m"] = np.nan dataframe["position_m"] = np.where(dataframe["close"] > dataframe["midDon"], 1, dataframe["position_m"]) dataframe["position_m"] = dataframe["position_m"].ffill().fillna(0) return dataframe def don_channel_breakout(self, dataframe, period=20, shorts=True): dataframe["position_b"] = np.nan dataframe["position_b"] = np.where(dataframe["close"] > dataframe["upperDon"].shift(1), 1, dataframe["position_b"]) dataframe["position_b"] = dataframe["position_b"].ffill().fillna(0) return dataframe def don_reversal(self, dataframe, period=20, shorts=True): dataframe["position_r"] = np.nan dataframe["position_r"] = np.where(dataframe["close"] < dataframe["lowerDon"].shift(1), 1, dataframe["position_r"]) dataframe["position_r"] = dataframe["position_r"].ffill().fillna(0) return dataframe def leverage(self, pair: str, current_time: datetime, current_rate: float, proposed_leverage: float, max_leverage: float, entry_tag: Optional[str], side: str, **kwargs) -> float: return self.leverage_value def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: # Swing high/low dataframe = self.calc_swings(dataframe) dataframe = self.calc_donchian_channels(dataframe=dataframe, period=20) dataframe = self.mid_don_cross_over(dataframe=dataframe) dataframe = self.don_reversal(dataframe=dataframe) dataframe = self.don_channel_breakout(dataframe=dataframe) return dataframe def calc_swings(self, dataframe): dataframe['swing_low'] = (dataframe['close'].shift(2) > dataframe['close'].shift(1)) & \ (dataframe['close'].shift(1) < dataframe['close']).astype(int) dataframe['swing_high'] = (dataframe['close'].shift(2) < dataframe['close'].shift(1)) & \ (dataframe['close'].shift(1) > dataframe['close']).astype(int) return dataframe def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( (dataframe['position_r'] == 1) | (dataframe['swing_low'] == 1) | (dataframe['position_m'] == 1) | (dataframe['position_b'] == 1) ), ['enter_long', 'enter_tag'] ] = (1, 'swing_low') return dataframe def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: dataframe.loc[ ( (dataframe['swing_high'] == 1) ), ['exit_long', 'exit_tag'] ] = (1, 'swing_high') return dataframe def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: float, rate: float, time_in_force: str, exit_reason: str, current_time: datetime, **kwargs) -> bool: dataframe, _ = self.dp.get_analyzed_dataframe(pair, self.timeframe) profit_ratio = trade.calc_profit_ratio(rate) if 'swing' in exit_reason or 'trailing' in exit_reason: return profit_ratio > 0 return True |
Strategy League — fixed backtest that feeds the ranking
The fixed-params backtest (33 pairs · 20210101-20260101) — the only run that feeds the Strategy League ranking.
Backtests — over a market period
Backtest this strategy over a chosen crypto-cycle period. These don't affect the League ranking, and need that period's candle data downloaded.
Log in or sign up to run backtests.
| Period | Range | Total % | Win % | Max DD | Trades | |
|---|---|---|---|---|---|---|
| 2020 · DeFi Summer & Pre-Halving Rally | 20200101-20210101 | not run | ||||
| 2021 · Institutional Bull Market | 20210101-20220101 | not run | ||||
| 2022 · Post-Bull Crash & Macro Tightening | 20220101-20230101 | not run | ||||
| 2023–2024 · Recovery & ETF Anticipation | 20230101-20250101 | not run | ||||
| 2025–2026 · Current Cycle | 20250101-20260101 | not run | ||||
Walk forward
Out-of-sample backtest on recent data · 33 pairs · 20260101-20260701.
Backtest trust check
Static source analysis — instant, does not run the strategy. Flags future-data leaks, backtest-realism problems, and indicators worth a second look.
Lookahead analysis
freqtrade lookahead-analysis: detects strategies peeking at future candles.