Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

comparing data series price values

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

    comparing data series price values

    hi all,

    I need to compare values between two data series. These data series are plotted on the chart. I need the comparison to be consistent with what the user is seeing.

    As an example, say the user is seeing in the databox 3.11 for both values. I need a way to compare them to be equal. The dataseries are doubles btw and I am aware of comparing floating point issues.

    I have basically two questions:
    1. Is there a way to retrieve the text/string representation of a value as it is presented in the databox? Then I would be able to do a simple string comparison.
    2. If 1 is not available, when NT formats a double for presentation, what midpoint rounding method is used?

    Onn

    #2
    Hello onnb1,

    Thank you for your post.

    I am not aware of a method to pull the values as presented from the Data Box.

    Are you asking what member is used for MidpointRounding? (http://msdn.microsoft.com/en-us/libr...trounding.aspx)

    I look forward to your response.

    Comment


      #3
      thanks for following up.
      I guess. If I can't get the actual text, I'd need to round the values and compare them in a similar way. Any insight on how the values are printed would help in that.

      Another suggestion is to include an api method that essentially compares two doubles in a manner that is consistent with what the databox is showing. Hope this makes sense. Let me know if you need more details.

      Onn

      Comment


        #4
        Originally posted by onnb1 View Post
        ... I have basically two questions:
        1. Is there a way to retrieve the text/string representation of a value as it is presented in the databox? Then I would be able to do a simple string comparison.

        Onn
        Data in the DataBox is rounded to TickSize. You merely need to do the same for your DataSeries before you do the comparison. That also happens to be the correct thing to do mathematically, as the average price cannot exist to a precision greater than the values from which the average is being calculated. The instrument can never transact at a price of 100.025451235500215, so why use that value for any calculations?

        Comment


          #5
          thanks for answering koganam,

          By rounded to tick size, do you mean rounded to the nearest tick or do you mean the number of decimals in rounding is the same as the number of decimals in the ticksize? Like of ES, it would be 2 decimals. I am guessing that you mean the latter?

          When you round floating point values, there is no one way to do it. As an example: what do you do with the mid point - do you round up or round down?

          Onn

          Comment


            #6
            Are you asking what member is used for MidpointRounding? (http://msdn.microsoft.com/en-us/libr...trounding.aspx)

            Btw, yes

            Onn

            Comment


              #7
              Originally posted by onnb1 View Post
              thanks for answering koganam,

              By rounded to tick size, do you mean rounded to the nearest tick or do you mean the number of decimals in rounding is the same as the number of decimals in the ticksize? Like of ES, it would be 2 decimals. I am guessing that you mean the latter?

              When you round floating point values, there is no one way to do it. As an example: what do you do with the mid point - do you round up or round down?

              Onn
              Depends, but most often I use the method that NT has already provided. Why reinvent the wheel?

              ref: http://www.ninjatrader.com/support/h...trument_ro.htm

              Comment


                #8
                Consider rounding 1350.316 on the ES.
                That method would return 1350.25
                In the databox, you would see 1350.32

                Comment


                  #9
                  Originally posted by onnb1 View Post
                  Consider rounding 1350.316 on the ES.
                  That method would return 1350.25
                  In the databox, you would see 1350.32
                  Of course. That is the point. Can you buy or sell the /ES at 1350.32? If you cannot, then 1350.32 cannot be a valid price of anything to do with the /ES. "Average price" means "most likely price". A most likely price of 1350.32 does not exist, and cannot exist, so using it for any kind of comparison makes no sense. That is what happens with all quantized entities. Think of the reality, not the pure elementary arithmetic.

                  Comment


                    #10
                    Originally posted by NinjaTrader_PatrickH View Post
                    Hello onnb1,

                    Thank you for your post.

                    I am not aware of a method to pull the values as presented from the Data Box.

                    Are you asking what member is used for MidpointRounding? (http://msdn.microsoft.com/en-us/libr...trounding.aspx)

                    I look forward to your response.
                    Just following for others as I think I have something that works. Say you want to compare two values as they appear in the databox.

                    val1, val2 are double values appearing in the databox
                    precision is the number of places to the right of the point as they appear in the databox.

                    thoughts?

                    Code:
                    int precision = 2;
                    
                    decimal val1Dec = (decimal)Math.Round(val1, precision, MidpointRounding.ToEven);
                    decimal val2Dec = (decimal)Math.Round(val2, precision, MidpointRounding.ToEven);
                    
                    if (val1Dec == val2Dec)
                    {
                      // ...
                    }

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    581 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    338 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by Mindset, 02-09-2026, 11:44 AM
                    0 responses
                    103 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                    0 responses
                    554 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    552 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X