OPEN-SOURCE SCRIPT

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

98

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.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.