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 cmoran13, 04-16-2026, 01:02 PM
      0 responses
      57 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      36 views
      0 likes
      Last Post PaulMohn  
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      165 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      101 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      162 views
      2 likes
      Last Post CaptainJack  
      Working...
      X