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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          68 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          151 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          100 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          288 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X