The KC_BB strategy is a trading strategy that combines the use of Keltner Channels (KC) and Bollinger Bands (BB) indicators. The strategy aims to identify potential buying and selling opportunities in the market. In the populate_indicators method, several indicators are calculated and added to the input dataframe.
These indicators include:
trange: True Range, which measures the price volatility.
Simple Moving Averages (SMA) of different time periods (sma_20 and sma_28).
Moving Averages of the True Range (range_ma_20 and range_ma_28). Keltner Channel upper and lower bands based on the SMA and the range multiplier (kc_upperband_20_2, kc_lowerband_20_2, kc_upperband_28_1, kc_lowerband_28_1). Bollinger Bands (BB) upper and lower bands based on the typical price and standard deviations (bb_lowerband2, bb_middleband2, bb_upperband2). kc_bb_delta: The percentage difference between the Keltner Channel lower band and the Bollinger Bands lower band. Additionally, other indicators such as Heikin Ashi candlestick data, RSI (Relative Strength Index), Fisher Transform, exponential moving average (ema_fast), and Williams %R are calculated and added to the dataframe. The populate_buy_trend method determines the conditions for buying. The strategy looks for situations where the Keltner Channel lower band crosses above the Bollinger Bands upper band, the percentage delta between the two is within a specific range, the Williams %R indicator is in a certain range, and the Heikin Ashi candlestick shows a significant change. The populate_sell_trend method determines the conditions for selling. The strategy looks for situations where the Fisher Transform indicator exceeds a certain threshold, the Heikin Ashi candlestick pattern indicates a reversal, the exponential moving average is above the Heikin Ashi close, the Heikin Ashi close is above a certain percentage of the Bollinger Bands middle band, and the volume is greater than zero. The strategy utilizes the Williams %R indicator, which calculates the current closing price's relation to the highest and lowest prices within a given period. The Williams %R oscillator ranges from -100 (lowest) to 0 (highest) and helps identify whether a market is trading near its recent high or low. Lastly, the strategy calculates the Williams %R indicator independently in a separate function by using the highest high and lowest low prices within a given period and the current closing price. The resulting Williams %R values are scaled by -100 and returned. Overall, the KC_BB strategy combines multiple indicators and conditions to generate potential buy and sell signals based on the market's price volatility, moving averages, candlestick patterns, and oscillators like the Williams %R.