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 CaptainJack, 05-29-2026, 05:09 AM
            0 responses
            160 views
            0 likes
            Last Post CaptainJack  
            Started by CaptainJack, 05-29-2026, 12:02 AM
            0 responses
            81 views
            0 likes
            Last Post CaptainJack  
            Started by charlesugo_1, 05-26-2026, 05:03 PM
            0 responses
            125 views
            0 likes
            Last Post charlesugo_1  
            Started by DannyP96, 05-18-2026, 02:38 PM
            1 response
            206 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 05-11-2026, 05:56 AM
            0 responses
            184 views
            0 likes
            Last Post CarlTrading  
            Working...
            X