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!
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
NinjaTrader
Matrix with Ninja trader
Collapse
X
-
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.
Comment
-
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
-
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.
Comment
-
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
-
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
-
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 PostI 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 Touch-Ups, Today, 10:36 AM
|
0 responses
5 views
0 likes
|
Last Post
by Touch-Ups
Today, 10:36 AM
|
||
Started by geddyisodin, 04-25-2024, 05:20 AM
|
8 responses
61 views
0 likes
|
Last Post Yesterday, 10:45 AM | ||
Started by jxs_xrj, 01-12-2020, 09:49 AM
|
4 responses
3,289 views
1 like
|
Last Post
by jgualdronc
Today, 10:02 AM
|
||
Can someone turn this thinkscript into a ninjascript. 5PM CST OHL and Previous Day
by Option Whisperer
Started by Option Whisperer, Today, 09:55 AM
|
0 responses
5 views
0 likes
|
Last Post Today, 09:55 AM | ||
Started by halgo_boulder, 04-20-2024, 08:44 AM
|
2 responses
24 views
0 likes
|
Last Post Today, 09:41 AM |
Comment