Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaScript: Price as String to Nearest TickSize

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

    NinjaScript: Price as String to Nearest TickSize

    Is there a NinjaScript function in NT7 that can return a price value as a string, formatted to the nearest tick size?

    Kind Regards
    Vivek

    #2
    Hello Vivek,

    Thank you for writing in.

    You'll first want to use the Round2TickSize() method to round your value to nearest valid value evenly divisible by the instrument's tick size: https://ninjatrader.com/support/help...trument_ro.htm

    Then, you can use the ToString() method on the return value of Round2TickSize() and assign the return value of that method to a new string: https://msdn.microsoft.com/en-us/lib...v=vs.110).aspx

    Example:

    Code:
    double myNumber = 104.22;
    
    // with the ES for example, the price will be rounded up to 104.25
    string priceAsString = Instrument.MasterInstrument.Round2TickSize(myNumber).ToString();
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      Thanks Zachary!

      It worked as desired.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      630 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      364 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      105 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      566 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      568 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X