Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Warning

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

    Warning

    Dear Traders, developers and support team

    I come through this text report a serious situation that is occurring with the NinjaTrader.
    So far already lost over more than 40 days trying to find out what's going on with my systems I worked more than four months to develop and now are not adequate performance.
    Well, I discovered that the code (either indicator or strategy) when inserting a function (indicator) when running the code the NinjaTrader gets lost and consumes absurdities memory values causing the system to crash, and even after complete the process memory remains full.
    This problem occurs in both indicators as in the strategies, you will feel their effects depending on how often your code will call the functions can be the simplest MAX, MIN, WMA, SMA, etc. until custom indicators and complex strategies that uses in their code function calls. (take a look this exemple: http://ninjatrader.com/support/forum...ad.php?t=80443)
    I'm really concerned because I'm trying over 40 days to resolve this and was thinking that the problem was my logic, I was surprised to find that the problem is not my code but the "indicators calls" that get lost.
    Already tried all possible resources, and I report to you that nothing works, I tried: GC.Collection timer without timer and when I identify high memory numbers. I tried to sleep in one thread, re-wrote all dataseries in a intraday Lists with this thinking it would consume less memory, etc. I tried everything and nothing worked.
    What I think is happening is that when the NinjaTrader calls an indicator within another indicator the Threads get lost. And as a result there is the absurd increase in memory.
    I will relate below my performance tips and best practices I have learned in force after who knows how many thousands of lines of programming.

    1 - Never call indicator in indicators and strategies;
    2 - Do not make any difference using List to make a base in parallel;
    3 - loops are very fast and efficient producers rather than the NT team says, "the problem of loops" is when they call functions that moment the system get lost. This can happen in backtests, optimization and complex strategies.
    4 - GC.Collection only works on the system start, you can clear the memory that previously was lost because of Threads problems. Call it only once at the beginning of the code.
    5 - use a lot "For" and "While" use loopings without fear they are fast and efficient.
    6 - believe it or not the size of the bases no effect on performance if you not call any functions in the code. I use 5min with 1 year based on the screen with 60 indicators and loads the chart in 5s
    7 - Trust your code, not ever-they are wrong.

    I wrote this text as a warning to NinjaTrader that there is something very wrong and for your users (traders and developers) identify with my problems so that we can come together and require an solution to this problem that greatly affects the performance of NinjaTrader.

    Thank you.

    #2
    Your observations are correct, if you do not store the referenced type, a new reference in memory will be created. Depending on how frequently you are doing this, it could severely impact the memory usage.

    To resolve this, you can store a reference to the indicator class on your startup, assuming you're always going to use the same input parameters, this should improve the performance in terms of memory.

    Code:
    private SMA mySMA = null;
    
    protected override void OnStartUp()
    {
    	if(mySMA  == null)
    		mySMA = SMA(20);
    }
    
    protected override void OnBarUpdate()
    {
    	if(mySma[0] >= Close[0])
    	{
    		// do something
    	}
    }
    Our NinjaTrader 8 indicators have been updated to employ this concept and we will be updating our performance Tips in NinjaTrader 8 to help ensure 3rd party developers are aware of this behavior.

    I've attached an example from your other thread which should resolve what you have noted.
    Attached Files
    Last edited by NinjaTrader_Matthew; 11-23-2015, 01:20 PM.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Matthew hi, thanks for the quick reply

      I understand your code, but in my case I need to change the parameters because I'm developing a genetic algorithm.
      How I do???
      The code below is what's inside the loop.

      gene01=rnd.Next(geneMin01,geneMax01);
      gene02=rnd.Next(geneMin02,geneMax02);
      gene02 = geneTick02 * gene02;
      gene03=rnd.Next(geneMin03,geneMax03);
      gene03 = geneTick03 * gene03;
      gene04=rnd.Next(geneMin04,geneMax04);
      gene05=rnd.Next(geneMin05,geneMax05);
      gene06=rnd.Next(geneMin06,geneMax06);
      gene07=rnd.Next(geneMin07,geneMax07);
      gene07 = geneTick07 * gene07;
      gene08=rnd.Next(geneMin08,geneMax08);
      gene09=rnd.Next(geneMin09,geneMax09);
      gene10=rnd.Next(geneMin10,geneMax10);
      gene11=rnd.Next(geneMin11,geneMax11);
      gene12=rnd.Next(geneMin12,geneMax12);
      gene13=rnd.Next(geneMin13,geneMax13);
      gene14=rnd.Next(geneMin14,geneMax14);
      gene15=rnd.Next(geneMin15,geneMax15);
      gene15 = geneTick15 * gene15;
      gene16=rnd.Next(geneMin16,geneMax16);
      gene17=rnd.Next(geneMin17,geneMax17);

      double backtest = EliteEMAFast02(gene01,true,gene02,gene03,gene04,ge ne05,gene06,
      gene07,gene08,gene09,gene10,gene11,gene12,gene13,g ene14,gene15,gene16,
      gene17, false, false, false, false).ProfitTradeTotalReal[0];

      Comment


        #4
        Please continue dicussion in this thread: http://ninjatrader.com/support/forum...ad.php?t=80443
        MatthewNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by yertle, Yesterday, 08:38 AM
        7 responses
        28 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by bmartz, 03-12-2024, 06:12 AM
        2 responses
        21 views
        0 likes
        Last Post bmartz
        by bmartz
         
        Started by funk10101, Today, 12:02 AM
        0 responses
        5 views
        0 likes
        Last Post funk10101  
        Started by gravdigaz6, Yesterday, 11:40 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Yesterday, 10:49 PM
        3 responses
        11 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X