-
Notifications
You must be signed in to change notification settings - Fork 76
Open
Description
Your code is well-written and works nicely. However, I think it has a significant shortcoming. I couldn't add the pivot levels to your code because I don't know how to do it. That's why I decided to write to you. Also, I think the window scanning is not very reliable. I believe it should be dynamic and all swings should be analyzed in relation to each other.
Your code signals in circles
df = yf.download('BTC-USD', period='3mo',interval='1d') used below graph.

`# Define your swing function
def swing(df, i):
if i == 0 or i == len(df) - 1:
return None # Return None for the first and last indices
is_swing_low = df['Low'].iloc[i] < df['Low'].iloc[i - 1] and df['Low'].iloc[i] < df['Low'].iloc[i + 1]
is_swing_high = df['High'].iloc[i] > df['High'].iloc[i - 1] and df['High'].iloc[i] > df['High'].iloc[i + 1]
if is_swing_low:
return 2 # Low swing
elif is_swing_high:
return 1 # High swing
else:
return None`
Metadata
Metadata
Assignees
Labels
No labels