The ClucDCA strategy is a trading strategy that uses a combination of technical indicators to make buy and sell decisions. Here's a breakdown of what the strategy does:
In the populate_indicators method:
Heikin Ashi candles are calculated based on the provided dataframe, and the open, close, high, and low values are stored in new columns. Bollinger Bands are calculated using the Heikin Ashi typical price, with a window size of 40 and 2 standard deviations.
The lower and middle bands are stored in separate columns.
Various other indicators like Bollinger Band delta, close delta, tail, exponential moving averages (EMA), volume mean, and rate of change ratio (ROCR) are calculated and added to the dataframe.
The RSI (Relative Strength Index) and Fisher Transform indicator are calculated based on the dataframe's close price. Additional informative data is fetched for a different timeframe, and relevant columns like Heikin Ashi close and ROCR are added to the original dataframe. In the populate_buy_trend method:
Buy parameters are fetched. Buy signals are determined based on specific conditions:
ROCR of the 1-hour timeframe is greater than a specified value. Several conditions related to Bollinger Bands, delta values, tail, and close prices are checked to identify potential buy opportunities. The Heikin Ashi close price should be lower than the previous lower Bollinger Band value and less than or equal to the previous Heikin Ashi close price. If the conditions are met, a 'buy' signal is set to 1 for the corresponding rows in the dataframe. In the populate_sell_trend method:
Sell parameters are fetched. Sell signals are determined based on specific conditions:
Fisher Transform indicator value is greater than a specified sell-fisher parameter. Various conditions related to Heikin Ashi high, close, exponential moving average, and Bollinger Band middle band are checked. The volume should be greater than 0. If the conditions are met, a 'sell' signal is set to 1 for the corresponding rows in the dataframe. The ClucDCA class is a subclass of IStrategy and implements the backtesting logic for this particular strategy.