OPEN-SOURCE SCRIPT

Market Euphoria Index - MEI

253
1. The Three Core Factors
The script measures market sentiment by evaluating three different "factors" of price action and assigning a score from 0 to 100 for both Euphoria and Panic.

RSI Factor (Momentum Extremes): It checks if the traditional RSI is overextended.

If RSI is above 70, it scales the value into an Euphoria Score. For example, an RSI of 85 will have a higher Euphoria score than an RSI of 75.

If RSI is below 30, it scales into a Panic Score.

VWAP Stretch Factor (Overextension): It measures how far the current price has stretched away from the Volume Weighted Average Price (VWAP), normalized by the Average True Range (ATR).

If the price shoots up higher than the VWAP by a multiple of the ATR (default is 2.0x), it triggers a maximum 100 Euphoria Score (indicating the asset is heavily overvalued relative to its average volume-weighted baseline).

If it crashes below the VWAP by the same distance, it triggers a 100 Panic Score.
Price Momentum / K's Factor (Candlestick Sentiment): This looks purely at the candlesticks over the last 14 periods (by default).

It counts how many candles closed higher than they opened (Bullish candles) and converts that ratio into an Euphoria Score.

It does the inverse for Bearish candles to create a Panic Score.

2. The Composite Blend
Once the script has the three Euphoria scores and three Panic scores, it averages them:

pinescript -
euphoriaScore = (rsiEuphoria + vwapEuphoria + momEuphoria) / 3
panicScore = (rsiPanic + vwapPanic + momPanic) / 3
Finally, it subtracts the panicScore from the euphoriaScore to get the final mei value.

3. Interpretation & Visuals
The indicator plots as a histogram with dynamic colors and static threshold lines:

> +50 (Red): Extreme Euphoria. The market is firing on all cylinders (RSI overbought, stretched far above VWAP, heavily bullish candles). High risk of a blow-off top reversal.

> +20 (Orange): Standard Euphoria/Strong Uptrend.
Between -20 and +20 (Gray): Neutral market.

< -20 (Teal): Standard Panic/Strong Downtrend.

< -50 (Green): Extreme Panic. The market is oversold, stretched far below VWAP, and showing heavy bearish momentum. High probability of a capitulation bottom bounce.

The script also includes built-in alert conditions (Extreme Euphoria Alert and Extreme Panic Alert) so you can automate notifications when the market reaches these psychological extremes!

Clause de non-responsabilité

Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.