Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Double vs. Integer

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

    Double vs. Integer

    Is there a simple way to get a CME data feed as integers (which is how it actually leaves CME)?

    I am a long time programmer so I eventually figured out what was happening but a non-programmer would never in a million years have figured this one out.

    I didn't want to have a long entry below a stop loss from an opposite side trade (obviously using the unmanaged approach), so I compared the two prices (the proposed entry vs. the existing stop loss).

    1.2979 (a tick above a certain price) vs. 1.2979 (existing stop loss) expecting to find them equal and therefore, the entry would need to be moved up or not put out at all.

    As I am sure you can guess by this point, they aren't necessarily equal even though they appear to be because they are both doubles (and come directly from NinjaTrader supplied prices with a multiple of TickSize added or subtacted).

    Once I figured out what the issue was, I converted them both to integers and then did the compare. Does the documentation warn about this anywhere? My mistake but it didn't occur to me that I couldn't compare two numbers that come directly from OnExecution and see if they are equal.

    No real issue from my end but thought it is something others might want to be aware of. Of course, I now have to go through every line of my code base looking to see if I repeated the error anywhere else.

    Such is the life of a programmer.

    #2
    Hi Scott,

    Unfortunately there's no way to expose the raw values from the data feed. These are already converted by the time you have access to them within NinjaTrader.

    The issue you're likely seeing is covered here, in the floating point arithmetic tips:
    Floating-Point Arithmetic
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thank you Ryan for your quick response. I didn't think there would be any way but thought it couldn't hurt to ask.

      Scott

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      65 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      41 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      23 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      26 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      52 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X