The TrendFollowingStrategy is a trading strategy implemented in Python using the Freqtrade library. It is designed to backtest and execute trades based on trend-following principles. Here's a breakdown of how the strategy works:
Timeframe: The strategy operates on 5-minute candlestick data.
Buy Parameters: The strategy has predefined buy parameters that include the following indicators and their corresponding values:
Trailing stop: 0.98
Relative Strength Index (RSI): 53
Exponential Moving Average (EMA) with a period of 14: 38
EMA with a period of 28: 68
Williams %R: -98
Sell Parameters: The strategy also has predefined sell parameters that include the following indicators and their corresponding values:
Trailing stop: 1.01
RSI: 43
EMA with a period of 14: 60
EMA with a period of 28: 28
Williams %R: -34
ROI Table: The strategy defines a minimal return on investment (ROI) table, which specifies the minimum desired ROI at different time intervals.
For example, at 0 minutes, the desired ROI is 0.05 (5%).
Stoploss: The strategy sets a stop loss at -0.1 (10% loss). Trailing Stop: The strategy enables a trailing stop feature. When the price reaches the trailing_stop_positive value (0.01), it sets a trailing stop offset at trailing_stop_positive_offset (0.02). The strategy will only apply the trailing stop when the offset is reached (trailing_only_offset_is_reached = True). Optimal Timeframe: The strategy considers the 5-minute timeframe as the optimal timeframe for its operation. Order Types and Time in Force: The strategy defines the order types for different actions. It uses 'limit' orders for buying and selling, and a 'market' order for the stoploss. The strategy sets the order time in force as 'gtc' (good 'til canceled) for both buying and selling. The strategy also includes methods to populate indicators, buy trends, and sell trends based on the given indicators and their respective values. The populate_indicators method calculates the EMA, RSI, and Williams %R indicators for the given dataframe. The populate_buy_trend method identifies buy signals based on specific conditions, such as the price being above EMAs, RSI being above the buy_rsi value, and Williams %R being below the buy_williamsr value. The populate_sell_trend method identifies sell signals based on similar conditions but with opposite comparisons. Overall, the TrendFollowingStrategy aims to capture trends by buying when certain conditions are met and selling when different conditions are satisfied. It utilizes technical indicators such as EMAs, RSI, and Williams %R to make informed trading decisions.
Traceback (most recent call last):
File "/freqtrade/freqtrade/main.py", line 42, in main
return_code = args['func'](args)
^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/commands/optimize_commands.py", line 58, in start_backtesting
backtesting.start()
File "/freqtrade/freqtrade/optimize/backtesting.py", line 1401, in start
min_date, max_date = self.backtest_one_strategy(strat, data, timerange)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/optimize/backtesting.py", line 1335, in backtest_one_strategy
results = self.backtest(
^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/optimize/backtesting.py", line 1213, in backtest
data: Dict = self._get_ohlcv_as_lists(processed)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/optimize/backtesting.py", line 381, in _get_ohlcv_as_lists
df_analyzed = self.strategy.ft_advise_signals(pair_data, {'pair': pair})
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/strategy/interface.py", line 1391, in ft_advise_signals
dataframe = self.advise_entry(dataframe, metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/strategy/interface.py", line 1425, in advise_entry
df = self.populate_entry_trend(dataframe, metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/strategy/interface.py", line 225, in populate_entry_trend
return self.populate_buy_trend(dataframe, metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/user_data/strategies/TrendFollowingStrategy_2.py", line 69, in populate_buy_trend
(dataframe['rsi'] > self.buy_rsi.value) &
^^^^^^^^^^^^
AttributeError: 'TrendFollowingStrategy_2' object has no attribute 'buy_rsi'