N Bar Reversal Detector
By LuxAlgoSep 4, 2024
N Bar Reversal Detector is an indicator on Vela, our next-generation charting platform, written in Pine Script®.

N Bar Reversal Detector extends the three-bar reversal into a configurable N-bar engine: you choose how many candles build the setup instead of settling for three. A bullish signal forms when an initial high bar leads a run of N-1 downtrending bars and the next bar's high takes out that first bar's high; the bearish case mirrors it at the lows. In Enhanced mode that breakout bar must close beyond the first bar's extreme, a stricter demand in the spirit of a key reversal, where the close does the confirming.
How to Trade the N Bar Reversal Detector?
- Normal pattern: the breakout bar's extreme breaches the sequence's first bar, the earliest form of the reversal cue.
- Enhanced pattern: the breakout bar closes beyond the first bar's extreme, trading immediacy for conviction.
- Projected levels: patterns that confirm against price action draw support and resistance boundaries, reference points for entries, stops, and continuation checks.
- Trend filter: show only patterns agreeing with the prevailing trend for continuation trading, or only counter-trend ones for fading, judged by your choice of Moving Average Cloud, Supertrend, or Donchian Channel.
The Min Percentage of Required Candles input decides how many of the first N-1 candles must lean the right way before a pattern qualifies, letting you tighten or relax detection to match conditions.
N Bar Reversal Detector Settings
- Pattern Type: detect "Normal" patterns, "Enhanced" patterns, or both.
- Reversal Pattern Sequence Length: N, how many bars back the reference bar sits; the pattern spans that bar, the N-1 bars after it, and the breakout bar, so the minimum of 2 is the classic three-bar case.
- Min Percentage of Required Candles: the share of the first N-1 candles that must align with the prior trend.
- Derived Support and Resistance: Level draws the projected levels; None turns them off.
- Trend indicator settings: Moving Average Cloud type with fast/slow lengths, Supertrend ATR length and factor, and Donchian Channel length are each configurable.
Frequently Asked Questions
Free to use
Run it on Vela. Go further with a paid plan.
- Up to 500 Custom Alerts, with webhook automation
- Up to 10× the chart history of Free
- Orderflow lookback up to full history
- More Quant usage to customize it, plus extra usage when you need it
- Futures data alongside crypto, stocks, forex and commodities
Also works on
Related indicators
Run it on Vela. Make it yours with Quant.
Open this indicator free on Vela, our next-generation charting platform. Then ask Quant, our coding agent built into Vela, to retune it or turn it into a backtested strategy of your own.



