Moving Average Liquidity Sweeps - Candle Iron Core

435
Moving Average Liquidity Sweeps - Candle Iron Core

OVERVIEW

Moving Average Liquidity Sweeps is a rule-based indicator designed to identify wick-based sweeps around a dynamically calculated moving average.

Unlike a fixed horizontal liquidity level, a moving average continuously changes with price. This indicator uses the selected EMA or SMA as a dynamic reference and evaluates how individual candles interact with it.

A candle is not classified as a sweep simply because its wick touches or crosses the moving average.

To qualify, the interaction must satisfy independent conditions involving:

  • The position of the candle body relative to the moving average.
  • The total length of the wick.
  • The actual depth of penetration beyond the moving average.


The purpose is to provide a configurable and repeatable method for distinguishing qualifying wick-based interactions from ordinary touches or shallow retests of a moving average.


CORE CONCEPT

The selected moving average acts as the dynamic reference level.

Users can choose:

  • EMA - Exponential Moving Average
  • SMA - Simple Moving Average
  • Moving Average Length
  • Moving Average Source


For example, the indicator can evaluate interactions with a 21 EMA, 89 SMA, 200 EMA, or any other user-defined combination.

The moving average itself does not determine whether an interaction qualifies as a sweep.

The candle must independently satisfy the sweep conditions described below.


MOVING AVERAGE CALCULATION

When EMA is selected, the script calculates an Exponential Moving Average using the selected source and length.

When SMA is selected, the script calculates a Simple Moving Average using the selected source and length.

The resulting value becomes the Liquidity Moving Average used as the reference for each candle.

Because the moving average is recalculated over time, the reference level evaluated by the script changes from bar to bar.


TWO INDEPENDENT PERCENTAGE FILTERS

The indicator separates two measurements:

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


These measurements serve different purposes.

A candle can have a large wick while only slightly crossing the moving average.

Conversely, crossing the moving average does not necessarily mean that the wick itself is significant.

Requiring both conditions provides additional control over what the user chooses to classify as a qualifying sweep.


1. MINIMUM WICK LENGTH

This parameter evaluates the complete wick responsible for the interaction.

For a sweep below the moving average:


Lower edge of candle body → Candle Low


For a sweep above the moving average:


Upper edge of candle body → Candle High


The lower edge of the candle body is defined as the lower value between Open and Close.

The upper edge of the candle body is defined as the higher value between Open and Close.

Therefore, the calculation works consistently for both bullish and bearish candles.

The percentage calculation used by the indicator is:


Lower Wick % = (Body Low - Low) / Body Low × 100

Upper Wick % = (High - Body High) / Body High × 100


The complete wick must meet or exceed the Minimum Wick Length selected by the user.


2. MINIMUM SWEEP DEPTH BEYOND MA

Sweep Depth measures a different distance.

Instead of measuring the complete wick, it measures only how far price extends beyond the moving average.

For a sweep below:


Moving Average → Candle Low


For a sweep above:


Moving Average → Candle High


The percentage calculation is:


Sweep Depth Below % = (Moving Average - Low) / Moving Average × 100

Sweep Depth Above % = (High - Moving Average) / Moving Average × 100


This condition helps distinguish a qualifying penetration from a candle that merely touches or moves slightly beyond the moving average.


SWEEP ABOVE MOVING AVERAGE

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 moving average.
  2. The upper wick crosses above the moving average.
  3. The complete upper wick meets or exceeds the selected Minimum Wick Length.
  4. The distance from the moving average to the candle High meets or exceeds the Minimum Sweep Depth Beyond MA.
  5. The selected direction settings allow sweeps above the moving average.


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


SWEEP BELOW MOVING AVERAGE

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 moving average.
  2. The lower wick crosses below the moving average.
  3. The complete lower wick meets or exceeds the selected Minimum Wick Length.
  4. The distance from the moving average to the candle Low meets or exceeds the Minimum Sweep Depth Beyond MA.
  5. The selected direction settings allow sweeps below the moving average.


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


WHY BODY POSITION MATTERS

The candle body is intentionally required to remain on the original side of the moving average.

A candle whose body crosses through the moving average represents a different type of interaction from a candle that penetrates the level only with its wick.

For this reason:


Sweep Above → Body remains below the MA.

Sweep Below → Body remains above the MA.


This allows the indicator to focus specifically on wick-based interactions rather than classifying every candle that crosses a moving average as a sweep.


WHY WICK LENGTH AND SWEEP DEPTH ARE SEPARATE

Consider a candle with a large lower wick.

The candle may satisfy the Minimum Wick Length requirement while extending only slightly below the moving average.

Without an additional depth requirement, a shallow interaction could qualify solely because the candle happened to have a long wick.

The Minimum Sweep Depth Beyond MA solves this by requiring price to travel a separately defined minimum distance beyond the moving average.

Therefore:


Wick Length measures the wick itself.

Sweep Depth measures the penetration beyond the moving average.


A qualifying signal must satisfy both.


SWEEP DIRECTION

The indicator allows users to select:

  • Both - Detect interactions above and below the moving average.
  • Above MA - Detect only sweeps above the moving average.
  • Below MA - Detect only sweeps below the moving average.



CANDLE CLOSE CONFIRMATION

The Confirm only after candle close option determines whether the script waits for the current candle to close before confirming a signal.

When enabled, a sweep is marked only after the bar is confirmed.

This is particularly relevant because the High, Low and Close of an active candle can continue changing before the candle closes.


VISUAL SETTINGS

Users can customize:

  • Whether the moving average is displayed.
  • Moving Average color.
  • Moving Average width.
  • Sweep marker color.


The plotted moving average corresponds directly to the dynamic reference used by the sweep calculations.


HOW TO USE

A basic workflow is:

  1. Select EMA or SMA.
  2. Choose the Moving Average Length.
  3. Select the Moving Average Source.
  4. Define the Minimum Wick Length.
  5. Define the Minimum Sweep Depth Beyond MA.
  6. Choose whether to detect sweeps above, below, or in both directions.
  7. Optionally require candle-close confirmation.
  8. Evaluate qualifying interactions within the context of the user's own trading methodology.



EXAMPLE

Suppose a trader selects a 200 EMA.

A candle trades below the EMA and its upper wick extends through it.

Crossing the EMA alone does not produce a signal.

For the candle to qualify as a Sweep Above:

  • Its complete body must remain at or below the EMA.
  • Its upper wick must cross the EMA.
  • Its complete upper wick must satisfy the Minimum Wick Length.
  • The portion extending beyond the EMA must satisfy the Minimum Sweep Depth Beyond MA.


Only when all conditions are satisfied does the indicator plot the sweep marker.


ORIGINALITY AND PURPOSE

This indicator is not intended to introduce another moving-average crossover system.

The moving average serves only as a dynamically changing reference level.

The script's primary functionality is the classification of candle interactions around that reference using three independent structural conditions:

  • Candle-body position relative to the moving average.
  • Minimum total wick length.
  • Minimum penetration depth beyond the moving average.


Separating total wick length from actual penetration depth is particularly important because the two measurements describe different characteristics of the candle.

This combination allows users to define a consistent threshold for wick-based interactions with dynamic EMA or SMA levels rather than treating every touch, crossover, or wick penetration as equivalent.


ALERTS

Alert conditions are included for:

  • Liquidity Sweep Above MA
  • Liquidity Sweep Below MA


The alerts use the same conditions as the corresponding visual markers.


IMPORTANT NOTES AND LIMITATIONS

The term "Liquidity Sweep" in this indicator describes a candle interaction that satisfies the quantitative rules defined above.

The indicator does not observe the exchange order book and therefore does not confirm the presence of resting orders, stop-loss concentrations, institutional orders, or actual available liquidity at the moving average.

Likewise, an EMA or SMA is not inherently a liquidity level.

The moving average is used by this script as a dynamic reference selected by the user for evaluating wick behavior.

A qualifying sweep does not predict that price will reverse, continue, or produce a profitable trading opportunity.

Moving averages, volatility and candle characteristics can behave differently across assets and timeframes. Parameters should therefore be evaluated specifically for the market, timeframe and methodology in which they are intended to be used.

This indicator does not provide Buy or Sell signals and does not guarantee future market behavior.

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.