• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8B8 - System.Reflection.TargetInvocationException

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

    NT8B8 - System.Reflection.TargetInvocationException



    win7 64bit nt8b8 64bit

    Had this same stuff on win10 (more, I counted 27 to dismiss)... I commented out my code that caused this massive increase - and only at 4... which gives me something I might be able to reproduce in the future with a test script.




    Code:
    2016-02-15 18:16:16:600 (Playback Connection) Cbi.Account.AccountItemCallback: account='Playback101' accountItem=RealizedProfitLoss currency=UsDollar value=*****
    2016-02-15 18:16:16:601 *************** unhandled exception trapped ***************
    2016-02-15 18:16:16:601 Exception has been thrown by the target of an invocation.
    2016-02-15 18:16:16:602 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at NinjaTrader.Gui.NinjaScript.StrategiesGrid.CalculateRealizedProfit(StrategyBase strategy, Instrument instrument)
       at NinjaTrader.Gui.NinjaScript.StrategiesGrid.<OnPositionUpdate>b__66_0(PositionEventArgs e)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

    Code:
    2016-02-15 18:46:32:049 *************** unhandled exception trapped ***************
    2016-02-15 18:46:32:049 Exception has been thrown by the target of an invocation.
    2016-02-15 18:46:32:050 (Playback Connection) Cbi.Order.OrderUpdateCallback.HandleOco.Unchanged: orderId='f1ca095bbfe640019a36609ebb03d30b' account='Playback101' name='Stop loss' orderState=TriggerPending instrument='ES 09-14' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=1919.25 quantity=1 tif=Gtc oco='06348e4d226644ba9b9f84b3baf6d603' filled=0 averageFillPrice=0 id=8168 gtd='2099-12-01' currentOrderState=TriggerPending
    2016-02-15 18:46:32:050 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
       at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
       at System.Collections.Generic.List`1.Enumerator.MoveNextRare()
       at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
       at NinjaTrader.Gui.NinjaScript.StrategiesGrid.CalculateRealizedProfit(StrategyBase strategy, Instrument instrument)
       at NinjaTrader.Gui.NinjaScript.StrategiesGrid.<OnPositionUpdate>b__66_0(PositionEventArgs e)
       --- End of inner exception stack trace ---
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
       at System.Delegate.DynamicInvokeImpl(Object[] args)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

    #2
    Oh yeah - this is my first foray with NT8 in adding a secondary dataseries - so it might be related to that.

    edit:
    And I'm having random issues with strategies turning off...

    It's not consistent..happens on different contracts. Sometimes it's good, sometimes it isn't.


    Code:
    		protected override void OnBarUpdate()
    		{
    			
    			if (BarsInProgress != 0)
    				return;
    			
    			if (CurrentBars[0] < 0 || CurrentBars[1] < 0)
    				return;
    			//Add your custom strategy logic here.
    			// only process on real-time data 
       			if (State == State.Historical) 
    				return;
    Last edited by sledge; 02-15-2016, 09:53 PM.

    Comment


      #3
      Hello,

      Thank you for the post.

      I am uncertain what could have happened in this case with what is provided. You said that potentially you would be able to reproduce this with a future test script, were you able to produce a test that can reach this result?

      Without further details on the steps to reproduce or code used it is hard to say what may have happened here.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello,

        Thank you for the post.

        I am uncertain what could have happened in this case with what is provided. You said that potentially you would be able to reproduce this with a future test script, were you able to produce a test that can reach this result?

        Without further details on the steps to reproduce or code used it is hard to say what may have happened here.

        I look forward to being of further assistance.
        Reproduced in NT8B9 with sample script. Adding ^VIX causes the issue with that exception and trades.
        Code:
        				AddDataSeries("^VIX", Data.BarsPeriodType.Minute, 3);
        Attached is the sample strategy. So far in this run, I've gotten 4 exceptions in 3 weeks.

        Apply the strategy to a 15 second ES chart. I also have a VIX chart open with an EMA(6) and SMA(12), which I don't think matters in this situation. It's more of an issue inside the trade routine... it's having an issue with secondary series.

        Note: If you turn on Chart Trader hidden - it will at some point cause Playback-Market Replay to stall or crash. I'm currently testing NT8B9 to make sure it still stalls/crashes. (Initial Findings say YES, MyCustomStrategy.cs in that post died in 18 days). See here: http://ninjatrader.com/support/forum...ad.php?t=82252
        Attached Files

        Comment


          #5
          The exceptions appear to happen only when there is a profit (long or short). Most of these exceptions happened in ES 03-14 and ES 09-14. There might have been 1 or 2 in ES 06-14.



          This also stalled, so replay is dead, and I must end task NT.

          Comment


            #6
            Hello,

            Thank you for providing the sample on this.

            I will try this out and see if I can reproduce as well with what you have provided, if I have further questions while testing this I will let you know and report back once I have further tested this.

            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Jesse View Post
              Hello,

              Thank you for providing the sample on this.

              I will try this out and see if I can reproduce as well with what you have provided, if I have further questions while testing this I will let you know and report back once I have further tested this.

              I look forward to being of further assistance.
              This attached strategy generated 30 some plus exceptions in ES 03-16 for 3 months.

              I even added itself as the data series. If I remove the AddDataSeries - there is no exception.

              AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 3);






              Interesting ..strategy runs out of margin with AddDataSeries. lol
              Attached Files

              Comment


                #8
                Originally posted by sledge View Post
                This attached strategy generated 30 some plus exceptions in ES 03-16 for 3 months.

                I even added itself as the data series. If I remove the AddDataSeries - there is no exception.

                AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 3);






                Interesting ..strategy runs out of margin with AddDataSeries. lol
                Do you even still work there or did they let you go last week friday? You haven't logged in since. apologies if you needed the weekend off or have vacation scheduled.

                Can someone else pick this up if nt_jesse was let go or quit?

                Maybe nt_ericb was also let go last week...
                Last edited by sledge; 03-14-2016, 10:36 PM.

                Comment


                  #9
                  Hello,

                  Thank you for the reply.

                  I tried the script provided this morning but have been unable to reproduce the same result.

                  Could you please list the exact steps you are using to reproduce to know I am doing the same test as you are?

                  Unfortunately beta items are a lower priority so in the case we can not directly reproduce by the instructions you provide, it may be awhile before the item is resolved. If you have specific steps that reproduce the errors immediately there will be a quick resolution.

                  Per your prior messages, I tested using a 15 second ES chart. I also had a VIX chart open with an EMA(6) and SMA(12) although you stated that this does not matter.

                  I tried turning on Chart Trader and making it hidden, The market replay seemed to work normally at all speeds tested on.

                  Unfortunately with these steps, I am not able to see the same error, potentially we are not doing the same test as the steps provided are limited.

                  If you can instead provide steps that directly reproduce the issues I can certainly look further into it or even submit it to development in the case there is a problem.

                  Please let me know if I may be of further assistance.
                  JesseNinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Jesse View Post
                    Hello,

                    Could you please list the exact steps you are using to reproduce to know I am doing the same test as you are?

                    Welcome back. Might it be the TABS?

                    This is after I launched NT8. Connect to market replay. Set to max, change date, add strategy to chart, enabled strategy, hit play.

                    http://screencast.com/t/010OTj1B

                    5 minutes go by, I hit pause, and restart recording.

                    On 12/30 the first exception happens, and I stopped the video.

                    http://screencast.com/t/Wtj5XGhy

                    Comment


                      #11
                      Hello,

                      Thank you for providing the sample.

                      I reviewed the videos, I have yet been able to reproduce the errors you are but using the steps I do see that the script is causing a freeze for me.

                      I noted the line that controls if the freeze happens or not was this line:
                      AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 3);

                      Unfortunately using Instrument in this way would not be recommended as it may or may not work, I generally go with it will not work. Also the documentation for this needed updated, it looks like in the help guide it was marked as Instruments instead of Instrument. There is a note about this already:

                      Warning: The properties in this class should NOT be accessed within the OnStateChange() method before the State has reached State.DataLoaded

                      After removing this line I no longer see the freeze, are you able to still reproduce the error while not using Instrument in the starting States?


                      I look forward to being of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Jesse View Post
                        Hello,


                        I noted the line that controls if the freeze happens or not was this line:
                        AddDataSeries(Instrument.FullName, Data.BarsPeriodType.Minute, 3);

                        Unfortunately using Instrument in this way would not be recommended as it may or may not work, I generally go with it will not work. Also the documentation for this needed updated, it looks like in the help guide it was marked as Instruments instead of Instrument. There is a note about this already:

                        Warning: The properties in this class should NOT be accessed within the OnStateChange() method before the State has reached State.DataLoaded

                        After removing this line I no longer see the freeze, are you able to still reproduce the error while not using Instrument in the starting States?
                        I only added it as I figure you wouldn't have 2 years+ of ^VIX data.

                        The Instrument.FullName prints for me to the output window when I add it to various contracts. It would be insane if it doesn't work and I had to hardcode "ES 03-14" with some logic.

                        PsuedoCode:

                        Code:
                        If Instrument.FullName = "ES 03-14"
                        
                        AddDataSeries ( "ES 03-14", .... ) ;

                        Ok I saw in the NT7 examples to just use Add with no name

                        So this compiled, and I'll try this for another test on another machine:
                        Code:
                        AddDataSeries( Data.BarsPeriodType.Minute, 3);
                        Now - Are you adding the strategy to the CHART and not to the strategies TAB?

                        The strategies TAB has become worthless in NT8 since there is no link back to the chart and I could never see any trades on the charts.
                        NT7 does print to all charts each trade when using strategies tab.

                        Maybe this has been changed in a later BETA release in NT8, but I haven't tried.

                        Comment


                          #13
                          Originally posted by NinjaTrader_Jesse View Post
                          Hello,

                          Thank you for providing the sample.





                          I look forward to being of further assistance.
                          I changed the code as I mentioned a little earlier.

                          I used a different skin (Slate Dark), a different machine.

                          I thought I was in the clear as I made it almost 1.5 months before throwing 10 errors in the remaining 1.5 months.




                          Starting on 12/15/2015 will result in some nice profits and allow the whole contract to play out.

                          Starting on 12/14/2015 will result in bankruptcy.

                          Comment


                            #14
                            I did not close NT8B9.

                            I disconnect Playback-MR.

                            I created a new workspace to try to eliminate anything in the TABS being an issue or previous workspaces. I created 1 chart only.


                            I added the strategy to the chart.

                            And it went crazy.

                            This is too many for me to Count.




                            I'm going to disconnect and reconnect replay and see if it goes crazy more crazy.

                            (At least we had the same result, $127,975).

                            Comment


                              #15
                              And re-play did not double the errors. Same #.

                              Re-starting NT8 and using "intel graphics integrated" chip to see if there's any difference.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by GussJ, Today, 01:30 PM
                              1 response
                              2 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Started by GARZONJ, Today, 12:25 PM
                              3 responses
                              13 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Started by RandanAL, Today, 11:53 AM
                              1 response
                              13 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by yeshujbp, 07-21-2019, 02:40 PM
                              2 responses
                              35 views
                              0 likes
                              Last Post omololu
                              by omololu
                               
                              Started by seagraph, Yesterday, 03:27 PM
                              1 response
                              28 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Working...
                              X