Announcement

Collapse
No announcement yet.

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.
    http://www.ninjatrader-support.com/H...helpguide.html
    and then Order entry windows->SuperDOM.

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

    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.
        DierkNinjaTrader Customer Service

        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.
            DierkNinjaTrader Customer Service

            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
                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 
                   ---------
                  0| 1 | 2 |
                   ---------
                  1| 3 | 4 |
                    --------
                  */    
                }
                


                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..

                        http://metanumerics.codeplex.com

                        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 Lance El Camino, Today, 04:14 PM
                              1 response
                              12 views
                              0 likes
                              Last Post s.kinra
                              by s.kinra
                               
                              Started by jtrading82, Today, 04:56 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_ShawnB  
                              Started by dmking, Today, 06:00 PM
                              1 response
                              6 views
                              0 likes
                              Last Post NinjaTrader_EricB  
                              Started by WHICKED, Today, 03:23 PM
                              1 response
                              12 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by demarcog, Today, 02:24 PM
                              1 response
                              10 views
                              0 likes
                              Last Post NinjaTrader_Kate  
                              Working...
                              X