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

Range over range

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

    Range over range

    Hello,

    I am having trouble plotting the range of the NQ of the range of the ES, and display that fraction as an indicator. The NQ is the primary series and the ES is called via AddDataSeries. The indicator complies fine but nothing plots on the chart. Thank you for your help.

    AddPlot(new Stroke(Brushes.Green, 1), PlotStyle.Line, "other");
    }
    else if (State == State.Configure)
    {
    AddDataSeries("ES 12-19", BarsPeriodType.Second, 10);
    }
    }

    protected override void OnBarUpdate()
    {
    if(CurrentBars[0] < 1 || CurrentBars[1] < 1) return;
    if(BarsInProgress != 0) return;
    double a = High[0] - Low[0];
    double b = Highs[0][0] - Lows[0][0];
    Values[0][0] = a / b;

    #2
    Hello edmata1109,

    Thanks for your post.

    When a script is not working as expected (in this case no plot), always check the "log" tab of the control center for any related error messages. In this case I suspect you have divide by zero type errors as with 10 second bars I could see where High - Low will produce a zero result which would result in unrenderable values.

    To verify this, simply add a Print statement to send the values of a and b to the output window.
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Dave,

      Thanks for the reply and clarifying that. I added the Print statement and I see that I get values of NaN and the infinity symbol. I assume NaN refers to dividing by zero, but what does the infinity symbol represent?

      Thank you

      Edgar

      Comment


        #4
        Sorry Paul, I was reading another post that Dave was involved, and I mistakenly replied to you as Dave.

        Comment


          #5
          Hello edmata1109,

          Thanks for your reply.

          Here is a link that provides the definition of NaN (Not a Number): https://docs.microsoft.com/en-us/dot...tframework-4.8

          Can you provide the print statement you are using?

          No worries about the name, thanks!
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Paul,

            Values[0][0] = a / b;
            Print(string.Format("{0}", Values[0][0]));

            Comment


              #7
              Hello edmata1109,

              Thanks for your reply.

              I do not see the infinity symbol, either a 1 of a NaN here.

              I could only assume it is advising that the number is greater or lesser than the data type used can express.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                HI Paul,

                Checking back in on this. I am still having issues getting this range over range indicator to plot. I'm using a bigger time frame, as 1 minute. There should be a high and a low and a non zero range at that time scale. I'm plotting only fifty bars to see were I get the error and on the control panel I get an an error:

                Error on calling 'CalculateMinMax' method on bar 49: The calculation results in unrenderable values.

                Any help would be appreciated. Thank you again.

                else if (State == State.Configure)
                {
                AddDataSeries("NQ 12-19", BarsPeriodType.Minute, 1);
                AddDataSeries("ES 12-19", BarsPeriodType.Minute, 1);
                }
                }

                protected override void OnBarUpdate()
                {
                if(CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars[2] < 1) return;
                if(BarsInProgress != 0) return;
                double a = Highs[1][0] - Lows[1][0];
                double b = Highs[2][0] - Lows[2][0];
                Values[2][0] = a / b;

                Comment


                  #9
                  Originally posted by edmata1109 View Post
                  HI Paul,

                  Checking back in on this. I am still having issues getting this range over range indicator to plot. I'm using a bigger time frame, as 1 minute. There should be a high and a low and a non zero range at that time scale. I'm plotting only fifty bars to see were I get the error and on the control panel I get an an error:

                  Error on calling 'CalculateMinMax' method on bar 49: The calculation results in unrenderable values.

                  Any help would be appreciated. Thank you again.

                  else if (State == State.Configure)
                  {
                  AddDataSeries("NQ 12-19", BarsPeriodType.Minute, 1);
                  AddDataSeries("ES 12-19", BarsPeriodType.Minute, 1);
                  }
                  }

                  protected override void OnBarUpdate()
                  {
                  if(CurrentBars[0] < 1 || CurrentBars[1] < 1 || CurrentBars[2] < 1) return;
                  if(BarsInProgress != 0) return;
                  double a = Highs[1][0] - Lows[1][0];
                  double b = Highs[2][0] - Lows[2][0];
                  Values[2][0] = a / b;
                  Whenever you divide, you MUST take care of handling possible division by zero. To not do so is an error in coding logic. There is nothing that the compiler or runtime will do about it. It is the programmer'e responsibility to handle that situation directly in the code.
                  Last edited by koganam; 12-06-2019, 11:19 PM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Lumbeezl, 01-11-2022, 06:50 PM
                  31 responses
                  817 views
                  1 like
                  Last Post NinjaTrader_Adrian  
                  Started by xiinteractive, 04-09-2024, 08:08 AM
                  5 responses
                  14 views
                  0 likes
                  Last Post NinjaTrader_Erick  
                  Started by swestendorf, Today, 11:14 AM
                  2 responses
                  6 views
                  0 likes
                  Last Post NinjaTrader_Kimberly  
                  Started by Mupulen, Today, 11:26 AM
                  0 responses
                  7 views
                  0 likes
                  Last Post Mupulen
                  by Mupulen
                   
                  Started by Sparkyboy, Today, 10:57 AM
                  1 response
                  6 views
                  0 likes
                  Last Post NinjaTrader_Jesse  
                  Working...
                  X