Recent in Technology

Auto S/R with Breakouts & Trendlines v1.15 – Full Guide

Auto S/R with Breakouts & Trendlines v1.15 - Explanation

Auto S/R with Breakouts & Trendlines v1.15 - Explanation

1. Indicator Overview

This script automatically detects Support and Resistance (S/R) zones, tracks breakouts, and draws trendlines based on pivot highs/lows. It also provides a direction signal (buy/sell) based on price action, EMA trend filter, and optional volume confirmation.

It’s essentially a multi-purpose S/R + breakout dashboard for TradingView.

2. Inputs

The script is highly configurable via input parameters:

Input Purpose
left & right Number of bars to the left/right for pivot calculation. Determines how local highs/lows are identified.
atrLen & atrMult ATR length and multiplier for buffer around zones. Helps make zones slightly wider to account for volatility.
mergeFactor If two zones are close enough (within this factor × ATR), they are merged to avoid clutter.
zoneSizePct Small % buffer to expand pivot levels slightly into zones.
maxZonesToPlot Limits number of zones drawn on chart.
zoneMaxBars Maximum age of zones before they are removed.
minTouches Minimum number of times price touched the zone to consider it valid.
useEMAFilter & emaLen Enables trend filter based on EMA. Only considers trades in trend direction. emaLen = EMA period.
useVolumeConfirm, volLen & volMult Optional volume confirmation filter.
showZones, showLabels, showDirectionBox Display options for zones, labels, and direction box.
alertsEnabled Enable/disable alerts for breakout signals.

3. Trend & Pivot Detection

  • EMA Trend: Uses emaLen to identify overall trend.
    - trendBull → price above EMA
    - trendBear → price below EMA
  • Pivot Points:
    - ta.pivothigh → detects local highs (resistance)
    - ta.pivotlow → detects local lows (support)
  • Volume Confirmation: Checks if current volume exceeds volMult × average volume (volLen)

4. Zone Management

The core of the script is creating, merging, and maintaining S/R zones.

  • Zone Storage: Arrays track top/bottom of zones, touches, created bar, resistance/support flag, line & label objects.
  • Add or Merge Zones:
    • If a new pivot zone overlaps or is close → merge it.
    • If not → create a new zone with lines and label.
    • Color-coded: Red → Resistance, Green → Support
  • Expire Old Zones: Automatically deletes zones older than zoneMaxBars.
  • Redraw Zones: Refreshes the lines/labels every bar to keep chart clean.

5. Best Zone Calculation

  • Identifies the most relevant S/R zone near price.
  • Score = touches + distance to current price (closer → higher score)
  • bestIdx stores the index of the best zone.

6. Signals

  • Buy Signal: Price crosses above the top of best support zone, EMA trend bullish (if enabled), volume confirmed.
  • Sell Signal: Price crosses below bottom of best resistance zone, EMA trend bearish (if enabled), volume confirmed.
  • Signal Strength: More touches + trend alignment → stronger signal (Strong Buy/Sell, Weak Buy/Sell).

7. Direction Box

  • Shows current signal and zone strength at the last bar.
  • Color-coded: Green shades → Buy, Red shades → Sell, Gray → Neutral.

8. Alerts

  • Alerts trigger on breakout:
    • Buy breakout → "Buy breakout detected…"
    • Sell breakout → "Sell breakout detected…"
  • Only fires once per bar close to avoid spam.

9. Trendlines

  • Dynamic trendlines using last two pivot highs/lows:
    • Uptrend → connects last 2 pivot lows
    • Downtrend → connects last 2 pivot highs
  • Lines extend to the right and update dynamically.

10. Current S/R Lines

  • Dashed lines for most recent pivot high and low.
  • Helps visualize current support and resistance levels.

11. Info Table

  • Summary table at bottom right:
    • Number of zones tracked
    • Best zone touches
    • Zone strength

✅ Summary

This script is a fully automated support/resistance & breakout indicator with:

  • Dynamic S/R zones
  • Breakout signals (with trend & volume filter)
  • Trendline drawing
  • Visual info box for quick decision making
  • Alerts for automation or notifications

It’s perfect for traders who want to quickly spot strong zones, trend alignment, and breakout opportunities without manually drawing lines every day.

Post a Comment

0 Comments

Recent in Technology