OPEN-SOURCE SCRIPT
Actualizado

Setup Scanner [GBB]

38 688
SETUP SCANNER [GBB]

Most scanners tell you a setup fired and stop there. This one attaches a full trade plan to every signal: ATR stop, three R-multiple targets, an expiry and then tracks the outcome and keeps score per setup. New strategies can also be easily added to the scanner, so you do not have 20 different chart tabs open anymore at the same time.

How does it work?

On every confirmed bar the script evaluates six independent setups. Each one reports a state in the panel: off, dormant, forming, LONG or SHORT.

When a setup fires, a simulated trade opens at the close of the signal bar with:

- a stop at ATR(14) × 1.2 (configurable)
- TP1 / TP2 / TP3 at 1R / 2R / 3R
- an expiry after 60 bars

The trade is drawn as a risk box, a reward box, an entry line and a three-rung target ladder. As targets fill, their rungs promote from dashed to solid, so you can read how far a trade got at a glance. When it resolves, the whole drawing fades and gets an outcome tag: stop, TP3, or expired.

The panel counts, per setup, how many trades it opened and what share of them reached TP1.

Included Strategies in v1.0:

1. VWAP RECLAIM
Price must spend at least N consecutive closes (default 6) on one side of session VWAP, then close back across it. Volume filter applies. Forming state triggers when the run is mature and price is drifting back within 0.4 ATR of VWAP.

2. EMA PULLBACK (9/21)
Trend is defined by EMA21 vs EMA50 with EMA50 sloping in the same direction over three bars. Price must have touched EMA21 within the last N bars (default 3), then close back beyond EMA9 on a directional bar that takes out the previous bar's extreme. Volume filter applies.

3. BREAK AND RETEST
A confirmed swing pivot (length 5 either side) is broken on a close. Within the retest window (default 20 bars), price returns to within 0.3 ATR of the broken level and closes back beyond it on a directional bar. Pivots that form while a break is still live are queued rather than overwriting the level — the retest gets to finish before the reference moves. No volume filter.

4. LIQUIDITY SWEEP REVERSAL
A wick takes out the highest high or lowest low of the last 20 bars, the body closes back inside, and the rejection wick is larger than the opposite wick. Volume filter applies.

5. RSI DIVERGENCE
Consecutive confirmed pivots with a lower price low against a higher RSI low (or the inverse for shorts), within a maximum pivot gap of 60 bars. This confirms five bars after the pivot by construction. It is late, on purpose, and it has no forming state.

6. OPENING RANGE BREAK
The range is built from the session open for N minutes (default 15) in your chosen session and timezone, then the first close beyond either edge fires. One break per session, in either direction. The range levels plot once the range closes. For 24h crypto, set the timezone to UTC and pick your own anchor session.

TRADE COUNTING

Entry is the close of the signal bar. Risk is one ATR unit × the stop multiple, and the ladder is measured in multiples of that risk.

Exit accounting is deliberately conservative. If a bar touches both the stop and a target, the stop wins — intrabar sequence is unknowable from OHLC, so the outcome is on purpose counted as pessimistic. A trade that reaches TP1 or TP2 marks the rung and keeps running, only TP3 or the stop or the expiry closes it.

Three controls decide which signals become trades:

- Max concurrent trades (default 1)
- Block opposite-direction entries (default on)
- Re-entry cooldown in bars (default 0)

With the default of one concurrent trade, setups are evaluated in a fixed order — VWAP, EMA, break and retest, sweep, divergence, opening range — so when two fire on the same bar, the earlier one in that order takes the slot. Turn on "Mark blocked signals too" if you want to see the ones the limit swallowed.

The cooldown defaults to 0, which keeps every signal. That is why stops sometimes cluster back to back on an impulse bar. Raising it changes the record, so reset your counts when you change it.

READING THE SCOREBOARD — AND WHAT IT IS NOT

The "fired" column counts trades the engine actually opened, not raw setup fires. Signals blocked by the concurrency limit, the direction lock or the cooldown are not counted.

The "→TP1" column is trades that reached TP1 divided by trades fired. Reached, not captured: a trade that touches TP1 and later stops out still counts in the numerator. Read it as "how often does this setup get moving in my favour", not as a win rate and definitely not as an expectancy.

IMPORTANT

This is not a backtest. Counts accumulate forward over the bars loaded on your chart, they reset on every settings change and chart reload, and they include no commission, no spread, no slippage and no partial fills.

DEFAULTS AND TUNING

The defaults are not optimised. They are round numbers chosen to be readable and to avoid fitting a parameter set to whatever symbol happened to be on the chart during development. The ATR stop, the R ladder, the pivot length and the setup-specific windows are all exposed so you can adapt them to your instrument and timeframe, but every change invalidates the counts already on the panel.

If you tune, tune on one instrument at a time, and treat any improvement that does not survive on data you did not tune on as noise.

DISPLAY

- Trade zones can be turned off entirely if you only want the panel.
- Signal labels come in Full, Short, Arrow only, or Off.
- Closed trades fade by an adjustable amount; filled targets always fade less than unfilled ones, so a resolved trade still shows how far it ran.
- Keep last N drawings caps the chart clutter without affecting the counts.
- Panel position and text size are configurable; colours default to a dark-chart palette and should be dimmed for white backgrounds.

ALERTS


Every trade the engine opens fires an alert() call carrying the setup name, direction and price, once per bar close. Two alertcondition entries are also available for any long setup and any short setup. Note that those fire on the raw signal, whether or not the engine had room to take it.

LIMITATIONS


- Signals evaluate on confirmed bars only. Nothing is drawn or counted on an unclosed bar.
- Break and retest and divergence depend on pivots, which confirm five bars after the fact.
- The VWAP setup requires volume data and stays dormant on symbols that have none. The volume filter also passes automatically where volume is unavailable.
- The opening range setup depends on your session and timezone inputs being correct for the instrument.
- Designed for intraday timeframes. It will run on higher timeframes but the trade model and expiry are not calibrated for them.



Notas de prensa
v1.1

Small quality of life update.

Outcome tags no longer sit on top of the candle. The "stop" label used to be anchored exactly at the stop level, which put it right on the bar that hit it. On a dense chart you couldn't read the candle anymore. Tags are now pushed away from price and point back at the level instead of covering it. Stop tags sit beyond the stop, TP3 tags beyond the target.

There's a new input for this under Closed trade appearance called "Outcome tag offset (ATR)". Default is 0.6. If you liked the old look, set it to 0 and nothing changes for you. On low volatility pairs you might want to bump it up a bit.

Thanks to hivebit7 for the report.

One more thing since it came up: if you have alerts running and you change any settings, including turning setups on or off, your existing alert will NOT pick up the change. TradingView freezes the indicator settings inside the alert at the moment you create it. Delete the alert and set it up again after changing inputs. Same after any script update.

Exención de responsabilidad

La información y las publicaciones no constituyen, ni deben considerarse como, asesoramiento o recomendaciones financieras, de inversión, de trading u otro tipo, proporcionadas o respaldadas por TradingView. Obtenga más información en Condiciones de uso.