![]() |
This website will be down for maintenance from Friday May 24th at 6PM MDT until Saturday May 25th at 11AM MDT. We apologize for the inconvenience. If you need assistance during this time, please email sales@ninjatrader.com
|
|||||||
| General Programming General NinjaScript programming questions. |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#16 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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. |
|
|
|
|
|
#17 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#18 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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. |
|
|
|
|
|
#19 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Thanks for that.
To clarify, you only see this in market replay and you have not seen it in live correct? -Brett
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#20 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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. |
|
|
|
|
|
#21 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#22 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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, |
|
|
|
|
|
#23 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
|
The following user says thank you to NinjaTrader_Brett for this post: |
|
|
|
#24 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#25 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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, |
|
|
|
|
|
#26 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
Sorry, no facilities to that. I will send the user request in.
-Brett
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#27 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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. |
|
|
|
|
|
#28 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
|
|
#29 |
|
Member
Join Date: Nov 2010
Posts: 51
Thanks: 8
Thanked 3 times in 3 posts
|
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. |
|
|
|
|
|
#30 |
|
NinjaTrader Customer Service
Join Date: Dec 2009
Location: Denver, CO, USA
Posts: 6,498
Thanks: 109
Thanked 291 times in 280 posts
|
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
Brett
NinjaTrader Customer Service |
|
|
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Multi-instrument strategy PnL | jp_kettunen | Miscellaneous Support | 5 | 03-18-2010 09:46 AM |
| Is OnMarketData multi-threaded? | evlap | General Programming | 2 | 10-24-2009 11:46 AM |
| Exposing a dictionary | blarouche | Indicator Development | 8 | 10-20-2009 10:25 AM |
| NT is multi-threaded? | JS999 | Suggestions And Feedback | 3 | 04-16-2009 09:03 AM |
| Multi-Threaded | bsamani | General Programming | 1 | 02-08-2009 09:24 AM |