NinjaTrader Support Forum  
X

Attention!

This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com


Go Back   NinjaTrader Support Forum > NinjaScript Development Support > Strategy Development

Strategy Development Support for the development of custom automated trading strategies using NinjaScript.

Reply
 
Thread Tools Display Modes
Old 05-29-2010, 06:02 PM   #1
Shansen
Senior Member
 
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
Default 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 at 01:09 AM.
Shansen is offline  
Reply With Quote
Old 05-30-2010, 01:41 AM   #2
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,400
Thanks: 252
Thanked 969 times in 952 posts
Default

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.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 05-30-2010, 07:02 PM   #3
Shansen
Senior Member
 
Join Date: Jan 2009
Location: Melbourne
Posts: 178
Thanks: 3
Thanked 0 times in 0 posts
Default

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
Shansen is offline  
Reply With Quote
Old 05-31-2010, 05:34 AM   #4
NinjaTrader_Bertrand
NinjaTrader Customer Service
 
NinjaTrader_Bertrand's Avatar
 
Join Date: Sep 2008
Location: Germany
Posts: 22,400
Thanks: 252
Thanked 969 times in 952 posts
Default

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.
NinjaTrader_Bertrand is online now  
Reply With Quote
Old 05-31-2010, 12:55 PM   #5
Ralph
Senior Member
 
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
Default

Quote:
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
Ralph is offline  
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Request: "Show/Hide" Indicators and Drawn Objects saliva Version 7 Beta General Questions & Bug Reports 8 07-15-2010 12:17 PM
Prevent selection of objects drawn by indicators douggreen Version 7 Beta General Questions & Bug Reports 9 10-23-2009 09:59 AM
Multi-timeframe indicators sbgtrading Version 7 Beta General Questions & Bug Reports 1 10-09-2009 07:40 AM
Multi-timeframe Moving Average indicators sbgtrading Indicator Development 1 02-11-2009 12:42 PM
master list of do-not-use indicators in multi-timeframe strategies sysimp Strategy Development 1 07-07-2008 12:52 AM


All times are GMT -6. The time now is 08:45 AM.