# Center of Gravity

A Momentum & Oscillators concept (Classic single-name oscillators) in the LuxAlgo Library, with 1 indicator implementation.

## What is the Center of Gravity?

The Center of Gravity is John Ehlers's oscillator, published in 2002, that locates the balance point of recent prices. Over a fixed window it weights each bar's price by its position, counting the newest bar as one and the oldest as the window length, divides the sum of the weighted prices by the sum of the prices, and negates the result: the centroid of the window, expressed in bar positions. When rising prices load the front of the window, the centroid shifts toward the newest bars and the line turns up; when the oldest bars carry the weight, it turns down.

Because the output is the centroid of a finite window, a relative of windowed FIR smoothing, Ehlers argued it smooths price without the usual lag penalty, and the standard plot pairs the line with a one-bar-delayed copy of itself as a trigger. Two cautions: it is a cycle tool that pins to one side during persistent trends, and the same name is also used for an unrelated polynomial-regression channel drawn around price. This page covers the Ehlers oscillator.

Ehlers, an engineer who spent his career applying signal processing to markets, introduced the CG oscillator in the May 2002 issue of Technical Analysis of Stocks & Commodities and developed it further in his 2004 book Cybernetic Analysis for Stocks and Futures. His starting point was the standard filter tradeoff: conventional moving averages buy smoothness with lag. Because the centroid falls out of the window summation itself rather than an extra smoothing stage, he presented the CG as smoothed yet essentially lag-free, so cycle turns can be acted on early.

The CG is a cycle-timing specialist. Unlike raw [momentum](https://www.luxalgo.com/library/concept/momentum/), which differences prices, or fixed-scale tools like [RSI](https://www.luxalgo.com/library/concept/rsi/) that support absolute [overbought/oversold](https://www.luxalgo.com/library/concept/overbought-oversold/) rules, the CG has no fixed bounds, so its extremes are judged against its own recent swings. That is why Ehlers later added a stochastic-normalized variant, and why ports of both versions remain common on charting platforms.

## How to identify Center of Gravity signals on a chart

The CG plots in its own panel as two lines: the oscillator and a one-bar-delayed copy that serves as the trigger.

1. Establish the regime first from price structure or a trend filter; CG crossings are meant to be traded while price is ranging, not trending.
2. Mark crossings of the oscillator and trigger: an upward cross near the bottom of the indicator's recent envelope is a cycle-trough cue, a downward cross near the top a crest cue.
3. Check for pinning: if the line hugs one side and crossings stop alternating cleanly, a trend has taken over and counter-trend signals should be stood down.
4. Confirm turns against chart levels; a trough cross at range support is a materially different trade from one in mid-air.

## How traders use it

- For swing-turn timing in ranges: crossings of the oscillator and its delayed trigger line mark cycle turns with little lag while price is oscillating rather than trending.
- Through the stochastic variant, which applies [stochastic](https://www.luxalgo.com/library/concept/stochastic-oscillator/)-style normalization to the centroid over a lookback so cycle extremes register at consistent levels.
- Gated by a regime filter: since trends keep the centroid displaced in one direction, most workflows suppress its counter-trend signals once a trend regime is detected.
- For divergence reads: price making a higher high while the CG makes a lower high is a [regular bearish divergence](https://www.luxalgo.com/library/concept/regular-bullish-bearish-divergence/)-style warning that the cycle's upswings are weakening.

## Center of Gravity vs other oscillators

- **Stochastic Oscillator** (https://www.luxalgo.com/library/concept/stochastic-oscillator/): The stochastic locates the close within the high-low range of the lookback and is bounded 0 to 100, feeding fixed overbought and oversold rules. The CG locates the balance point of prices within the window and is unbounded, so extremes are relative. Both aim at swing timing; the CG trades fixed thresholds for smoother turns.
- **RSI** (https://www.luxalgo.com/library/concept/rsi/): RSI compares average gains against average losses and doubles as a regime gauge through its 50 line and shifted ranges. The CG carries no such level semantics; it is purely a turn-timing tool, typically smoother than RSI at comparable lengths but silent about trend strength.
- **CCI** (https://www.luxalgo.com/library/concept/cci/): CCI measures price's deviation from a moving average scaled by mean deviation and is likewise unbounded. The difference is what moves them: CCI stretches when price departs from its average, while the CG shifts when the distribution of recent prices tilts toward the newest or oldest bars.

## FAQ

### How is the Center of Gravity oscillator calculated?

Over a fixed window of N bars, weight each price by its position, counting the newest bar as one and the oldest as N, sum the weighted prices, divide by the sum of the prices, and negate the result. That is the centroid, the balance point of the window's prices measured in bar positions. A one-bar-delayed copy of the line serves as the trigger for crossover signals. The window length is the only parameter, though some published versions add a constant offset to center the line on zero.

### Does the Center of Gravity oscillator work in trends?

Poorly, by design. Ehlers built it for the cycling component of price: in a range it turns close to actual swing highs and lows, but in a persistent trend the centroid stays displaced in the trend's direction and the oscillator pins, producing early counter-trend signals. Pairing it with a trend or regime filter is the standard mitigation, not a guarantee.

### What is the Stochastic Center of Gravity oscillator?

A variant Ehlers published that applies stochastic-style normalization to the CG: the centroid is rescaled by its highest and lowest values over a lookback so cycle extremes register at consistent levels, much as [Stochastic RSI](https://www.luxalgo.com/library/concept/stochastic-rsi/) rescales RSI.

### What window length should I use for the Center of Gravity?

Ehlers's published examples use around 10 bars, but the window should match the swing you are trying to time, behaving best near the half-length of the dominant cycle. Because the centroid is recomputed from the whole window each bar, changing the length changes both the smoothness and the timing of every crossing.

### Is the Center of Gravity indicator the same as the Center of Gravity channel?

No. The same name is attached to an unrelated construction: a regression- or polynomial-fit channel drawn around price on the chart. The Ehlers CG is an oscillator in its own panel, so when loading a script named Center of Gravity or COG, check which of the two you are getting.

### Does the Center of Gravity oscillator lead price?

No indicator sees the future. The design goal is minimal added lag: smoothing comes from the window summation rather than an extra filter stage, so in a clean range turns land close to the actual swing extremes. In trends, or when the cycle length shifts, that alignment degrades, which is why regime checks and window tuning matter.

## Implementations in the Library

- Center of Gravity (LuxAlgo): https://www.luxalgo.com/library/indicator/center-of-gravity/

## Related concepts

- Balance of Power: https://www.luxalgo.com/library/concept/balance-of-power/
- CCI: https://www.luxalgo.com/library/concept/cci/
- Williams %R: https://www.luxalgo.com/library/concept/williams-percent-r/
- Ultimate Oscillator: https://www.luxalgo.com/library/concept/ultimate-oscillator/
- True Strength Index: https://www.luxalgo.com/library/concept/true-strength-index/
- Relative Vigor Index: https://www.luxalgo.com/library/concept/relative-vigor-index/
- Awesome Oscillator: https://www.luxalgo.com/library/concept/awesome-oscillator/
- Accelerator Oscillator: https://www.luxalgo.com/library/concept/accelerator-oscillator/
- Gator Oscillator: https://www.luxalgo.com/library/concept/gator-oscillator/
- Elder Ray: https://www.luxalgo.com/library/concept/elder-ray/

---

Source: https://www.luxalgo.com/library/concept/center-of-gravity/ (LuxAlgo Library, the encyclopedia of trading & technical analysis). Free to use with attribution: https://www.luxalgo.com/library/license/