![]() |
|
|||||||
| Strategy Development Support for the development of custom automated trading strategies using NinjaScript. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 179
Thanks: 3
Thanked 0 times in 0 posts
|
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.
|
|
|
|
|
|
#2 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,570
Thanks: 262
Thanked 1,018 times in 999 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#3 |
|
Senior Member
Join Date: Jan 2009
Location: Melbourne
Posts: 179
Thanks: 3
Thanked 0 times in 0 posts
|
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 |
|
|
|
|
|
#4 |
|
NinjaTrader Customer Service
Join Date: Sep 2008
Location: Germany
Posts: 22,570
Thanks: 262
Thanked 1,018 times in 999 posts
|
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.
Bertrand
NinjaTrader Customer Service |
|
|
|
|
|
#5 | |
|
Senior Member
Join Date: Jul 2008
Posts: 527
Thanks: 0
Thanked 9 times in 6 posts
|
Quote:
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;
}
}
Regards Ralph |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |