Dear programmers, i need some help with ninjatrader 8 scripting. Please forgive my ignorance. So, i'm playing up with the code, basically a simple test indicator, with 2 outputs: "Outputx" and "Outputxx". Now, as we can see in the first image, i put the code: Outputx[0]=High[0]; Outputxx[0]=Low[0]; And we can see the two lines of the indicator below the chart, working well. The thing i don't understand, if i put something before these commands, such as: indi[0][0]=0; (indi is defined as "public double[][] indi;"), so everything works fine in the compiler, no errors or anything like that. However, when i put this line, the indicator on chart disappear. I can't understand why? Whenever i work with other doubles that are not the outputs, the indicator stop working all together. Any idea of what's going on?
NinjaTrader has a really good support forum for developers, you're likely to get a better response there.
Try commenting out or even better try deleting the parts you added to the indicator, until you reach the point the indicator works again. Then add each line slowly and check to make sure everything is still working before you increase the complexity to a level where you can't locate what's wrong.
Ok look at this, i just take a working indicator (ATR), i made a copy of it (ATRx), and make the following modifies: added "private Series<double> speeda;" and "speeda[0]=1;" and magically everything stop working.
Disclaimer: I have never done any Ninjatrader scripting, but, AFAIU, Ninja script is C#. In C#, the line private Series<double> speeda; declares an object speeda but does not create an instance of it. Thus, when you do speeda[0]=1; You are referring to a null object, and getting an exception. Try changing the line to be private Series<double> speeda = new Series<double>(); depending on how the Series<T> object is programmed, that may still get you an index-out-of-range exception at your assignment statement, but at least the object will be defined.
Dear terr, thanks for your help. Apparently i managed to fix the situation, using the following code for declaring an array: double [] indi = new double[10]; //instead of just double[] indi; or also double [,] indi = new double[10,10]; // instead of double[][] indi; I must say i don't know a lot about coding but somehow we did it!