I have an oscillator, and I want to add the absolute oscillator values for the last ten bars.
So I have a variable intOsc and a series seriesOsc.
intOsc = Math.Abs(myOscillator[0])
seriesOsc[0] = intOsc (I’ve tried seriesOsc[0] = Math.Abs(intOsc) also)
sumOsc = SUM(seriesOsc,10)
When I add the last 10 bars with the above line, I get negative numbers!!
Here is an example:
Osc[0] is a positive number and prints correctly. Osc[1] is actually a negative number, so it is printing correctly as Math.Abs() has correctly made it a positive number.
Osc_Sum = SUM(seriesOsc, 2) should be adding Osc[1] and Osc[0] and coming up with a positive number, .0188327. It is not. First of all if the series is storing positive numbers, how is the sum a negative number, and not a correct number at that.
Ok. I was gonna say I think you weren’t using SUM correctly. If you have trouble with that, you can always google ninjatrader + whatever you are C# code you’re trying to use, in this case “Ninjatrader Sum” gave me their page of how to use it and what overloads it takes.