Timeframe
15m
Direction
Long Only
Stoploss
-5.0%
Trailing Stop
No
ROI
0m: 3.0%, 15m: 1.0%, 30m: 0.0%
Interface Version
3
Startup Candles
N/A
Indicators
2
freqtrade/freqtrade-strategies
freqtrade/freqtrade-strategies
this is an example class, implementing a PSAR based trailing stop loss you are supposed to take the `custom_stoploss()` and `populate_indicators()` parts and adapt it to your own strategy
freqtrade/freqtrade-strategies
Strategy 003 author@: Gerald Lonlas github@: https://github.com/freqtrade/freqtrade-strategies
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
# flake8: noqa: F401
# isort: skip_file
import numpy as np
import pandas as pd
from pandas import DataFrame
from functools import reduce
from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalParameter,
IntParameter, IStrategy)
import talib.abstract as ta
class ExtremeReboundStrategy(IStrategy):
INTERFACE_VERSION = 3
timeframe = '15m'
can_short = False
# Default ROI and Stoploss
minimal_roi = {"0": 0.03, "15": 0.01, "30": 0}
stoploss = -0.05
trailing_stop = False
# Hyperopt parameters
buy_rsi_threshold = IntParameter(10, 30, default=20, space='buy')
buy_atr_multiplier = DecimalParameter(1.1, 3.0, default=1.5, space='buy')
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
dataframe['atr'] = ta.ATR(dataframe, timeperiod=14)
dataframe['atr_sma'] = dataframe['atr'].rolling(window=20).mean()
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
conditions = []
conditions.append(dataframe['rsi'] < self.buy_rsi_threshold.value)
conditions.append(dataframe['atr'] > (dataframe['atr_sma'] * self.buy_atr_multiplier.value))
if conditions:
dataframe.loc[
reduce(lambda x, y: x & y, conditions),
'enter_long'] = 1
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# Exit if RSI recovers above 50 or handled by ROI
dataframe.loc[
(dataframe['rsi'] > 50),
'exit_long'] = 1
return dataframe