Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Newbie Question: Close price comparison at specific times to generate signals

Hi Guys

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.

df.loc[(df['close'].shift(1)>df['upper'].shift(1))&(df['close'].shift(1)>df['close'].shift(2)) \
& (df['close'].shift(1)>df['close'].shift(3)), ............................................. 'Signal']=1

My other sticky point is how to only check this at 8:15 AM and if above is true update a signal column to 1 at that time.

I can see the data by doing but that about it.
sig_time = dt.time(8, 15, 0)
df.loc[sig_time]

Any help will be much appreciated.

Regards

Al