Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

StrategyBase.RemoveDrawObjects takes AGES!

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

    StrategyBase.RemoveDrawObjects takes AGES!

    here's my stacktrace:

    Code:
    >	mscorlib.dll!System.Collections.ArrayList.RemoveAt(int index) Line 512 + 0x18 bytes	C#
     	mscorlib.dll!System.Collections.CollectionBase.System.Collections.IList.Remove(object value = {NinjaTrader.Gui.Chart.ChartLine}) Line 148	C#
     	NinjaTrader.Core.dll!NinjaTrader.Gui.Chart.ChartObjectCollection.Remove(NinjaTrader.Gui.Chart.ChartObject chartObject) + 0x9 bytes	
     	NinjaTrader.Core.dll!NinjaTrader.Strategy.StrategyBase.RemoveDrawObjects() + 0xe8 bytes	
     	NinjaTrader.Core.dll!NinjaTrader.Strategy.StrategyBase.Dispose() + 0x70e bytes	
     	3144178b65c14289a6756604d944436a.dll!NinjaTrader.Strategy.Strategy.Dispose() + 0x18 bytes	
     	NinjaTrader.Core.dll!NinjaTrader.Gui.PerformanceViewerControl.RunBackTest() + 0xdc3 bytes	
     	NinjaTrader.Core.dll!NinjaTrader.Gui.PerformanceViewerControl.Display() + 0x6b3 bytes	
     	NinjaTrader.Core.dll!NinjaTrader.Strategy.StrategyAnalyzer.OnAfterGridRowActivate(object sender, System.EventArgs e) + 0xdb6 bytes
    it looks like StrategyBase.RemoveDrawObjects is looping through all 276,000 items in the ChartObjectCollection and calling Remove, which calls ArrayList.RemoveAt(). RemoveAt is doing a linear search, so this is O(n^2). and for n==276,000, that's pretty big...

    this has taken several minutes so far. long enough for be to notice, launch the debugger, get a stack trace and write this post.

    you know about ArrayList.Clear()?

    #2
    Thanks for your suggestion. We'll add it to our list.

    Comment


      #3
      yeah, 276,000 is proably excessive. in this case it was a bug in the strategy. but i wouldn't be that surprised to see such numbers for a strategy using fancy indicators on a 1-min chart for a duration of several years...

      Comment


        #4
        We looked into it. Unfortunately it's not that simple as internally one container manages all chart objects for all indicators, strategies on that chart (even including manually drawn objects).

        However, we'll keep that issue on our to look into at a later point in time again.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        602 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        559 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X