Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi timeframe strategy calling indicators with drawn objects

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

    Multi timeframe strategy calling indicators with drawn objects

    All,

    I seem to have having trouble with an out of memory error (Exception of type 'System.OutOfMemoryException' was thrown). Any tips on isolating where the memory problem may be coming from?


    One thought I had:

    Where a Strategy calls a public variable from an indicator does the complete indicator code run? To clarify, a private variable in the strategy is set to equal the called indicator public variable ( e.g. int PrivateVariable = Indicator(args).PublicVariable ), the indicator is not added to the strategy ( e.g. Add(SMA(args) ).

    Now, the called indicator code includes some drawn objects (e.g. DrawRectangle, DrawDot). Drawn object are not required for the strategy to run (indicators are applied directly to the charts). In the event the complete indicator code ran, these drawn objects would be consuming memory over the entire life of number of days loaded in the chart from which the strategy was executed. This issue would be compounded in the event the indicator was called on several timeframes of a multi timeframe strategy.

    Any suggestions are most welcome.
    Shannon
    Last edited by Shansen; 05-30-2010, 01:09 AM.

    #2
    Shannon, an instance of the indicator would still need to be created to arrive at the calculated values you're after - I would suggest you try with a 'stripped' down 'system only' version of the indicator and also take a good look how many days back you're working with in case this on NT 6.5 and tick based chart intervals.

    Comment


      #3
      Bertrand,

      Thanks for the quick reply. I was thinking a simple boolean parameter "Display" would do the trick. Where an indicator was applied to a chart "Display" = true, where an indicator was called from a strategy "Display" = false, with the DrawDot / DrawRectangle contained in an IF statement.

      Is there any way to programmatically ascertain whether an indicator is referenced from a strategy? I imagine the namespace (i.e. namespace NinjaTrader.Strategy) from which the indicator is referenced would be different can this be used?

      Regards
      Shannon

      Comment


        #4
        Yes, the bool would be a good way to go to split this up as needed. Unfortunately checking programmatically if a strategy is calling the indicator is not supported, albeit likely possible given C#'s flexibility.

        Comment


          #5
          Originally posted by Shansen View Post
          ...Is there any way to programmatically ascertain whether an indicator is referenced from a strategy?...
          Shannon,

          you could let the strategy tell the indicator something about that:

          Code:
          private MyIndicator indicator;
           
          if (FirstTickOfBar)
          {
            if (!runtimeInit)
            {
              indicator = MyIndicator(arguments ...);
              indicator.IamAStrategy = true;
              runtimeInit = true;
            }
          }
          This code is called from within OnBarUpdate of the strategy and IamAStrategy is a public property of the indicator.

          Regards
          Ralph

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          666 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          376 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          110 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          580 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X