I'm trying to do some backtesting using the notebook to generate a buy signal that updates the signal column at 8:15AM every morning wondering if anyone can shed some light on this.
The idea is that the close price of the stock has to close above the upper Bolinger band and the price also has to be higher than all the previous close prices to 01:00 hours that evening this will generate the buy signal. I cannot figure a short way of doing this as it will iterate back 30 close price points at each price points is 15 minute candles.
There is an easier way of doing this. If I understand correctly, you want to generate signals when the time is 8:15. You can do this by first calculating the technical indicators such as the Bollinger bands and the ArronUp indicator from the Talib library.
Then convert the index to DateTime using pandas in-built function to_datetime and use the .time property to check the time.
df.index.time==time(8,15) to select the market open times.
Once you have these opening times, you check the if the close price is more than upper Bollinger band and Arronup is equal to 100. Aroonup will give you a score of 100 if the close price is the highest in the last x periods. Assuming that you are using a 15-minute candle then a time period of 4 in Aroonup calculation will give if a new high has been formed in the last one hour.
Your code looks good. You can further try to refine the signals by adding some Volume-based indicators from the Talib library. Ex: OBV (On Balance Volume) to check for momentum backed by volume.