What are some useful AFL applications that are suited for using matrices?

I have been using Amibroker for several years but have never used matrices before. I wonder what I have been missing out.

What are some useful AFL applications that employ matrices? Any examples?

Examples making use of matrices:

  1. Creating and doing calculations on independently sized vectors (since AmiBroker 1D arrays have fixed size (-> Barcount length of selected symbol)).

  2. Statistical analyses
    e.g. Regression analysis

  3. Machine learning

  4. Cointegration:
    How to do co-integration in Amibroker

  5. Efficient frontier:
    Scan, Exploration Back Test

  6. Volume Profiles/Order Flow Analysis



@thankyou18, if you search the forum you'll find some code example for this kind of usage of matrices.

For instance, I like to use them to sort items: search for "mxsort"
Or doing it on multiple rows/columns: look for "mxsortrows"
Fast way to create a vector: try "mxfromstring"

Some other useful / more advanced code samples are found looking for "mxsolve"

(Some of the results will be the same for the different search keywords since the code uses multiple Matrix related functions).

And if you are able to access the old Yahoo group you'll find an example of a Logistic Regression by @aron.


Another very interesting use of matrices was posted by @aron in this thread. He cleverly uses them to train a Machine Learning (ML) model to recognize a chart pattern.

If you missed his post, I encourage you to study it to see how, provided you have the appropriate skills, you can use AmiBroker to go beyond the traditional approach of technical analysis.


Geometric problems can also be addressed using MxSolve Circle through three points