The Hammer strategy is a trading strategy that uses various technical indicators to generate buy and sell signals for a given dataset. Here's a breakdown of what the strategy does:
In the populate_indicators method, the strategy calculates and adds the following technical indicators to the dataframe:
MFI (Money Flow Index)
Stochastic Fast (%K and %D)
RSI (Relative Strength Index)
Fisher RSI
Bollinger Bands (Upper and Lower Bands, and % Gain from Upper Band)
EMA (Exponential Moving Average) with time periods of 5 and 10
SAR (Parabolic SAR)
SMA (Simple Moving Average) with a time period of 40
Candlestick patterns (Hammer, Inverted Hammer, Hanging Man, Shooting Star)
Height, Body, Top, Bottom, Upper Shadow, and Lower Shadow of each candle
Upper and Lower Ratios, clipped between 0 and 10
The populate_buy_trend method determines the buy signals based on the specified conditions:
Volume is greater than 0
If enabled, the closing price is below the SMA (Simple Moving Average)
If enabled, the MFI (Money Flow Index) is less than or equal to the specified value
If enabled, the closing price is less than or equal to the EMA10 (Exponential Moving Average with a time period of 10)
If enabled, the Bollinger Bands gain is greater than or equal to the specified value
The candle body height is greater than 0.01
Either the upper or lower ratio is greater than 2
The populate_sell_trend method determines the sell signals based on the specified conditions:
If enabled, a "hold" condition is set, where the sell signal is not generated if the closing price is not null
Volume is greater than 0
The closing price is greater than or equal to the EMA10 (Exponential Moving Average with a time period of 10)
The candle body height is greater than 0.01
The upper ratio is greater than 2
The strategy applies these conditions to the dataframe and sets the 'buy' and 'sell' columns accordingly.