All indicators
Momentum / Own pane

Percentage Price Oscillator

MACD in percent of the slow average: PPO line, signal line and a four-color histogram.

  • PPO
  • Built into Spectral
  • Updates every tick
  • ppo
  • percentage price oscillator
  • macd
  • histogram
  • signal line
  • momentum

By Spectral · v1.0.0

MIT-0: free to use, change and share, no attribution needed. What you build from it is yours.

Already in Spectral: add it from the Indicators toolbox. The file here is the same indicator written as a custom indicator, to change or learn from. Installed, it appears next to the built-in one, marked Custom.

Percentage Price Oscillator on a Spectral chart
Spectral chart with sample market data, default settings.

Overview

The Percentage Price Oscillator is MACD expressed in percent: the difference between a fast and a slow average of price, divided by the slow average and multiplied by 100. The signal line is an exponential average of PPO, and the histogram is PPO minus its signal.

How to read it

Above zero the fast average is above the slow one; the value says by what percentage. PPO crossing its signal line, and the histogram crossing zero with it, shows momentum turning. The histogram colors show direction: dark and light green above zero for rising and falling bars, light and dark red below zero for rising and falling bars.

Because it is a percentage, PPO compares across instruments and across long histories where the price level changed a lot, which MACD in price units cannot.

Settings and limitations

Defaults are 12, 26 and 9 with exponential averages, the common definition (StockCharts and most platforms). The averages start at the first bar, so the earliest values settle after a few times Slow length bars.

Notes

Same lines and histogram colors as Spectral's MACD, in percent of the slow average instead of price units. The signal line is always exponential. TradingView's built-in Price Oscillator draws only the PPO line, with simple 10- and 21-bar averages by default; choose SMA and those lengths to match it.

Settings

Each setting appears in the indicator's settings panel in Spectral, next to a color setting for every output.

SettingTypeDefaultRange or optionsWhat it does
Fast lengthWhole number121 – 500Length of the fast moving average.
Slow lengthWhole number261 – 500Length of the slow moving average.
Signal lengthWhole number91 – 500Length of the exponential average of PPO that forms the signal line.
SourcePrice sourcecloseopen, high, low, close, hlc3Price the averages are calculated from.
Average typeChoiceEMAEMA, SMAExponential or simple averages for the fast and slow lines.

What it draws

Lines

  • PPOsolid · 1.5 px · primary#8AA9C3
  • Signalsolid · 1 px#C4A46A

Levels

  • Zero linedotted · 1 px#788493

Histograms

  • Histogram above zero, risinghistogram bars#6FAF8A
  • Histogram above zero, fallinghistogram bars#A4C9B1
  • Histogram below zero, risinghistogram bars#D8B1B1
  • Histogram below zero, fallinghistogram bars#C98282

Source

Save it as ppo.js and add it with Indicators → Custom indicators → Add file…. The format is explained in the custom indicators guide.

// Copyright (c) 2026 Spectral
// SPDX-License-Identifier: MIT-0
// Free to use, copy, modify and share: https://spectral.trade/docs/custom-indicators/LICENSE.txt
/** @type {import('./spectral-indicator').IndicatorV2} */
export default {
  schemaVersion: 2,
  id: 'ppo',
  name: 'Percentage Price Oscillator',
  shortName: 'PPO',
  version: '1.0.0',
  author: 'Spectral',
  description: 'MACD in percent of the slow average: PPO line, signal line and a four-color histogram.',
  pane: 'oscillator',
  live: { lookback: 1 },
  inputs: {
    fastLength: { type: 'integer', label: 'Fast length', default: 12, min: 1, max: 500, description: 'Length of the fast moving average.' },
    slowLength: { type: 'integer', label: 'Slow length', default: 26, min: 1, max: 500, description: 'Length of the slow moving average.' },
    signalLength: { type: 'integer', label: 'Signal length', default: 9, min: 1, max: 500, description: 'Length of the exponential average of PPO that forms the signal line.' },
    source: { type: 'source', label: 'Source', default: 'close', description: 'Price the averages are calculated from.' },
    maType: { type: 'select', label: 'Average type', default: 'EMA', options: ['EMA', 'SMA'], description: 'Exponential or simple averages for the fast and slow lines.' },
  },
  plots: {
    ppo: { label: 'PPO', color: '#8AA9C3', lineWidth: 1.5, primary: true },
    signal: { label: 'Signal', color: '#C4A46A', lineWidth: 1 },
  },
  levels: {
    zero: { label: 'Zero line', color: '#788493', lineStyle: 'dotted' },
  },
  columns: {
    posRising: { label: 'Histogram above zero, rising', color: '#6FAF8A' },
    posFalling: { label: 'Histogram above zero, falling', color: '#A4C9B1' },
    negRising: { label: 'Histogram below zero, rising', color: '#D8B1B1' },
    negFalling: { label: 'Histogram below zero, falling', color: '#C98282' },
  },
  docs: {
    overview: 'The Percentage Price Oscillator is MACD expressed in percent: the difference between a fast and a slow average of price, divided by the slow average and multiplied by 100. The signal line is an exponential average of PPO, and the histogram is PPO minus its signal.',
    howToRead: 'Above zero the fast average is above the slow one; the value says by what percentage. PPO crossing its signal line, and the histogram crossing zero with it, shows momentum turning. The histogram colors show direction: dark and light green above zero for rising and falling bars, light and dark red below zero for rising and falling bars.\n\nBecause it is a percentage, PPO compares across instruments and across long histories where the price level changed a lot, which MACD in price units cannot.',
    settings: 'Defaults are 12, 26 and 9 with exponential averages, the common definition (StockCharts and most platforms). The averages start at the first bar, so the earliest values settle after a few times Slow length bars.',
    notes: 'Same lines and histogram colors as Spectral\'s MACD, in percent of the slow average instead of price units. The signal line is always exponential. TradingView\'s built-in Price Oscillator draws only the PPO line, with simple 10- and 21-bar averages by default; choose SMA and those lengths to match it.',
  },
  calculate(ctx) {
    const { bars, inputs, ta } = ctx;
    const source = ta.source(bars, inputs.source);
    const average = (values, length) => (inputs.maType === 'SMA' ? ta.sma(values, length) : ta.ema(values, length));
    const fast = average(source, inputs.fastLength);
    const slow = average(source, inputs.slowLength);
    const ppo = fast.map((value, index) => (value === null || !slow[index] ? null : (100 * (value - slow[index])) / slow[index]));
    const signal = ta.ema(ppo, inputs.signalLength);
    const columns = { posRising: [], posFalling: [], negRising: [], negFalling: [] };
    let before = null;
    for (let index = 0; index < bars.length; index += 1) {
      const value = ppo[index] === null || signal[index] === null ? null : ppo[index] - signal[index];
      const previous = before === null ? value : before;
      const role = value === null ? null : value >= 0
        ? (value > previous ? 'posRising' : 'posFalling')
        : (value > previous ? 'negRising' : 'negFalling');
      for (const key of Object.keys(columns)) columns[key].push(key === role ? value : null);
      before = value;
    }
    return { plots: { ppo, signal }, levels: { zero: 0 }, columns };
  },
};

Adapt it with an LLM

Paste this into your assistant and replace the second-to-last line with the change you want.

Start from this Spectral custom indicator: https://spectral.trade/indicators/ppo.js
Format reference: https://spectral.trade/docs/custom-indicators.llm.md
Keep the file format and every rule of the reference; give the result a new id, name, shortName and version, and update docs and input descriptions to match.
Keep its live updates exact and fast (section "Fast live updates" of the reference): carry values from bar to bar only through ctx.ta, and raise live.lookback if the change reads further back; Spectral rejects a file whose live updates differ from a full recalculation or are too slow.
Change I want: <describe the change>
Answer with the complete file in one code block, ready to save as <id>.js.