The Hacklemore strategy is a trading strategy that involves backtesting various indicators and conditions to determine buy and sell signals. It follows the structure of a class called "Hacklemore" that implements the "IStrategy" interface. The strategy first populates indicators by processing the input dataframe and metadata.
It initializes trade-related data and checks if the strategy is running in live or dry run mode.
If there is an active trade, it calculates the current profit and peak profit.
If there are other open trades, it calculates the average profit from those trades. The strategy then calculates various indicators such as volume mean, RMI (Relative Momentum Index), SAR (Stop and Reverse), MACD (Moving Average Convergence Divergence), rolling max, rolling min, and trend indicators. Next, the strategy populates the buy trend by defining a set of conditions. If there is an active trade and the peak profit is positive, it checks if the current profit is higher than 80% of the peak profit and if the RMI-slow indicator is greater than or equal to 60. Otherwise, it checks for multiple conditions such as exponential moving average (ema) crossovers, MACD signal, uptrend, RMI-slow value, positive MACD histogram, low volume, and price and SAR relationships. If any of the conditions are met, a "buy" signal is generated. Similarly, the strategy populates the sell trend by defining conditions. If there is an active trade, it checks for conditions such as negative current profit, current profit within the stop loss limit, downtrend, low RMI-fast value, and positive volume. If there are other trades open, it checks if the average profit from those trades is above a certain threshold. If any of the conditions are met, a "sell" signal is generated. The strategy also includes custom methods for obtaining the current price from order books or tickers and for price protection on trade entry and timeouts. Additionally, there is a subclass called "Hacklemore_Slow" that inherits from the "Hacklemore" class, indicating a variation of the strategy with a focus on slower indicators or timeframes. Overall, the Hacklemore strategy uses a combination of indicators, conditions, and price analysis to generate buy and sell signals for backtesting trading strategies.