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

MRO error in v7, but not in 6.5

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

    MRO error in v7, but not in 6.5

    The below line is causing the error: "Error on calling 'OnBarUpdate' method for indicator 'CCI_Forecaster_DE' on bar 34: 'MRO' on bar 0 threw exception: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart." where Bar 34 is the first bar processed.

    BarsAgo_100Xdown = MRO(delegate{return (myWoodies[0] < 100 && (myWoodies[Math.Min(CurrentBar, 1)]==100 ? myWoodies[Math.Min(CurrentBar, 2)]>100 : myWoodies[Math.Min(CurrentBar, 1)]>100));},1,CurrentBar) +1;// 100 line cross up

    This line is identical to the MRO in the previous line except that the > and < operators are reversed. That line reads:

    BarsAgo_100Xup = MRO(delegate{return (myWoodies[0] > 100 && (myWoodies[Math.Min(CurrentBar, 1)]==100 ? myWoodies[Math.Min(CurrentBar, 2)]<100 : myWoodies[Math.Min(CurrentBar, 1)]<100));},1,CurrentBar) +1;// 100 line cross up


    Also of interest is that if I change the last > to a < the line passes muster. I have checked it against a standard CCI and the CCI has exceeded both 100 and -100 before bar 34. I also changed the return statement to start bar processing as high as 200 and it still throws the error.

    Like I said, this line has worked for v6.5 for years.

    This much simpler line throws the same error:

    BarsAgoSidewaysreset = MRO(delegate{return (Math.Abs(myWoodies[Math.Min(CurrentBar, 1)])>=Extremes);},1,CurrentBar) +1;// Extreme cross up

    Where Extremes is an int (def == 200)
    If I change the >= to a <= it passes muster.

    Any help would be appreciated.

    #2
    snaphook, thanks we're looking into matters and see if we can reproduce the issue here.

    Thanks for reporting in.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Hi snaphook,

      Is myWoodies a dataseries, what does it access? Code snippet?
      TimNinjaTrader Customer Service

      Comment


        #4
        myWoodies access the WoodiesCCI Indicator and is located in Initialize..

        myWoodies = WoodiesCCI(2, 5, Periods, 34, 25, 6, 30, 100, 2);

        This occurred during a port from v6.5 to v7.15b. The v6.5 indicator is available in the indicators forum. CCI_Forecaster_DE
        Last edited by snaphook; 06-02-2010, 05:39 AM.

        Comment


          #5
          Hi snaphook,

          Looks like the creator is using some unsupported methods, however, you can try putting in the OnStartUp() instead.

          More info at - http://www.ninjatrader.com/support/h...?onstartup.htm
          TimNinjaTrader Customer Service

          Comment


            #6
            OK. Well, I am the creator and never claimed to be an expert C# programmer.

            I moved the myWoodies declaration to OnStartUp() (thank you) and left the
            WoodiesCCI myWoodies;
            statement in variables.

            I am still getting an error in:
            BarsAgoExtremeXdown = MRO(delegate{return (myWoodies[0]<Extremes && myWoodies[Math.Min(CurrentBar, 1)]>=Extremes);},1,CurrentBar) +1;// Extreme cross down

            Extremes is an int == 200.

            Using
            if(CurrentBar<135) return;
            on bar 135 myWoodies crossed below 200, therefore the test evaluated to TRUE and no error occurred. On bar 134, however, myWoodies was > 200 and had never been > 200 before as shown below (note the 134 identifying bar 134). Using
            if(CurrentBar<134) return;
            this test evaluated to false on bar 134, resulting in the error reported, rather than a -1 as documented.

            Comment


              #7
              I think I may have found the problem. The lookback period was set to CurrentBar, which worked fine in v6.5, but in v7 it fails. If, however, I change the lookback period to CurrentBar-1 the tests all pass muster. Apparently a change was made to bar 0 such that the v6.5 test failed in v7 when testing bar 0. CurrentBar-1 only tests back to bar 1.

              Comment


                #8
                Hi snaphook,

                Understood, and thank you for the update.
                TimNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Jon17, Today, 04:33 PM
                0 responses
                1 view
                0 likes
                Last Post Jon17
                by Jon17
                 
                Started by Javierw.ok, Today, 04:12 PM
                0 responses
                4 views
                0 likes
                Last Post Javierw.ok  
                Started by timmbbo, Today, 08:59 AM
                2 responses
                10 views
                0 likes
                Last Post bltdavid  
                Started by alifarahani, Today, 09:40 AM
                6 responses
                41 views
                0 likes
                Last Post alifarahani  
                Started by Waxavi, Today, 02:10 AM
                1 response
                20 views
                0 likes
                Last Post NinjaTrader_LuisH  
                Working...
                X