OPEN-SOURCE SCRIPT
Équilibre du Sentiment – Multi-Périodes (v6)

English
A unique and advanced sentiment indicator based on the harmonic mean of highs and lows over nested rolling windows.
How it works:
The neutral sentiment point is reached when positive sentiment equals negative sentiment, which corresponds to the situation where the percentage between the price and the minimum is equal to the percentage between the maximum and the price.
For each chosen period N, the script calculates N different "neutral feeling" values:
- One using the last 1 bar
- One using the last 2 bars
- …
- One using the last N bars
It then extracts the exact median of these N values using a sorted insertion method (no approximation).
This produces an extremely smooth, non-repainting equilibrium line that represents the true "central sentiment" of the market over the selected lookback.
Features:
- Up to 3 independent periods (365, 52, 26 by default – fully customizable)
- Optional background coloring (green/red) when price is above/below the main curve
- Clean labels on the last bar showing the current value for each active period
- Zero repainting – fully compatible with strategies and alerts
- Highly responsive even with very long periods (up to 3500 bars)
Great for:
- Identifying long-term fair value / equilibrium zones
- Building mean-reversion or breakout systems
Pure Pine Script® v6 – no external libraries, no security calls, no repainting-free.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.