Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Round Instrument

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

    Round Instrument

    Hello,

    I want to ask please about difference in rounding of prices. Is there a difference when rounding price of equity-future, currency-futures (6E...), CL, GC and on forex (liek EURUSD, EURJPY)?

    RoundToTickSize, Round...???

    I´m having some strange results from calculations.

    Thank you!
    Tony
    Last edited by tonynt; 10-28-2021, 04:35 AM. Reason: translation error

    #2
    Hello tonynt,

    Unfortunately we cannot look into the internal code to provide that context. If you are seeing something unexpected we always ask that you for the most simple example that you can of what you are doing and provide that sample along with directions on how to observe the issue. It is also helpful if you can provide the print output and explain what specific observation you made that you think is not correct.

    Please let me know if I may be of further assistance.

    Comment


      #3
      Hello,

      OK, I do my question different...

      when to use "Math. Round..." and when to use "Instrument.MasterInstrument.Round..."

      Thank you!
      Tony

      Comment


        #4
        Hello tonynt,

        Math.Round is a C# rounding function, you could use that in line with any normal math rounding you needed. MasterInstrument.Round is a NinjaTrader method which takes into account the instrument and its tick size.


        Please let me know if I may be of further assistance.

        Comment


          #5
          Originally posted by tonynt View Post
          when to use "Math. Round..." and when to use "Instrument.MasterInstrument.Round..."
          When to use?

          Well, if you're dealing with price values in the price panel, use RoundToTickSize.
          But if you need the raw relationship, for ex, of how two different MAs in the price
          panel
          compare against each other, you may not want that.

          Summary: Use RoundToTickSize for price values only, ie, values on the y-axis in the
          price panel
          . Use it when you need a 'snap to' effect to make the value represent
          a valid price point on the y-axis of the price panel.

          [EDIT: Remember, the prices on the y-axis of the price panel are discrete, there is no
          such thing as a valid price in between two adjacent prices. Contracts are sold at tick
          intervals, for ex, you cannot buy CL at 84.505584747, the price is either 84.50 or 84.51,
          etc -- prices in between those values simply don't exist -- price is a discrete concept.
          But wait wait .. the calculated EMA value could be 84.505584747 because calculated
          values are continuous values. Thus, most values stored in a Plot series are continuous,
          exactly because they result from calculations. Every chart vendor draws their EMA or
          other plot values continuously, in order to show a nice smooth effect of the plot line.
          Think about it: rarely do continuous plot values match precisely to the discrete price
          values on the y-axis of the price panel. My point is: RoundToTickSize guarantees the
          return of a discrete price value, regardless if the input value is discrete or continuous.]

          [EDIT-2: Use RoundToTickSize when you know you need a discrete price value, that
          is, you know you need a valid price point on the y-axis of the price panel.]

          In contrast, avoid RoundToTickSize for indicator values that are not running on the price
          panel, such as CCI, MACD, etc. These indicators have their own panel and their own
          y-axis, and those y-values are not prices, so, IMHO, RoundToTickSize is almost never
          appropriate for values from such indicators.

          Summary: Values from indicators which are not price values (ie, they have their
          own panel) have no need to get rounded by RoundToTickSize.
          Last edited by bltdavid; 10-28-2021, 04:26 PM. Reason: Added big discussion on discrete vs continuous.

          Comment


            #6
            Originally posted by bltdavid View Post

            when to use?

            Well, if you're dealing with price values in the price panel, use roundtoticksize.
            But if you need the raw relationship, for ex, of how two different mas in the price
            panel
            compare against each other, you may not want that.

            Summary: Use roundtoticksize for price values only, ie, values on the y-axis in the
            price panel
            . Use it when you need a 'snap to' effect to make the value represent
            a value price point on y-axis of the price panel.

            In contrast, avoid roundtoticksize for indicator values that are not running on the price
            panel, such as cci, macd, etc. These indicators have their own panel and their own
            y-axis, and those y-values are not prices, so, imho, roundtoticksize is almost never
            appropriate for values from such indicators.

            Summary: Values from indicators which are not price values (ie, they have their
            panel) have no need to get rounded by roundtoticksize.
            thank you!

            Comment


              #7
              Originally posted by tonynt View Post
              thank you!
              You're welcome!



              I just updated the post by adding a detailed explanation
              of discrete vs continuous, and how RoundToTickSize fits
              in that discussion.
              Last edited by bltdavid; 10-28-2021, 07:50 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              574 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              333 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              101 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              553 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              551 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X