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 Waxavi, Today, 02:10 AM
      0 responses
      4 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Started by TradeForge, Today, 02:09 AM
      0 responses
      10 views
      0 likes
      Last Post TradeForge  
      Started by Waxavi, Today, 02:00 AM
      0 responses
      2 views
      0 likes
      Last Post Waxavi
      by Waxavi
       
      Started by elirion, Today, 01:36 AM
      0 responses
      4 views
      0 likes
      Last Post elirion
      by elirion
       
      Started by gentlebenthebear, Today, 01:30 AM
      0 responses
      4 views
      0 likes
      Last Post gentlebenthebear  
      Working...
      X