Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Matrix with Ninja trader

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Matrix with Ninja trader

    Is there a tutorial explaining how to use matrix in NinjaScript ?

    #2
    Not sure what you mean by matrix. NT has a concept which is called SuperDOM. May be that's what you are looking for.

    and then Order entry windows->SuperDOM.

    Also: there are webinars related available. Please see link in my signature

    Comment


      #3
      What i meant was :
      creating and using matrix (line vector x colomn vector) when coding in C#.

      Is there a tutorial ?

      Comment


        #4
        Unfortunately there is no tutorial for that issue available.

        Comment


          #5
          But can we use it when implementing a code ?
          If yes, can you give me an example of code using matrix (just a few lines so I can figure out the process) ?

          Comment


            #6
            Sorry, we don't have a sample available. Please check the MS docs on C# e.g. for "Array" or "ArrayList" etc.

            Comment


              #7
              A year on, I don't suppose there is an example using matrices in NinjaScript?

              Thank
              Shannon

              Comment


                #8
                A simple example of an integer matrix

                Code:
                //Define the matrix
                [FONT=monospace]int[,] sMatrix;
                
                //Initialize the matrix and define the size
                Initialize()
                {
                    //this is a 2x2 matrix
                    int[,] sMatrix = new int[2,2];
                }
                
                //Now, lets use the matrix a little
                OnBarUpdate()
                {
                    //matrix starts at index 0,0
                    sMatrix[0,0] = 1;
                    sMatrix[0,1] = 2;
                    sMatrix[1,0] = 3;
                    sMatrix[1,1] = 4;
                
                  //this matrix looks like this in memory
                  /*
                    0   1 
                   [/FONT][FONT=monospace]---------[/FONT]
                  0[FONT=monospace]| 1 | 2 |
                   [/FONT][FONT=monospace]---------[/FONT]
                  1[FONT=monospace]| 3 | 4 |
                    --------
                  */    
                }
                [/FONT]


                Here's some more information

                Hope this helps.
                mrlogik
                NinjaTrader Ecosystem Vendor - Purelogik Trading

                Comment


                  #9
                  Unfortunately not Shannon, thanks for the post mrlogik!
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    mrlogic & Bertrand,

                    Thanks for your quick replies.

                    With numbers in a matrix, what is the extent to which NinjaTrader is able to run calculations on matrices (e.g. multiply, divide, matrix inversion)? Where can I locate this information / code?

                    In the link mrlogic supplied, the "system.array" class was referred to. Is it required to add this system.array to the declarations section of a NinjaScript?

                    On that point, I am trying to calculate some statistics, hence this line of questioning. I don't suppose there is some statistics class that is NinjaScript has access to?

                    As always, thanks
                    Shannon

                    Comment


                      #11
                      Shannon,

                      Yes, you need to add "using System.Collections.Generic;"

                      NT does not directly have matrix functions, but this is C# .NET; you should find plenty of information with google. Same goes for statistical analysis. NT does have some things in the Performance Class (strategy statistics).

                      I hope this is helpful.
                      mrlogik
                      NinjaTrader Ecosystem Vendor - Purelogik Trading

                      Comment


                        #12
                        MetaNumerics is a good C# library for linear algebra, etc..



                        keep in mind that you must account for the fact that NT dataseries are indexed in reverse

                        Comment


                          #13
                          "keep in mind that you must account for the fact that NT dataseries are indexed in reverse"

                          Does that mean that when you use an array/multi-dimensional array,it is indexed in reverse ?

                          Comment


                            #14
                            I believe what sefstrat is saying is

                            Close[0] = Current Bar Close
                            Close[1] = Previous Bar Close
                            Close[2] = 2 Bars ago Close
                            etc.

                            Just a reference to DataSeries indexing. You can design / use an array / matrix any way you choose; you can index them in any fashion that is appropriate for your design.
                            mrlogik
                            NinjaTrader Ecosystem Vendor - Purelogik Trading

                            Comment


                              #15
                              True you can index them in any fashion you want, but you must remember that position in a matrix is very important in linear algebra since for example multiplication is not commutative.

                              So if you are working with other libraries and operating against data which is generated from outside NinjaTrader they will most likely expect Close[0] to be the close of the first bar, rather than the close of the most recent bar.

                              That is all I was getting at =)

                              Originally posted by mrlogik View Post
                              I believe what sefstrat is saying is

                              Close[0] = Current Bar Close
                              Close[1] = Previous Bar Close
                              Close[2] = 2 Bars ago Close
                              etc.

                              Just a reference to DataSeries indexing. You can design / use an array / matrix any way you choose; you can index them in any fashion that is appropriate for your design.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Perr0Grande, Today, 08:16 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post Perr0Grande  
                              Started by elderan, Today, 08:03 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post elderan
                              by elderan
                               
                              Started by algospoke, Today, 06:40 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post algospoke  
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              12 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post quantismo  
                              Working...
                              X