Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Back Test - running out of memory problem

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

    Strategy Back Test - running out of memory problem

    I'm trying to use one of the supertrend indicators. There are a butch of variants but they all seem to have the same structure. When I add it thus:

    protected override void Initialize()
    {
    Add(AdaptiveSuperTrend(0.92,16200,false));
    }

    It plots OK and the strategy is processed quickly. When I use it in OnBarUpdate() thus:

    if (Position.MarketPosition == MarketPosition.Long && aptiveSuperTrend(0.792,16200,false).Oscillator[1] == 0.0 )
    {
    ExitLong("allLongs","");
    }

    The strategy takes forever to run. If the numbers of days is say 50 days of 1min bars then Ninja crashes with an out of memory warning.

    When I added the plot using Add(AdaptiveSuperTrend(0.92,16200,false)) a dataseries object must have been created. Is there a way I can access it to avoid calling AdaptiveSuperTrend(0.92,16200,false) for each iteration of the backtest.

    Here is the message from the log file:

    5/21/2013 12:22:35 AM|3|128|Error on calling 'OnBarUpdate' method for strategy 'New/66d0fc7216204c768b0d7749e5b96906': Exception of type 'System.OutOfMemoryException' was thrown.
    Last edited by boreland; 05-20-2013, 10:27 PM.

    #2
    boreland, If I recall correctly this custom script wasn't pretty efficiently coded to begin with....

    You could check into something like this to see if it would help improving performance -

    // Vars region
    private AdaptiveSuperTrend myInd;

    // OnStartup
    myInd = AdaptiveSuperTrend(0.92,16200,false);

    And then change your code in OnBarUpdate() to only refer to this myInd instance of the indicator.

    Comment


      #3
      Thanks that did the trick.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      64 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      59 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      62 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      51 views
      0 likes
      Last Post CarlTrading  
      Working...
      X