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 algospoke, Yesterday, 06:40 PM
      2 responses
      21 views
      0 likes
      Last Post algospoke  
      Started by ghoul, Today, 06:02 PM
      3 responses
      14 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by jeronymite, 04-12-2024, 04:26 PM
      3 responses
      45 views
      0 likes
      Last Post jeronymite  
      Started by Barry Milan, Yesterday, 10:35 PM
      7 responses
      21 views
      0 likes
      Last Post NinjaTrader_Manfred  
      Started by AttiM, 02-14-2024, 05:20 PM
      10 responses
      181 views
      0 likes
      Last Post jeronymite  
      Working...
      X