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.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.
Script de código aberto
Em verdadeiro espírito do TradingView, o criador deste script o tornou de código aberto, para que os traders possam revisar e verificar sua funcionalidade. Parabéns ao autor! Embora você possa usá-lo gratuitamente, lembre-se de que a republicação do código está sujeita às nossas Regras da Casa.
Aviso legal
As informações e publicações não se destinam a ser, e não constituem, conselhos ou recomendações financeiras, de investimento, comerciais ou de outro tipo fornecidos ou endossados pela TradingView. Leia mais nos Termos de Uso.