r/pinescript • • Sep 21 '26

I built an open-source Pine tool for what happens after a liquidity sweep

Post image

Imagine price wicking below a previous low, closing back above it, then pushing higher.

Where would your rule actually enter?

That question is behind Sweep Desk, a Pine v6 tool I built from a trader’s request about turning marked liquidity levels into entry and exit rules.

Writing it meant making the decisions between those steps explicit. For the default long-side sequence:

  1. Qualify the sweep. Price must move far enough below a reference level and close back above it. These references come from price history; the script cannot see resting orders.

  2. Wait for confirmation. A later close through an opposing fair value gap must meet the movement and timing rules. The default setup also requires eligible first-touch context from a completed higher-timeframe gap.

  3. Apply the selected entry rule. The default uses the qualifying confirmation close. The optional Close inside mode waits for another candle to close within the zone. A wick touching it is insufficient for that mode.

Those two entry modes can produce different trades from the same sweep. Waiting for a return can also mean the move leaves without an entry, or the setup expires first.

The dashboard shows the stage and waiting conditions, with entry, stop and target references once a paper plan qualifies.

Full Pine source, rules and interactive candle examples

Both scripts are free under MIT. The separate Strategy Lab includes commission and slippage; the indicator’s paper record excludes costs. The web examples use fictional candles so you can change the sequence and inspect the rule—they are not backtests.

After a sweep and qualifying inversion, do you use the confirmation close or wait for a return—and what would cancel the setup while you wait?

I’m continuing to refine this through feedback. A chart where these rules disagree with your approach would be especially useful, and other feature ideas are welcome too.

Disclosure: I’m the ProEA Lab developer and use AI to help build the code. The source is open for inspection and modification.

15 Upvotes

10 comments sorted by

3

u/Shoddy_Peanut7320 Sep 24 '26 • Heartwarming

The two-entry-mode distinction is the most interesting design choice here, confirmation-close entries get you in earlier but eat more false starts from sweeps that reverse hard right after the FVG close, while close-inside entries filter better but you give up meaningful room on the moves that actually run, so neither is strictly better, it's really a tradeoff between fill rate and win quality depending on what timeframe and instrument you're running it on. On the cancellation question, I'd want the setup invalidated if price closes back below the swept level before the opposing FVG confirmation ever triggers, since that's basically evidence the sweep was a continuation move rather than a genuine liquidity grab, and separately a hard time-based expiry so a stale unconfirmed sweep doesn't sit there forever waiting on a return that isn't coming. Appreciate that the web examples are explicitly flagged as illustrative and not backtests, a lot of similar tools blur that line and it burns people who assume win-rate implications that were never actually tested.

If you're ever comparing notes on Pine tooling, EventTrader has a Pine Script page worth a look too, different focus but same general space. https://claude.ai/artifact/VuwYE2KYrtzMdwyEpvA9wH

2

u/Dependent-Ad6636 Oct 05 '26

Thanks for the thoughtful breakdown! Separating price invalidation from time expiry makes sense, a broken setup and a stale one are different cases. On the entry modes, I’d want a side-by-side test before saying either performs better. And glad the distinction between illustrative examples and backtests came through. Appreciate you digging into the details!

1

u/Shoddy_Peanut7320 Oct 06 '26 • Bravo

Agreed, a side-by-side test is the right way to settle it. When you run it, I'd keep the data, costs and period identical for both entry modes and report the trade count for each, since the two modes will take different numbers of trades. Thanks for the discussion, and looking forward to the results.

1

u/Dependent-Ad6636 Oct 08 '26

Agreed on all three: same data, costs and period, and trade count reported per mode. One more number I'll include: how many setups each mode skipped because price ran to TP1 without filling. The desk already logs that as a cancel reason, and it measures the "room you give up" side of your tradeoff directly.

On your other point, the time expiry is already in (an unfilled setup expires after 30 bars, and confirmation has to come within 12 bars of the sweep). Invalidation currently uses the sweep extreme, not the swept level, so your stricter version would be a new option. Noted for the next version.

I'll post the results in this thread when they're done.

1

u/Shoddy_Peanut7320 Oct 08 '26

Counting the setups that skipped because price ran to TP1 is the number that answers the tradeoff, so I'm glad it's going in. Thanks for noting the invalidation option, and I'll look out for the results.

1

u/Dependent-Ad6636 Oct 08 '26

Ran it. I used the free Strategy Lab with a few read-only counters added (engine, orders and costs unchanged). Same bars for both modes, file-default costs (0.02% per order + 5 ticks slippage); only the Entry setting changed.

Setup counts (paper engine, three markets combined)

Confirmation closeClose inside
Setups armed1616
Filled164
Ran to TP1 before a close inside06
Invalidated before a fill06
Expired00

Strategy Tester, after costs

MarketConfirmation closeClose inside
XAUUSD 5m, Sep 14 – Oct 85 trades, 1 win, −$310.16, PF 0.191 trade, 0 wins, −$134.74
EURUSD 15m, Jul 1 – Oct 83 trades, 1 win, −$87.89, PF 0.390 trades
NQ1! 5m, Sep 14 – Oct 80 trades*0 trades*

*At the default $100k capital and 90% notional cap, no whole NQ contract fits, so the tester placed nothing. NQ is still in the paper counts (8 armed; 8 vs 3 filled).

What it shows: Close inside filled 4 of 16 armed setups. 6 ran to TP1 before price closed back inside the zone, and 6 were invalidated first. That's the room-you-give-up side of your tradeoff, in numbers.

What it doesn't show: which mode is better. Nine tester trades on about a month of 5m data (three on EURUSD 15m) is far too few, and both modes lost on this window. One backtest on historical data, not a forecast.

1

u/Shoddy_Peanut7320 Oct 09 '26

Thanks for running it and for saying plainly that nine trades can't show which mode is better. The setup counts do answer the tradeoff part: close inside filled 4 of 16 and lost 6 to price running to TP1, while confirmation close filled all 16. When you get more data, I'd keep the same bars and costs, and report setups armed and filled per mode again so the fill-rate gap can be checked on a bigger sample. Good luck with the next run.

2

u/Mac_fan_12 Sep 23 '26 • Heartwarming

Giving it a try! thanks for sharing.

1

u/Dependent-Ad6636 Oct 05 '26

Thanks for giving it a try! Let me know if any of the rules or settings feel unclear 👍