Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Plot0.Set()

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

    Plot0.Set()

    Hi,

    I am calculating values which I would like to plot as my indicator using the following:

    in Initialize() I have:
    Add(new Plot(Color.FromKnownColor(KnownColor.Cyan), PlotStyle.Dot, "TD"));

    in InBarUpdate() I have:
    td = ... ;
    TD.Set(td);

    My question is as follows. I have set td to be a nullable double type. The idea is that if td is null I should be plotting null values. Can TD.Set(td) handle nullable types?

    Thank you.

    #2
    Hi Zeos6,

    Sorry, I did not understand the question. Can you please clarify what you mean by nullable double type? Code sample?
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Hi Ryan,

      A nullable type is a a data type that can take its data value as well as null. So a nullable double can take double values as well as have null value assigned to them. You can have int and bool etc. as nullalble types as well. The question essentially was whether Plot() can take null values as inputs or does it require a double as input.

      double x; // double data type
      double? x; // nullable double data type

      If x is defined as nullable I can write x = 3.0 or I can write x = null. If x is only a double then writing x = null will raise an exception.
      Last edited by Zeos6; 06-08-2011, 09:35 AM.

      Comment


        #4
        I see. No, plots can't accept this as input. You may want to look into the DataSeries Reset() method:

        TD.Reset();

        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.

        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.
        Last edited by NinjaTrader_RyanM1; 06-16-2011, 01:25 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks Ryan. That is exactly what I was after.

          Comment


            #6
            Ryan, could you please point me to an example of using Reset()? Thank you.

            Comment


              #7
              Sure, TD.Reset(); is one example. Are you looking for something else?
              Ryan M.NinjaTrader Customer Service

              Comment


                #8
                An example of setting a value to a series and of using reset with the same series would be great. Thank you very much.

                Comment


                  #9
                  Usage is fairly basic. Just call reset by adding .Reset() to the plot or data series.

                  TD.Set(50);
                  TD.Reset();
                  Ryan M.NinjaTrader Customer Service

                  Comment


                    #10
                    So basically I would use the Reset() if I want null values in the data series; i.e don't want any value plotted, but want zero saved for the bar for mathematical purposes. Is this correct? Thank you.

                    Comment


                      #11
                      Originally posted by Zeos6 View Post
                      So basically I would use the Reset() if I want null values in the data series; i.e don't want any value plotted, but want zero saved for the bar for mathematical purposes. Is this correct? Thank you.
                      This is correct.
                      RayNinjaTrader Customer Service

                      Comment


                        #12
                        Thank you.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                        0 responses
                        571 views
                        0 likes
                        Last Post Geovanny Suaza  
                        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                        0 responses
                        330 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
                        548 views
                        1 like
                        Last Post Geovanny Suaza  
                        Started by RFrosty, 01-28-2026, 06:49 PM
                        0 responses
                        549 views
                        1 like
                        Last Post RFrosty
                        by RFrosty
                         
                        Working...
                        X