The VWAP (Volume-Weighted Average Price) strategy aims to identify potential buying and selling opportunities based on several indicators. Here is a breakdown of what the strategy does:
In the populate_indicators function:
Calculates the VWAP using the VWAPB function with a period of 20 and a standard deviation of 1. The VWAP is split into three components: vwap_low, vwap, and vwap_high.
Computes the top percent change (tcp_percent_4) using the top_percent_change function with a period of 4.
Calculates the CTI (Cumulative Tick Indicator) using the pta.cti function with a length of 20.
Computes the RSI (Relative Strength Index) using the ta.RSI function with a time period of 14, 84, and 112. Calculates the Bollinger Bands using the qtpylib.bollinger_bands function with a window of 20 and 2 standard deviations. Three bands are generated: bb_lowerband, bb_upperband, and bb_middleband. In the populate_buy_trend function:
Sets the 'buy_tag' column to 'vwap'. Identifies potential buying opportunities by applying several conditions:
The closing price is below vwap_low. The top percent change (tcp_percent_4) is greater than 0.04. The CTI (cti) is less than -0.8. The RSI (rsi) is below 35. The RSI (rsi_84) is below 60. The RSI (rsi_112) is below 60. The volume is greater than 0. Sets the 'buy' column to 1 for the identified buying opportunities. In the populate_sell_trend function:
Sets the 'sell' column to 1 for all rows. Overall, the strategy calculates various indicators such as VWAP, top percent change, CTI, RSI, and Bollinger Bands. It then generates buy signals based on specific conditions, and all rows are marked as sell signals.