NEWCard payments are live · from $18/month, USDT also acceptedSee plans
COINPRED / STRATEGY LIBRARY

BTC Liquidity Sweep Filter: Flips the Position After a Close Breaks the Volatility Bands

An open-source (MPL 2.0) strategy by PineIndicators, based on AlgoAlpha's Liquidity Sweep Filter. Live orders follow trend flips after the close breaks a volatility band; the sweep marks and volume profile are drawn and can fire alerts, but they do not place trades. The author's chart is CRYPTO:BTCUSD on the 2-hour timeframe. The default mode is long only, with 100% of equity. The rules below follow the source; this page invents no backtest figures.

Illustrated guidesPine Script®Included with monthly & annual plans
← All strategies
PineIndicators · 1.0 · 2026-11-24 · Trend following
BTC Liquidity Sweep Filter: Flips the Position After a Close Breaks the Volatility Bands

The idea

This is an open-source script published by PineIndicators as Liquidity Sweep Filter Strategy [AlgoAlpha X PineIndicators]. The publication credits AlgoAlpha for the concept and the original indicator; this file adds strategy orders on top. The name highlights liquidity sweeps, but in the source strategy.entry and strategy.close are tied only to the trend variable crossing through zero. Sweep lines, volume labels, and triangle marks are plotted, and they can raise alerts, yet they do not open or close a trade on their own.

The trend itself is a band filter. Price is reduced to a double moving-average basis, then upper and lower bands are built from how far price has stretched away from that basis. A close above the upper band sets trend to 1; a close below the lower band sets it to −1; between the bands the previous state is kept. When trend crosses up through zero the script can enter a long or flatten a short; when it crosses down it can enter a short or flatten a long. The author's publication chart is CRYPTO:BTCUSD on the 2-hour timeframe, so this entry is filed under BTC. The script does not hard-code a symbol and will load on other charts, but the write-up and the image follow that chart.

Author chart of the Liquidity Sweep Filter strategy on CRYPTO:BTCUSD 2-hour, showing trend bands, sweep marks, and a volume profile
Author chart: CRYPTO:BTCUSD (Bitcoin / U.S. Dollar index), 2-hour timeframe, from the author's publication image. Trend bands, sweep marks, and the volume profile are visible; this only shows the layout and is not a performance claim.

How the indicators are calculated

  • Basis and bands: basis = ta.sma(ta.ema(src, Length), Length), with Length defaulting to 12 and src defaulting to close. The band width is ta.ema(math.abs(close − basis), Length × 3) times Multiplier (default 2.0), so the absolute deviation is smoothed with a 36-period EMA. Upper = basis + deviation; lower = basis − deviation.
  • Trend variable: trend becomes 1 when close is above the upper band and −1 when close is below the lower band. Between the bands it keeps its previous value, so the mid-range is a hold state rather than a stream of flips.
  • Normalized volume nvol: over int(Length × Multiplier) bars (24 by default), volume is scaled linearly into a 0–100 range.
  • Sweep lines: in a downtrend, a swing high (the previous bar higher than its neighbors) that is still below the upper band is stored as a horizontal line; in an uptrend, a swing low still above the lower band is stored the same way. If a later high takes out those high lines, their volume is added to bearliq; if a later low takes out the low lines, the volume is added to bullliq. If a band crosses the line the other way, the line is deleted without adding to the sweep total. When the normalized total exceeds Major Sweep Threshold (default 50), the chart labels it as a stronger sweep.
  • Volume profile: from the most recent trend-zero cross to the current bar, volume is binned at Resolution (default 40) and a POC can be shown. This block is visual only.
  • Order conditions use only ta.crossover(trend, 0) and ta.crossunder(trend, 0). They do not depend on whether a sweep has cleared the threshold.

Entry rules

  • Trend crossing up through zero: if Trade Mode is Long Only (the default) or Long & Short, and there is no open long, the script enters long under the name Long, with the comment Enter Long on Bullish Trend. An open short is closed first.
  • Trend crossing down through zero: a short is opened only if Trade Mode is Long & Short or Short Only, under the name Short, with the comment Enter Short on Bearish Trend. In the default Long Only mode this branch only closes an existing long.
  • On a flip bar, the close and the entry run in that order. process_orders_on_close=true, so orders are processed on the close.
  • The strong/weak sweep markers, horizontal lines, and volume profile do not, on their own, call strategy.entry.

Exits and position size

  • Default Long Only: when trend flips bearish, strategy.close("Long") exits the long with the comment Close Long on Bearish Trend. There is no separate take-profit, stop-loss, or time stop.
  • In Long & Short mode a bullish flip closes a short and opens a long, and a bearish flip does the reverse. Short Only opens shorts on a bearish flip and flattens them on a bullish flip.
  • The declaration sizes trades at 100% of equity (default_qty_value=100), with commission 0.05, slippage of 2 ticks, and margin_long and margin_short both set to 20. A 100% equity default is a very large size; change it to a level you can accept before you trade it.
  • initial_capital is 100000 in the declaration. That only scales the absolute figures in the tester; it does not change the percent-of-equity sizing.

Inputs (source defaults)

InputDefaultRole
Trade ModeLong OnlyLong only, short only, or both. The default is long only.
Length12Length of the double moving-average basis; also used in the deviation EMA and the volume window.
Multiplier2.0Band-width multiplier; the volume normalization window is int(Length × Multiplier).
SourceclosePrice source for the basis.
Major Sweep Threshold50Normalized-volume cutoff for labeling a stronger sweep; it does not change orders.
Show Major / Minor Liquidationstrue / trueShow or hide the stronger and weaker sweep labels.
Show Volume Profile / Bounding Boxtrue / trueShow or hide the volume profile and its bounding box.
Resolution / Scale40 / 30Number of profile bins and the horizontal width of the profile.
Dismiss No Volume WarningfalseHide the warning when the symbol has no volume.

Things to know before using it

  • The title and the publication text put the weight on liquidity sweeps, but orders follow trend flips only. Treating a sweep as an entry filter would not match this source.
  • This is not the same rule set as the existing PresentTrading liquidity-breakout strategy (id 16). Here the trigger is a moving-average-band trend flip, not that script's liquidity-breakout logic.
  • The default size is 100% of equity, and there is no stop. If the trend is slow to flip, the drawdown is measured on a full position.
  • Because trend holds its state between the bands, not every approach to a band is a trade. Orders fire only when the close breaks a band and the trend variable crosses zero.
  • Sweeps and the volume profile need volume. On an index chart with no volume those marks can be missing, but a trend flip can still place an order.

Installing it on TradingView

  1. Download the .pine file from Coinpred (active membership required, see below), or check the original page for a newer version.
  2. Open the Pine Editor, create a blank script, paste the full source, and save.
  3. Click Add to chart. To match the author image, start with CRYPTO:BTCUSD on the 2-hour timeframe.
  4. Cut the default 100% equity size to a level you can accept, note that Trade Mode defaults to long only, then review fills in the Strategy Tester.
  5. Past tester results do not guarantee future returns.

About backtest figures

Source, license and version

  • Source: https://www.tradingview.com/script/gx7267BR-Liquidity-Sweep-Filter-Strategy-AlgoAlpha-X-PineIndicators/
  • Author: PineIndicators; the publication credits AlgoAlpha for the concept and the original indicator. Source version 1.0 (Pine v6), scriptAccess=open_no_auth.
  • License: Mozilla Public License 2.0. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified full source.
  • Members can download the .pine file on this page to study the rules. Judge the risk yourself, and follow your venue's rules.

Source, license and version

Mozilla Public License 2.0 (MPL 2.0),源码头注明 © AlgoAlpha X PineIndicators。再分发须保留原版权与许可声明;如修改源码文件,修改后的文件仍须按 MPL 2.0 提供。Coinpred 未修改源码。 / Licensed under MPL 2.0 per the source header, © AlgoAlpha X PineIndicators. Redistribution must keep the copyright and license notices; modified files must remain under MPL 2.0. Coinpred ships the unmodified source.

View original source ↗

Check the script license and your TradingView account features. Historical results do not guarantee future performance.

More strategies

All strategies →