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

Multi-threaded.. Key in dictionary: 'PnL'

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

    #16
    Hi Brett,

    Here is a simple strategy, but it does similar things to what I am seeing in the complex case. It will give you something to play with. You can see there is nothing in the Custom Event section. It is truly the TriggerCustomEvent() that creates the error, and I can't trap it, which may be part of the problem...

    It is run on a 4 Range chart on the CL 03-12 for 1/23/2012 (Downloaded the data from your service).

    I have enclosed a Pic to show you what happens, trades just stop occurring..... The error on this one has been consistently this error:
    **NT** Error on triggering custom event for strategy 'NTTimerTesting/b72dfaea2c654817b98e737a5340f26c': Collection was modified; enumeration operation may not execute.

    Time of the error will depend upon your system speed, I have run this at 500X and got the problem anywhere from 4AM to 2PM on that day. Your mileage may vary....

    I enclosed the Log file as well.
    Attached Files

    Comment


      #17
      Hello,

      I have not had a chance to setup tests yet. However I did review the code.

      The only thing I see of the top of the head is that you are not disposing your timer in OnTermination()? If this just in the sample code or the production code as well?

      -Brett

      Comment


        #18
        Mainly just this code, I will play with it but I know you can restart NT and get this error, so it would not have called the OnTerminate(). Certainly for subsequent runs, it may be an issue, but I could see the timed events (printing) where it still seems like only one occurance is running. Sometimes I need to restart NT to get the new software libraries to load.

        Although that is better practice, I don't think it is the cause of the problem I am seeing.

        Comment


          #19
          Thanks for that.

          To clarify, you only see this in market replay and you have not seen it in live correct?

          -Brett

          Comment


            #20
            Unfortunately, I haven't done enough live testing yet to really trigger the issue. I was hoping to find the cause of the issue before burning lots of time (at 1X).

            Replay is currently the only confirmed fault to date.

            Comment


              #21
              I see.

              I was able to replicate, with that said however I feel that using a timer and setting market replay at anything other then 1x will give you bad/incorrect results.

              As the timer would not be sped up but the bars would be. Throwing off all timing and accuracy of your code.

              Therefor the primary issue is it simply doesn't make since to debug a scenario that is not accurate or correct in the first place. Do you disagree?

              -Brett

              Comment


                #22
                Hi Brett,

                I understand your reasoning. I would not have a big issue with this error if I could be sure it was a replay issue only. I am hoping you guys can confirm that fact, maybe it gives you insite into a different issue as it would seem NT shouldn't through this error.

                From a Sim perspective, although I know the Timed Events are not valid, there are times you want to test the strategy containing timed events but simply looking at other aspects of the logic such as Entry, Exit, trailing, and money management. In these cases, I would still want to run at 500X. If I knew this issue was within the Replay section, and you guys could point me to detecting a Sim account running >1X, I could disable the timer automatically (As I speed up/slow down as thing of interest happen).

                Hopeful that makes sense. So if we can get some level of comfort that order entry isn't going to freeze like the demo in Live runs or 1X and I can screen >1X, I can get around this issue. My biggest concern is if this same fault could occur Live Trading and freeze an order open!

                Thanks,

                Comment


                  #23
                  Understood.

                  Giving you a quick update I have already contacted development to get a bit more information on this and this is expected. If it is not expected we will check into it further and if expected then running in live shouldn't give you any issues.

                  I will update you when I have heard back.

                  -Brett

                  Comment


                    #24
                    Thanks for patience.

                    Here is what development suggested:

                    Timers in market replay would not make any sense except in 1x speed. If the instrument he is testing against is liquid enough he could redo the test code with pseudo "close enough" timer based off OnMarketDate timestamps.


                    Therefor the idea is you should be fine in 1X mode and not run into this. However if you wanted to test it out on live market data you could run tests on this in OnMarketData live and test to make sure you never run into it. We do not suspect that you would however wanted to be the first to know if you did.

                    -Brett

                    Comment


                      #25
                      Okay,

                      So it sounds like Development said this is a replay issue only?

                      What I would like to do is detect if the "strategy" is in replay mode and if it is >1X, is there a way I can do this?

                      Thanks,

                      Comment


                        #26
                        Sorry, no facilities to that. I will send the user request in.

                        -Brett

                        Comment


                          #27
                          I am struggling to get around this issue during simulations. It would be nice if I could at least Try/Catch the error, but NT doesn't seem to through an exception. It only reports this type of error:
                          **NT** Error on calling 'OnMarketData' method for strategy 'GHPLOMSampleGoodUntilTime/edcb6a99aeaa48e2ba03582b14fc2a95': Collection was modified; enumeration operation may not execute.

                          If I could catch this and have the strategy continue would be fine, but right now, it trashes the ability to place orders for some reason.

                          Comment


                            #28
                            Just curious have to tried a Try/Catch around OnMarketData()?

                            What code segment is generating this error? I would not expect this to be related at all to our other issue.

                            -Brett

                            Comment


                              #29
                              Brett,

                              Thanks, I have tried that. As you can see if the demo version I posted, you cannot trap that "error" from the CustomTimerEvent() function either. It stops NT7 from processing Orders which is the issue. If I could trap the error and ignore it, that would be one thing, but it doesn't seem like the error is Thrown, but simply reported from NT7.

                              Comment


                                #30
                                Ok, so in that case we would need to reset here and re attack this new case.

                                Is it somehow related to the timer again? If it is I would be sure to get it into development.

                                I would not expect an NT method to fail, unless there was some code inside the override that you are doing to cause this.

                                What specifically are you doing inside of OnMarketData()?

                                Is this in market reply or live data?


                                -Brett

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by manitshah915, Today, 12:59 PM
                                1 response
                                3 views
                                0 likes
                                Last Post NinjaTrader_Erick  
                                Started by ursavent, Today, 12:54 PM
                                1 response
                                3 views
                                0 likes
                                Last Post NinjaTrader_Jesse  
                                Started by cre8able, Today, 01:01 PM
                                1 response
                                4 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by Mizzouman1, Today, 07:35 AM
                                3 responses
                                17 views
                                0 likes
                                Last Post NinjaTrader_Gaby  
                                Started by RubenCazorla, Today, 09:07 AM
                                2 responses
                                13 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Working...
                                X