Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trying to plot a cumulative index

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

    Trying to plot a cumulative index

    Hi,

    Trying to create a cumulative index using the formula ((Close[0]-Open[0])/(High[0]-Low[0])).

    The code is attached. The error I am getting is "Error on plotting indicator 'pressurecum'. Please check the 'OnBarUpdate' or the Plot method: Overflow error. I suppose when High[0] - Low[0] = 0, that is when the problem happens.

    Can someone help with a workaround? Thanks!
    Attached Files

    #2
    Hello,

    I didn't look in your zip (we don't really debug for people), but you might want to just build a condition that filters out that 0 occurance:
    if(High[0] != Low[0])
    {
    //plot here
    }
    DenNinjaTrader Customer Service

    Comment


      #3
      Ben,

      Apart from the Add(new Plot...)line, I only have this line:-

      PCum.Set((Close[0]-Open[0])/(High[0]-Low[0]));

      Not sure what I can do here to address the issue of (High[0]-Low[0]) = 0.

      If I want to keep the previous value in such circumstances, what would I have to write in the script?

      Comment


        #4
        Originally posted by kaywai View Post
        Ben,

        Apart from the Add(new Plot...)line, I only have this line:-

        PCum.Set((Close[0]-Open[0])/(High[0]-Low[0]));

        Not sure what I can do here to address the issue of (High[0]-Low[0]) = 0.

        If I want to keep the previous value in such circumstances, what would I have to write in the script?
        Try this http://www.ninjatrader-support2.com/...ead.php?t=3170

        Comment


          #5
          PrTester, I don't have an issue with insufficient bars. The issue lies with the denominator (High[0]-Low[0])=0. As you know, nothing can be divisible by zero....

          Comment


            #6
            Originally posted by kaywai View Post
            PrTester, I don't have an issue with insufficient bars. The issue lies with the denominator (High[0]-Low[0])=0. As you know, nothing can be divisible by zero....
            double denom = (High[0]-Low[0]);
            if( denom <= 0)
            denom =1;

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by muratb35, Today, 03:36 AM
            0 responses
            3 views
            0 likes
            Last Post muratb35  
            Started by fernlicht, Today, 02:16 AM
            2 responses
            9 views
            0 likes
            Last Post fernlicht  
            Started by fernlicht, 04-12-2021, 06:01 PM
            1 response
            28 views
            0 likes
            Last Post NinjaTrader_PaulH  
            Started by memonolog, Today, 02:10 AM
            3 responses
            6 views
            0 likes
            Last Post memonolog  
            Started by orenytz, Today, 12:25 AM
            0 responses
            8 views
            0 likes
            Last Post orenytz
            by orenytz
             
            Working...
            X