From ffae38235f7bd2a9a481547212149b669afb5305 Mon Sep 17 00:00:00 2001 From: mablue Date: Sun, 12 Feb 2023 21:51:39 +0330 Subject: [PATCH 1/4] Tree Black Crows Strategy added! --- user_data/strategies/ThreeBlackCrows.py | 115 ++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 user_data/strategies/ThreeBlackCrows.py diff --git a/user_data/strategies/ThreeBlackCrows.py b/user_data/strategies/ThreeBlackCrows.py new file mode 100644 index 0000000..00ccfc6 --- /dev/null +++ b/user_data/strategies/ThreeBlackCrows.py @@ -0,0 +1,115 @@ +# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement +# flake8: noqa: F401 +# isort: skip_file +# --- Do not remove these libs --- +import numpy as np +import pandas as pd +from pandas import DataFrame +from datetime import datetime +from typing import Optional, Union + +from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter, + IntParameter, IStrategy, merge_informative_pair) + +# -------------------------------- +# Add your lib to import here +import talib.abstract as ta +import pandas_ta as pta +from technical import qtpylib + + +class ThreeBlackCrows(IStrategy): + # By: Masoud Azizi (@mablue) + # Investopedia Link: https://www.investopedia.com/terms/t/three_black_crows.asp + + # Strategy interface version - allow new iterations of the strategy interface. + # Check the documentation or the Sample strategy to get the latest version. + INTERFACE_VERSION = 3 + + # Optimal timeframe for the strategy. + timeframe = '5m' + + # Can this strategy go short? + can_short: bool = False + + # $ freqtrade hyperopt -s ThreeBlackCrows --hyperopt-loss SharpeHyperOptLossDaily + + # "max_open_trades": 1, + # "stake_currency": "USDT", + # "stake_amount": 990, + # "dry_run_wallet": 1000, + # "trading_mode": "spot", + # "XMR/USDT","ATOM/USDT","FTM/USDT","CHR/USDT","BNB/USDT","ALGO/USDT","XEM/USDT","XTZ/USDT","ZEC/USDT","ADA/USDT", + # "CHZ/USDT","BTT/USDT","LUNA/USDT","VRA/USDT","KSM/USDT","DASH/USDT","COMP/USDT","CRO/USDT","WAVES/USDT","MKR/USDT", + # "DIA/USDT","LINK/USDT","DOT/USDT","YFI/USDT","UNI/USDT","FIL/USDT","AAVE/USDT","KCS/USDT","LTC/USDT","BSV/USDT", + # "XLM/USDT","ETC/USDT","ETH/USDT","BTC/USDT","XRP/USDT","TRX/USDT","VET/USDT","NEO/USDT","EOS/USDT","BCH/USDT", + # "CRV/USDT","SUSHI/USDT","KLV/USDT","DOGE/USDT","CAKE/USDT","AVAX/USDT","MANA/USDT","SAND/USDT","SHIB/USDT", + # "KDA/USDT","ICP/USDT","MATIC/USDT","ELON/USDT","NFT/USDT","ARRR/USDT","NEAR/USDT","CLV/USDT","SOL/USDT","SLP/USDT", + # "XPR/USDT","DYDX/USDT","FTT/USDT","KAVA/USDT","XEC/USDT" + # "method": "StaticPairList" + + # 44/100: 73 trades. 33/39/1 Wins/Draws/Losses. + # Avg profit 1.04%. + # Median profit 0.00%. + # Total profit 754.07546328 USDT ( 75.41%). + # Avg duration 10:04:00 min. + # Objective: -9.94281 + + # Buy hyperspace params: + buy_params = { + "buy_pow": 1.821, + } + + # Sell hyperspace params: + sell_params = { + "sell_pow": 1.989, + } + + # ROI table: + minimal_roi = { + "0": 0.19, + "29": 0.049, + "60": 0.027, + "152": 0 + } + + # Stoploss: + stoploss = -0.213 + + # Trailing stop: + trailing_stop = False # value loaded from strategy + trailing_stop_positive = None # value loaded from strategy + trailing_stop_positive_offset = 0.0 # value loaded from strategy + trailing_only_offset_is_reached = False # value loaded from strategy + + # Number of candles the strategy requires before producing valid signals + startup_candle_count: int = 30 + + # Strategy parameters + buy_pow = DecimalParameter(1, 2, decimals=3, default=1.5, space="buy") + sell_pow = DecimalParameter(1, 2, decimals=3, default=1.5, space="sell") + + def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + return dataframe + + def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[ + ( + (dataframe['close'].shift(0) > dataframe['close'].shift(2) ** self.buy_pow.value) & + (dataframe['close'].shift(1) > dataframe['close'].shift(3) ** self.buy_pow.value) & + (dataframe['close'].shift(2) > dataframe['close'].shift(4) ** self.buy_pow.value) + + ), + 'enter_long'] = 1 + + return dataframe + + def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: + dataframe.loc[( + (dataframe['close'].shift(0) < dataframe['close'].shift(2) ** self.sell_pow.value) | + (dataframe['close'].shift(1) < dataframe['close'].shift(3) ** self.sell_pow.value) | + (dataframe['close'].shift(2) < dataframe['close'].shift(4) ** self.sell_pow.value) + ), + 'exit_long'] = 1 + + return dataframe From 43a21eefdbcfad2c45eb352814b5ef48665331f4 Mon Sep 17 00:00:00 2001 From: mablue Date: Mon, 13 Feb 2023 00:12:47 +0330 Subject: [PATCH 2/4] hyperopted again --- user_data/strategies/ThreeBlackCrows.py | 28 ++++++++++++------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/user_data/strategies/ThreeBlackCrows.py b/user_data/strategies/ThreeBlackCrows.py index 00ccfc6..98919cf 100644 --- a/user_data/strategies/ThreeBlackCrows.py +++ b/user_data/strategies/ThreeBlackCrows.py @@ -48,33 +48,31 @@ class ThreeBlackCrows(IStrategy): # "XPR/USDT","DYDX/USDT","FTT/USDT","KAVA/USDT","XEC/USDT" # "method": "StaticPairList" - # 44/100: 73 trades. 33/39/1 Wins/Draws/Losses. - # Avg profit 1.04%. - # Median profit 0.00%. - # Total profit 754.07546328 USDT ( 75.41%). - # Avg duration 10:04:00 min. - # Objective: -9.94281 + # 38/100: 67 trades. 32/34/1 Wins/Draws/Losses. + # Avg profit 1.23%. Median profit 0.00%. + # Total profit 815.05358020 USDT ( 81.51%). + # Avg duration 10:58:00 min. Objective: -9.86920 # Buy hyperspace params: buy_params = { - "buy_pow": 1.821, + "buy_pow": 3.849, } # Sell hyperspace params: sell_params = { - "sell_pow": 1.989, + "sell_pow": 3.798, } # ROI table: minimal_roi = { - "0": 0.19, - "29": 0.049, - "60": 0.027, - "152": 0 + "0": 0.213, + "39": 0.048, + "56": 0.029, + "159": 0 } # Stoploss: - stoploss = -0.213 + stoploss = -0.288 # Trailing stop: trailing_stop = False # value loaded from strategy @@ -86,8 +84,8 @@ class ThreeBlackCrows(IStrategy): startup_candle_count: int = 30 # Strategy parameters - buy_pow = DecimalParameter(1, 2, decimals=3, default=1.5, space="buy") - sell_pow = DecimalParameter(1, 2, decimals=3, default=1.5, space="sell") + buy_pow = DecimalParameter(0, 4, decimals=3, default=3.849, space="buy") + sell_pow = DecimalParameter(0, 4, decimals=3, default=3.798, space="sell") def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: return dataframe From fd2edba8386fbd7bc0df5668c8fd89a44172445b Mon Sep 17 00:00:00 2001 From: mablue Date: Mon, 13 Feb 2023 00:59:38 +0330 Subject: [PATCH 3/4] renamed to PowerTower! --- user_data/strategies/{ThreeBlackCrows.py => PowerTower.py} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename user_data/strategies/{ThreeBlackCrows.py => PowerTower.py} (92%) diff --git a/user_data/strategies/ThreeBlackCrows.py b/user_data/strategies/PowerTower.py similarity index 92% rename from user_data/strategies/ThreeBlackCrows.py rename to user_data/strategies/PowerTower.py index 98919cf..4d579af 100644 --- a/user_data/strategies/ThreeBlackCrows.py +++ b/user_data/strategies/PowerTower.py @@ -18,9 +18,10 @@ import pandas_ta as pta from technical import qtpylib -class ThreeBlackCrows(IStrategy): +class PowerTower(IStrategy): # By: Masoud Azizi (@mablue) - # Investopedia Link: https://www.investopedia.com/terms/t/three_black_crows.asp + # Power Tower is a complitly New Strategy(or Candlistic Pattern or Indicator) to finding strongly rising coins. + # much effective than "Three black Crows" but based on Idea of this candlestick pattern, but with different rules! # Strategy interface version - allow new iterations of the strategy interface. # Check the documentation or the Sample strategy to get the latest version. @@ -32,7 +33,7 @@ class ThreeBlackCrows(IStrategy): # Can this strategy go short? can_short: bool = False - # $ freqtrade hyperopt -s ThreeBlackCrows --hyperopt-loss SharpeHyperOptLossDaily + # $ freqtrade hyperopt -s PowerTower --hyperopt-loss SharpeHyperOptLossDaily # "max_open_trades": 1, # "stake_currency": "USDT", From 190c419c2c51a72c190676391046198d343f819e Mon Sep 17 00:00:00 2001 From: Masoud Date: Tue, 14 Feb 2023 03:43:32 +0330 Subject: [PATCH 4/4] unnecessary Buy and sell dict removed --- user_data/strategies/PowerTower.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/user_data/strategies/PowerTower.py b/user_data/strategies/PowerTower.py index 4d579af..c99cdfe 100644 --- a/user_data/strategies/PowerTower.py +++ b/user_data/strategies/PowerTower.py @@ -53,17 +53,7 @@ class PowerTower(IStrategy): # Avg profit 1.23%. Median profit 0.00%. # Total profit 815.05358020 USDT ( 81.51%). # Avg duration 10:58:00 min. Objective: -9.86920 - - # Buy hyperspace params: - buy_params = { - "buy_pow": 3.849, - } - - # Sell hyperspace params: - sell_params = { - "sell_pow": 3.798, - } - + # ROI table: minimal_roi = { "0": 0.213,