# Moving Average

Moving averages are used to smooth trends. TC2000 offers four different types of moving averages.

**Simple**

A simple moving average gives equal weight to each data point for the period. If the period is 3 and the last three data points are 3, 4 and 5 the most recent average value would be (3+4+5)/3=4 (divide by three because there are three data points).

**Exponential**

An exponential moving average (EMA), sometimes also called an exponentially weighted moving average (EWMA), applies weighting factors which decrease exponentially. The weighting for each older data point decreases exponentially, giving much more importance to recent observations while still not discarding older observations entirely

**Front Weighted**

A front-weighted average, like an exponential average, allows the most recent data being averaged to impact the average value more than older data. It is calculated differently than exponential averages but it also gives recent data more weight. A 5 period front weighted average is calculated as follows (C is the most recent bar, C4 is 4 bars ago):

Front Weighted Average = ((C*5) + (C1*4) + (C2*3) + (C3*2) + C4) / 15

**Hull Moving Average** - The Hull Moving Average solves the age old dilemma of making a moving average more responsive to current price activity whilst maintaining curve smoothness. In fact the HMA almost eliminates lag altogether and manages to improve smoothing at the same time. Read more at AlanHull.com.

You can see how the different averaging types produce different results. All four averages are plotted using a period of 21: simple (yellow), exponential (cyan), front-weighted (red) and Hull moving average (orange).

Function Version | Base |
`tAVG(w, x)` |
`w` =Numeric, `x` =Period |

Simple |
`AVG(w, x)` |
||

Exponential |
`XAVG(w, x)` |
||

Front Weighted |
`FAVG(w, x)` |
||

Hull |
`HAVG(w, x)` |
||

Indicator Version of Price or Volume |
Base |
`tAVGpx.z` |
`t` =AverageType, `p` =PriceVolume, `x` =Period, `z` =Offset |

Simple |
`AVGpx.z` |
||

Exponential |
`XAVGpx.z` |
||

Front Weighted |
`FAVGpx.z` |
||

Hull |
`HAVGpx.z` |

Where `w`

is any formula returning a numeric value.

Where `x`

is the period which must be an integer.

Where `t`

is the Average Type. Leave blank for Simple, X for Exponential, F for Front Weighted, or H for Hull.

Where `p`

is the price or volume component being averaged. O for Open, H for High, L for Low, C for Close, or V for Volume.

Where `z`

is the offset. An offset of 1 returns the value for the previous bar instead of the current bar.

### Examples

A 21 period simple moving average for the current bar can be written as follows.

`AVGC21.0`

Or as follows.

`AVGC21`

Or as follows.

`AVG(C, 21)`

Converting this to exponential adds an X to the beginning of any of the previous forms.

`XAVGC21`

While front weighted uses an F.

`FAVGC21`

And Hull uses an H.

`HAVGC21`

In addition, you can choose what element of price to use in the calculation of the average: Last, Open, High, Low, or Typical Price. (1)

Moving averages have an Offset parameter (2) that allows you to shift the average plot forward or backwards (negative offset value). This allows you to plot what are commonly referred to as "displaced" moving averages.

Read more about Moving Averages at Investopedia