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 helpwanted, Today, 03:06 AM
            1 response
            7 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            7 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            5 views
            0 likes
            Last Post aussugardefender  
            Started by pvincent, 06-23-2022, 12:53 PM
            14 responses
            242 views
            0 likes
            Last Post Nyman
            by Nyman
             
            Started by TraderG23, 12-08-2023, 07:56 AM
            9 responses
            384 views
            1 like
            Last Post Gavini
            by Gavini
             
            Working...
            X