Indicators/probuilder · probacktest · proorder · proscreener

PriceOscillator

PriceOscillator in ProBuilder returns the difference between a short and a long moving average, a momentum measure. Syntax, formula, examples, gotchas.

Syntax

probuilder
PriceOscillator[S,L](price)

Parameters

NameTypeDefaultDescription
SintegernonePeriod of the short-term moving average. Must be smaller than L.
LintegernonePeriod of the long-term moving average.
priceprice sourcecloseThe price series both averages are computed on, typically close.

Formula

code
PO = MA(price, S) - MA(price, L)

A percentage variant can be derived by dividing by the short average:

code
PO% = (PO / MA(price, S)) * 100

The instruction itself returns the difference in price units. The percentage form must be computed manually when cross-instrument comparability is needed.

How it works

The Price Oscillator condenses a classic two-average crossover system into a single line. Instead of watching two moving averages cross on the price chart, the oscillator plots their difference around a zero line. The short average reacting faster than the long one means the difference grows during accelerating trends and shrinks as momentum fades.

A positive reading means the short average sits above the long average, the configuration associated with upward momentum. A negative reading means the opposite. A crossing of the zero line is exactly equivalent to the two moving averages crossing on the chart.

The concept is the same family as MACD, which is the specific case of exponential averages with periods 12 and 26 plus a signal line. The Price Oscillator exposes the two periods as parameters, making the fast and slow horizons fully configurable.

Examples

Example 1, Basic price oscillator (Indicator)

probuilder
// Difference between the 10-bar and 20-bar moving averages of the close
RETURN PriceOscillator[10,20](close) AS "Price Oscillator", 0 AS "Zero line"

Plots the 10 versus 20 period oscillator with a zero reference line. The line is above zero whenever the 10-bar average trades above the 20-bar average.

Example 2, Zero-line crossover system (ProOrder)

probuilder
// Enter long on upward momentum, exit when momentum flips negative
po = PriceOscillator[10,20](close)

IF NOT OnMarket AND po CROSSES OVER 0 THEN
  BUY 1 CONTRACT AT MARKET
ENDIF
IF LongOnMarket AND po CROSSES UNDER 0 THEN
  SELL AT MARKET
ENDIF

Translates the oscillator's zero-line logic directly into entries and exits. This is functionally identical to trading a 10 and 20 period moving average crossover.

Example 3, Percentage oscillator screener (ProScreener)

probuilder
// Rank instruments by momentum in percentage terms
po = PriceOscillator[10,20](close)
popct = po / average[10](close) * 100
SCREENER[popct > 1](popct AS "PO %")

Converts the oscillator to its percentage form so instruments at different price levels become comparable, then lists those with the short average more than 1 percent above the long one.

Interpretation

ReadingMeaning
Above 0Short average above long average, upward momentum.
Below 0Short average below long average, downward momentum.
Crossing above 0Bullish crossover of the underlying averages.
Crossing below 0Bearish crossover of the underlying averages.
Rising while positiveTrend accelerating.
Falling while positiveTrend still up but losing pace.

Divergences between price and the oscillator, such as higher price highs with lower oscillator highs, are read the same way as with other momentum tools, as early signs of a weakening move.

Common errors and gotchas

  • Swapped periods flip the sign. PriceOscillator[20,10](close) inverts every reading, turning bullish configurations negative. Keep S strictly smaller than L.
  • Point values are not comparable across instruments. The raw output is in price units, so a reading of 5 means something different at every price level. Use the percentage form for screeners and cross-market work.
  • Moving average type is fixed. The averaging method inside the instruction is not a parameter. When a specific type is required, such as exponential, build the oscillator manually from ExponentialAverage calls.
  • Whipsaws in ranging markets. Like any two-average system, the zero line gets crossed repeatedly when price moves sideways. A trend filter or a minimum-distance threshold reduces false signals.
  • MACD, the exponential 12 and 26 period special case with a signal line.
  • MACDLine, the MACD difference line on its own.
  • Average, simple moving average building block.
  • ExponentialAverage, for constructing an exponential variant manually.
  • Momentum, price difference over a fixed lookback.
  • ROC, percentage rate of change.
  • DPO, detrended price oscillator, price relative to a displaced average.
  • VolumeOscillator, the same two-average construction applied to volume.