Average

Category: Indicators

The Average function in ProBuilder language is used to calculate moving averages, which are fundamental tools in technical analysis for smoothing out price data and identifying trends. The function can compute various types of moving averages depending on the parameters provided.

Syntax

Average[N](price)
Average[N,M](price)

Here, N represents the number of periods over which the average is calculated, and price specifies the price series (like Close, Open, etc.). The optional parameter M determines the type of moving average:

  • 0 – Simple Moving Average (SMA)
  • 1 – Exponential Moving Average (EMA)
  • 2 – Weighted Moving Average (WMA)
  • 3 – Wilder’s Moving Average
  • 4 – Triangular Moving Average
  • 5 – End Point Moving Average
  • 6 – Time Series Moving Average
  • 7 – Hull Moving Average (Available only in PRT v11 and later)
  • 8 – ZeroLag Moving Average (Available only in PRT v11 and later)

Examples

Example 1: Simple Moving Averages

FastMA = Average[7](Close)
SlowMA = Average[20](Close)
RETURN FastMA coloured(221,33,33), SlowMA coloured(35,194,57)

This example calculates two simple moving averages (SMA) for 7 and 20 periods of the closing price and colors them red and green, respectively.

Example 2: Mixed Moving Averages

FastMA = Average[7,1](Close) // EMA
SlowMA = Average[20,4](Close) // Triangular MA
RETURN FastMA coloured(221,33,33), SlowMA coloured(35,194,57)

This example demonstrates the use of an Exponential Moving Average (EMA) for fast MA and a Triangular Moving Average for slow MA, both applied to the closing price.

Example 3: Smoothing an Indicator

myRSI = RSI[14]
SmoothRSI = Average[10](myRSI)
RETURN myRSI, SmoothRSI coloured(121,45,180)

In this example, the Relative Strength Index (RSI) is smoothed using a 10-period simple moving average. This technique is often used to reduce noise and make the indicator easier to interpret.

Additional Information

Moving averages are versatile and can be applied not only to price data but also to other indicators to smooth out their values and reduce volatility. Understanding the different types of moving averages and their applications can significantly enhance technical analysis strategies.

Logo Logo
Loading...