Closed rocketpoweryul closed 6 months ago
Peak not detected at true left hand side candidate, leading to it being ignored by the consolidation detection.
Missed high Peak Detection on Apr 8, 2024.
Likely find_swing_high_and_lows
function in TATools module, because since there is no arrow, this means it doesn't consider this day a swing high.
As you can see the Apr 8 high is actually also a swing low. In these cases, the code in find_swing_high_and_lows
at fault is:
# Check for outside day condition
if is_swing_high and is_swing_low:
# Neutralize the signal for outside days
df.at[df.index[i], 'SwHL'] = 0
However this mutes important peaks. Mitigation will need consider both needs.
There is no reason for the tiebreaker. The fact one bar can be both doesn't affect anything. Therefore the condition is removed.
for i in range(1, len(df) - 1):
curr_high = df['High'].iloc[i ]
next_high = df['High'].iloc[i + 1]
prev_high = df['High'].iloc[i - 1]
is_swing_high = curr_high > next_high and curr_high > prev_high
curr_low = df['Low'].iloc[i ]
next_low = df['Low'].iloc[i + 1]
prev_low = df['Low'].iloc[i - 1]
is_swing_low = curr_low < next_low and curr_low < prev_low
# Check for outside day condition
#if is_swing_high and is_swing_low:
# # Neutralize the signal for outside days
# df.at[df.index[i], 'SwHL'] = 0
if is_swing_high:
df.at[df.index[i], 'SwHL'] = 1
elif is_swing_low:
df.at[df.index[i], 'SwHL'] = -1
When commented out the consolidation now looks correct:
Code is now deleted, rearranged to make more sense and better commented.
for i in range(1, len(df) - 1):
# determine current high and low values
curr_high = df['High'].iloc[i ]
next_high = df['High'].iloc[i + 1]
prev_high = df['High'].iloc[i - 1]
curr_low = df['Low'].iloc[i ]
next_low = df['Low'].iloc[i + 1]
prev_low = df['Low'].iloc[i - 1]
# detect swing high
is_swing_high = curr_high > next_high and curr_high > prev_high
# detect swing low
is_swing_low = curr_low < next_low and curr_low < prev_low
# add detection results to dataframe
if is_swing_high:
df.at[df.index[i], 'SwHL'] = 1
elif is_swing_low:
df.at[df.index[i], 'SwHL'] = -1
Excursion not detected, likely due to peak non-detection.