Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 nandhumca, Today, 03:41 PM
      0 responses
      4 views
      0 likes
      Last Post nandhumca  
      Started by The_Sec, Today, 03:37 PM
      0 responses
      3 views
      0 likes
      Last Post The_Sec
      by The_Sec
       
      Started by GwFutures1988, Today, 02:48 PM
      1 response
      5 views
      0 likes
      Last Post NinjaTrader_Clayton  
      Started by ScottWalsh, 04-16-2024, 04:29 PM
      6 responses
      33 views
      0 likes
      Last Post ScottWalsh  
      Started by frankthearm, Today, 09:08 AM
      10 responses
      36 views
      0 likes
      Last Post frankthearm  
      Working...
      X