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 Mindset, 04-21-2026, 06:46 AM
          0 responses
          77 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by M4ndoo, 04-20-2026, 05:21 PM
          0 responses
          109 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by M4ndoo, 04-19-2026, 05:54 PM
          0 responses
          57 views
          0 likes
          Last Post M4ndoo
          by M4ndoo
           
          Started by cmoran13, 04-16-2026, 01:02 PM
          0 responses
          108 views
          0 likes
          Last Post cmoran13  
          Started by PaulMohn, 04-10-2026, 11:11 AM
          0 responses
          65 views
          0 likes
          Last Post PaulMohn  
          Working...
          X