Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

OnUnhandledThreadException - Index was outside the bounds of the array.

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

    OnUnhandledThreadException - Index was outside the bounds of the array.

    Hello,
    • backtest_1.png: the backtest was run on more currency, the result can be seen on the picture. You can see, that hundreds of trades were made.
    • backtest_2.png: click on the EURUSD and the "Trades" tab, then the trades can be seen.
    • backtest_3.png: mark EURGBP and the "Summary tab, everthing is OK.
    • backtest_4.png: click on the "Trades" tab and error is thrown.
    In the trace file (a clean is attached):

    in OnUnhandledThreadException
    2009-08-13 15:08:38:627 ********* exception trapped *********
    2009-08-13 15:08:38:627 Index was outside the bounds of the array.
    2009-08-13 15:08:38:627 at NinjaTrader.Gui.PerformanceViewerControl.RunBackTe st()
    at NinjaTrader.Gui.PerformanceViewerControl.Display()
    at NinjaTrader.Gui.PerformanceViewerControl.OnTabSele cted(Object sender, EventArgs e)
    at System.EventHandler.Invoke(Object sender, EventArgs e)
    at System.Windows.Forms.TabControl.OnSelectedIndexCha nged(EventArgs e)
    at System.Windows.Forms.TabControl.WmSelChange()
    at System.Windows.Forms.TabControl.WndProc(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
    at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
    at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


    What is to be done?
    Thanks,

    ps: After the error, backtest on currency can be run only after the restart of NT.
    Attached Files

    #2
    Hello Tamas,

    Thank you for your post.

    There may be some data corruption in your database.

    Can you please try repairing this: Tools --> Options --> Misc --> Repair DB?
    Ray S.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_RJStein View Post
      Hello Tamas,

      Thank you for your post.

      There may be some data corruption in your database.

      Can you please try repairing this: Tools --> Options --> Misc --> Repair DB?
      Hello RJStein,

      unfortunately it did not help. It was not probable, because it is a clear last NT release install. Historical datas were imported, not upgrade.

      I have guess about the reproduction of the error, my code is huge, i have to make a smaller sample code. If it is finished, i post it.

      Not associated this thread, but what does DB repair do? When it is interesting to use?

      Comment


        #4
        Originally posted by tamas View Post
        Hello RJStein,

        unfortunately it did not help. It was not probable, because it is a clear last NT release install. Historical datas were imported, not upgrade.

        I have guess about the reproduction of the error, my code is huge, i have to make a smaller sample code. If it is finished, i post it.

        Not associated this thread, but what does DB repair do? When it is interesting to use?
        Only use repair database when instructed by NinjaTrader support.
        It will attempt to repair any corrupt data using a MicroSoft management routine.

        Please report back if you locate your issue.
        Ray S.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_RJStein View Post
          Only use repair database when instructed by NinjaTrader support.
          It will attempt to repair any corrupt data using a MicroSoft management routine.
          Thank you.

          Then the sample:

          I uploaded here the movie and sample strategy, this error absolutely(!) reproducable at my end. I tested not at the same time like in the movie, the error came up as well.

          Iteresting: if dont use multiinstrument, then below error will come up (but not clearly) after few click on the rows.

          ApplicationStart done, took 25,7 secs
          2009-08-14 07:01:02:716 in OnUnhandledThreadException
          2009-08-14 07:01:02:986 ********* exception trapped *********
          2009-08-14 07:01:02:986 Parameter has to greater/equal 1, but was -25
          Parameter name: rows
          2009-08-14 07:01:02:986 at NinjaTrader.Gui.Grid.NTGrid.AppendRows(Int32 rows)
          at NinjaTrader.Gui.PerformanceViewerControl.Display()
          at NinjaTrader.Strategy.StrategyAnalyzer.OnInstrument sSelectionChangedNow(RowInfo rowInfo)
          at NinjaTrader.Strategy.StrategyAnalyzer.OnInstrument sSelectionChanged(Object sender, SelectionChangeEventArgs e)
          at SourceGrid2.SelectionChangeEventHandler.Invoke(Obj ect sender, SelectionChangeEventArgs e)
          at SourceGrid2.Selection.OnSelectionChange(SelectionC hangeEventArgs e)
          at SourceGrid2.Selection.AddRange(Range p_Range)
          at SourceGrid2.Selection.OnCellGotFocus(CellGotFocusE ventArgs e)
          at SourceGrid2.Selection.Focus(Position pCellToSetFocus)
          at SourceGrid2.GridVirtual.OnGridMouseDown(MouseEvent Args e)
          at SourceGrid2.GridSubPanel.OnMouseDown(MouseEventArg s e)
          at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
          at System.Windows.Forms.Control.WndProc(Message& m)
          at System.Windows.Forms.ScrollableControl.WndProc(Mes sage& m)
          at System.Windows.Forms.ContainerControl.WndProc(Mess age& m)
          at System.Windows.Forms.UserControl.WndProc(Message& m)
          at System.Windows.Forms.Control.ControlNativeWindow.O nMessage(Message& m)
          at System.Windows.Forms.Control.ControlNativeWindow.W ndProc(Message& m)
          at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)



          I dont now if it has any association, but i have posted a similar error before. There if add multiinstrument in strategy then chart freeze. I reproduce it in two desktop, two enviroment.
          - This thread can be found.
          - The mentioned movies in thread here.

          I would be great if there where any solution for this problem. This problem is very frustrated. The problem mentioned in april was not as bothered, in last 3 months i wrote minimum 5-6000 rows of code in NT for FOREX (log and trace extensions, FXRate for marketanalyzer and strategy, etc, etc), everything works without any mistake. And finaly when i put together everything in a strategy, i even can not run backtest.

          Thanks your help in advance

          Comment


            #6
            Thanks for posting that detailed info. We'll look into and will come back to you.

            Comment


              #7
              Unfortunately this is a limitation of the NT6.5 strategy analyzer where it would be thrown off as you backtested a strategy with a "dynamically" added series (e.g. if backtested on instrument A no series would be added, but if backtested on instrument B one series would be added). We're looking into overcoming this limitation for NT7.

              Sorry for inconvenience.

              Comment


                #8
                Originally posted by NinjaTrader_Dierk View Post
                Unfortunately this is a limitation of the NT6.5 strategy analyzer where it would be thrown off as you backtested a strategy with a "dynamically" added series (e.g. if backtested on instrument A no series would be added, but if backtested on instrument B one series would be added). We're looking into overcoming this limitation for NT7.
                Hello Dierk and Others,

                It is really not my aim to provoke, but your answer is not really good because of more reasons:
                1. Backtest runs the instruments one after the other (because in this case it can not be able to run multi - drawn together - result), so it is completaly all the same if I run two strategies seperately (in one there is a multiinstrument, in the other is not), or i decide it dynamically. Surely all backtests give seperate results, as if i ran seperately. (Otherwise, at the result rows can be seen that it adds correctly. I assume, that according to programming logic, you did not write a logic which run more seperate backtest, but you wrote a huge dynamic logic.)
                2. On the other hand it does not matter, if i add it dynamically or not, because nothing else happen, but it adds the object to the BarsArray. Either I could add other 30, or other 30 variable, or add dynamically classes that contain whatsoever values. At the most, I get the result more slowly, but anyway backtests will run independently, see point 1).
                3. The added instrument is not used by the strategy, only if it is added to the BarsArray. If i dont use it, then it makes no difference how many is used. Sample code also counted the result from the primary bar, so it has to make no difference how many was added.
                4. If you run the backtest with and without the multiinstrument, then it can be seen nicely, that it runs in both cases and (because multiinstrument is not used for the result) it visualise exactly the same quantity and the same kind of result on the Summary tab as it has to be.
                5. I uploaded one more movie here, and the point 4) can be seen nicely and also you can see that it makes no difference, if i run it simultaneously or seperate. If i run it on one instrument, it will be not able to visualise and it will throw exception, nevertheless it is evidently not right and it is a bug.
                Because I dont see into the NT code, i only can guess (it might be a bad guess): if i clik on all tabs, except Summary and Setting, it will throw error, and these would visualise the trade items from its objects. Since the backetst itself runs, thing might be that to click on any other (because of the multiinstrument), it calls wrong index in array and it would be visualised on the GUI.

                Or it can be:

                Originally posted by tamas View Post
                ApplicationStart done, took 25,7 secs
                2009-08-14 07:01:02:716 in OnUnhandledThreadException
                2009-08-14 07:01:02:986 ********* exception trapped *********
                2009-08-14 07:01:02:986 Parameter has to greater/equal 1, but was -25
                Parameter name: rows
                2009-08-14 07:01:02:986 at NinjaTrader.Gui.Grid.NTGrid.AppendRows(Int32 rows)
                If i were no right in the first two points, I think the error can be seen clearly in point 5). It would be great if there were any solution and/or hotfix, because if it was not able to visualise the results, than it would not be usable. So now either i could throw away the complete works of the previous months, or i could wait for the new version, which, i hope that could handle multiinstrument without any mistake. From the two latter versions, none of them are liked (I have two more weeks to finish and use NT for live trading.)

                Would it be possible to check it again?

                Comment


                  #9
                  - I had been able to reproduce the problem -> I exactly know what went wrong
                  - the problem already is addressed in our NT7 code base, however requires internal testing still

                  Not sure what you are looking for.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Dierk View Post
                    - I had been able to reproduce the problem -> I exactly know what went wrong
                    - the problem already is addressed in our NT7 code base, however requires internal testing still

                    Not sure what you are looking for.
                    I tested it, interesting:
                    1. If i add multiinstrument without if() iteration (what you said not dinamically), and run it on one instrument, it works. It is good for temporary solution. (I thought, you said do not run it dynamically on more intrument.)
                    2. If i add multiinstrument without if() iteration (what you said not dinamically), and run it on more instrument, it works, but after approximately 10 click on result rows, error come up as well.
                    Am i understand correctly, that it will be fixed only in NT 7, and not in NT 6.5?

                    Thanks everything, i can go further with point 1.

                    Comment


                      #11
                      One more thing (i have just seen it), it gave two different results. Differenc is minimal, but there should be no difference, because sample code always trade on primary bar (independetly if multiinstrument added or not)

                      This post is just for your information, bye
                      Attached Files

                      Comment


                        #12
                        >> Am i understand correctly, that it will be fixed only in NT 7, and not in NT 6.5?
                        Your understanding is correct

                        Comment


                          #13
                          Originally posted by NinjaTrader_Dierk View Post
                          Your understanding is correct
                          OK, thank you Dierk

                          Comment


                            #14
                            Hello Dierk,

                            Sorry, but I would have two qiuck questions to this:
                            1. According to your oppinion, does this problem come out if I add multi-time frame dynamically to this?
                            2. According to your oppinion, does this problem come out if I add indicator dynamically to this?
                            Because you can see the exact causes, that's why I ask it. If the answer in yeson one of the questions, then I will wait for the new versoin with this, as well. (It is not a big problem, but I would not write codes needlessly.)

                            Thanks in advance

                            Comment


                              #15
                              There are several issues related to backtesting multi-series strategies on the strategy analyzer which might cause the trouble you experienced. These issues will be addressed with NT7.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by sightcareclickhere, Today, 01:55 PM
                              0 responses
                              1 view
                              0 likes
                              Last Post sightcareclickhere  
                              Started by Mindset, 05-06-2023, 09:03 PM
                              9 responses
                              258 views
                              0 likes
                              Last Post ender_wiggum  
                              Started by Mizzouman1, Today, 07:35 AM
                              4 responses
                              18 views
                              0 likes
                              Last Post Mizzouman1  
                              Started by philmg, Today, 01:17 PM
                              1 response
                              8 views
                              0 likes
                              Last Post NinjaTrader_ChristopherJ  
                              Started by cre8able, Today, 01:01 PM
                              1 response
                              9 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Working...
                              X