Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 Mindset, 05-06-2023, 09:03 PM
            10 responses
            262 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by michi08, 10-05-2018, 09:31 AM
            5 responses
            741 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by The_Sec, Today, 02:29 PM
            0 responses
            2 views
            0 likes
            Last Post The_Sec
            by The_Sec
             
            Started by tsantospinto, 04-12-2024, 07:04 PM
            4 responses
            62 views
            0 likes
            Last Post aligator  
            Started by sightcareclickhere, Today, 01:55 PM
            0 responses
            1 view
            0 likes
            Last Post sightcareclickhere  
            Working...
            X