PROTECTED SOURCE SCRIPT

TTMW: Zig Zag (Deviation Adjusted)

### Objective
The **TTMW+: Zig Zag (Deviation Adjusted)** indicator identifies significant price movements by determining key support and resistance levels. It helps traders spot turning points in price trends using deviation thresholds and pivot points. Additionally, it highlights price reversals, cumulative volume at these points, and percentage changes, providing insights into price rotation dynamics.

---

### Brief Calculation
1. **Deviation Threshold Calculation**:
- The deviation is based on the difference between the high and low of the previous monthly bar, normalized by the close price and adjusted by a user-defined multiplier (`dev_threshold_mul`).

\[
\text{Deviation Threshold} = \left(\frac{|M_{High}[1] - M_{Low}[1]|}{M_{Close}} \times 100\right) \times \text{Multiplier}
\]

2. **Pivot Detection**:
- **High Pivot**: A point where the current price is higher than a defined range of preceding and succeeding prices (`depth`).
- **Low Pivot**: A point where the current price is lower than a defined range of preceding and succeeding prices.
- Pivots are calculated using the `pivots` function.

3. **Price Rotation and Reversal**:
- Measures the percentage or absolute price change from the last pivot to the current price.
- Labels and lines are dynamically plotted at reversal points to reflect the cumulative volume and price changes.

\[
\text{Price Rotation} = \frac{(P_{\text{current}} - P_{\text{last}})}{P_{\text{last}}} \times 100
\]

4. **Line and Label Plotting**:
- When the price moves beyond the deviation threshold, a line connects the previous pivot to the current price.
- Labels display details like price, percentage change, and cumulative volume.

5. **Extension to Last Bar**:
- Optionally, extends the last significant price movement to the latest bar for real-time monitoring.

---

### Use Case
This indicator is ideal for:
- Identifying **trend reversals**.
- Highlighting **support and resistance zones**.
- Visualizing **price momentum and volume dynamics**.

Wyłączenie odpowiedzialności