Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Reset() Broken?

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

    Reset() Broken?

    Hi,

    This driving me crazy and I think there may be a problem with the Reset() method. Consider the code snippet

    if(CurrentBar < minBarsToBeLoaded)
    {
    Print(
    "**************");
    Print(
    "Time[0] = "+Time[0]);
    Print(
    "CurrentBar = "+CurrentBar);
    TUp.Set(
    9999);
    Print(
    "TUp[0] = "+TUp[0]);
    TUp.Reset();
    // ensures that TUp plot value has been set to a non-plotting 0 value
    Print("TUp[0] after Reset() = "+TUp[0]);
    Print(
    "Close[0] = "+Close[0]);
    }

    I expected to get null or zero values after the reset. Instead I got the close values - see the pic attached. Ninjatrader documentation states:

    "The Reset() method allows you to reset the current bar's DataSeries value to a zero for calculation purposes but Ninjascript would ignore this value when it plotted it on a chart."


    Attached Files

    #2
    Zeos6,

    When .Reset is used that means no value is set to that DataSeries. When no values are set and you access it you will get the Close value since that is what NT stuffs in as a placeholder value. Documentation has been updated. Thanks for bringing this to our attention.

    To check if your values are either the NT stuffed in default values or actually a value you specifically set you could check if it is a valid value first. You can do this by using DataSeries.ContainsValue(int barsAgo).

    So something like:
    Code:
    if (TUp.ContainsValue(0) == true)
         // Do something only when the DataSeries holds a value I have specifically set
    else
         // Do something else when the DataSeries does not hold a value
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Thank you very much Josh. That's exectly what I ended up doing. I very much appreciate your reply.

      Comment


        #4
        Same Issue/Don't Understand

        I have a DataSeries and I only want to plot selective sections of it. I also had hoped to use .Reset for that purpose and encountered the same problem.

        Bottom Line: How do I prevent NT from plotting the placeholder value?

        I assume I test it with

        if (TUp.ContainsValue(0) == true)
        // Do something only when the DataSeries holds a value I have specifically set
        else
        // Do something else when the DataSeries does not hold a value
        But how exactly do I prevent it from plotting the invalid value? Can you please be more specific then "Do something else when the DataSeries does not hold a value..."

        Comment


          #5
          Originally posted by Srgtroy View Post
          I have a DataSeries and I only want to plot selective sections of it. I also had hoped to use .Reset for that purpose and encountered the same problem.

          Bottom Line: How do I prevent NT from plotting the placeholder value?

          I assume I test it with



          But how exactly do I prevent it from plotting the invalid value? Can you please be more specific then "Do something else when the DataSeries does not hold a value..."
          You simply use Reset(). The purpose of Reset() is to NOT plot a value. You only need to check for valid values if you are going to be using the values from the plot in other calculations.

          Comment


            #6
            Thanks for the explanation. It helped!

            Comment

            Latest Posts

            Collapse

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