The LinearRegression function in ProBuilder language is used to calculate the linear regression value of a selected price over a specified number of periods. This function helps in identifying the equilibrium price trend over a given period, which is useful for analyzing market trends and potential price deviations from the equilibrium.
LinearRegression[N](price)
Where N represents the number of periods over which the linear regression is calculated, and price specifies the price data (e.g., close, open, high, low) to be used in the calculation.
To illustrate how to use the LinearRegression function, consider a scenario where you want to calculate the linear regression of the closing price over the last 10 periods and then create a Linear Regression Oscillator:
REM Calculate Linear Regression of close price over the last 10 periods
a = LinearRegression[10](close)
REM Store the current close price
b = close
REM Calculate the Linear Regression Oscillator
c = b - a
RETURN c
In this example, a represents the linear regression value of the close price over the last 10 periods. The variable b stores the current close price, and c calculates the difference between the current close price and its linear regression value, effectively creating an oscillator that measures deviation from the linear regression line.
Understanding the output of the LinearRegression function can provide insights into the general direction of the market and help in making informed trading decisions.