Announcement

Collapse
No announcement yet.

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 iceman2020, Today, 09:39 PM
      0 responses
      1 view
      0 likes
      Last Post iceman2020  
      Started by jimmy_trader, Today, 09:26 PM
      0 responses
      3 views
      0 likes
      Last Post jimmy_trader  
      Started by xxzbill, Today, 08:30 PM
      1 response
      14 views
      0 likes
      Last Post NicholasJoannette  
      Started by fercho, Yesterday, 09:28 AM
      3 responses
      29 views
      0 likes
      Last Post fercho
      by fercho
       
      Started by omololu, Today, 07:10 PM
      6 responses
      22 views
      0 likes
      Last Post omololu
      by omololu
       
      Working...
      X