Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Microsoft StatisticFormula Class & NormalDistribution Method

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

    Microsoft StatisticFormula Class & NormalDistribution Method

    I am using Ninja build version 8.1.4.1 64-bit

    How do you load the Microsoft StatisticFormula class into a Ninja Strategy? I would like to have access to the NormalDistribution method for use in my script.

    The StatisticFormula class is found at:
    https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting.st atisticformula?view=netframework-4.8.1

    It indicates adding line:

    public class StatisticFormula Where should this line be inserted into a script?

    The NormalDistribution method is found at:
    https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.datavisualization.charting.st atisticformula.normaldistribution?view=netframewor k-4.8.1

    It indicates adding the line:

    public double NormalDistribution (double zValue); Where should this line be inserted into a script?

    Is there anything else that I will need to do in order to use the NormalDistribution method for calculations within my script?

    Thank you for your guidance.
    Last edited by Dr Kerry; 01-06-2025, 04:33 AM.

    #2
    Hello Dr Kerry,

    The link you supplied is for windows forms apps, that is not what NT8 uses so that won't be an available namespace. You may be able to add the dll that namespace is in as a reference however you would have to experiment if that works in NT8 as it is not a windows forms app.

    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello Dr Kerry,

      The link you supplied is for windows forms apps, that is not what NT8 uses so that won't be an available namespace. You may be able to add the dll that namespace is in as a reference however you would have to experiment if that works in NT8 as it is not a windows forms app.
      Jesse,

      I thought that all modern apps are now using the Windows Forms .NET framework and therefore would have access to all of the powerful advancements that are available via Microsoft. Is this not the case with Ninja? I know that Ninja is built upon a very very old version of C# that has never, to my knowledge, been updated to the current version of C#. Is this what is limiting its computational features today? It is a severe handicap not to be able to take advantage of all the tools and features currently available. Statistical computational capabilities are a basic requirement for modern quantitative analysis which have been literally available for decades. Yet I can't easily get access to them when I really need them in Ninja, correct? I shouldn't have to "experiment" as you say, they should just be available with no additional headaches imposed upon Ninja users. Why is this not the case? Are you telling me that I will need to write my own method from scratch like it's the year 1984?

      Thanks,

      Kerry

      Comment


        #4
        Hello Dr Kerry,

        Windows forms was an older framework that may still be used in some applications but it has largely been replaced by WPF as it is obsolete. Microsoft has not developed windows forms for a number of years since around 2014.

        NinjaTrader has a general C# compiler built into it to compile custom C# code. NT8 application is built using the WPF window framework.

        You can add other C# dll references but not all are included by default as that would heavily impact runtime performance and may not apply toward a WPF application. You can experiment with other namespaces from other dlls that are not included by default, at that point you are just utilizing the C# compiler to include that code. Not all included code will work as that library may require other components from windows forms that are also not included. Beyond that some items may require some runtime requirements from a windows forms app which would not be available in the context of a WPF app.

        Rather than trying to import something from a different framework that may not work I would suggest looking up the math that is involved for what you wanted out of that library and then just make a indicator that calculates that value and plots it. From there that could be referenced in other strategies or indicators as much as you wanted.

        Comment


          #5
          Originally posted by NinjaTrader_Jesse View Post
          Hello Dr Kerry,

          Windows forms was an older framework that may still be used in some applications but it has largely been replaced by WPF as it is obsolete. Microsoft has not developed windows forms for a number of years since around 2014.

          NinjaTrader has a general C# compiler built into it to compile custom C# code. NT8 application is built using the WPF window framework.

          You can add other C# dll references but not all are included by default as that would heavily impact runtime performance and may not apply toward a WPF application. You can experiment with other namespaces from other dlls that are not included by default, at that point you are just utilizing the C# compiler to include that code. Not all included code will work as that library may require other components from windows forms that are also not included. Beyond that some items may require some runtime requirements from a windows forms app which would not be available in the context of a WPF app.

          Rather than trying to import something from a different framework that may not work I would suggest looking up the math that is involved for what you wanted out of that library and then just make a indicator that calculates that value and plots it. From there that could be referenced in other strategies or indicators as much as you wanted.
          Hello Jesse,

          Thank you for your explanation. Whether it's Windows forms or WPE the Ninja C# is still a very old version. I recall that sometime last year I was forced to use an old-fashioned (and slow) for-loop because the old version of C# that Ninja utilizes doesn't have the parallel processing instruction available that the later versions of C# have incorporated for many years.

          Do you know what the hesitation is in updating Ninja to the latest version of C#? Is it because in doing so too many things will break that would then need to be updated with the newer code instructions?

          I will dig out my Numerical Recipes and Abramowitz and Stegun​ paper text books and do exactly as you suggest, write the the indicator code from scratch (like it's 1984).

          I do appreciate your guidance and insights.

          Thank you again.

          Regards,

          Kerry

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Today, 05:17 AM
          0 responses
          30 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X