Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 DayTradingDEMON, Today, 09:28 AM
            2 responses
            15 views
            0 likes
            Last Post DayTradingDEMON  
            Started by Stanfillirenfro, Today, 07:23 AM
            6 responses
            23 views
            0 likes
            Last Post Stanfillirenfro  
            Started by navyguy06, Today, 09:28 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by cmtjoancolmenero, Yesterday, 03:58 PM
            8 responses
            32 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by helpwanted, Today, 03:06 AM
            2 responses
            22 views
            0 likes
            Last Post NinjaTrader_LuisH  
            Working...
            X