Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Singleton Classes - Where do they go?

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

    Singleton Classes - Where do they go?

    I have a Singleton that I wish to use with an AddOn. I have tried several different namespaces and/or derived classes, but can't seem to find a combination that will give me good access to the "NinjaTrader.NinjaScript" features.

    It looks like this is due to the private constructor of the singleton. Once I make the constructor public the issue goes away, but then it isn't a singleton.

    Is there a derived class I don't know about that will not try to Initiate my singleton, but still fits into the architecture of NT8?

    #2
    You can place your singleton in any namespace, the namespace doesn't matter much outside code collision purposes and doesn't actually inherit or give functionality depending on where you place it. Just influences the using statements you would need to use for methods. If I was going to place a singleton I'd likely place it in my own namespace to keep my code separate to prevent collision if possible.

    I can't think of any reason why a public vs private constructor would make any difference here. What exactly are you referring to wanting to access for "good access to NinjaTrader.NinjaScript features", could you give one or two examples and I could help guide you.
    BrettNinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    670 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    379 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    111 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    582 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X