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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        169 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        327 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        252 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        353 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        180 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X