Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

public private -

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

    public private -

    Hello,

    I could find in the forum "private double - private int" and I know about difference of double and int and I´m trying to use int when possible for cpu. But cant find an explanation for the difference between "private - public - "_" "

    private int/double
    public int/double
    int/double

    Thanks
    Tony

    #2
    Hello,

    Private and Public really wouldn't be explained much on this forum as these are just C# concepts rather than anything that is specific to NinjaTrader. You do use public properties in NinjaTrader, and also private variables, it would depend on the use case for what access modifier needs to be used.

    To better understand these "access modifiers" you could review the MSDN information on "C# access modifiers" https://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx

    For a less dry explanation we can use google to get some other tutorials like the following which has a huge amount of information: http://www.codeproject.com/Articles/...-Access-Modifi

    Because NinjaTrader utilizes C#, you can find a huge amount of information on this language outside of NinjaTrader documents which in turn will help you develop items with more ease.

    I look forward to being of further assistance.

    Comment


      #3
      Hello,

      thank you for your reply.

      Public and private clear but when to use a variable without both?

      Thanks
      Tony

      Comment


        #4
        Hello,

        Again this falls back to standard C# concepts.

        A blank or no modifer variable is a private varaible by default.

        To know if the variable needs a public or private modifier depends on how you will use it in your logic.

        I could not say it has to be public or private without knowing how the variable would be used in logic. A public variable is generally used where you need that variable public or visible to other classes or when making a Property that shows up in the Property Grid. A private variable is generally used when you do not need to make it public or it is only used in code.

        Again this is up to your best judgement and what you need to do based on the logic you make.

        The only time this would play a specific role in NinjaTrader would be related to making Plots or User Inputs that show up in the user interface, those properties are public and are marked with [ ] attributes above the class. you can see an example of one of these properties in the SMA indicator.

        Please let me know if I may be of further assistance.

        Comment


          #5
          Hello,

          thanks.

          This is what I asked for "A blank or no modifer variable is a private varaible by default. "


          Tony

          Comment


            #6
            Originally posted by tonynt View Post
            Hello,

            thanks.

            This is what I asked for "A blank or no modifer variable is a private varaible by default. "


            Tony
            Do not rely on default access modifiers. Specify exactly what you want. It makes your code clearer when you come to read it a few months from now.

            Just my $0.02.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            80 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            46 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            29 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            32 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            66 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X