OPEN-SOURCE SCRIPT

Liquidity Sweep with Deviation - Candle Iron Core

367
Liquidity Sweep with Deviation - Candle Iron Core

OVERVIEW

Liquidity Sweep with Deviation is a rule-based tool designed to identify wick-based sweeps around a user-defined liquidity level.

Instead of classifying every touch or small penetration of a level as a liquidity sweep, the indicator applies objective conditions to distinguish a qualifying sweep from a simple retest or minor interaction with the level.

The user first defines a specific price as the Liquidity Level. This can represent any price level relevant to the user's analysis, such as a swing high, swing low, previous high/low, daily open, weekly open, monthly open, yearly open, support, resistance, or another manually selected reference.

The indicator then evaluates how each candle interacts with that level.


CORE CONCEPT

A liquidity sweep, for the purposes of this indicator, requires the wick to cross a defined liquidity level while the candle body remains on the original side of that level.

However, crossing the level alone is not enough.

The indicator uses two independent percentage filters:

  • Minimum Wick Length (%)
  • Minimum Sweep Depth (%)


This distinction is the main purpose of the script.

It allows users to separately control:

  • How significant the wick itself must be.
  • How far price must actually travel beyond the liquidity level.



1. MINIMUM WICK LENGTH

This parameter measures the complete wick responsible for the sweep.

For a sweep below the level:


Lower edge of candle body → Candle Low


For a sweep above the level:


Upper edge of candle body → Candle High


The percentage is calculated relative to the corresponding edge of the candle body.

This filter prevents candles with very small wicks from qualifying simply because they crossed the selected level.


2. MINIMUM SWEEP DEPTH

Sweep Depth measures only the portion of price movement that extends beyond the defined Liquidity Level.

For a sweep below:


Liquidity Level → Candle Low


For a sweep above:


Liquidity Level → Candle High


This is intentionally different from Wick Length.

A candle may have a large wick but penetrate the liquidity level by only a very small amount. Without a separate depth requirement, that interaction could be classified as a sweep even when it behaves more like a precise retest of the level.

Minimum Sweep Depth allows the user to determine how far price must move beyond the level before the interaction qualifies.


VALID SWEEP CONDITIONS

Sweep Below

A candle qualifies as a Sweep Below when all of the following conditions are satisfied:

  1. The entire candle body remains at or above the Liquidity Level.
  2. The lower wick crosses below the Liquidity Level.
  3. The complete lower wick meets or exceeds the Minimum Wick Length.
  4. Price penetrates below the Liquidity Level by at least the Minimum Sweep Depth.


When all conditions are satisfied, an upward triangle is plotted below the candle.


Sweep Above

A candle qualifies as a Sweep Above when all of the following conditions are satisfied:

  1. The entire candle body remains at or below the Liquidity Level.
  2. The upper wick crosses above the Liquidity Level.
  3. The complete upper wick meets or exceeds the Minimum Wick Length.
  4. Price penetrates above the Liquidity Level by at least the Minimum Sweep Depth.


When all conditions are satisfied, a downward triangle is plotted above the candle.


WHY TWO PERCENTAGE FILTERS?

Wick Length and Sweep Depth measure two different characteristics.

Consider a candle with a large lower wick that barely crosses a support level.

Its wick may satisfy the Minimum Wick Length requirement, but its penetration beyond the level may be extremely small.

With this indicator, the candle must satisfy both requirements.

This provides a configurable framework for separating:


A wick that merely interacts with a level

from

A wick that penetrates the level by a user-defined minimum amount.



LIQUIDITY ZONE

The indicator displays a visual zone around the selected Liquidity Level.

The upper and lower boundaries correspond to the Minimum Sweep Depth selected by the user.

Therefore, the zone is not only a visual reference.

For a qualifying Sweep Above, the wick must reach or exceed the upper depth threshold.

For a qualifying Sweep Below, the wick must reach or exceed the lower depth threshold.

The zone color and transparency can be customized.


LIQUIDITY LEVEL MODES

The indicator provides two methods for defining the reference level:

  • Manual Price — The user enters the exact price level to evaluate.
  • Current Asset Price — The indicator establishes the reference from the current/recent chart price according to the script's automatic-level logic.


Manual Price is particularly useful when evaluating predefined structural or liquidity references.


SWEEP DIRECTION

Users can choose which interactions should be detected:

  • Both
  • Above Level
  • Below Level


This allows the indicator to be adapted to the directional context being studied.


CANDLE CLOSE CONFIRMATION

The option Confirm only after candle close can be enabled to require the candle to be confirmed before a sweep signal is displayed.

When enabled, the final Open, High, Low and Close of the completed candle determine whether the conditions were satisfied.


VISUAL CUSTOMIZATION

Users can customize:

  • Liquidity Level color
  • Liquidity Zone color
  • Liquidity Zone transparency
  • Sweep arrow color
  • Visibility of the Liquidity Zone
  • Visibility of price labels
  • Price label text color
  • Price label horizontal offset



HOW TO USE

A basic workflow is:

  1. Identify a price level that is relevant to your analysis.
  2. Enter that price as the Manual Liquidity Level.
  3. Define the Minimum Wick Length required for a candle to qualify.
  4. Define the Minimum Sweep Depth required beyond the level.
  5. Select whether sweeps should be detected above, below, or in both directions.
  6. Evaluate qualifying signals within the context of your own trading methodology.



EXAMPLE

Suppose a trader defines 93,000 as a liquidity level.

For a Sweep Below, simply trading below 93,000 is not sufficient.

The candle body must remain at or above 93,000, while its lower wick crosses below it.

The complete lower wick must satisfy the selected Minimum Wick Length, and the portion extending below 93,000 must independently satisfy the selected Minimum Sweep Depth.

Only when all conditions are satisfied will the indicator mark the candle as a qualifying Sweep Below.


ORIGINALITY AND PURPOSE

The purpose of this script is not to automatically determine where liquidity exists or to label every wick through a price level as a liquidity sweep.

Its purpose is to provide an objective and configurable framework for testing user-defined liquidity levels.

The script separates two measurements that are often treated as a single condition:

  • The total length of the wick performing the interaction.
  • The actual depth of penetration beyond the liquidity level.


Combined with the requirement that the candle body remains on the original side of the level, these independent conditions allow users to define and consistently reproduce their own threshold for what constitutes a qualifying liquidity sweep.


ALERTS

Alert conditions are included for:

  • Liquidity Sweep Above
  • Liquidity Sweep Below


These alerts follow the same conditions used by the visual sweep markers.


IMPORTANT NOTES

This indicator does not automatically identify institutional liquidity, resting orders, stop-loss concentrations, or future price reactions.

A Liquidity Level is a price reference selected by the user. The script evaluates candle behavior around that reference according to the mathematical conditions described above.

A detected sweep is therefore a classification of price behavior according to the selected parameters, not a prediction that price will reverse or continue.

Different assets and timeframes have different volatility characteristics. Minimum Wick Length and Minimum Sweep Depth values should therefore be evaluated for the specific market, timeframe, and methodology in which they are used.

The indicator does not provide Buy or Sell signals and does not guarantee that a detected sweep will produce a favorable trading outcome.

Haftungsausschluss

Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.