Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
When you run the NT New Indicator wizard, it will write out a stub indicator that you can modify, and it will put these "using" declarations into the code, which is how references to different namespaces are added in C#:
#region Using declarations
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Data;
using NinjaTrader.Gui.Chart;
#endregion
If you ever need to reference anything else, you put in the appropriate "using" statement.
If you're not familiar with C# development, I would do some work to get familiar with developing code there, and then dig through some of the code for the standard NT indicators, plus the Help file on NinjaScript, to see what classes are provided and how things are implemented.
I tried to add System.Int32 and System.Array in the declarations but they are unavailable in the NJ editor. Please take a look at the image to see what I am talking about.
I tried to add System.Int32 and System.Array in the declarations but they are unavailable in the NJ editor. Please take a look at the image to see what I am talking about.
I should also add I am using NT 8
You don't need additional libraries.
To declare an array just add the square brackets ([]) after the object type:
int[] numbers = new int[5];
Print("len: " + numbers.Length;
I tried to add System.Int32 and System.Array in the declarations but they are unavailable in the NJ editor. Please take a look at the image to see what I am talking about.
I should also add I am using NT 8
Obviously, I should have asked before offering advice, since I have not gotten into NT8 yet and am not familiar with its editor. Apologies for that.
However, in general I assume you can just type in any appropriate using statement in the NT8 editor and it should compile.
I see that @sam028 has already given the answer, which I wasn't thinking of because I was focused on the "usings".... Duh.
You don't need additional libraries.
To declare an array just add the square brackets ([]) after the object type:
int[] numbers = new int[5];
Print("len: " + numbers.Length;
I wanted to find the length of a given array/series and also be able to get the array position with the highest number and lowest number without have to use a loop to go through the entire series.
I wanted to find the length of a given array/series and also be able to get the array position with the highest number and lowest number without have to use a loop to go through the entire series.
You can try something like this:
int[] numbers = new int[5];
...
Print("len: " + numbers.Length;
int indexAtMax = numbers.ToList().IndexOf(numbers.Max());
int indexAtMin = numbers.ToList().IndexOf(numbers.Min());