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

Round to Next To Nearest Tick

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

    Round to Next To Nearest Tick

    Hey Guys I have code
    Code:
    roundedClose = Instrument.MasterInstrument.Round2TickSize( (Close[0])) ;
    		DrawTextFixed("Round", roundedClose.ToString(), TextPosition.TopRight, Color.Black, new Font ("Arial", 14), Color.Empty, Color.Empty,0);
    My chart is set EUR/USD (TenthOfAPiP) so I get number like 1.06978 but I want to display the nearest Pip not Pipette. How would I do this? so that if the Close[0] = 1.06978 ; I'll get 1.0698?

    What do I have to change? thank you

    #2
    Hello ginx10k,

    Thanks for your post.

    Try:

    Code:
    DrawTextFixed("Round", roundedClose.ToString("0.0000"), TextPosition.TopRight, 
    			Color.Black, new Font ("Arial", 14), Color.Empty, Color.Empty,0);
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      That's great for Writing the String. Thanks so much. HOWEVER,

      How do I get that value now so I can use it in another variable. or in the same variable. I want that roundedClose the same as it displays, I want the value in a variable.

      Comment


        #4
        Hello ginx10k,

        Thanks for your reply.

        Math.Round(number to round, decimals wanted) would meet your needs.

        newrounded = Math.Round(roundedClose, 4);

        Rounds a value to the nearest integer or to the specified number of fractional digits.
        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Great. thanks a lot!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by funk10101, Today, 09:43 PM
          0 responses
          2 views
          0 likes
          Last Post funk10101  
          Started by pkefal, 04-11-2024, 07:39 AM
          11 responses
          36 views
          0 likes
          Last Post jeronymite  
          Started by bill2023, Yesterday, 08:51 AM
          8 responses
          44 views
          0 likes
          Last Post bill2023  
          Started by yertle, Today, 08:38 AM
          6 responses
          25 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by algospoke, Yesterday, 06:40 PM
          2 responses
          24 views
          0 likes
          Last Post algospoke  
          Working...
          X