Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries Issue

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

    DataSeries Issue

    Hi

    I have troubles passing DataSeries to Indicators

    Take a look at the attached cs file

    Varying the last element of the DataSeries, why I cannot obtain the correct SMA Value, but always the same result as if I never changed the DataSeries?

    This is the Output from the Print() function in the code:

    (1+2+3+0)/4 = SMA: 1,5
    (1+2+3+1)/4 = SMA: 1,5
    (1+2+3+2)/4 = SMA: 1,5
    (1+2+3+3)/4 = SMA: 1,5
    (1+2+3+4)/4 = SMA: 1,5

    Can you tell where I'm wrong or if you know any tips to fix this issue?

    Thanks in advance
    Antonio Raso
    Attached Files

    #2
    We will check into this and report back tomorrow.

    Thanks
    RayNinjaTrader Customer Service

    Comment


      #3
      This is expected. Once the first call to SMA for the current bar is made, the calculation for that bar is complete and held in the series. Any further change intrabar is not used. This is not true if CalculateOnBarClose is set to false.
      RayNinjaTrader Customer Service

      Comment


        #4
        DataSeries as input to Indicators - Indicator Dispose

        Ok Ray, thank you for your answer, now I try to explain how I solved the previous issue and what I want to obtain now:

        a) I'm working to make a TS for BackTest simulations

        My Goal is:
        * See how the CCI Indicator changes through the Ticks between the Open and Close Values of a Bar

        This is what I've done:
        1. I created a DataSeries (named ticks) to collect the Closes and pass it as Input to the Indicator
        2. for semplicity I consider only Bars with Open<Close
        2. In a "For" loop I cycle the "ticks[0]" value through the Open[0] to Close[0] Value, Tick by Tick ( ticks[0] += TickSize )
        3. On every cycle I pass the "ticks" DataSerie to the CCI Indicator to Print the returned value

        (The 1st Problem I solved - my previous post)
        4. After the call to the Indicator I "Dispose()" it, otherwise in every cycle I obtain always the same value

        Doing like this I reached my goal but I have still 1 big problem:

        * Everytime I call the CCI Indicator, NT seems to create a new istance of the CCI class; this makes the RAM usage Overflow and steals all the system resources.

        -> How can I avoid this problem? <-

        In attach the .cs example file I created
        - Min. bars required = 0
        - I make it works only for Historical Bars from 21 to 100, otherwise the system locks


        Thank you again
        Best regards
        Antonio Raso
        Attached Files

        Comment


          #5
          Hi Antonio,

          When you set values to a DataSeries you would want to use .Set instead.

          ticks[0] = Close[0];
          should be
          ticks.Set(Close[0]);

          See if that helps.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            ops... you're right

            but that doesn't seem the solution.

            The problem is in the Code of every Indicator.

            Everytime the Indicator is called with different Input or Period the Strategy Add it as "new" to the Indicator's internal Array

            CCI[] tmp = new CCI[cacheCCI == null ? 1 : cacheCCI.Length + 1];

            if (cacheCCI != null)
            cacheCCI.CopyTo(tmp, 0);

            tmp[tmp.Length - 1] = indicator;
            cacheCCI = tmp;
            Indicators.Add(indicator);

            Comment


              #7
              Is there a way to "Flush" it Completely?

              Comment


                #8
                Hi Antonio,

                Unfortunately that is what happens when you call indicators. There is no "flush". If you want to pass in Close for your CCI you can just use CCI(Close,...) instead.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by Antonio79 View Post
                  Is there a way to "Flush" it Completely?
                  When you terminate your strategy or indicator, the cache is then freed once .NET garbage collector kicks in.
                  RayNinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  574 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  332 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  553 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  551 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X