The SqueezeOff strategy is a trading strategy that utilizes various technical indicators to determine buy and sell signals in a backtesting environment. Here is a brief description of what the strategy does:
In the populate_indicators function:
The strategy calculates moving averages (SMA, EMA, TEMA) and exponential moving averages (EMA3, EMA5) of the price data. It calculates the MACD (Moving Average Convergence Divergence) and its components (macd, macdsignal, macdhist).
It computes the Money Flow Index (MFI), Average Directional Index (ADX), and directional movement components (dm_plus, dm_minus, dm_delta).
It calculates the Parabolic SAR (SAR) indicator.
It computes the Relative Strength Index (RSI) and transforms it into the Fisher RSI. It calculates Bollinger Bands (bb_upperband, bb_mid, bb_lowerband) and the percentage gain between the upper band and the closing price (bb_gain). It calculates Keltner Channels (kc_upper, kc_lower, kc_middle). It computes the Donchian Channel (dc_upper, dc_lower, dc_mid), the distance between upper and lower bands (dc_dist), and Fibonacci levels based on the channel (dc_hf, dc_chf, dc_clf, dc_lf). It calculates the squeeze indicators by subtracting Keltner Channel values from Bollinger Band values (sqz_upper, sqz_lower) and identifies squeeze conditions (sqz_on, sqz_off). It calculates the average between Donchian Channel midpoint and TEMA (sqz_ave) and the delta between the closing price and sqz_ave (sqz_delta). It calculates the linear regression of sqz_delta (sqz_val). In the populate_buy_trend function:
The strategy defines a list of conditions that must be met for a buy signal. These conditions include a negative sqz_val, optional criteria such as ADX, directional movement, MFI, SAR, MACD, and Fisher RSI, and the transition from a squeeze-off state to a squeeze-on state. If the conditions are met, the 'buy' column of the dataframe is set to 1. In the populate_sell_trend function:
The strategy defines a list of conditions that must be met for a sell signal. These conditions include optional criteria such as crossing below Bollinger Bands or Keltner Channels and the price being below the lower bands. If the conditions are met, the 'sell' column of the dataframe is set to 1. Overall, the SqueezeOff strategy combines multiple indicators to identify potential buying opportunities when certain conditions are met and provides sell signals based on different criteria.