Commit 8a10a1b
committed
fix: Correct extrema neighbor lookup in triangle detection
The triangle pattern detector was iterating over labels from
window.index (positions in the price series, often >100) but using
them with .iloc, which treats them as positional indexes into max_min
(only ~119 rows). This caused IndexError crashes during demo runs.
The guard 'idx-1 in max_min.index' was also faulty: extrema are not
at consecutive price positions, so it almost never evaluated true,
silently skipping the high/low classification entirely.
Switch to positional iteration on max_min directly: each window slot
maps to position (i - 4) + j, and neighbors are (pos - 1) and
(pos + 1) within max_min itself. This restores intended behavior and
the demo now completes end-to-end with non-empty triangle results.1 parent 9fa20ce commit 8a10a1b
1 file changed
Lines changed: 12 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
0 commit comments