This is the code for my candlestick scanner. My aim is to scan multiple variables simultaneously however when my code runs it only results in a single column of false. If anyone knows how to scan multiple tickers at once it will help tremendously.
import datetime as dt
import pandas_datareader as web
import pandas as pd
start = dt.datetime(2020,12,31)
end = dt.datetime.now()
Stock = ('ANZ.AX','APT.AX','FMG.AX')
df = web.DataReader(Stock, 'yahoo', start, end)
# Change data to omit volume and adjusted close (can change later to display volume)
data = df[['Open', 'High', 'Low', 'Close']]
for i in range(2, df.shape[0]):
current = df.iloc[i, :]
prev = df.iloc[i - 1, :]
prev_2 = df.iloc[i - 2, :]
realbody = abs(current['Open'] - current['Close'])
candle_range = current['High'] - current['Low']
idx = df.index[i]
# Bullish engulfing
df.loc[idx, 'Bullish Engulfing'] = (prev['Open'] > prev['Close']) & (current['Close'] > current['Open']) \
& (current['High'] > prev['High']) & (current['Low'] < prev['Low'])
df.fillna(False, inplace=True)
pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)
print(df['Bullish Engulfing'])
Resulted code:
Date
2020-12-30 False
2021-01-03 False
2021-01-05 False
Name: Bullish Engulfing, dtype: bool