#stratégia
df["Signal"] = 0
df.loc[(df["Close"] > df["50napos"]) & (df["stochrsi_k"] > df["stochrsi_d"]) & (df["stochrsi_k"] < stochrsi_alsohatar), "Signal"] = 1 # Vételi jel
df.loc[(df["stochrsi_k"] < df["stochrsi_d"]) & (df["stochrsi_k"] > stochrsi_felsohatar), "Signal"] = -1 # Eladási jel
# feltételek meghatározása
df["position"] = 0
cond1 = df["Signal"] == 1
cond2 = df["position"].shift(-1) == 1
cond3 = df["Signal"] == -1
# "position" oszlop frissítése
df.loc[cond1 | cond2, "position"] = 1
df.loc[cond2 & cond3, "position"] = -1