Use of Matrix and Vectors!!! MQL structures are in infant stage?

 

@Lorentzos Roussos @Dominik Egert 

I was just trying to start with Matrix and Vectors, but reading this thread (https://www.mql5.com/en/forum/448355) makes me think again.

Tell me frankly man, is it worth to invest time in learning them? The documentation is very poor to explain the correct ways of using 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 used without the input parameter const vector& vctName!!!

So which one is correct?

 if(BarOffset > 0)
   {
      // make a copy of the balance
      vector backtest = balance;
      // select only "historical" bars for backtesting
      backtest.Resize(BarCount - BarOffset);
      // bars for the forward test have to be copied manually
      vector forward(BarOffset);
      for(int i = 0; i < BarOffset; ++i)
      {
         forward[i] = balance[BarCount - BarOffset + i];
      }
      // compute regression metrics independently for both parts
      Print("Backtest R2 = ", backtest.RegressionMetric(REGRESSION_R2));
      Print("Forward R2 = ", forward.RegressionMetric(REGRESSION_R2));
   }
   else
   {
      Print("R2 = ", balance.RegressionMetric(REGRESSION_R2));
   }

Below is my first attempt and I got non convincing results.

vector  vctClose;
if(vctClose.CopyRates(mSymbol,mTimeFrame,COPY_RATES_CLOSE,mStart,mLength)) {
        Print("vector_rates COPY_RATES_CLOSE: \n", vctClose);
        double MSE = vctClose.RegressionMetric(vctClose,REGRESSION_MSE);
        double MAE = vctClose.RegressionMetric(vctClose,REGRESSION_MAE);
        double R2  = vctClose.RegressionMetric(vctClose,REGRESSION_R2);
        PrintFormat("vctClose MSE[%.8f] MAE[%.8f] R2[%.8f]",MSE,MAE,R2);
}

results :

2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    vector_rates COPY_RATES_CLOSE: 
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    [2256.67,2253.55,2255.63,2256.39,2261.03,2260.66,2262.13,2260.56,2257.57,2265.25,2260.74,2258.68,2260.31,2265.94,2271.41,2277.43,2280.47,2281.69,2279.92,2283.28,2282.56,2283.36,2285.04,2283.65,2285.96,2282.02,2271.16,2273.24, ...
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    vctClose MSE[0.00000000] MAE[0.00000000] R2[1.00000000]
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    vector_rates COPY_RATES_CLOSE: 
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    [2256.67,2253.55,2255.63,2256.39,2261.03,2260.66,2262.13,2260.56,2257.57,2265.25,2260.74,2258.68,2260.31,2265.94,2271.41,2277.43,2280.47,2281.69,2279.92,2283.28,2282.56,2283.36,2285.04,2283.65,2285.96,2282.02,2271.16,2273.24, ...
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    vctClose MSE[0.00000000] MAE[0.00000000] R2[1.00000000]
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    vector_rates COPY_RATES_CLOSE: 
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    [2256.67,2253.55,2255.63,2256.39,2261.03,2260.66,2262.13,2260.56,2257.57,2265.25,2260.74,2258.68,2260.31,2265.94,2271.41,2277.43,2280.47,2281.69,2279.92,2283.28,2282.56,2283.36,2285.04,2283.65,2285.96,2282.02,2271.16,2273.24, ...
2024.04.14 15:41:33.094 iCPatterns_v2.02 (XAUUSD,H1)    vctClose MSE[0.00000000] MAE[0.00000000] R2[1.00000000]

Any clues what is wrong here?

Documentation on MQL5: Matrix and Vector Methods / Machine learning / RegressionMetric
Documentation on MQL5: Matrix and Vector Methods / Machine learning / RegressionMetric
  • www.mql5.com
Compute the regression metric to evaluate the quality of the predicted data compared to the true data Parameters vector_true/matrix_true [in]  ...