2018-06-27 09:42:54 -07:00
|
|
|
from pandas import DataFrame
|
|
|
|
|
from technical.indicators import cmf
|
|
|
|
|
|
2022-05-31 06:43:02 +02:00
|
|
|
from freqtrade.strategy import IStrategy
|
2018-06-27 09:42:54 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class TechnicalExampleStrategy(IStrategy):
|
2022-07-10 11:44:41 +02:00
|
|
|
INTERFACE_VERSION: int = 3
|
2018-06-27 09:42:54 -07:00
|
|
|
minimal_roi = {
|
|
|
|
|
"0": 0.01
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stoploss = -0.05
|
|
|
|
|
|
2020-11-06 07:04:29 +01:00
|
|
|
# Optimal timeframe for the strategy
|
|
|
|
|
timeframe = '5m'
|
2018-06-27 09:42:54 -07:00
|
|
|
|
2019-08-10 13:37:34 +03:00
|
|
|
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
2018-06-27 09:42:54 -07:00
|
|
|
dataframe['cmf'] = cmf(dataframe, 21)
|
|
|
|
|
|
|
|
|
|
return dataframe
|
|
|
|
|
|
2022-07-10 11:34:40 +02:00
|
|
|
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
2018-06-27 09:42:54 -07:00
|
|
|
dataframe.loc[
|
|
|
|
|
(
|
|
|
|
|
(
|
2020-11-06 07:04:29 +01:00
|
|
|
(dataframe['cmf'] < 0)
|
2018-06-27 09:42:54 -07:00
|
|
|
|
|
|
|
|
)
|
|
|
|
|
),
|
2022-07-10 11:34:40 +02:00
|
|
|
'enter_long'] = 1
|
2018-06-27 09:42:54 -07:00
|
|
|
return dataframe
|
|
|
|
|
|
2022-07-10 11:34:40 +02:00
|
|
|
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
2018-06-27 09:42:54 -07:00
|
|
|
# different strategy used for sell points, due to be able to duplicate it to 100%
|
|
|
|
|
dataframe.loc[
|
|
|
|
|
(
|
2020-11-06 07:04:29 +01:00
|
|
|
(dataframe['cmf'] > 0)
|
2018-06-27 09:42:54 -07:00
|
|
|
),
|
2022-07-10 11:34:40 +02:00
|
|
|
'exit_long'] = 1
|
2018-06-27 09:42:54 -07:00
|
|
|
return dataframe
|