def trades(data): buy = [] sell = [] flag = 0 for index, row in df.iterrows(): if row[\'Q\'] > row[\'Upper_Line\']: if flag !=1: buy.a