Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Intraday Intesity problems / calculation returns NaN

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

    Intraday Intesity problems / calculation returns NaN

    Hi,

    I am trying to code an Intraday Intensity oscillator, involving only some very simple arithmetic - however, the calculation is failing. I have been adding parts of the calculation into a test script to pinpoint where the issue is, and it appears to be with the following division for 'tempval3':

    double tempval1 = ((2*Close[0]) - High[0] - Low[0]);
    double tempval2 = (High[0]-Low[0]);
    double tempval3 = tempval1/tempval2;
    temp.Set(tempval2);
    Print(tempval3);
    I_Intensity.Set(temp[0]);

    I can plot tempval1, no problems. The same applies to tempval2, but no plot shows for tempval3.

    In the output window, I notice that tempval3 is returning lots of -1 and 1 values, and also NaN occasionally.

    Any ideas why this could be - as far as I can see I am only asking for the most basic of arithmetic here?

    Thanks in advance

    Julian

    #2
    Hello Julian,
    Thanks for writing in and I am happy to assist you.

    In case High and Low are equal you are then dividing tempval1 with 0 (zero). In such case you will get NaN.

    You can filter your code with

    Code:
    if (double.IsNaN(tempval3))
    {
       //do something
    }
    Please use the Print() function to debug the code throughly. Please go through this post which discusses how to debug in NinjaTrader http://www.ninjatrader.com/support/f...ead.php?t=3418

    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Thanks - my sheer stupidity on this one. Yesterday was a long day...

      Comment


        #4
        Hello Julian,
        Glad you could figure it out.
        Please let me know if I can assist you any further.
        JoydeepNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        607 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        353 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        105 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        561 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X