Below is my first attempt and I got inconclusive results.
results :
Any clues as to what is wrong here?
The book was written in 2021-2022. Since then, MQL5 has changed a lot. In particular, the functions for working with matrices have changed: in RegressionMetric, the prototype has changed - a new first parameter has been added.
The source code of the MatrixForexBasket.mq5 example was corrected for it immediately after the announcement of the changes - see the 4th part in the codebase - https://www.mql5.com/en/code/45593.
...
// build a model of best balance - stable profit on every barvector model(BarCount - BarOffset, ConstantGrow);
...
// now estimate the quality of solutionif(BarOffset > 0)
{
// NB: MQL5 doesn't have Split for vectors!// NB: MQL5 can't assign vector to matrix or matrix to vector!// make a copy of balancevector backtest = balance;
// only historic in-sample bars are used for backtest estimation
backtest.Resize(BarCount - BarOffset);
// prepare forward out-of-sample part of the bars manuallyvector forward(BarOffset);
for(int i = 0; i < BarOffset; ++i)
{
forward[i] = balance[BarCount - BarOffset + i];
}
// calculate regression metrics for backtest and forwardPrint("Backtest R2 = ", backtest.RegressionMetric(model, REGRESSION_R2));
model.Resize(BarOffset);
model += BarCount - BarOffset;
Print("Forward R2 = ", forward.RegressionMetric(model, REGRESSION_R2));
}
else
{
Print("R2 = ", balance.RegressionMetric(model, REGRESSION_R2));
}
...
В четвертой части книги мы сосредоточимся на освоении встроенных функций (MQL5 API) и будем последовательно углубляться в специализированные подсистемы. Перечень технологий и функциональности, доступных любой программе на MQL5, огромен. Поэтому для начала имеет смысл рассмотреть наиболее простые и полезные функции, которые могут применяться в большинстве программ.
In this article, we will talk about matrix calculations. Dear readers, do not rush to refuse reading this article, thinking that we will talk about something purely mathematical and too complicated. Contrary to what many people think, a good programmer is not someone who writes a giant program that only they can understand, or someone who writes code in a trendy programming language. A real and good programmer understands that a computer is nothing more than a computing machine to which we can tell how computations should be performed. It doesn't matter what exactly we are creating, it can be a simple text editor that does not contain any mathematical code. But this is just an illusion. Even a text editor contains a fair amount of math in its code, especially if it has a spell checker built into it.
Since the goal here is didactic, we will proceed as simply as possible. That is, we will implement only what we need: matrix multiplication. You will see today that this is enough to simulate matrix-scalar multiplication. The most significant difficulty that many people encounter when implementing code using matrix factorization is this: unlike scalar factorization, where in almost all cases the order of the factors does not change the result, this is not the case when using matrices.
In the previous article "Matrix Factorization: The Basics", I talked a little about how you, my dear readers, can use matrices in your general calculations. However, at that time I wanted you to understand how the calculations were done, so I didn't pay much attention to creating the correct model of the matrices.
You might not have noticed that the matrix modeling was a little strange, since only columns were specified, not rows and columns. This looks very strange when reading the code that performs matrix factorizations. If you were expecting to see the rows and columns listed, you might get confused when trying to factorize. Moreover, this matrix modeling method is not the best. This is because when we model matrices in this way, we encounter some limitations that force us to use other methods or functions that would not be necessary if the modeling were done in a more appropriate way.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
for this specific case yes but for other complex stuff no
for this specific case yes but for other complex stuff no
But that's what I mean, as far as my imagination goes, I cannot think of a use case where you actually need that.
i've used it somewhere if i recall , something with distances .
And the ceo is playing around with ai so this came about from a need probably .
These libraries are supposed to be "faster" than any custom solution .
Also in this case you probably can get the benefit of initializing inside a compute unit if you utilize open cl , i assume
although , you will still initialize sequentially ... hmmi've used it somewhere if i recall , something with distances .
And the ceo is playing around with ai so this came about from a need probably .
These libraries are supposed to be "faster" than any custom solution .
Also in this case you probably can get the benefit of initializing inside a compute unit if you utilize open cl , i assume
although , you will still initialize sequentially ... hmmor we can't see what's coming up and it has to be this way
yeah , or its abandoned 😅
also , this stuff is brutal so@Lorentzos Roussos @Dominik Egert
I was just about to start with matrices and vectors, but reading this thread got me thinking again.
Tell me honestly, is it worth spending time to learn them? The documentation is very poor at explaining the correct ways to use them.
Example from https://www.mql5.com/en/docs/matrix/matrix_machine_learning/matrix_regressionmetrics
Another example at https://www.mql5.com/en/book/common/matrices/matrices_sle is used without the input parameter const vector& vctName!!!
So which one is correct?
Below is my first attempt and I got inconclusive results.
results :
Any clues as to what is wrong here?
The book was written in 2021-2022. Since then, MQL5 has changed a lot. In particular, the functions for working with matrices have changed: in RegressionMetric, the prototype has changed - a new first parameter has been added.
The source code of the MatrixForexBasket.mq5 example was corrected for it immediately after the announcement of the changes - see the 4th part in the codebase - https://www.mql5.com/en/code/45593.
Matrix Factorization: The Basics
Matrix Factorization: A more practical modeling