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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        160 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        307 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        245 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        348 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        178 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X