• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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 thgamey, Yesterday, 08:38 PM
      1 response
      10 views
      0 likes
      Last Post NinjaTrader_Marco  
      Started by stredtity, Today, 01:21 AM
      0 responses
      4 views
      0 likes
      Last Post stredtity  
      Started by superg3, Yesterday, 10:12 PM
      0 responses
      8 views
      0 likes
      Last Post superg3
      by superg3
       
      Started by johnnybegoode, Yesterday, 07:02 PM
      0 responses
      11 views
      0 likes
      Last Post johnnybegoode  
      Started by YevhenShynkarenko, Yesterday, 05:02 PM
      1 response
      17 views
      0 likes
      Last Post YevhenShynkarenko  
      Working...
      X