u/Biiiscuit ·
Reddit — r/algotrading
· April 23, 2026 at 15:26
· ⬆ 15 pts
· 💬 60 comments
| View on Reddit ↗
AI Summary
Summary
Post discusses building a robust swing high/swing low detector for algorithmic trading, aiming to minimize lookahead bias.
Author describes using a 3-candle pattern but finds too many signals in choppy markets; seeks to classify swings into intermediate-term (IT) and long-term (LT) categories.
The post is a technical inquiry about methodology and implementation, not a trade recommendation or analysis of any specific asset.
Quality assessment: This is a technical discussion/query, not a well-researched DD or speculative thesis. It provides insights on algorithmic design but no actionable trade ideas.
Score15
Comments60
Upvote %86%
▶ Full Post Text
I’m working on an algo trading project and trying to build a robust swing high / swing low detector with as little lookahead as possible (ideally none).
Right now my definition is very simple:
\- Swing High: a 3-candle pattern where the middle candle’s high is higher than both neighboring candles’ highs
\- Swing Low: a 3-candle pattern where the middle candle’s low is lower than both neighboring candles’ lows
The issue is this generates a huge number of signals, especially in choppy/low-volatility conditions.
My goal is to classify swings into:
\- IT (Intermediate-Term) swings
\- LT (Long-Term) swings
and filter out insignificant noise.
I’ve found some implementations in TradingView scripts and Python examples, but many of them use things like “highest high of the last 10 bars and next 5 bars” or similar logic. That introduces significant lookahead / future leak, which is exactly what I’m trying to avoid and why I’m emphasizing this constraint.
Main constraint: I want to minimize lookahead bias for backtesting and keep it realistic for live trading.
For those who’ve implemented this before:
1. How do you define “meaningful” swings without introducing too much lag?
2. How do you structure IT vs LT swings? Recursive/fractal approach?
3. Is zero-lookahead realistic, or is 1–2 bar confirmation the practical compromise?
4. Any recommended algorithms / indicators / market structure concepts I should study?
Would appreciate any practical advice or implementation ideas.