OPEN-SOURCE SCRIPT

MTF S&R Confluence Detector

226
MTF S&R Confluence Detector

OVERVIEW

MTF S&R Confluence Detector automatically maps support and resistance across three independently configurable timeframes, then highlights the spots where those levels stack on top of one another. Confluence — the alignment of multiple structural levels in the same price area — is one of the more reliable ways to identify zones where price is likely to react, and this script does the work of tracking it in real time instead of requiring you to flip between chart timeframes and eyeball it yourself.

Alongside the multi-timeframe pivots, the script also plots Previous Day High/Low and Today's High/Low, and checks those session levels for confluence with your MTF pivots — surfacing "high conviction" areas where intraday structure and prior-session structure line up.

Built and tested on Pine Script v6.

HOW IT WORKS

For each of the three timeframes, the script finds swing highs and swing lows using pivot detection (ta.pivothigh / ta.pivotlow) with independently adjustable lookback and lookahead periods. Each pivot is only confirmed once price has moved the required number of bars past it, so the levels you see are based on confirmed swing points, not predictions.

The most recently confirmed support and resistance level from each timeframe is held on the chart as a line until a new pivot forms and replaces it. A percentage-based "range" is drawn around each level (also configurable per timeframe) to represent a zone rather than a single exact price.

CONFLUENCE DETECTION

The script compares the current support level (and separately, the current resistance level) across all three timeframes. If two levels sit within your chosen confluence threshold (a percentage distance you control), they're flagged as confluent and both lines turn gold. If all three timeframes agree, that's flagged as a "triple confluence" — the strongest signal the script can produce. Confluent zones also get a soft gold fill so they stand out visually from ordinary single-timeframe levels.

The same confluence logic is applied to Previous Day High/Low against your MTF levels, so you can immediately see when a prior session extreme is reinforced by higher-timeframe structure.

KEY FEATURES

- Three independent, fully configurable timeframes for support/resistance detection (defaults: 1H, 4H, Daily)
- Adjustable pivot lookback/lookahead for support and resistance detection separately
- Per-timeframe color, and adjustable percentage "zone" width around each level
- Automatic confluence detection between any two timeframes, plus triple-confluence detection
- Adjustable confluence threshold (%) to control how close levels need to be to count as aligned
- Gold highlighting and zone fills on confluent levels so they stand out at a glance
- Previous Day High/Low and Today's High/Low overlays, each independently toggleable
- Increasing visual weight by timeframe — the highest timeframe is drawn thicker and dashed so higher-timeframe structure reads as more significant
- Clean price-scale labels identifying which timeframe each level belongs to

ALERTS

The indicator ships with a full set of ready-to-use alert conditions, including:

- Pairwise support/resistance confluence for every timeframe combination
- Triple confluence (all three timeframes aligned) for both support and resistance
- Price entering a confluent support or resistance zone
- Price breaking above Previous Day High or below Previous Day Low
- Price making a new session high or low
- Previous Day High/Low aligning with multi-timeframe resistance/support (high-conviction setups)

HOW TO USE IT

1. Set your three timeframes under the "Timeframe 1/2/3" input groups. By default these are 1H, 4H, and Daily, but you can set them to whatever combination fits your trading style (e.g., 15m/1H/4H for intraday, or 4H/D/W for swing trading).
2. Tune the pivot lookback/lookahead under "S&R Detection" to control how sensitive the swing detection is — shorter values find levels faster but produce more of them; longer values are more selective.
3. Adjust the "Confluence Threshold" to set how close levels from different timeframes need to be before they're treated as the same zone. Tighter for precision, wider to catch near-misses.
4. Toggle Previous Day High/Low and Today's High/Low on or off depending on whether you trade session-based levels.
5. Set alerts on any of the built-in alert conditions to get notified the moment a confluence zone forms or price reaches one.

NOTES

- Support and resistance levels are based on confirmed pivots — a pivot only appears after the lookahead period has elapsed, which is standard practice for pivot-based tools and avoids false, unconfirmed levels, but it also means levels are inherently a few bars behind the most recent swing.

- Because the script pulls data from higher timeframes via request.security, values on historical bars from an unclosed higher-timeframe candle can adjust intrabar until that higher-timeframe candle closes — as with any multi-timeframe tool, always wait for confirmation on the current higher-timeframe bar before treating a fresh level as final.

- This indicator is a visual and analytical tool for identifying areas of interest; it does not generate buy or sell signals and should be combined with your own risk management and analysis. Nothing here is financial advice.

คำจำกัดสิทธิ์ความรับผิดชอบ

ข้อมูลและบทความไม่ได้มีวัตถุประสงค์เพื่อก่อให้เกิดกิจกรรมทางการเงิน, การลงทุน, การซื้อขาย, ข้อเสนอแนะ หรือคำแนะนำประเภทอื่น ๆ ที่ให้หรือรับรองโดย TradingView อ่านเพิ่มเติมใน ข้อกำหนดการใช้งาน