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 charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      60 views
      0 likes
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      148 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      162 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      98 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      286 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Working...
      X