ZigZag ATR Pct

ZigZag ATR % Library
A PineScript v6 library for detecting price pivots based on ATR percentage change (volatility shifts) rather than fixed ATR multiples.
How It Works
Traditional ZigZag indicators use a fixed price threshold to detect pivots. This library takes a different approach: pivots are detected when volatility is changing significantly.
The ATR % change measures how much the Average True Range has shifted over a lookback period:
Pine Script®
Pivots form when |ATR %| exceeds your threshold, capturing turning points during volatility transitions.
Exported Types
Exported Functions
Usage Example
Pine Script®
Parameters
Use Cases
A PineScript v6 library for detecting price pivots based on ATR percentage change (volatility shifts) rather than fixed ATR multiples.
How It Works
Traditional ZigZag indicators use a fixed price threshold to detect pivots. This library takes a different approach: pivots are detected when volatility is changing significantly.
The ATR % change measures how much the Average True Range has shifted over a lookback period:
- Positive ATR % = Volatility expanding (market becoming more volatile)
- Negative ATR % = Volatility contracting (market calming down)
Pivots form when |ATR %| exceeds your threshold, capturing turning points during volatility transitions.
Exported Types
- Settings - Configuration (ATR length, lookback, threshold, display options)
- Pivot - Pivot point data (price, time, direction, volume, ATR %)
- ZigZag - Main state container
Exported Functions
- newInstance(settings) - Create a new ZigZag instance
- update(zz, atr, atrPct) - Update on each bar
- getLastPivot(zz) - Get the most recent pivot
- getPivot(zz, index) - Get pivot at specific index
- getPivotCount(zz) - Get total number of pivots
- calcTR() - Calculate True Range
- calcATR(length) - Calculate ATR using EMA
- calcATRPct(atr, atrPrev) - Calculate ATR % change
- calcPricePct(startPrice, endPrice) - Calculate price % change
Usage Example
Parameters
- ATR Length - Period for ATR calculation (default: 14)
- ATR Lookback - Bars to look back for ATR % change (default: 14)
- ATR % Threshold - Minimum |ATR %| to trigger pivot detection (default: 5.0)
- Depth - Minimum bars between pivots (default: 10)
Use Cases
- Identify reversals during volatility regime changes
- Filter noise during low-volatility consolidation
- Detect breakout pivots when volatility expands
- Build volatility-aware trading systems
This library detects when the market's behavior is changing, not just how much price has moved.
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。