Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best practice for structuring computationally intensive Indicators

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

    #16
    Hello jeronymite,

    I'm not quite sure what you are wanting me to comment on in this thread. However, yes, set variables to null if you want to mark the objects previously references by them for garbage collection. With a string series vs a double series, it would depend on how long the string is on which would take more memory. Each character of a string would be 4 bytes. A double would be 8 bytes. If the string is more than 2 characters long, then the string would take more memory.
    I have a client application that connects to a WCF service, I get the file size from the server as a long value then I convert it at the client to string so it appears like ex:52.21 MB The applica...


    With plots, there would be more CPU and graphics use for plot series added with AddPlot() verses using a custom Series<T>. By adding this as a plot, NinjaTrader is now using CPU to check the values and try and rendering these using the GPU. A custom series is not going to have any attempts to render a plot, so marginally less CPU.


    Shansen,

    An indicator added to a chart with IsSuspendedWhileInactive true is similar to an indicator called from a strategy.
    The indicator while inactive, queues the updates until its active, then runs through the queue of updates.
    OnBarUpdate() is still triggered exactly the same for all of the queued events, including with IsFirstTickOfbar.

    If there is something time sensitive in that you need OnBarUpdate() to run to trigger some kind of action that does not result in data being accessed by the host script, you can call Update() from the host script and that will trigger the bar update queue to run through to current.

    However, if the point is to fetch data from the hosted indicator, then by calling series information or calling a public property with Update() will run the queue the same as if it was active the entire time.

    Calling AddChartIndicator() from a strategy specifically, would keep the indicator from being inactive.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Thanks, NinjaTrader_ChelseaB, for looking at the thread. The request is simply to review the thread, in particular the document created by Richard Todd, and to provide any equivalent relevant recommendations for NinjaTrader 8. Simple as that. If the same advice applies, great. If it's different now, fine; just need the updated recommended approach.

      Thanks.
      Multi-Dimensional Managed Trading
      jeronymite
      NinjaTrader Ecosystem Vendor - Mizpah Software

      Comment


        #18
        Originally posted by NinjaTrader_ChelseaB View Post
        Each character of a string would be 4 bytes. A double would be 8 bytes. If the string is more than 2 characters long, then the string would take more memory.
        https://stackoverflow.com/questions/...-or-long-value

        Four bytes?
        You sure about that?

        Chelsea, that is incorrect.
        In fact, that is not what your stackoverflow link says.

        Let's carefully re-read that link,

        "Strings in C# are Unicode characters (every character is two bytes) + a pointer
        to that address (minimum 4 bytes, 8 bytes on an x64 .NET application).

        Long is 8 bytes. Once you exceed 2 characters on x86, or any characters on x64
        you'll take more memory than long."


        How did you fail to see that each character is two bytes?

        -=o=-

        A second answer in that stackoverflow link says this,

        "A .NET string is an array of UTF-16 code units, each 2 bytes long."

        Again, more confirmation that each character in a string is 2 bytes, not 4 bytes.


        Comment


          #19
          Hello bltdavid,

          I was thinking a 2 byte character and 2 byte pointer which to me is 4 bytes in memory. However, this would be advanced c# and I definitely may not be correct about this.

          Hopefully the link found from a google search is able to provide some insight. You may want to further clarify on stack overflow.
          Chelsea B.NinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          650 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X