search the BNBUSDT chart for any maximum and minimum to determine the maximum and minimum of a Japanese candle that is in the extreme, and plot Fibonacci levels from 0 to 1 on the extreme candle, where 0 should be at the extreme.
def search_max_min(df, long_num_candles, short_num_candles, step_candles): df = df.reset_index(drop=True) for i in range(0, len(df), step_candles): print(i) if i > long_num_candles + short_num_candles + 1: sub_df = df.loc[i-long_num_candles-short_num_candles:i, ["high", "low"]] max_price = sub_df["high"].max() min_price = sub_df["low"].min() if df.loc[i-short_num_candles, "close"] == max_price: print("max") df.loc[i-short_num_candles, "max_min"] = "max" elif df.loc[i-short_num_candles, "close"] == min_price: print("min") df.loc[i-short_num_