Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    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.
        BertrandNinjaTrader Customer Service

        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 nicthe, Today, 07:38 AM
          3 responses
          17 views
          0 likes
          Last Post nicthe
          by nicthe
           
          Started by samish18, Yesterday, 12:20 PM
          1 response
          12 views
          0 likes
          Last Post WaleeTheRobot  
          Started by Lancer, 01-29-2020, 10:15 PM
          6 responses
          460 views
          1 like
          Last Post neveral0n3  
          Started by Rogers101, Today, 11:30 AM
          1 response
          13 views
          0 likes
          Last Post WaleeTheRobot  
          Started by AndreiBig, Yesterday, 12:30 AM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_Eduardo  
          Working...
          X