OPEN-SOURCE SCRIPT
Aggiornato MP AMS (100 bars)

Indicator Name: ICT Nested Pivots: Advanced Structure with Color Control
Description:
This indicator identifies and labels nested pivot points across three levels of market structure:
Short-Term Pivots (STH/STL)
Intermediate-Term Pivots (ITH/ITL)
Long-Term Pivots (LTH/LTL)
It detects local highs and lows using a user-defined lookback period and categorizes them into short, intermediate, and long-term pivots based on their relative strength compared to surrounding pivots.
Key Features:
Multi-level pivot detection: Nested identification of short, intermediate, and long-term highs and lows.
Customizable display: Toggle visibility of each pivot level independently for both highs and lows.
Color control: Customize colors for high and low pivot labels and text for enhanced chart readability.
Clear labeling: Each pivot is marked with intuitive labels ("STH", "ITH", "LTH" for highs and "STL", "ITL", "LTL" for lows) placed above or below bars accordingly.
Safe plotting: Avoids errors by validating data and only plotting labels within the lookback range.
This tool helps traders visually analyze market structure and identify key turning points at different time scales directly on their price charts.
Description:
This indicator identifies and labels nested pivot points across three levels of market structure:
Short-Term Pivots (STH/STL)
Intermediate-Term Pivots (ITH/ITL)
Long-Term Pivots (LTH/LTL)
It detects local highs and lows using a user-defined lookback period and categorizes them into short, intermediate, and long-term pivots based on their relative strength compared to surrounding pivots.
Key Features:
Multi-level pivot detection: Nested identification of short, intermediate, and long-term highs and lows.
Customizable display: Toggle visibility of each pivot level independently for both highs and lows.
Color control: Customize colors for high and low pivot labels and text for enhanced chart readability.
Clear labeling: Each pivot is marked with intuitive labels ("STH", "ITH", "LTH" for highs and "STL", "ITL", "LTL" for lows) placed above or below bars accordingly.
Safe plotting: Avoids errors by validating data and only plotting labels within the lookback range.
This tool helps traders visually analyze market structure and identify key turning points at different time scales directly on their price charts.
Note di rilascio
Absolutely! Here’s a clean **upgrade note/changelog** and a **feature summary** you can use when publishing your indicator, plus a quick “How to Use” guide for your users. You can copy-paste or adapt for TradingView.---
## MP AMS V1 — ICT Nested Pivots (Custom Labels)
### **What's New in V1**
* 🔺 **Visual Upgrade:** High/Low pivots now show triangle shapes **and** text labels (e.g., "STH", "LTH") for clear, fast visual identification.
* 🌈 **Fully Customizable Colors:** Easily set custom colors for **triangle shapes** and **pivot text** for each level (Short, Intermediate, Long-term) — both highs and lows.
* 🧩 **Cleaner Code:** All pivot arrays and label plotting logic updated for clarity, reliability, and max performance.
* ⚡ **Performance Fixes:** No more missing or delayed labels. Labels are always plotted on detected pivots for up to 100 bars.
* 🛠️ **Bug Fixes:** Fixed an issue where some recent pivots didn’t display. Now all pivots within the selected lookback window appear as expected.
* 🔍 **Improved Readability:** Label positions adjusted for better visibility (text and triangle do not overlap).
* 🎛️ **Settings Panel:** All colors and lookback values are adjustable directly from the settings menu.
---
### **How to Use**
1. **Apply the Indicator:** Add “MP AMS V1” to any chart.
2. **Adjust Lookback:** Set the lookback (bars to scan for pivots) — default is 100.
3. **Customize Colors:** Use the settings to choose different colors for triangles (shapes) and text labels for each type/level.
4. **Interpret Signals:**
* **High Pivots:** Triangles & labels above bars (STH/ITH/LTH).
* **Low Pivots:** Triangles & labels below bars (STL/ITL/LTL).
---
### **Pro Tips**
* For larger timeframes, consider increasing the lookback period for more visible pivots.
* If you want labels for more than 100 bars, increase `max_bars_back` in the code and set a higher lookback (may impact performance).
* Labels use the TradingView maximum label count (50 for standard, more for Premium). If you zoom out or increase lookback, some older labels may disappear (Pine Script limitation).
* This script is optimized for live/manual analysis; it’s not intended for automated backtesting.
---
### **Credits & Acknowledgments**
Built for ICT/SMC traders and anyone who likes a visual pivot map!
Inspired by classic nested pivot logic, but with modern TradingView visuals.
---
#### **Have feedback, feature requests, or bug reports? Leave a comment or DM!**
---
Let me know if you want this tailored further (or want a Russian/Ukrainian translation, etc)!
Note di rilascio
What Was Fixed & Improved1. Out-of-Bounds Index Protection
The old script sometimes tried to access data at high[i-1] or high[i+1] (or low[...]) where i-1 could be negative, or i+1 could exceed the current bar, especially on the first few bars or higher timeframes.
Now: The loop and pivot checks include a condition: if i-1 >= 0 and i+1 <= bar_index. This guarantees you never try to access before the first bar or past the last available bar, so you never get the "The script attempts to reference historical data that is too far from the current bar" error.
2. Always Start From First Available Bar
The script now works from the very first valid bar (as soon as 3 bars are available), on any timeframe. This way, you’ll see pivots for all possible bars (not just on 15m, but also 1H, 4H, etc).
This is handled with the check: if bar_index >= 2 before the loop starts, so the script won’t try to calculate pivots before enough data exists.
3. Loop Boundaries Adjusted
Used lb = math.min(lookback, bar_index) to ensure the pivot search only runs within the available bars, regardless of your lookback input or the number of bars currently loaded on the chart.
The for-loop now runs from i = 1 up to lb - 2, which is always safe (never negative or too far ahead).
4. Label Creation Is Safe
The plotting function checks if bar_index - _offset >= 0 before creating each label, so it never tries to place a label outside the available chart area.
5. Robust For All Timeframes
These changes ensure the script works correctly on ANY timeframe (1m, 5m, 15m, 1H, 4H, etc.), and that pivots/labels are always drawn where possible, not just on smaller timeframes.
In short:
No more index errors
No more missing pivots on large timeframes
All pivots are detected as soon as enough bars are available
Label plotting is always safe and robust
Note di rilascio
MP AMS V1 – Advanced Multi-Scale Swing/Pivot DetectorMP AMS V1 automatically detects and labels market swing points at three different time horizons:
Short-Term (STH/STL)
Intermediate-Term (ITH/ITL)
Long-Term (LTH/LTL)
The script works on any timeframe and visually marks:
Short-Term Highs/Lows (STH/STL): Standard swing highs/lows, formed when a bar’s high/low is greater/less than its immediate neighbors.
Intermediate-Term Highs/Lows (ITH/ITL): Higher-level pivots formed from sequences of short-term swings. An ITH is a STH that’s higher than the previous and next STH; likewise for ITL.
Long-Term Highs/Lows (LTH/LTL): Major pivots among intermediate pivots (ITH/ITL).
Features:
Automatic detection of pivots at all three scales.
Priority labeling: If a pivot is, for example, both STH and ITH, only the higher class (ITH) will show, keeping the chart clean.
Works on any symbol and timeframe.
Customizable colors for each pivot label via settings.
Handles TradingView’s bar history and label limitations automatically.
How to Use:
Add the indicator to your chart.
Use the detected pivots to identify structure, potential support/resistance, and multi-timeframe swing alignment.
For advanced traders: combine with your SMC or liquidity concepts for enhanced context.
Tip:
The indicator is especially useful for multi-timeframe traders, SMC practitioners, and anyone interested in clean, automated swing labeling for journaling or trade planning.
Let me know if you want it shorter, longer, or to add a section about how to use in specific SMC workflows!
Ask ChatGPT
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.
Script open-source
In pieno spirito TradingView, il creatore di questo script lo ha reso open-source, in modo che i trader possano esaminarlo e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricorda che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni ed i contenuti pubblicati non costituiscono in alcun modo una sollecitazione ad investire o ad operare nei mercati finanziari. Non sono inoltre fornite o supportate da TradingView. Maggiori dettagli nelle Condizioni d'uso.