This is a sample strategy from the Freqtrade Strategy Development Starter Kit. The full kit, with advanced templates and detailed guides, is available for purchase.
Timeframe
5m
Direction
Long Only
Stoploss
-10.0%
Trailing Stop
Yes
ROI
0m: 5.0%, 30m: 3.0%, 60m: 1.0%, 120m: 0.0%
Interface Version
N/A
Startup Candles
N/A
Indicators
1
freqtrade/freqtrade-strategies
Strategy 003 author@: Gerald Lonlas github@: https://github.com/freqtrade/freqtrade-strategies
# --- Do not remove these libs ---
from freqtrade.strategy.interface import IStrategy
from pandas import DataFrame
import talib.abstract as ta
import freqtrade.vendor.qtpylib.indicators as qtpylib
# --- Strategy Class ---
class SimpleRsi(IStrategy):
"""
This is a sample strategy from the Freqtrade Strategy Development Starter Kit.
The full kit, with advanced templates and detailed guides, is available for purchase.
[Find out more on Gumroad](https://YOUR_GUMROAD_LINK_HERE)
"""
# Minimal ticker timeframe for the strategy (in minutes)
timeframe = '5m'
# Number of candles to load at startup
startup_candle_count: int = 30
# Stoploss configuration for the strategy
stoploss = -0.10
# Return on Investment (ROI) table
minimal_roi = {
"0": 0.05,
"30": 0.03,
"60": 0.01,
"120": 0
}
# Trailing stoploss configuration
trailing_stop = True
trailing_stop_positive = 0.01
trailing_stop_positive_offset = 0.02
trailing_only_offset_is_reached = True
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Calculates and adds the indicators needed for the strategy.
"""
dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14)
return dataframe
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Defines the conditions for the buy signal.
"""
dataframe.loc[
(
(dataframe['rsi'] < 30) &
(dataframe['volume'] > 0)
),
'buy'] = 1
return dataframe
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
"""
Defines the conditions for the sell signal.
"""
dataframe.loc[
(
(dataframe['rsi'] > 70) &
(dataframe['volume'] > 0)
),
'sell'] = 1
return dataframe