Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

DataSeries.Reset()

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

    DataSeries.Reset()

    I thought I understood this method, but perhaps not. I have developed a very simple indicator that just plots the projected high and low of range bars thus.

    double projectedhigh = Low[0]+Bars.Period.Value*TickSize;
    double projectedlow = High[0]-Bars.Period.Value*TickSize;
    Phigh.Set(projectedhigh);
    Plow.Set(projectedlow);
    if (FirstTickOfBar)
    {
    Phigh.Reset(1);
    Plow.Reset(1);
    }

    I thought this would plot the hash for every bar and reset the value on the previous bar (1) each time a new bar was formed so all I would see is the current bar hash or dot.

    Unfortunately, I see no plot at all. If I alter the .Reset(1) to .Reset(), I see the hash, but it is persistent from the implementation point forward. If I remove the resets altogether, of course I see hashes for all bars.

    Is there a more detailed description or tutorial available than is provided in the help section? or am I misunderstanding the use for reset? I have used this technique several times before in non-price panels and it works fine.

    Snap

    #2
    Hello,

    You are using .Reset incorrectly. All you need to use is DataSeires.Set(int barsAgo, double value) instead. Reset only works for the current bar.

    Calling the Reset() method is unique and can be very powerful for custom indicator development. DateTimeSeries objects can hold null values which simply means that you do not want to store a value for the current bar. Reset() will reset the current index value to null.

    You will find more information about DataSeires here:
    DenNinjaTrader Customer Service

    Comment


      #3
      I'm trying to compute projected high low using the formula:

      double projHigh = Low[0] + Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize;

      Taken from an indicator by wlas on Woodies site. The indicator works perfectly but my computations are out of sync.

      Does this have something to do with the Data Series command?

      What's the MasterInstrument about that's not in snaphooks formula.

      Comment


        #4
        Hello,

        The indicator works perfectly but my computations are out of sync.
        >>do you mean your calc's that are trying to duplicate the indicator?

        For your other questions I will need more details. What is a snaphook?

        A master instrument is the instrument that you are basing everything off of and the instrument that you attach the indicator to.

        I suggest giving it a try again and posting your code with a question.

        Maybe tell me in words what you are trying to calc when you posted this?:
        double projHigh = Low[0] + Bars.Period.Value * Bars.Instrument.MasterInstrument.TickSize;
        DenNinjaTrader Customer Service

        Comment


          #5
          Yes I'm trying to duplicate the indicator.

          snaphook posted the original question with what I think is a similar problem. His formula is:

          double projectedhigh = Low[0]+Bars.Period.Value*TickSize;

          no master Instrument reference.

          I'm trying to compute the values projHigh and ProjLow

          My results seem to be those for the previous bar

          Comment


            #6
            Hello,

            I think I am missing something... what is the calculation for the projected bar in words (not code)?
            DenNinjaTrader Customer Service

            Comment


              #7
              I really don't know. I stole the formula and am trying to use it. Can I send you my code and wlas's indicator which I'm trying to emulate?

              Comment


                #8
                Hello,

                I'm sorry, this is beyond our level of service. However if you want some help when you get stuck on a specific coding issue we can try to help.
                DenNinjaTrader Customer Service

                Comment


                  #9
                  My specific coding issue is how do I compute values for a parameter based on current bar data as opposed to using prior bar data?

                  Comment


                    #10
                    [0] is the index to access values based on the current bar. You need to use CalculateOnBarClose = false to get it while the bar is still building. I am not quite sure I follow your requirements.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Thank you very much!!!!! That solves my problem.

                      Comment


                        #12
                        I have an indicator which works the way I want with CalculateOnBarClose = true
                        Is there a way to embed code which needs CalculateOnBarClose = false
                        without affecting the original code?

                        Comment


                          #13
                          Yes, but the other way round - set the indicator to calculate on bar close = false. Then do end of bar calculations on the first tick of the new bar and reference one bar back further to adjust for calling it at the start of the next bar.

                          Code:
                           
                          if (FirstTickOfBar)
                          {
                          // do on bar close calcs, reference a bar further back 
                          myROC = Close[1] - Close[2];
                          }

                          Comment


                            #14
                            I'm not sure I get it.

                            if (FirstTickOfBar)
                            {
                            All my old stuff with [0] replaced by [1]
                            }
                            New stuff calculated on building bar using [0]

                            I'm not getting my old stuff

                            Comment


                              #15
                              Jerry, to clarify, please put on calculations that you want be calculated 'on bar close' into the if (FirstTickOfBar) statement. Then rest would need to be done outside of this to be updated on each tick then, provided indicator would be run on CalculateOnBarClose = false.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              580 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              335 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              102 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              552 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X