OPEN-SOURCE SCRIPT
Atualizado

Clean Pivot Lines with Alerts

1 415
Technical Overview

This Script is designed for detecting untouched pivot highs and lows. It draws horizontal levels only when those pivots remain unviolated within a configurable lookback window and removes them automatically upon price breaches or sweeps.

Key components include:

  • Pivot detection logic: Utilizes ta.pivothigh()/ta.pivotlow() (or equivalent via request.security for HTF) with parameterized pivotLength to ensure flexibility and adaptability to different timeframes.
  • Cleanliness filtering: Checks lookbackBars prior to line creation to skip levels already violated, ensuring only uncontaminated pivots are used.
  • Dynamic level tracking: Stores active levels in arrays (highLines, lowLines) for continuous real-time monitoring.
  • Violation logic: Detects both close-based breaks (breakAbove/breakBelow) and wick-based sweeps (sweepAbove/sweepBelow), triggering alerts and automatic teardown.
  • Periodic housekeeping: Every N (10) confirmed bars, re-verifies “clean” status and removes silently invalidated levels—maintaining chart hygiene and avoiding stale overlays.
  • Customization options: Supports pivot timeframe override, colors, line width/style, lookback length, and alert toggling.


Utility

This overlay script provides a disciplined workflow for drawing meaningful support/resistance levels, filtering out contaminated pivot points, and signaling validations (breaks/sweeps) with alerts. Its modular design and HTF support facilitate integration into systematic workflows, offering far more utility than mere static pivot plots.

Usage Instructions

1. Adjust `pivot_timeframe`, `pivot_length`, and `lookback_bars` to suit your strategy timeframe and volatility structure.
2. Customize visual parameters as required.
3. Enable alerts to receive in-platform messages upon pivot violations.
4. Use HTF override only if analyzing multi-timeframe pivot behavior; otherwise, leave empty to default to chart timeframe.

Performance & Limitations

- Pivot lines confirmation lags by `pivot_length` bars; real-time signals may be delayed.
- Excessive active lines may impact performance on low-TF charts.
- The “clean” logic is contingent on the `lookback_bars` parameter; choose sufficiently high values to avoid false cleanliness.
- Alerts distinguish between closes beyond and wick-only breaches to aid strategic nuance.

Notas de Lançamento
WHAT’S NEW
  • []Historical Break/Sweep Lines: when a pivot is broken or swept, a dashed historical line is plotted and kept visible for a user-set number of bars.
    []Customizable: length (bars to keep), separate colors for break and sweep lines.
    []Organized Inputs: grouped into Pivot Detection, Pivot Line Appearance, Alerts, and Historical Lines for a cleaner UI.
    []Auto-Cleanup: historical lines expire automatically after their set duration; old pivot levels still cleaned periodically.
  • Core Logic Preserved: original pivot detection and alert conditions remain unchanged; optional higher-timeframe pivots via “Pivot Timeframe”.
Notas de Lançamento
ON/OFF Toggle to Historic Triggered Lines

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.