Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Performenace Question

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

    Performenace Question

    Scenario:
    I am dynamically calculating, drawing, and removing of support/resistance rectangles starting at the current time until end of session time on the chart throughout for each session on the chart. The actual number of rectangles will vary based on user parameters input. The user can specify how many support/resistance levels he wants for a specified tick range so I rank them and only show that number of rectangles.

    Question:
    What is my most efficient method of checking if a drawing object rectangle already exists on the chart? My thinking is to track what I have currently drawn in an array and not draw it again if the tag name (tag name = session date + price) currently exists in the array. When a rectangle is no longer in effect I will redraw the rectangle shorter than the end of session time and remove the tag name from the array so I can see where rectangles were at each point in time in the past for post analysis. I could check for the actual existence of the draw object on the chart but it did not seem to be the most effective method to me so I thought I would ask you the experts for your thoughts.

    The indicator works well but does many calculations so is a resource pig but trying to reduce any unneeded over head I can. I allow a user specified frequency in an added time fame be that every every few seconds or minutes for a timing trigger so the logic only executes as frequently as the user decides and is independent of the chart time frame.

    I hope the above makes sense. Thanking you in advance.

    Cheers
    Last edited by ct; 06-05-2023, 09:28 PM.

    #2
    Checking in your array is faster than checking in the actual drawing objects. You could simply make a List<string> for the tags and check to is if it .Contains() the tag, then use the actual drawing objects to retrieve the object (since you know its tag).

    If you want to REALLY speed up performance, don't use drawing objects but draw the relevant ones in OnRender.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      QuantKey_Bruce

      Thanks a lot. Appreciate all the helpful feedback. Realize the on render will be faster but that will be Phase II optimize task.


      Comment


        #4
        Okay. Don't optimize (very much) until you observe a bottleneck. Lots of effort is wasted optimizing things that turn out later to be immaterial.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          QuantKey_Bruce I apply IBM logic. Get it done first then if there is merit you can make it faster.

          Comment


            #6
            Hello ct,

            Thanks for your post.

            QuantKey_Bruce is correct in the advice they gave regarding using a C# List.

            OnRender() would improve the performance compared to drawing objects with Draw methods.

            Please note that using C# Lists in a custom NinjaScript would go beyond the support we would be able to provide you with in the Support department.

            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            80 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            46 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            29 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            32 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            66 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X