Download MetaTrader 5

Watch how to download trading robots for free

Interesting script?
So post a link to it -
let others appraise it

You liked the script? Try it in the MetaTrader 5 terminal

2011.10.28 12:56

Matrix operations library - library for MetaTrader 5

| English Русский 中文 Español Deutsch 日本語 Português

votes: 17
matrix.mqh (8.81 KB)view


The library provides simple matrix operations: addition, subtraction, multiplication, inversion.

The matrix.mqh must be placed to terminal_data_folder/MQL5/Include/.

Simple example:

Find the inverted matrix for matrix: F3=((F1+F2)*F2)/10-F2.

F1 and F2 are 3х3 matricies.

#include <Matrix.mqh> 
//| Script program start function                                    |
void OnStart()
   CMatrix          *F1;
   CMatrix          *F2;
   CMatrix          *F3;

   F1=new CMatrix(3,3);
   F2=new CMatrix(3,3);
   F3=new CMatrix(3,3);

   El(F1,0,0)=1;  El(F1,0,1)=4;  El(F1,0,2)=-2;
   El(F1,1,0)=-3; El(F1,1,1)=2;  El(F1,1,2)=2;
   El(F1,2,0)=1;  El(F1,2,1)=0;  El(F1,2,2)=-2;

   El(F2,0,0)=2;  El(F2,0,1)=2;  El(F2,0,2)=-3;
   El(F2,1,0)=-1; El(F2,1,1)=1;  El(F2,1,2)=7;
   El(F2,2,0)=3;  El(F2,2,1)=2;  El(F2,2,2)=10;

   F3.Add(F1,F2); // F3=F1+F2
   F3.Mul(F2);    // F3=F3*F2
   F3.Mul(1./10); // F3=F3/10
   F3.Sub(F2);    // F3=F3-F2

   double det=F3.Inv();  // Invert F3
   printf("det=%5.3f   F3[2,2]=%5.3f",det,El(F3,2,2));
   delete F1;
   delete F2;
   delete F3;

Experts log output:

det=6.624   F3[2,2]=0.548

Translated from Russian by MetaQuotes Software Corp.
Original code:

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

Average Directional Movement Index (ADX) Average Directional Movement Index (ADX)

The Average Directional Movement Index Indicator (ADX) helps to determine if there is a price trend.

TP-SL_Removing TP-SL_Removing

Immediately deletes the SL/TP of all positions.

Closed_TOTAL Closed_TOTAL

Total closure of all positions (winners/losers). You can also select which are of a single instrument.