Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bar size calculation

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

    Bar size calculation

    I use a simple line of code to calculate the size of a bar in ticks

    SignalBarSize = ((High[0] - Low[0]) / TickSize);

    In the ES and NQ this works fine. I get expected results, 4, 6, 9 etc etc..

    However in the RTY. I get unexpected results like:

    27.0000000000027
    34.0000000000009
    49,9999999999991

    Why is this?

    #2
    Hello several,

    This may be due to floating point arithmetic.

    Below is a link to the help guide which discusses.


    You can use Instrument.MasterInstrument.RoundToTickSize() to round to a tick size if you need to.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks.

      Using Instrument.MasterInstrument.RoundToTickSize seems just to return the point size, not the ticksize on the RTY

      In the RTY, each tick is 0.10points. So 1.5 points is 15 ticks.

      Instrument.MasterInstrument.RoundToTickSize(High[0] - Low[0]) gives a result of 1.5

      Comment


        #4
        Hello several,

        It would depend on what the High[0] and Low[0] are to produce a distance of 1.5 points.

        Were you meaning to divide this by .1?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          I did not divide it.

          Comment


            #6
            Hello several,

            If not divided by .1, this would be the difference in points, not ticks.

            It would depend on what the High[0] and Low[0] are to produce a distance of 1.5 points.

            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            50 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            126 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            69 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            42 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X