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

MTF indicator crashes in native code

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

    MTF indicator crashes in native code

    Hello,

    I am trying to develop a multi time frame indicator that gathers the data on 3 time frames Range and Minutes with range being the base.

    I have read the tutorial on how to create additional time series (declare them and initialize the later in OnBarUpdate with providing the barsArray wrapped in the indicator input).

    I have created several little indicators for this purpose - each of them works fine on the graph when used separately.

    Then I have a one indicator composed of those small ones and passing various BarsArrays (for the added timeframes) to them. I use the DataSeries for storing the values within the main indicator. The indicator is then used in the strategy for querying the calculated values.

    When I don't instantiate additional time frames, everything works fine and the strategy starts evaluating the data in OnBarUpdate. It starts properly and is visible as green in the Strategies tab.
    However, when adding a single additional timeframe everything goes well as far as I am able to debug within Visual Studio - that means when the Initialize method finishes.

    Then the strategy crashes miserably within the native code with no error being raised. The strategy just simply vanishes from the strategies tab... I don't know what is the problem so I cannot report it. Is there a way to get the error report from within the native code?

    Even adding a break on exception when attached to the process in VS does not help.

    Is the concept feasible or am I going the wrong way?

    Thanks for help

    Regards

    Petr

    #2
    Hello petrmac,

    Yes, this concept would be possible.

    When the strategy disables, are you receiving any errors on the Log tab of the Control center or from the output window?

    Can you try running the TraceOrders property and see if this gives you an additional information:

    MatthewNinjaTrader Product Management

    Comment


      #3
      Hi Matthew,

      thanks for the quick reply. I see no errors in the logs tab, nor there is an error generated to the logs in the logs dir...

      I will try the tracing though.

      Will be back with the results.

      Comment


        #4
        OK,

        so it is actually not the native code at all. The exception is just not trapped within VS... obfuscation i presume. Anyway the trace file tells me that the error is the following:

        Code:
        2011-08-29 23:47:47:015 *************** unhandled exception trapped ***************
        2011-08-29 23:47:47:015 Index je mimo hranice pole. (Index out of bounds)
        2011-08-29 23:47:47:015    v NinjaTrader.Indicator.IndicatorBase.EnsureLifeTimeStatus(LifeTimeStatus status)
           v NinjaTrader.Strategy.StrategyBase.EnsureLifeTimeStatus(LifeTimeStatus status)
           v NinjaTrader.Strategy.StrategyBase.Sync2Live()
           v NinjaTrader.Strategy.StrategyBase.set_Running(Boolean value)
           v NinjaTrader.Gui.Chart.ChartControl.Add(StrategyBase strategyTemplate)
           v NinjaTrader.Strategy.StrategyGridDisplay.EnableStrategy(StrategyBase strategy)
           v NinjaTrader.Strategy.StrategyGridDisplay.OnCellChange(Object sender, CellEventArgs e)
           v Infragistics.Win.UltraWinGrid.UltraGrid.OnCellChange(CellEventArgs e)
           v Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e)
           v Infragistics.Win.UltraWinGrid.UltraGridCell.CellChangeHelper(Object sender, EventArgs ev)
           v Infragistics.Win.EmbeddableEditorBase.RaiseValueChangedEvent()
           v Infragistics.Win.CheckEditor.SetEditorValueInternal(Object newVal)
           v Infragistics.Win.CheckEditor.SetNextState()
           v Infragistics.Win.CheckEditorCheckBoxUIElement.OnCheckStateChange()
           v Infragistics.Win.CheckBoxUIElement.OnClick()
           v Infragistics.Win.ControlUIElementBase.ProcessMouseUpHelper(Object sender, MouseEventArgs e)
           v Infragistics.Win.ControlUIElementBase.ProcessMouseUp(Object sender, MouseEventArgs e)
           v Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
           v Infragistics.Win.UltraControlBase.OnMouseUp(MouseEventArgs e)
           v NinjaTrader.Gui.Grid.NTGrid2.OnMouseUp(MouseEventArgs e)
           v System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
           v System.Windows.Forms.Control.WndProc(Message& m)
           v System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
           v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
           v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
        Sorry for the Czech .NET locale. I think the message is readable though.:-)

        This happens when enabling the strategy (on the strategy tab) on the open market replay. The program obviously crashes on some Index out of bounds error.

        Any ideas what could be wrong?


        Thanks

        Petr

        Comment


          #5
          Oh and I forgot,

          I updated to the latest NT version today (Version 7.0.1000.7)... The error has been there before though:-)

          Comment


            #6
            Hello,

            Thanks for the update - is the NT V7.0.1000.7 you are using? You can check this under Help--> About

            Do you have issues when running the SampleMultiTimeFrame or SampleMultiInstrument strategies which come preconfigured?

            Which version of .NET do you have installed?
            MatthewNinjaTrader Product Management

            Comment


              #7
              And here is another exception:

              Code:
              2011-08-30 00:05:19:125 Db.Globals.StrategyUpdateJob3: WARNING: NQ 09-11 Globex
              2011-08-30 00:05:28:281 in OnUnhandledThreadException
              2011-08-30 00:05:28:281 *************** unhandled exception trapped ***************
              2011-08-30 00:05:28:281 Index je mimo hranice pole. (Index out of bounds)
              2011-08-30 00:05:28:281    v NinjaTrader.Indicator.IndicatorBase.EnsureLifeTimeStatus(LifeTimeStatus status)
                 v NinjaTrader.Strategy.StrategyBase.EnsureLifeTimeStatus(LifeTimeStatus status)
                 v NinjaTrader.Strategy.StrategyBase.RollCurrentBar()
                 v NinjaTrader.Strategy.StrategyBase.Sync2Live()
                 v NinjaTrader.Strategy.StrategyBase.set_Running(Boolean value)
                 v NinjaTrader.Gui.Chart.ChartControl.Add(StrategyBase strategyTemplate)
                 v NinjaTrader.Strategy.StrategyGridDisplay.EnableStrategy(StrategyBase strategy)
                 v NinjaTrader.Strategy.StrategyGridDisplay.OnCellChange(Object sender, CellEventArgs e)
                 v Infragistics.Win.UltraWinGrid.UltraGrid.OnCellChange(CellEventArgs e)
                 v Infragistics.Win.UltraWinGrid.UltraGrid.FireEvent(GridEventIds id, EventArgs e)
                 v Infragistics.Win.UltraWinGrid.UltraGridCell.CellChangeHelper(Object sender, EventArgs ev)
                 v Infragistics.Win.EmbeddableEditorBase.RaiseValueChangedEvent()
                 v Infragistics.Win.CheckEditor.SetEditorValueInternal(Object newVal)
                 v Infragistics.Win.CheckEditor.SetNextState()
                 v Infragistics.Win.CheckEditorCheckBoxUIElement.OnCheckStateChange()
                 v Infragistics.Win.CheckBoxUIElement.OnClick()
                 v Infragistics.Win.ControlUIElementBase.ProcessMouseUpHelper(Object sender, MouseEventArgs e)
                 v Infragistics.Win.ControlUIElementBase.ProcessMouseUp(Object sender, MouseEventArgs e)
                 v Infragistics.Win.Utilities.ProcessEvent(Control control, ProcessEvent eventToProcess, EventArgs e)
                 v Infragistics.Win.UltraControlBase.OnMouseUp(MouseEventArgs e)
                 v NinjaTrader.Gui.Grid.NTGrid2.OnMouseUp(MouseEventArgs e)
                 v System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
                 v System.Windows.Forms.Control.WndProc(Message& m)
                 v System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
                 v System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
                 v System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

              Comment


                #8
                Hi again, Matthew,

                yes, the version is correct. As for the .NET runtime, I have probably all of them installed except 1.1 (I have development environment on the machine - VS 2010). Which one was picked by NT I don't know... seems like 2.0... I have also 3.5 and 4.0 .NET runtimes installed.

                The mentioned preconfigured strategies both start properly.

                Here is the beginning of the trace file:

                Code:
                2011-08-29 23:46:26:421 ******************* Session Start (Version 7.0.1000.7) ******************* 
                2011-08-29 23:46:26:421 Attaching global exception handlers...
                2011-08-29 23:46:26:484 InstallDir='C:\Program Files\NinjaTrader 7\'
                2011-08-29 23:46:26:484 UserDataDir='C:\Documents and Settings\Administrator\Dokumenty\NinjaTrader 7\'
                2011-08-29 23:46:27:671 Cbi.Globals.MachineId: True/True
                2011-08-29 23:46:27:671 MachineId='6CB3B1971306495A7B66A3F3A54918AA'
                2011-08-29 23:46:27:671 OS='Microsoft Windows NT 5.1.2600 Service Pack 3'/'Win32NT'
                2011-08-29 23:46:27:703 Processors: available=2 enabled=2
                2011-08-29 23:46:27:703 .NET/CLR Version='2.0.50727.3623'/32bit
                2011-08-29 23:46:27:703 Processor='Procesor Intel Pentium III Xeon'
                2011-08-29 23:46:27:703 PhysicalMemory=1024 MB
                2011-08-29 23:46:27:703 Timezone=EST +6 hour(s)
                2011-08-29 23:46:27:703 OptimizedCpuPerformance=True

                Comment


                  #9
                  Hello,

                  Thanks for the traces - can you clarify if you tried using the sample MTF strategies? Do they run as expected?

                  Does this only crash when you are in market replay? Do you see issues on a live connection?
                  MatthewNinjaTrader Product Management

                  Comment


                    #10
                    Hello Matthew,

                    thanks for the reply. Yes, the attached strategies start properly and do not crash.

                    As for my strategy, it works fine live and in replay as long as I restrict the strategy to just one timeframe. Otherwise it crashes on both live and replay connections. I haven't been able to get it past initialization,...

                    Could there be a problem, that the startegy uses MFT indicator and is not MTF itself?


                    Thanks

                    Regards

                    Petr Macek

                    Comment


                      #11
                      Petr,

                      Can you clarify the system you are running? Is this a desktop or are you running from a server? The memory reported is under our minimum requirements:

                      2011-08-29 23:46:27:703 PhysicalMemory=1024 MB

                      Is this reported correctly? Is there way for you to allocate more than 1GB to meet our 2GB minimum requirement?
                      MatthewNinjaTrader Product Management

                      Comment


                        #12
                        Hi, Matthew,

                        The physical machine is a laptop with parallels desktop (latest Macbook pro with i5). I can easily increase the nemory, but I am experiencing same issue on my quad core 4GB desktop with MS Vista OS.

                        Petr

                        Comment


                          #13
                          Petr,

                          Thanks for clarifying - yes please add more memory via parallels when possible to avoid any issues.

                          It sounds like this is an issue with the script itself. There should not be any issues with running MTF indicators as long as they are being initialized correctly.

                          I would suggest using try- catch blocks to isolate what's causing the 'Index was outside the bounds of the array' error.

                          It may help to simplify your strategy until it works without that message. If you want to post the script here we can give it a look over to ensure everything set correctly

                          Using Try-Catch Blocks:



                          The most common reason for this error is discussed in the following thread:

                          MatthewNinjaTrader Product Management

                          Comment


                            #14
                            Hi Matthew,

                            I tried to use the try-catch blocks already. The thing is, I cannot surround with try -catch the code that is not mine- part of api. Thus I need to know, what could potentially cause the error condition. Since I don't have the NT sources I cannot debug further and my conclusions are in area of wild guesses.

                            I can drastically increase the BarsRequired for the strategy... Let's see if it works.

                            Petr

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by CortexZenUSA, Today, 12:53 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post CortexZenUSA  
                            Started by CortexZenUSA, Today, 12:46 AM
                            0 responses
                            1 view
                            0 likes
                            Last Post CortexZenUSA  
                            Started by usazencortex, Today, 12:43 AM
                            0 responses
                            5 views
                            0 likes
                            Last Post usazencortex  
                            Started by sidlercom80, 10-28-2023, 08:49 AM
                            168 responses
                            2,266 views
                            0 likes
                            Last Post sidlercom80  
                            Started by Barry Milan, Yesterday, 10:35 PM
                            3 responses
                            13 views
                            0 likes
                            Last Post NinjaTrader_Manfred  
                            Working...
                            X