# Firefly Oscillator

Firefly Oscillator is an indicator on [Vela](https://vela.luxalgo.com/chart), our next-generation charting platform, written in Pine Script®.

Plots the Firefly oscillator: a z-score of the weighted price (high + low + 2 x close) / 4 against its 10-bar EMA basis, double-smoothed with a 3-period zero-lag pass and rescaled so 50 is neutral on a roughly 0-100 scale, with a glow that flares toward extremes. Dashed 80/20 levels mark stretched readings, optional divergence detection compares confirmed swings, and eight alerts cover crosses, fades and divergences.

- Indicator in the LuxAlgo Library, by LuxAlgo, published Jun 8, 2026.
- Access: free.
- Concepts: [Firefly Oscillator](https://www.luxalgo.com/library/concept/firefly-oscillator/) (primary)
- Open on Vela: https://vela.luxalgo.com/chart?pineScriptCodeId=m2tnc5rbxfa5rwq7f5lrumqd
- Page: https://www.luxalgo.com/library/indicator/firefly-oscillator/

**Firefly Oscillator** renders the community-bred momentum gauge in fully specified form, a first faithful implementation of the [Firefly oscillator](https://www.luxalgo.com/library/concept/firefly-oscillator/) recipe. A weighted price that double-counts the close is converted to a z-score against its own EMA basis and standard deviation, double-smoothed with a zero-lag pass, and rescaled so 50 is neutral on a roughly 0-100 scale. The line is bullish-colored above the midline and bearish below, a gradient fill anchors it to 50, and the optional glow flares as readings stretch, the flaring the oscillator is named for.

## How to Trade the Firefly Oscillator?

- **Midline crosses**: a cross of 50 flips the volatility-adjusted stretch from one side of the basis to the other; both directions carry alerts.
- **Overbought and oversold**: pushes beyond the dashed 80 and 20 levels mark statistically stretched readings, and the fades back through them carry their own alerts.
- **Divergences**: with detection on, price printing a fresh extreme while the oscillator prints a lesser one draws a line between the two swings, tagged Bullish or Bearish.

Because the z-score underneath is unbounded, violent bars can push readings slightly past 0 or 100: stretch, not error.

## Firefly Oscillator Settings

- **Basis Length** (default 10): lookback shared by the EMA basis and the deviation of the weighted price; shorter reads twitchier.
- **Smoothing Length** (default 3): EMA length of the zero-lag double smoothing pass.
- **Overbought** (default 80) and **Oversold** (default 20): the stretched-reading levels.
- **Show Divergences** (default off) with **Pivot Lookback** (default 5) and **Max Pivot Distance** (default 60): swing confirmation and the widest allowed gap between swings.
- **Glow Effect** (default on): the halo that intensifies toward the extremes.

## Frequently Asked Questions

### How does the Firefly compare to the CCI?

Both measure displacement from a moving basis, but the [Commodity Channel Index](https://www.luxalgo.com/library/indicator/commodity-channel-index/) scales by mean absolute deviation and stays unbounded, while the Firefly scales by standard deviation, double-smooths and rescales to a roughly 0-100 read, trading statistical rawness for a rounder, swing-friendly curve.

### Do the divergence drawings repaint?

A swing must survive Pivot Lookback bars on each side before it exists, so divergence lines appear with that confirmation delay, then stay put. The usual trade-off: fewer false swings, later notice.

### Why does my Firefly differ from other versions?

No canonical specification exists, so variants disagree on price input, lengths and smoothing details. This build fixes one coherent pipeline (weighted price, z-score, zero-lag pass, rescale) and exposes every parameter.

## Related indicators

- [Internal Candle Strength](https://www.luxalgo.com/library/indicator/internal-candle-strength/) (Balance of Power): markdown at https://www.luxalgo.com/library/indicator/internal-candle-strength.md
- [Pretty Good Oscillator](https://www.luxalgo.com/library/indicator/pretty-good-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/pretty-good-oscillator.md
- [Gator Oscillator](https://www.luxalgo.com/library/indicator/gator-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/gator-oscillator.md
- [Wave Trend Oscillator](https://www.luxalgo.com/library/indicator/wave-trend-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/wave-trend-oscillator.md
- [Traders Dynamic Index](https://www.luxalgo.com/library/indicator/traders-dynamic-index/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/traders-dynamic-index.md
- [Center of Gravity](https://www.luxalgo.com/library/indicator/center-of-gravity/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/center-of-gravity.md
- [QQE Weighted Oscillator](https://www.luxalgo.com/library/indicator/qqe-weighted-oscillator/) (QQE): markdown at https://www.luxalgo.com/library/indicator/qqe-weighted-oscillator.md
- [5/35 Oscillator](https://www.luxalgo.com/library/indicator/5-35-oscillator/) (Momentum & Oscillators): markdown at https://www.luxalgo.com/library/indicator/5-35-oscillator.md

---

Source: https://www.luxalgo.com/library/indicator/firefly-oscillator/ (LuxAlgo Library). Free to use with attribution: https://www.luxalgo.com/library/license/
