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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            47 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            23 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            33 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            51 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            42 views
            0 likes
            Last Post CarlTrading  
            Working...
            X