Skip to content

Price Oscillator ​

Percentage difference between a short and a long moving average.

Kind indicator · Drawn in its own pane

Try it ​

On the chart, press / and choose Price Oscillator under Oscillators. To change it, copy the source below into the AlphaScript editor.

Inputs ​

InputTypeDefault
Short lengthint10
Long lengthint21
Sourcesource"close"
Exponentialboolfalse
Colorcolor"#089981"

Source ​

From packages/alphascript/indicators/ppo.as.js.

js
indicator({ name: "Price Oscillator", shortTitle: "PPO", overlay: false, precision: 2 });
const shortLength = input.int("Short length", 10, { min: 1 }), longLength = input.int("Long length", 21, { min: 1 });
const src = input.source("Source", "close");
const exponential = input.bool("Exponential", false);
const fast = exponential ? ta.ema(src, shortLength) : ta.sma(src, shortLength), slow = exponential ? ta.ema(src, longLength) : ta.sma(src, longLength);
plot(ta.calc([fast, slow], (f, s) => ((f - s) / s) * 100), { title: "PPO", color: input.color("Color", "#089981", { group: "Style" }) });
hline(0, { title: "Zero", color: "rgba(120,123,134,0.5)", style: "dashed" });

AlphaScript language v0.1 · runtime 0.2.0