Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 nicthe, 08-23-2023, 07:53 AM
            7 responses
            196 views
            0 likes
            Last Post nicthe
            by nicthe
             
            Started by nicthe, Today, 09:24 AM
            0 responses
            5 views
            0 likes
            Last Post nicthe
            by nicthe
             
            Started by stalt, 12-28-2015, 01:36 PM
            6 responses
            1,536 views
            0 likes
            Last Post giulyko00  
            Started by Tburg1073, Today, 08:36 AM
            0 responses
            7 views
            0 likes
            Last Post Tburg1073  
            Started by alexstox, 10-16-2018, 03:29 PM
            10 responses
            334 views
            0 likes
            Last Post Tburg1073  
            Working...
            X