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.
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:
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.
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.