Extrapolating Forex Curves Using Linear Algebra Methods
Anyone who have ever heard about extrapolation and financial trading is tempted to try using some of those math methods for an advantage in trading. After all, it seems quite logical to assume that a price chart curve (Forex or stock, or any other security) is a function of some sort that can be predicted mathematically, like parabola or a sine function. So, here you will find the test results for some extrapolation methods in Forex trading using the MetaTrader 5 platform.
To tell the long story short, they aren't very effective — and there's no surprise, as the methods that were created for interpolation (and can extrapolate simple functions) fail to extrapolate complex functions with high levels of variance, the same way as the pure mathematical methods cannot account for fundamental and sentimental factors behind the markets. If you aren't interested in the math details of these tests, you can just note down that using algebraic extrapolation isn't a good idea in Forex and stop reading here. If you want more details, please do read further.
Lagrange polynomials. The first method to try is polynomial interpolation using the Lagrange polynomials. It is probably the first extrapolation method that comes to mind and it is rather simple in computation. We have used the Barycentric form — it is just a faster and simpler way to interpolate/extrapolate using the Lagrange polynomials. If the Forex market behaved like a function similar to x², there would be some success with this method, but in reality Runge's phenomenon messes it all up. If we use just two last points to extrapolate, we get a straight line extrapolation, which obviously fails in Forex; if we try to use a large number of points to improve the input data for extrapolation, we fail because of Runge's phenomenon — the extrapolated values just jump up or fall down disproportionally to the input data. You can see the Lagrange polynomials extrapolation indicator and play around with it to see how the result changes depending on the number of the input points.
Lagrange polynomials on Chebyshev nodes. If you read about Runge's phenomenon, you can also find out that, using unevenly distributed points of the sample function data, it is possible to minimize the effect of the phenomenon. Chebyshev nodes provide the
Systems of linear equations. A less obvious and a little bit more complex approach to mathematical market predictions is systems of linear equations. If we assume that each time point on chart n with a price Pn has its own parameter Rn such that:
Rn * Pn + Rn-1 * Pn-1 + ... + R1 * P1 + R0 * P0 = Current Price,
we can assemble a system of linear equations to find all the Rn values and use them to extrapolate the future prices knowing the previous prices. It looked quite logical, but the result wasn't any better than in the first two attempts (Lagrange polynomials). We used the Doolittle algorithm to perform the LU decomposition to solve the systems of equations. A nice example of C++ code for Doolittle LU Decomposition served very well as a base our my MT5 code. Now you can freely download the working MT5 indicator that tries to predict the future prices with the systems of linear equations.
Pattern matching. Although it isn't exactly a method from the linear algebra (it is just a simplified
In conclusion, one can say that extrapolation works rather poorly in Forex. And this is true for any other financial trading analysis. Purely static mathematical methods cannot produce sustainable trading results. Market participants should look beyond the linear algebra if they want to be successful in trading — be it automated or manual.
If you have any comments or questions on using algebraic methods in Forex trading, you can join for a discussion in our community of traders.