14 Commits

Author SHA1 Message Date
Stefano Ariestasia 0727df98ac Typo on enter_short line 2024-06-25 14:52:16 +09:00
Matthias d207422bdf Merge pull request #303 from froggleston/master
Update example strategies to use process_only_new_candles=True
2023-07-16 16:10:52 +02:00
froggleston 6fce5f382b Update example strategies to use process_only_new_candles=True 2023-07-15 19:06:51 +01:00
Matthias 89d3915a55 Merge pull request #291 from mablue/3bc
Tree Black Crows Strategy added!
2023-02-14 07:09:02 +01:00
Matthias 2ca5431b5d Merge pull request #290 from mablue/umacd
Universal MACD Strategy Added!
2023-02-14 07:08:30 +01:00
Masoud b8820cbe4a unnecessary Buy and sell dict removed 2023-02-14 03:45:52 +03:30
Masoud 190c419c2c unnecessary Buy and sell dict removed 2023-02-14 03:43:32 +03:30
mablue fd2edba838 renamed to PowerTower! 2023-02-13 00:59:38 +03:30
mablue ca78f5670e varbuse removed 2023-02-13 00:24:30 +03:30
mablue 43a21eefdb hyperopted again 2023-02-13 00:12:47 +03:30
mablue 9c18ccd089 moved to right directory 2023-02-12 21:57:57 +03:30
mablue ffae38235f Tree Black Crows Strategy added! 2023-02-12 21:51:39 +03:30
mablue d0629c849a Universal MACD Strategy Added! 2023-02-12 21:08:18 +03:30
Matthias 3d6219186e Merge pull request #289 from freqtrade/frglstn-patch-1
Set process candles to True
2023-02-10 06:58:20 +01:00
12 changed files with 227 additions and 10 deletions
+104
View File
@@ -0,0 +1,104 @@
# 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 PowerTower(IStrategy):
# By: Masoud Azizi (@mablue)
# 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.
INTERFACE_VERSION = 3
# Optimal timeframe for the strategy.
timeframe = '5m'
# Can this strategy go short?
can_short: bool = False
# $ freqtrade hyperopt -s PowerTower --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"
# 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
# ROI table:
minimal_roi = {
"0": 0.213,
"39": 0.048,
"56": 0.029,
"159": 0
}
# Stoploss:
stoploss = -0.288
# 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(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
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
+1 -1
View File
@@ -43,7 +43,7 @@ class Strategy001(IStrategy):
trailing_stop_positive_offset = 0.02
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
@@ -44,7 +44,7 @@ class Strategy001_custom_exit(IStrategy):
trailing_stop_positive_offset = 0.02
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
+1 -1
View File
@@ -44,7 +44,7 @@ class Strategy002(IStrategy):
trailing_stop_positive_offset = 0.02
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
+1 -1
View File
@@ -44,7 +44,7 @@ class Strategy003(IStrategy):
trailing_stop_positive_offset = 0.02
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
+1 -1
View File
@@ -43,7 +43,7 @@ class Strategy004(IStrategy):
trailing_stop_positive_offset = 0.02
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
+1 -1
View File
@@ -45,7 +45,7 @@ class Strategy005(IStrategy):
trailing_stop_positive_offset = 0.02
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
+113
View File
@@ -0,0 +1,113 @@
# 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 UniversalMACD(IStrategy):
# By: Masoud Azizi (@mablue)
# Tradingview Page: https://www.tradingview.com/script/xNEWcB8s-Universal-Moving-Average-Convergence-Divergence/
# 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 UniversalMACD --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"
# *16 / 100: 40 trades.
# 31 / 9 / 0 Wins / Draws / Losses.
# Avg profit 2.34 %.
# Median profit 3.00 %.
# Total profit 928.95036811 USDT(92.90 %).
# Avg duration 3: 13:00 min.\
# Objective: -11.63412
# ROI table:
minimal_roi = {
"0": 0.213,
"27": 0.099,
"60": 0.03,
"164": 0
}
# Stoploss:
stoploss = -0.318
# 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_umacd_max = DecimalParameter(-0.05, 0.05, decimals=5, default=-0.01176, space="buy")
buy_umacd_min = DecimalParameter(-0.05, 0.05, decimals=5, default=-0.01416, space="buy")
sell_umacd_max = DecimalParameter(-0.05, 0.05, decimals=5, default=-0.02323, space="sell")
sell_umacd_min = DecimalParameter(-0.05, 0.05, decimals=5, default=-0.00707, space="sell")
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe['ma12'] = ta.EMA(dataframe, timeperiod=12)
dataframe['ma26'] = ta.EMA(dataframe, timeperiod=26)
dataframe['umacd'] = (dataframe['ma12'] / dataframe['ma26']) - 1
# Just for show user the min and max of indicator in different coins to set inside hyperoptable variables.cuz
# in different timeframes should change the min and max in hyperoptable variables.
# print(dataframe['umacd'].min(), dataframe['umacd'].max())
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['umacd'].between(self.buy_umacd_min.value, self.buy_umacd_max.value))
),
'enter_long'] = 1
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe.loc[
(
(dataframe['umacd'].between(self.sell_umacd_min.value, self.sell_umacd_max.value))
),
'exit_long'] = 1
return dataframe
@@ -41,7 +41,7 @@ class ReinforcedAverageStrategy(IStrategy):
trailing_only_offset_is_reached = False
# run "populate_indicators" only for new candle
process_only_new_candles = False
process_only_new_candles = True
# Experimental settings (configuration will overide these if set)
use_exit_signal = True
@@ -41,7 +41,7 @@ class FAdxSmaStrategy(IStrategy):
# trailing_stop_positive_offset = 0.0 # Disabled / not configured
# Run "populate_indicators()" only for new candle.
process_only_new_candles = False
process_only_new_candles = True
# Number of candles the strategy requires before producing valid signals
startup_candle_count: int = 14
@@ -43,7 +43,7 @@ class FReinforcedStrategy(IStrategy):
# trailing_stop_positive_offset = 0.0 # Disabled / not configured
# Run "populate_indicators()" only for new candle.
process_only_new_candles = False
process_only_new_candles = True
# Number of candles the strategy requires before producing valid signals
startup_candle_count: int = 14
@@ -46,7 +46,7 @@ class TrendFollowingStrategy(IStrategy):
(dataframe['close'] < dataframe['trend']) &
(dataframe['close'].shift(1) >= dataframe['trend'].shift(1)) &
(dataframe['obv'] < dataframe['obv'].shift(1)),
'enter_short'] = -1
'enter_short'] = 1
return dataframe