The STRATEGY_CORAL_AND_WAVETREND strategy is designed to backtest trading strategies using several technical analysis (TA) indicators. It consists of three main parts: indicator population, buy signal population, and sell signal population. In the populate_indicators method, the strategy adds three exponential moving averages (EMAs) to the given DataFrame: EMA10, EMA100, and EMA1000.
These indicators are calculated based on the closing price of the asset.
After populating the indicators, the strategy calculates additional values using a set of formulas.
These calculations involve a series of iterative calculations based on previous values. The resulting values are stored in columns named 'i1' to 'i6'. Using the calculated values, the strategy calculates a trend indicator called 'coral_trend'. The calculation involves weighted combinations of the 'i' values and specific coefficients. In the populate_buy_trend method, the strategy determines the buy signal based on the crossing of EMA10 above EMA100. When this condition is met, the 'buy' column in the DataFrame is set to 1. In the populate_sell_trend method, the strategy determines the sell signal based on the crossing of EMA100 above EMA10. When this condition is met, the 'sell' column in the DataFrame is set to 1. Overall, this strategy uses EMAs, iterative calculations, and trend indicators to generate buy and sell signals for backtesting trading strategies.
Traceback (most recent call last):
File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3791, in get_loc
return self._engine.get_loc(casted_key)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "index.pyx", line 152, in pandas._libs.index.IndexEngine.get_loc
File "index.pyx", line 181, in pandas._libs.index.IndexEngine.get_loc
File "pandas/_libs/hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item
File "pandas/_libs/hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item
KeyError: 'i1'
The above exception was the direct cause of the following exception:
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 1318, in backtest_one_strategy
preprocessed = self.strategy.advise_all_indicators(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/strategy/interface.py", line 1378, in advise_all_indicators
return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/strategy/interface.py", line 1378, in
return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/freqtrade/strategy/interface.py", line 1410, in advise_indicators
return self.populate_indicators(dataframe, metadata)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/freqtrade/user_data/strategies/STRATEGY_CORAL_AND_WAVETREND.py", line 149, in populate_indicators
dataframe['i1'] = c1*dataframe["close"] + c2*DataFrame.fillna(dataframe['i1'].shift(1))
~~~~~~~~~^^^^^^
File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/frame.py", line 3893, in __getitem__
indexer = self.columns.get_loc(key)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ftuser/.local/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 3798, in get_loc
raise KeyError(key) from err
KeyError: 'i1'