OPEN-SOURCE SCRIPT
Adaptive Square Levels - for all Instruments

Description:
The Adaptive Square Levels indicator generates mathematically derived horizontal trendlines based on perfect squares (1², 2², 3², …) anchored to the first trading day’s open of each month.
✨ Key Features
📐 Adaptive Anchoring: Locks onto the nearest square number to the monthly open.
🔁 Dual Context: Displays both current month and previous month levels for comparison.
➕➖ Expansion: Automatically plots ±10 square levels around the anchor.
🟧 Highlighting: Multiples of 3² (9, 36, 81, …) are marked in orange for quick recognition.
⭐ Focus Line: The nearest square is bold and labeled with a ★.
🏷️ Readable Labels: Large fonts ensure values are clearly visible, even on high-value instruments.
📊 Finite Trendlines: Levels extend only within the month, not as infinite rays.
⚙️ Configurable: Adjustable max price coverage up to 250,000 (default) to suit stocks, indices, futures, or commodities.
⚙️ How It Works
At the start of a new month, the script locks the opening price of the first bar.
It finds the nearest perfect square to that open.
It then plots 10 square levels above and below the anchor.
Current month levels extend to today’s bar; previous month levels stop at month end.
The nearest square line is emphasized with a bold ★ label.
🎯 How to Use
Support & Resistance: Use square levels as natural price magnets or turning points.
Monthly Structure: Compare previous vs. current month grids for context.
Confluence Tool: Combine with price action, Fibonacci retracements, or market profile.
Focus Points: Pay special attention to the ★ bold nearest-square — it often becomes the key pivot for the month.
📚 Study Note: Why Square Numbers?
Square numbers (1, 4, 9, 16, 25, …) create a nonlinear but structured grid.
Unlike linear step levels (e.g., round numbers), square levels:
Expand naturally as prices rise.
Provide distinct mathematical anchors.
Have been observed to align with natural support/resistance zones.
This indicator makes square mathematics practical by adapting them to live market opens.
⚠️ Disclaimer
This script is for educational purposes only.
It is not financial advice.
Trading carries risk; always test and combine with proper risk management.
The Adaptive Square Levels indicator generates mathematically derived horizontal trendlines based on perfect squares (1², 2², 3², …) anchored to the first trading day’s open of each month.
✨ Key Features
📐 Adaptive Anchoring: Locks onto the nearest square number to the monthly open.
🔁 Dual Context: Displays both current month and previous month levels for comparison.
➕➖ Expansion: Automatically plots ±10 square levels around the anchor.
🟧 Highlighting: Multiples of 3² (9, 36, 81, …) are marked in orange for quick recognition.
⭐ Focus Line: The nearest square is bold and labeled with a ★.
🏷️ Readable Labels: Large fonts ensure values are clearly visible, even on high-value instruments.
📊 Finite Trendlines: Levels extend only within the month, not as infinite rays.
⚙️ Configurable: Adjustable max price coverage up to 250,000 (default) to suit stocks, indices, futures, or commodities.
⚙️ How It Works
At the start of a new month, the script locks the opening price of the first bar.
It finds the nearest perfect square to that open.
It then plots 10 square levels above and below the anchor.
Current month levels extend to today’s bar; previous month levels stop at month end.
The nearest square line is emphasized with a bold ★ label.
🎯 How to Use
Support & Resistance: Use square levels as natural price magnets or turning points.
Monthly Structure: Compare previous vs. current month grids for context.
Confluence Tool: Combine with price action, Fibonacci retracements, or market profile.
Focus Points: Pay special attention to the ★ bold nearest-square — it often becomes the key pivot for the month.
📚 Study Note: Why Square Numbers?
Square numbers (1, 4, 9, 16, 25, …) create a nonlinear but structured grid.
Unlike linear step levels (e.g., round numbers), square levels:
Expand naturally as prices rise.
Provide distinct mathematical anchors.
Have been observed to align with natural support/resistance zones.
This indicator makes square mathematics practical by adapting them to live market opens.
⚠️ Disclaimer
This script is for educational purposes only.
It is not financial advice.
Trading carries risk; always test and combine with proper risk management.
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.