Skip to main content
On this page

Sweep Indicator in TradingView: Pattern Rules, Inputs, and Limits

· 5 min read
Pineify Team
Pine Script and AI trading workflow research team

Pineify's Sweep Tracker flags a specific price pattern: a bar crosses a qualifying prior swing level and closes back at or inside it. That can help identify a failed excursion through a level. OHLC data alone cannot prove who traded, whether stops were triggered, or whether anyone deliberately manipulated the move.

How to search for and add indicator pages in the Pineify editor

What the implementation checks​

The bearish branch searches prior bars for a local high higher than its two immediate neighbors. The current high must exceed that level, the current open must be below it, and the current close must be at or below it. The bullish branch mirrors those conditions around a local low: the current low goes below the level, the open is above it, and the close is at or above it.

The scan tracks intervening extremes and stops when its blocking conditions are met. It is therefore not a detector for every historical pivot crossing. Each branch stops after its first qualifying match, draws a horizontal line from that past level to the current bar, and returns a Boolean signal.

OutputCurrent-bar relationship to the prior level
Bearish SweepHigh above, open below, close at or below a qualifying local high
Bullish SweepLow below, open above, close at or above a qualifying local low

The drawing layer can show a bearish triangle above the bar and a bullish triangle below it. The horizontal line begins at a past swing bar, but the sweep event is detected on the current bar. Do not treat the line's starting point as the time the current signal became available.

The scan limit is fixed in this version​

The underlying function loops over at most 1,000 prior bars per direction and may stop much earlier. The current indicator configuration exposes no calculation inputs. There is no lookback setting that lets you switch this implementation from 1,000 to 200 bars in the Visual Editor.

The exposed drawing options control the visibility and color of the sweep markers. Changing those options does not change the scan rule. Historical data availability and Pine drawing limits can also affect what is visible; a 1,000-iteration bound does not mean every level in that history remains drawn.

Add and inspect the generated script​

Select Sweep Tracker in Pineify's Visual Editor, check your plan access, and choose the drawing options. Generate and review the Pine Script. Open TradingView's Pine Editor through the right-side Pine icon, paste the script, compile it, and add it to the chart.

How to search for and add indicator pages in the Pineify editor

This manual workflow does not promise automatic installation into your TradingView account. Check several marked and unmarked examples against the price conditions above before using the Boolean outputs in another rule.

Timing matters more than the label​

The sweep calculation itself does not require a confirmed bar. While the current candle is open, its high, low, and close can change, so an apparent rejection may disappear before close. For a bar-close test, apply that timing consistently to the strategy and alert logic and verify it during forward observation.

The word liquidity is an interpretation of the pattern, not an input to this function. It does not read an order book, identify a trader, or measure stop orders. A volume spike can be additional context but cannot establish intent either. Likewise, a news-driven price excursion can satisfy the same mathematical rule.

Turn a pattern into a testable strategy​

Choose whether the event is an entry condition, an exit condition, or context only. Define the confirmation, order type, sizing, stop, target, and invalidation before examining the result. A stop beyond the swept extreme is a possible rule to test, not protection against gaps or a guaranteed maximum realized loss.

Compare all qualifying events on a stated symbol, feed, timeframe, session, and date range. Include commissions, spread or slippage assumptions, and losing examples. If you add RSI, volume, or higher-timeframe conditions, test their incremental effect rather than assuming they improve accuracy.

This article provides no measured win rate, preferred market, or validated optimal timeframe. The indicator's Boolean outputs describe pattern matches; profitability depends on a complete strategy and its execution assumptions.

Can I change the lookback to 200 bars?

Not through this indicator's current calculation inputs. Its function has a fixed scan bound of 1,000 prior bars and can exit earlier.

Does the indicator identify smart-money intent?

No. It evaluates historical highs, lows, opens, and closes. It does not identify participants or prove that stop orders caused the move.

Is a sweep confirmed as soon as the marker appears?

Not necessarily. The current bar can still change. Use and verify closed-bar timing if that is what your strategy requires.

The Best Pine Script Generator