Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

division is not working

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

    division is not working

    Hello, I'm having an issue with something that hopefully you can help me with.
    Something I do regularly is calculate a number in a bar, find the MAX of that using the MAX indicator going 10 bars back, then dividing that max number into the current bar number to see if the current bar number is big or not. (I do the exact same thing for negative numbers using the MIN indicator.)

    This gives me the correct value unless I use division to calculate the number that I'm MAXing or MINing. For example, if I use (variable[0] - variable[1]) ("[bars back]"), to calculate the number, or if I add, it works. But if I use ((variable[0] / variable[1]) * 100), I have constant problems. Even though the numbers I calculate using this formula look fine, when I apply my MAX, MIN methodology the values do not come out right. I do not know where the problem is. It does not seem to be a divide by 0 issue.

    Does anyone know what is happening?

    Thank you.

    #2
    Hello imalil,

    Thank you for your post.

    What errors are you encountering when applying your MAX/MIN calculations to the script?

    What behavior are you seeing and what behavior is expected when applying your MAX/MIN calculations?

    Do you see any errors in the Log tab of the Control Center? If so, what does the error(s) report?

    Please send a test script that demonstrates the behavior you are seeing so that we may further investigate this matter.

    Thanks in advance, I look forward to resolving this.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Hi Brandon, there are no errors. I am simply getting answers that I shouldn't be getting. I get the right answer every now and then, but it's rare. So I know something's working. I'm looking at a bar right now which has a value of 6.2, and the max of the previous 10 bars is 44.0. These values were derived by [0] / [1]. So, using my MAX code, I should be getting a value of 6.2/44, which is .14. But the answer I'm looking at right now is 1.95.

      Using the same MAX code on different numbers on the same bar, which I got by subtracting [1] from [0], I get 76 on the current bar, and the MAX going back 10 bars is 54. So my answer should be 76/54, or 1.41, which is exactly what I get. So I'm not getting errors, just wrong answers. I'll send the script in a little while. Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      657 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      373 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      579 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X