• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 10:19 PM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by forrestang, Yesterday, 11:39 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post forrestang  
                  Started by luxurious_04, Yesterday, 08:08 PM
                  1 response
                  9 views
                  0 likes
                  Last Post NinjaTrader_EricB  
                  Started by martyn73, Yesterday, 03:08 PM
                  1 response
                  10 views
                  0 likes
                  Last Post NinjaTrader_ChrisL  
                  Started by raffu, Yesterday, 01:16 PM
                  2 responses
                  8 views
                  0 likes
                  Last Post raffu
                  by raffu
                   
                  Started by fx.practic, Yesterday, 01:04 PM
                  2 responses
                  8 views
                  0 likes
                  Last Post fx.practic  
                  Working...
                  X