Skip to content

Instantly share code, notes, and snippets.

@zachlim98
Created December 4, 2020 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zachlim98/701542cabfcf0c5e66cf405bbe830c83 to your computer and use it in GitHub Desktop.
Save zachlim98/701542cabfcf0c5e66cf405bbe830c83 to your computer and use it in GitHub Desktop.
for i in range(0,len(data)):
if data["Pos"][i-1] == 0:
if data["RSI"].iloc[i] > 50 and data["MACD_diff"][i] > 0 and (data["Pos"][i] == 0):
data["Buy_Signal"][i] = 1
data["Pos"][i] = 1
data["SL"][i] = (data[ticker][i]*0.97)
data["TP"][i] = (data[ticker][i]*1.5)
elif data["RSI"].iloc[i] < 50 and data["MACD_diff"][i] < 0 and (data["Pos"][i] == 0):
data["Buy_Signal"][i] = 1
data["Pos"][i] = -1
data["SL"][i] = (data[ticker][i]*1.03)
data["TP"][i] = (data[ticker][i]*0.95)
else:
data["Buy_Signal"][i] = 0
data["Pos"][i] = 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment