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 DayTradingDEMON, Today, 09:28 AM
      4 responses
      21 views
      0 likes
      Last Post DayTradingDEMON  
      Started by geddyisodin, Yesterday, 05:20 AM
      9 responses
      50 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by George21, Today, 10:07 AM
      1 response
      12 views
      0 likes
      Last Post NinjaTrader_ChristopherJ  
      Started by Stanfillirenfro, Today, 07:23 AM
      9 responses
      24 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by navyguy06, Today, 09:28 AM
      1 response
      9 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X