Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Percentage between two prices

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

    Percentage between two prices

    double Percent = (((PriceBig - PriceLow) / PriceLow) * 100);

    if (Percent == 40)
    {
    Print(Close[0].ToString());
    }

    Please tell me why doesn't it work?

    #2
    'Cos it's hard to nail exactly 40
    Use <, >, <=, >= instead. Or use Math.Round

    Comment


      #3
      Originally posted by Gorkhaan View Post
      'Cos it's hard to nail exactly 40
      Use <, >, <=, >= instead. Or use Math.Round
      but after all at the moment somewhere it was 40 why doesn't it show where?

      Or use Math.Round

      as ? / How?
      Last edited by memonolog; 11-04-2020, 04:53 AM.

      Comment


        #4
        Math.Round https://docs.microsoft.com/en-us/dot...ew=netcore-3.1

        Print all your variables, so you understand what is going on.
        Print output is visible on the Ninjascript Output window https://ninjatrader.com/support/help...t8/?editor.htm

        You could use Math.Round to round 39.93453 to 40, then it will match in your if statement.

        Comment


          #5
          Hello memonolog,

          Thanks for your post.

          As forum member Gorkhaan has advised the best path forward would be to print out all of the values of your calculations so that you understand what you are specifically working with.



          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          668 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          377 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          110 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          575 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          580 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X