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

To use 'new' or not

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

    To use 'new' or not

    It was my understanding that indicators are objects. However, I thought the 'new' keyword needed to be used to create an object, but that's not the case in NT, at least not all the time. For example, this code works just fine, WITHOUT creating a new myCustomIndicator() object using 'new'...

    onBarUpdate()
    {
    myValue = myCustomIndicator().Plot0[0]

    // other stuff goes here

    }

    Why is this? And, are there any general rules for when you need to use 'new' or not?

    Thanks much!

    #2
    coolmoss,

    Some of these indicators are pre-initialized in a way from my understanding. For example, calling EMA(15) is referencing something NT creates in the background and under-the-hood.

    Using the "new' keyword is usually the way to create a new object.
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      Thanks, Adam. I suspected some such thing but wanted to verify as I'm self-teaching some new C# stuff and wanted to be sure I understood what's going on

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CortexZenUSA, Today, 12:53 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by CortexZenUSA, Today, 12:46 AM
      0 responses
      1 view
      0 likes
      Last Post CortexZenUSA  
      Started by usazencortex, Today, 12:43 AM
      0 responses
      5 views
      0 likes
      Last Post usazencortex  
      Started by sidlercom80, 10-28-2023, 08:49 AM
      168 responses
      2,265 views
      0 likes
      Last Post sidlercom80  
      Started by Barry Milan, Yesterday, 10:35 PM
      3 responses
      11 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Working...
      X