Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator on Indicator - Value.Reset() passes incorrect value

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

    Indicator on Indicator - Value.Reset() passes incorrect value

    Value.Reset(0) applied to an indicator output is supposed to create a non-displayed value of 0. IN NT7, the value is not displayed on the chart when plotted, which is the correct behavior.

    However, when passed to another indicator, the value appears to be set to the Close of the primary instrument. This is undesirable behavior, because it means that you can't use another indicator on any indicator which uses Value.Reset(0).

    Desired behavior is to pass an indication that the value doesn't exist (i.e., something like "NaN" or Input[0].ContainsValue). Or treat it like you would treat a missing bar for a price input: don't even have a place in the input series for a missing value, and don't call OnBarUpdate. A quick improvement would be to pass a value of 0, which for most indicators would produce a much more reasonable result than passing the Close.

    How to reproduce:

    Create a modified version of SMA called SMATest2.
    In SMATest2, place the following lines as the first 2 lines in OnBarUpdate:

    Value.Reset(0);
    return;

    In a chart, apply the indicator SMA, using SMATest2 as the Input Data Series.

    SMA will plot the SMA of the close even though SMATest2 has produced no output.
    Last edited by kdoren; 11-17-2009, 01:56 PM.

    #2
    kdoren,

    It does use the Close price as a space holder. What you would need to do is check if it is a valid value or not with .ContainsValue(). Please see the section for checking valid values: http://www.ninjatrader-support.com/H...taSeriesObject

    This would need to be checked from the hosting indicator.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      ContainsValue is not a property of the Input DataSeries. It should be.

      And Close is the wrong thing to use as a placeholder, it should be 0.

      In fact, there probably shouldn't be a placeholder at all, because there shouldn't be a place. I suspect the best thing would be to treat it like a missing bar and have no place in the DataSeries at all. But if it's there it needs to be detectable as missing.
      Last edited by kdoren; 11-17-2009, 03:13 PM.

      Comment


        #4
        Value.Reset(0) is definitely broken.

        Place the following code at the beginning of OnBarUpdate:

        Value.Reset(0);
        Print(Value[
        0].ToString());

        It will print the Close instead of Zero.

        From the NT6 Help Guide:

        Calling the Reset() method is unique and can be very powerful for custom indicator development. DataSeries objects can hold null values which simply means that you do not want to store a value for the current bar. Mathematically, you can correctly assign a value of zero however if the DataSeries was the primary DataSeries of an indicator whose values would be used for plotting, you may NOT want a zero value plotted. Meaning, you want a zero value for proper calculations but not a zero value for chart visualization. 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.




        Comment


          #5
          kdoran, if you want a value of 0 stored in your DataSeries, couldn't you just .Set() the DataSeries with a value of 0? In addition, if you want to "back set" a plot's value some bars back, you could use the historical overload:
          Code:
          // .Set(int BarsBack, double value)
          // to set the dataseries value 4 bars back to 6.2
          SomeDataSeries.Set(4, 6.2);
          AustinNinjaTrader Customer Service

          Comment


            #6
            I was looking for something that wouldn't print, but would behave reasonably when passed to another indicator. Value.Reset() is supposed to do that, but it's broken - it passes the Close instead of 0.

            You should also implement the ContainsValue method for the IDataSeries inteface so it's available to another indicator. If I use Value.Reset(0) on the Value DataSeries, then Value.ContainsValue(0) inside that indicator is correctlly set to false. But if apply another indicator to it, it becomes the Input IDataSeries, and the ContainsValue() method is not available.

            Comment


              #7
              We are researching this issue and will get back to you early next week. Thanks

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              627 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              359 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              105 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              562 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              567 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X