Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

Linear Regression - MetaTrader 5 Script - MQL5 #23045 - MT4/MT5 Resources

author EAcpu | 4 reads | 0 comments |

Liner regression - indicator for MetaTrader 5

Liner regression - indicator for MetaTrader 5

Liner regression - indicator for MetaTrader 5

Liner regression - indicator for MetaTrader 5

Liner regression - indicator for MetaTrader 5

Liner regression - indicator for MetaTrader 5

Linear regression attempts to model the relationship between two variables by fitting a linear model to an equation of observed data. One variable is considered as the explanatory variable and the other is considered as the dependent variable. For example, a modeler might want to relate an individual's weight to his or her height using a linear regression model. The equation is as follows:

Liner regression - indicator for MetaTrader 5

where x is the number of bars and y is the price.

The ratio of the above equation is calculated as follows:

Liner regression - indicator for MetaTrader 5

Liner regression - indicator for MetaTrader 5

There are many good implementations (some of them are explained in a very good way here: 3 Indicator speedup methods using linear regression as an example) but there are some issues that need to be solved (mainly that some methods are not suitable for use on in-code data...).

This is "another" method that produces exact results (without approximations) just like the "to last letter" method, can be used with arbitrary data and is fast (it's even faster than the method using built-in functions to speed up calculations). The execution time does not depend on the calculation cycle (very large cycles are negligibly slower than calculations on short cycles), which makes it suitable for various filtering/calculations/smoothing...

You can use color changes as signals

Liner regression - indicator for MetaTrader 5


Attachment download

📎 linear_regression.mq5 (9.5 KB)

Source: MQL5 #23045

Verification code Refresh