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.
    DierkNinjaTrader Customer Service

    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 kazisl, Today, 06:41 PM
            0 responses
            2 views
            0 likes
            Last Post kazisl
            by kazisl
             
            Started by einstein, Today, 06:20 PM
            0 responses
            2 views
            0 likes
            Last Post einstein  
            Started by op1031, Today, 05:51 PM
            0 responses
            3 views
            0 likes
            Last Post op1031
            by op1031
             
            Started by nighttrader99, Today, 04:34 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_ShawnB  
            Started by Simon Investimens, Today, 02:51 PM
            1 response
            15 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Working...
            X