PINE LIBRARY

LuxyEnergyIndex

655
The Luxy Energy Index (LEI) library provides functions to measure price movement exhaustion by analyzing three dimensions: Extension (distance from fair value), Velocity (speed of movement), and Volume (confirmation level).

LEI answers a different question than traditional momentum indicators: instead of "how far has price gone?" (like RSI), LEI asks "how tired is this move?"

This library allows Pine Script developers to integrate LEI calculations into their own indicators and strategies.

How to Import

Pine Script®
//@version=6 indicator("My Indicator") import OrenLuxy/LuxyEnergyIndex/1 as LEI


Main Functions

`lei(src)` → float

Returns the LEI value on a 0-100 scale.
  • src(optional): Price source, default is `close`
  • Returns: LEI value (0-100) or `na` if insufficient data (first 50 bars)


Pine Script®
leiValue = LEI.lei() leiValue = LEI.lei(hlc3) // custom source


`leiDetailed(src)` → tuple

Returns LEI with all component values for detailed analysis.

Pine Script®
[lei, extension, velocity, volumeZ, volumeModifier, vwap] = LEI.leiDetailed()


Returns:
  • `lei` - Final LEI value (0-100)
  • `extension` - Distance from VWAP in ATR units
  • `velocity` - 5-bar price change in ATR units
  • `volumeZ` - Volume Z-Score
  • `volumeModifier` - Applied modifier (1.0 = neutral)
  • `vwap` - VWAP value used


Component Functions

| Function | Description | Returns |
|-----------------------------------|---------------------------------|---------------|
| `calcExtension(src, vwap)` | Distance from VWAP / ATR | float |
| `calcVelocity(src)` | 5-bar price change / ATR | float |
| `calcVolumeZ()` | Volume Z-Score | float |
| `calcVolumeModifier(volZ)` | Volume modifier | float (≥1.0) |
| `getVWAP()` | Auto-detects asset type | float |

Signal Functions

| Function | Description | Returns |
|---------------------------------------------|----------------------------------|-----------|
| `isExhausted(lei, threshold)` | LEI ≥ threshold (default 70) | bool |
| `isSafe(lei, threshold)` | LEI ≤ threshold (default 30) | bool |
| `crossedExhaustion(lei, threshold)` | Crossed into exhaustion | bool |
| `crossedSafe(lei, threshold)` | Crossed into safe zone | bool |

Utility Functions

| Function | Description | Returns |
|----------------------------|-------------------------|-----------|
| `getZone(lei)` | Zone name | string |
| `getColor(lei)` | Recommended color | color |
| `hasEnoughHistory()` | Data check | bool |
| `minBarsRequired()` | Required bars | int (50) |
| `version()` | Library version | string |

Interpretation Guide

| LEI Range | Zone | Meaning |
|-------------|--------------|--------------------------------------------------|
| 0-30 | Safe | Low exhaustion, move may continue |
| 30-50 | Caution | Moderate exhaustion |
| 50-70 | Warning | Elevated exhaustion |
| 70-100 | Exhaustion | High exhaustion, increased reversal risk |


Example: Basic Usage

Pine Script®
//@version=6 indicator("LEI Example", overlay=false) import OrenLuxy/LuxyEnergyIndex/1 as LEI // Get LEI value leiValue = LEI.lei() // Plot with dynamic color plot(leiValue, "LEI", LEI.getColor(leiValue), 2) // Reference lines hline(70, "High", color.red) hline(30, "Low", color.green) // Alert on exhaustion if LEI.crossedExhaustion(leiValue) and barstate.isconfirmed alert("LEI crossed into exhaustion zone")


Technical Details

Fixed Parameters (by design):
  • Velocity Period: 5 bars
  • Volume Period: 20 bars
  • Z-Score Period: 50 bars
  • ATR Period: 14
  • Extension/Velocity Weights: 50/50


Asset Support:
  • Stocks/Forex: Uses Session VWAP (daily reset)
  • Crypto: Uses Rolling VWAP (50-bar window) - auto-detected


Edge Cases:
  • Returns `na` until 50 bars of history
  • Zero volume: Volume modifier defaults to 1.0 (neutral)


Credits and Acknowledgments

This library builds upon established technical analysis concepts:
VWAP - Industry standard volume-weighted price measure
ATR by J. Welles Wilder Jr. (1978) - Volatility normalization
Z-Score - Statistical normalization method
Volume analysis principles from Volume Spread Analysis (VSA) methodology

Disclaimer
This library is provided for **educational and informational purposes only**. It does not constitute financial advice. Past performance does not guarantee future results. The exhaustion readings are probabilistic indicators, not guarantees of price reversal. Always conduct your own research and use proper risk management when trading.

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.