• 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 JTizz, Today, 12:17 PM
      0 responses
      2 views
      0 likes
      Last Post JTizz
      by JTizz
       
      Started by Tradarr, Today, 09:25 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by 7robert, Today, 10:39 AM
      1 response
      13 views
      0 likes
      Last Post NinjaTrader_ShawnB  
      Started by dieci, Today, 09:14 AM
      0 responses
      7 views
      0 likes
      Last Post dieci
      by dieci
       
      Started by brunoviveiros, Today, 09:10 AM
      1 response
      7 views
      0 likes
      Last Post brunoviveiros  
      Working...
      X