Announcement

Collapse
No announcement yet.

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.

      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 CarlTrading, 03-31-2026, 09:41 PM
            1 response
            156 views
            1 like
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            90 views
            1 like
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            140 views
            2 likes
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            130 views
            1 like
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            107 views
            0 likes
            Last Post CarlTrading  
            Working...
            X