Expert Advisors • Indicators • Scripts • Libraries

MQL.RobotFX.org is the biggest collection of MetaTrader expert advisors (MT5 & MT4), indicators, scripts and libraries that can be used to improve trading results, minimize risks or simply automate trading tasks

MetaTrader 5 Indicator | Linear Regression calculation based on pine script v4

Linear regression curve

A line that best fits the prices specified over a user-defined time period. It is calculated using the least squares method. The result of this function is calculated using the formula: linreg = intercept + slope * (length - 1 - offset), where length is the y argument, offset is the z argument, intercept and slope are the values calculated with the least squares method on source series (x argument)

pine script v4 function I/O

linreg(source, length, offset) → series[float]

This indicator includes a simple function to calculate the linreg function based on pine script. This function can be used as a copy and paste snippet in conversion projects from tradingview platform.

MetaTrader Experts, Indicators, Scripts and Libraries
47746