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() Question

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

    Reset() Question

    HI,

    I am having an issue with the Reset() method. I have the following code:

    In Initialize():
    Add(new Plot(Color.Cyan, PlotStyle.Dot, "TDown"));
    Add(
    new Plot(Color.Blue, PlotStyle.Dot, "TUp"));
    Plots[
    0].Pen = new Pen(Color.Cyan, 6);
    Plots[
    1].Pen = new Pen(Color.Red, 6);

    In OnBarUpdate():
    if(CurrentBar < 10)
    {
    TDown.Reset(); // sets null value for plotting purposes but 0 value for mathematical purposes
    TUp.Reset();
    ...
    }

    When I print values of TDown[0] or TUp[0] I get actual price values - the Close value of the bar. I expected to see null, or zero values or NaN. I must be using Reset() incorrectly because my output does not agree with the documentation. Any suggestions?

    Thank you for any help you may be able to provide.

    Last edited by Zeos6; 06-11-2011, 05:46 PM.

    #2
    Zeos6, I will have someone get back to you tomorrow.
    AustinNinjaTrader Customer Service

    Comment


      #3
      Originally posted by Zeos6 View Post
      HI,

      I am having an issue with the Reset() method. I have the following code:

      In Initialize():
      Add(new Plot(Color.Cyan, PlotStyle.Dot, "TDown"));
      Add(
      new Plot(Color.Blue, PlotStyle.Dot, "TUp"));
      Plots[
      0].Pen = new Pen(Color.Cyan, 6);
      Plots[
      1].Pen = new Pen(Color.Red, 6);

      In OnBarUpdate():
      if(CurrentBar < 10)
      {
      TDown.Reset(); // sets null value for plotting purposes but 0 value for mathematical purposes
      TUp.Reset();
      ...
      }

      When I print values of TDown[0] or TUp[0] I get actual price values - the Close value of the bar. I expected to see null, or zero values or NaN. I must be using Reset() incorrectly because my output does not agree with the documentation. Any suggestions?

      Thank you for any help you may be able to provide.

      The point may be moot, as that code seems to indicate that you are pretty much otherwise doing nothing if (CurrentBar < 10), at which point, as you have done nothing, I believe Plots are, bu default, set to the Close value for the bar, but not plotted.

      You can always force the value to zero, before you reset, thus:

      Code:
      TDown.Set(0);
      TDown.Reset();
      You might want to check if those values are even a valid plot. ref: http://www.ninjatrader.com/support/h...dataseries.htm

      Comment


        #4
        Hi Koganam,

        Thanks for your reply. I was actually wondering about that over the weekend. It appears that you actually need to set a value before you can reset it - even though a default value is already in place. Seems odd since a default value of bar close already exists there but I will give it a go.

        On another note, the code snippet with CurrentBar < 10 is contrived and artificial. I simply wanted to check what values were being reset in the plot.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Sparkyboy, Today, 10:57 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by swestendorf, Today, 11:14 AM
        1 response
        3 views
        0 likes
        Last Post swestendorf  
        Started by TheMarlin801, 10-13-2020, 01:40 AM
        21 responses
        3,917 views
        0 likes
        Last Post Bidder
        by Bidder
         
        Started by timmbbo, 07-05-2023, 10:21 PM
        3 responses
        156 views
        0 likes
        Last Post grayfrog  
        Started by Lumbeezl, 01-11-2022, 06:50 PM
        30 responses
        812 views
        1 like
        Last Post grayfrog  
        Working...
        X