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 number

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

    round number

    Hi,
    Is there any way I can determine if the price is a round number e.g.

    2740
    2750
    2760
    I want to determine this in a strategy or an indicator. I can then draw a line, enter LONG, enter SHORT etc.
    probably missed this somehow


    TIA.
    Regards,


    SDG

    #2
    Sure...

    Code:
    decimalPlaces  = (YourNumber).ToString().Substring(YourNumber.ToString().IndexOf(".")).Length - 1;
    See if the number of decimal places in your number is 0.

    Comment


      #3
      Hello SuperDriveGuy,

      Thank you for the reply.

      You could use a modulus operator to check for whole numbers, here is a simple example comparing the Close to check if it is whole:
      Code:
      if(CurrentBar < 1) return;
      if(Close[0] % 1 == 0)
      {
      	DrawLine("tag" + CurrentBar, 1, Close[0], 0, Close[0], Color.Lime);
      }
      Here is a link for further information on this question and other examples as it is a general C# question surrounding Math. https://stackoverflow.com/a/2751597


      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        I'm looking for an indicator that can draw a line at round number, or any specified number for that matter. Could you please help direct me to one such indicator? Thanks.

        Comment


          #5
          Have a look at this: https://ninjatrader.com/support/foru...ator-need-help
          Find my comment. Maybe this can help.

          Comment


            #6
            Ah was hopeful but didn't work for me maybe its for ninja 7

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by hazylizard, Today, 08:38 AM
            0 responses
            4 views
            0 likes
            Last Post hazylizard  
            Started by Max238, Today, 01:28 AM
            5 responses
            42 views
            0 likes
            Last Post Max238
            by Max238
             
            Started by giulyko00, Yesterday, 12:03 PM
            3 responses
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by habeebft, Today, 07:27 AM
            1 response
            14 views
            0 likes
            Last Post NinjaTrader_ChristopherS  
            Started by AveryFlynn, Today, 04:57 AM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X