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 r68cervera, Today, 04:45 AM
      0 responses
      4 views
      0 likes
      Last Post r68cervera  
      Started by r68cervera, 04-25-2024, 05:29 AM
      2 responses
      18 views
      0 likes
      Last Post r68cervera  
      Started by SugarDefHealth, Today, 03:30 AM
      0 responses
      6 views
      0 likes
      Last Post SugarDefHealth  
      Started by ETFVoyageur, Today, 02:08 AM
      1 response
      10 views
      0 likes
      Last Post ETFVoyageur  
      Started by kujista, 04-22-2024, 07:46 AM
      3 responses
      14 views
      0 likes
      Last Post kujista
      by kujista
       
      Working...
      X