• 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

Unhandled exception

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

    Unhandled exception

    I have the same problem with a stopLoss Order. I tried everything from these links
    https://ninjatrader.com/support/foru...tion-of-orders
    https://ninjatrader.com/support/help...-threading.htm
    but could not find a solution.

    #2
    Hello Trino,

    To confirm, the exact error message you are getting is 'Unhandled exception: Collection was modified; enumeration operation may not execute'?

    If you comment out the SetStopLoss() or Exit() method does the error stop?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, commenting out the stopLoss eliminates the error, but (obviously) the strategy does not function then.

      Comment


        #4
        Hello Trino,

        It is not exactly clear how you are hitting this error.

        Chelsea's recommendation for accessing the Account.Orders collection involves adding a lock() to protect the code that accesses the collection to avoid this error.

        Are you accessing the Account.Orders collection and hitting this error? If so, please be sure to use a lock() to protect the code that accesses the collection.

        If this is not the case, could you attach a barebones example similar to the following that demonstrates how you are hitting this error?

        SampleMonitorStopProfit - https://ninjatrader.com/support/help..._and_profi.htm

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

        Comment


          #5
          I use a strategy from the Wizard. The line that produces the error while back testing is

          ExitLongStopLimit(Default.Quantity, 0, 0, “”, “”);

          If I comment that line out, the error disappeared.




          What should be inside the brackets of the lock() command: (?)

          lock() ExitLongStopLimit(Default.Quantity, 0, 0, “”, “”);

          still produces the error.

          Thank you for your patience.

          Comment


            #6
            Hello Trino,

            Are you able to reproduce this error using a Strategy Builder created strategy that has not been unlocked?

            If so, could you attach an export of this strategy with some steps that I can take to hit this error in the Strategy Analyzer?

            If this is a an error that you have encountered with an unlocked strategy, could you attach a reduced version that only depicts this issue and could you also include a screenshot showing the exact context of the error you are receiving?

            Please follow the instructions below to attach an exported NinjaScript strategy.

            Exporting as Source Code - https://ninjatrader.com/support/help...tAsSourceFiles

            Attaching a screenshot

            To send a screenshot with Windows 7 or newer I would recommend using Window's Snipping Tool.

            Click here for instructions

            Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save as a jpeg file and send the file as an attachment.

            Click here for detailed instruction

            I look forward to your reply.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by swcooke, Today, 09:20 AM
            5 responses
            14 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by chartish, Today, 08:21 AM
            2 responses
            7 views
            0 likes
            Last Post chartish  
            Started by xbionicx, Today, 01:12 AM
            2 responses
            12 views
            0 likes
            Last Post xbionicx  
            Started by NinjaCustomer, Today, 07:52 AM
            2 responses
            6 views
            0 likes
            Last Post NinjaCustomer  
            Started by tradr, Today, 07:45 AM
            2 responses
            8 views
            0 likes
            Last Post tradr
            by tradr
             
            Working...
            X