All indicators

Center of Gravity

By LuxAlgoJun 23, 2026

Center of Gravity is an indicator on Vela, our next-generation charting platform, written in Pine Script®.

Static chart image

Center of Gravity plots the balance point of a rolling price window as an oscillator: each bar's price is weighted by its position, the newest counting 1 and the oldest N, and the negated ratio of the weighted sum to the plain sum is the window's centroid in bar positions. This is the definitive clean build of Ehlers's Center of Gravity, paired with its standard trigger (the same line delayed one bar), whose crossings supply the entire signal grammar.

How to Trade the Center of Gravity?

  • Cross above the trigger: a cycle-trough cue, strongest when it fires near the bottom of the oscillator's recent envelope.
  • Cross below the trigger: a crest cue, read the same way near the top of the envelope.
  • No fixed bounds: the line carries no universal overbought or oversold levels, so stretch is sized against the oscillator's own recent travel.
  • Pinning: one color hugging one side of the pane means a persistent trend is loading the window, the cue to stand the counter-trend crossings down.

The tool is a cycle instrument: it earns its keep while price ranges and misleads while price trends, which is exactly the behavior the coloring makes visible.

Center of Gravity Settings

  • Length (default 10): the window N whose balance point is measured, the only parameter. The oscillator behaves best near half the dominant cycle length.
  • Source (default hl2): the price series in the window; the original construction uses the high-low midpoint.
  • Center on Zero (default on): adds the (N + 1) / 2 offset so the line swings around zero; disabled, the raw centroid rests near -(N + 1) / 2 and the midline follows.
  • Style: bullish, bearish, trigger, and midline colors, Gradient Fill (default on), and Trigger Cross Markers (default off). The crossing alerts fire either way.

Frequently Asked Questions

Free to use

Run it on Vela. Go further with a paid plan.

  • Up to 500 Custom Alerts, with webhook automation
  • Up to 10× the chart history of Free
  • Orderflow lookback up to full history
  • More Quant usage to customize it, plus extra usage when you need it
  • Futures data alongside crypto, stocks, forex and commodities
See plans
Original indicatorBuilt in-house by LuxAlgo

Run it on Vela. Make it yours with Quant.

Open this indicator free on Vela, our next-generation charting platform. Then ask Quant, our coding agent built into Vela, to retune it or turn it into a backtested strategy of your own.