Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stdev discrepencies

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Stdev discrepencies

    Greetings,

    I've got a series of data in a DataSeries object for the last 17 periods. I want to find the Standard Deviation for the FIRST 9 periods...when I input the values on the statistical calculator (in Windows) the values for SUM and AVERAGE match what I'm getting in my output, however there are small differences in Standard Deviation, I'm at a loss to explain why?

    The data in question:

    the DataSeries is called "MINORS" and the period data is as follows:

    [0] = 24; [1] = 34; [2] = 38; [3] = 37; [4] = 37; [5] = 32; [6] = 30.2;
    [7] = 48.1; [8] = 47;

    the STDEV command: Ds = StdDev(MINORS, 9)[0];

    The Output Window reports the StdDev as "7.2252" however the calculator outputs "7.6635", why the difference?

    #2
    Sorry I don't know. Please see the StdDev sources to see how NT calculates the StdDev.

    Comment


      #3
      Thank you for the reply. So I guess you agree at least that my command line to calculate "Ds" is at least correct?

      As for the discrepency I guess you are also correct there must be some difference in how the calculator and NT are figuring Stdev, however without knowing how the calculator is doing it just looking at the NT source isn't much help. I checked the Help files in the calculator and it simply seems to give instructions on how to calculate Stdev, but not the internal math processes used...

      Comment


        #4
        Syntax looks correct but you can verify in the Help Guide.
        RayNinjaTrader Customer Service

        Comment


          #5
          No Stdev discrepencies with this code

          I use this code to get standard deviation:

          ...

          double sum = 0;
          for ( int i = 1; i <= Periods; i++)
          sum += Math.Pow(Close[i-1]-SMA(Periods)[0],2);

          Value.Set(Math.Sqrt(sum/(Periods-1)));

          ...

          Difference between Ninjatrader and other charting applications (or Excel) is division by N (Periods) or N -1 (both is "correct" but division by N-1 is more common).

          Comment


            #6
            Thank you for that helpful information!

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            566 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            330 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            547 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            548 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X