Extrapolating Forex Curves Using Linear Algebra Methods

Anyone who have ever heard about extrapolation and about financial trading was tempted to try using some of those math methods for an advantage in trading. After all, it seems quite logical to assume that the 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, I’ve decided to test some of the extrapolation methods in Forex trading using the MetaTrader 5 platform.
To tell the long story short, I’ve failed — and there’s no surprise, as the methods that were created for interpolation (and can extrapolate simple functions) fail to extrapolate the complex functions with high levels of variance, the same way as the pure mathematical methods can’t account the fundamental and sentimental factors behind the markets. If you aren’t interested in the math details of my tests, you can just remember that using algebraic extrapolation isn’t a good idea in Forex and stop reading here. If you want more details, please, do read farther.
Lagrange polynomials. The first method that I’ve tried was polynomial interpolation using the Lagrange polynomials. It’s probably the first extrapolation method that comes to mind and it’s rather simple in computation. I’ve used the Barycentric interpolation — it’s 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 2 last dots to extrapolate, we get a straight line extrapolation, which obviously fails in Forex; if we try to use a big amount 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 my Lagrange polynomials extrapolation indicator and play with it to see how the result changes depending on the amount of the input dots.
Lagrange polynomials on Chebyshev nodes. If we read about Runge’s phenomenon, we can also find out that, using the unevenly distributed points of the sample function data, it’s possible to minify the effect of the phenomenon. Chebyshev nodes provide the best-fit dots for this purpose. That’s why after failing with plain Lagrange, I’ve tried doing the similar calculations with the Chebyshev nodes. Expectedly, the result wasn’t very impressive, as the Chebyshev nodes eliminate the problem only inside the input data set (that’s why they are good for interpolation) and don’t help at all for the data points outside of the initial set (extrapolation). You can see my Lagrange polynomials on Chebyshev nodes extrapolation indicator and have some fun with it.
Systems of linear equations. A less obvious and a little bit more complex approach to mathematical market predictions is the systems of the linear equations. If we assume that each time point in 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 the linear equations to find all the Rn and use them to extrapolate the future prices by knowing the previous prices. It looked quite logical but the result wasn’t any better than in my first two attempts :). I’ve used the Doolittle algorithm to perform the LU decomposition to solve the systems of the equations. A nice C++ code for Doolittle LU Decomposition served very well as a base for my MT5 code. Now you can freely download my MT5 indicator that tries to predict the future prices with the systems of linear equations.
Pattern matching. Although it’s not exactly a method from the linear algebra (it’s just a simplified self-learning system similar to one I had developed earlier), the pattern matching also uses mathematical methods to predict the future Forex rates. The patterns are composed of (Close — Open) / Open ratios for each candle that’s included into the pattern. Each pattern has its result stored — a difference between Close and Open of the next candle after the pattern. In theory, with enough number of such patterns with the results collected from the past we can predict the future rates by finding the best matching pattern for the current one. In practice, the results aren’t very accurate. Pattern Matching indicator helps to test this method of extrapolation.
In conclusion, I can say that extrapolation works rather poorly in Forex (or any other financial trading). Pure static mathematical methods can’t produce sustainable trading results. Market participants should look beyond the linear algebra if they want to be successful in trading — mechanical or manual.

If you have any comments or questions on using the algebraic methods in Forex trading, please, reply using the form below.

Leave a Reply

Your email address will not be published. Required fields are marked *

eighty six + = ninety two