Appearance
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
| Input | Type | Default |
|---|---|---|
| Short length | int | 10 |
| Long length | int | 21 |
| Source | source | "close" |
| Exponential | bool | false |
| Color | color | "#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" });