MovingAverage
MovingAverage is a moving average: a line of the average price over the last several bars. It smooths out fluctuations and shows the direction of the move and how far the price has moved away from its average.
The indicator is drawn over the price chart.
How it is calculated
The average is calculated from the price set in Source over Period bars. The kind of average is set by MA type:
- SMA — the simple average: the sum of prices over the period divided by the period;
- EMA — the exponential average: EMA = previous EMA + α × (price − previous EMA), where α = 2 / (period + 1); the starting value is the simple average of the first bars of the period;
- WMA — the weighted average: the last bar has a weight equal to the period, each earlier bar 1 less, the oldest bar of the period 1;
- KAMA — Kaufman’s adaptive average: nearly flat in a range, catches up with the price in a trend. Period is the window of the efficiency ratio ER: the absolute price change over the period divided by the sum of absolute bar-to-bar changes (the price path). The speed of the average varies from that of an EMA with period 30 (at ER = 0) to an EMA with period 2 (at ER = 1): KAMA = previous KAMA + sc × (price − previous KAMA), where sc = (ER × (2/3 − 2/31) + 2/31)²;
- SuperSmoother — Ehlers’ two-pole Butterworth filter: a smooth line with little lag. Period is the filter’s cutoff period: swings shorter than it are smoothed out;
- UltimateSmoother — Ehlers’ filter “price minus a two-pole high-pass filter”: almost no lag for swings longer than the cutoff period. Period is the cutoff period;
- Kalman — the level of a Kalman filter with a “level + velocity” model: follows the price without lag in a steady trend. Period works as for EMA: the share of a new bar in the level is the same as for an EMA of the same period. The price noise is estimated from the price changes over the period, and a price jump on a single bar is limited.
For SuperSmoother, UltimateSmoother and Kalman, a period below 2 is treated as 2.
The line appears once Period bars are available; for KAMA, Period + 1 bars, for Kalman, 2 × Period + 2 bars.
Shift only moves the line to the right by the given number of bars when drawing — it does not affect the calculation.
Parameters
| Parameter | Description | Default |
|---|---|---|
| Period | The number of bars the average is calculated over. At least 1. | 14 |
| Shift | How many bars to move the line to the right. | 0 |
| MA type | The kind of average: SMA, EMA, WMA, KAMA, SuperSmoother, UltimateSmoother or Kalman. | SMA |
| Source | The bar price: Close — the close, Median — (High + Low) / 2, Typical — (High + Low + Close) / 3. | Close |
Plots
| Parameter | Description | Default |
|---|---|---|
| MA | The average line. | Orange, solid, width 1 |
Style
The line has the Plot (show the line), Label (show the last value on the right scale), Color, Width (1–5) and Style (Solid, Dashes, Dots) fields.
How to add an indicator to the chart is described in Adding an indicator; parameters are changed in the indicator manager.