OPEN-SOURCE SCRIPT

Liquidity Swings & Sweeps

By outofoptions
Updated
This Pine script indicator is designed to create a visual representation liquidity as identified by swing Highs/Lows along with an indication of the liquidity level that was swept, optionally rating the strength of the sweep based on time & price.

Relevance:
Liquidity levels & sweeps are crucial for many SMC/ICT setups and can indicate a point at which the price changes direction or may re-trace in an opposite direction to provide additional liquidity for continued move in the original direction. Additionally, liquidity levels may provide targets for setups, as price action will often seek to take out those levels as they main contain many buy/sell stops.

How It Works:
The indicator tracks all swing points, as identified using user-defined strength of the swing. Once a swing is formed that meets the criteria, it is represented by a horizontal line starting at the price of the current swing until the last bar on the chart. While the swing is valid, this line will continue to be extended until the swing is invalid or a new swing is formed. Upon identifying a new swing, the indicator then scans the earlier swings in the same direction looking for a point of greatest liquidity that was taken by the current swing. This level is then denoted by dashed horizontal line, connecting earlier swing point to the current. At the same time any liquidity zones between the two swings are automatically removed from the chart if they had previously been rendered on the chart. If the setting to enable scan for maximum liquidity is enabled, then while looking back, the indicator will look for lowest low or highest high that was taken by the current swing point, which may not be a swing itself, however, is a lowest/highest price point taken (mitigated) by the current swing, which in many cases will be better price then then the one represented by previous swing. If the option to render sweep label is enabled, the sweep line will also be completed by a label, that will score the sweep and a tooltip showing the details of the level swept and the time it took to sweep it. The score explained further in configurability section ranks the strength of the sweep based on time and is complemented by price (difference in price between the two liquidity levels).

Configurability:
A user may configure the strength of the swing using both left/right strength (number of bars) as well as optionally instruct the indicator to seek the lowest/highest price point which may not be previous swing that was taken out by newly formed swing.
From appearance perspective liquidity level colors & line width presenting the liquidity/swing can be configured. There is also an option to render the liquidity sweep label that will generate an icon-based rating of the liquidity sweep and a tooltip that provides details on the scope of the swing, which includes liquidity level swept and when it was formed along with the time it took to sweep the liquidity.
Rating is of sweeps is primarily based on time with a secondary reference to price
  • 💥- Best rating, very strong sweep with an hourly or better liquidity sweep
  • 🔥- Second rating, strong sweep with 15 – 59 minute liquidity sweep, or 5+ minute sweep of 10+ points
  • ✅- Third rating, ok sweep with 5 - 15 minute liquidity sweep, or lower-time-frame sweep of 10+ points
  • ❄️ - Weakest sweep, with liquidity of 5 or less minutes swept


What makes this indicator different:
  • Designed with high performance in mind, to reduce impact on chart render time.
  • Only keeps valid liquidity levels & sweeps on the chart
  • Automatically removes previously taken liquidity levels
  • Ranks liquidity sweeps to indicate strength of the sweep
Release Notes
Fixed bug with subswing detection when looking for maximum liquidity
Release Notes
Added ability to trigger alerts based on liquidity sweeps, you via settings you can choose which sweeps you want alerts to be generated for.
There is also a video how-to on this indicator that may answer questions on its usage here:
https://youtu.be/O1o4Z4cv-wg
Release Notes
Fixed a bug where labels for 💥 and 🔥 were flipped
Candlestick analysislevelsliquidityliquiditygrabliquiditysweepPivot PointsPivot points and levelssweep

Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in publication is governed by House rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Disclaimer