Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Exception in @ProfitLoss.cs
Collapse
X
-
Hello carnitron,
Thanks for your post.
SystemPerformance.Calculate() is not a documented/supported method or property in the NinjaTrader help guide and using this would go beyond the support we would be able to provide you with in the Support Department at NinjaTrader.
SystemPerformance: https://ninjatrader.com/support/help...erformance.htm
Since this is not a documented/supported method or property in the help guide it would be up to your own discretion to use this in your script and debug the script if you see an error occurring when using this code.
This forum thread will be open for other community members to share their insights on the topic.Brandon H.NinjaTrader Customer Service
-
-
Hello carnitron,
Thanks for your notes.
To clarify, do you see an error message appearing when using the 'Profit loss' Market Analyzer Column? If so, what exactly does the error report?
Please provide us with the exact steps and settings you are using with the Market Analyzer window that reproduces this behavior so we may test reproducing the behavior on our end using the information you provide. Once we are able to reproduce the behavior we can look into this matter further.Brandon H.NinjaTrader Customer Service
Comment
-
Sorry for the delay, I'm trying to catch this again.
I do not see an error message box, it's just an exception in NT8 code.
I'm trading rapidly in this scenario on a number of tickers, so I think this bug may exist for everyone, but very rarely. I suspect I'm seeing it sometimes, b/c I'm more likely to be modifying the collection object in question at the "wrong" time, just b/c of the trading frequency.
I do have the Profit Loss column up, so that's a clue.
Comment
-
Hello carnitron,
Thanks for your notes.
To investigate this matter further we will need to be able to consistently reproduce the behavior on our end using specific steps.
Once you are able to consistently reproduce the behavior in question, please send us the exact steps and settings you are using to reproduce the behavior and a reduced exported copy of the NinjaScript you are using if it is necessary for reproducing the behavior.
Note that a reduced copy refers to a copy of the script that contains the minimum amount of code needed to reproduce the issue. All other code is commented out or removed.
To create a copy of your script to modify, open a New > NinjaScript Editor, select your script, right-click in the Editor, select 'Save as', name the script, and click OK.
To export a script, go to Tools > Export > NinjaScript AddOn.Brandon H.NinjaTrader Customer Service
Comment
-
So a couple of things:
1. We're not going to get exact steps. This is a timing bug that happens sporadically. Your programmers will understand what that means and why getting exact steps is hard and sometimes impossible. What I think we really want here is code that eventually produces the exception if you wait long enough, which is similar, but not quite the same.
2. Unfortunately, I don't have a simple script, I have 90k+ lines of proprietary code here and it would be very time consuming for me to cut this down and provide a case. What would probably do the trick on your end is just some code that trades a share of some instrument back and forth as fast as possible. Or maybe 20+ different instruments, as I am doing.
3. I don't need this fixed on my end, it's sporadic, it's non-lethal, and it's in code I'm shortly going to replace on my end anyway. I'm giving you this bug report so you can fix it for other people.
4. All that said, I think there's a good chance we don't need a case anyway. Just eyeballing the code in ProfitLose.OnAccountItemUpdate():
Code:foreach (Cbi.Execution execution in accountItemUpdate.Account.Executions) if (execution.Instrument == Instrument) executions.Add(execution); // Exception is on the next line, probably w the executions collection. realizedPL = Cbi.SystemPerformance.Calculate(executions).AllTrades.TradesPerformance.Currency.CumProfit;
"Collection was modified; enumeration operation may not execute"
So my hunch here is that if we are in the middle of the foreach statement in the OnAccountItemUpdate() function and a new execution is added to the accountItemUpdate.Account.Executions collection (perhaps on another thread), and then we get this exception.
The reason I'm seeing it and maybe others haven't is the torrential rate at which I'm trading here in this particular test case. The exception is rare and hard to repro for people making infrequent trades, but I see it more, b/c I'm hammering the executions collection many times a minute.
5. I think if you show what I have written to your programmers, they will be able to make sense of it and just deduce the issue by looking at the code. (I've been a programmer for 30+ years and have handled many issues like this myself, on evidence like this, so I'm not making some random speculative suggestion here.)
Hope this helps.
Cheers.
Comment
-
Hello carnitron,
Thanks for your notes.
Please write in to support[at]ninjatrader[dot]com to send me your Log and Trace files using the steps below so that I may report this behavior to the Development team so they may look into it further. In the subject of your email include "Attn: BrandonH" and in the body of your email include a link to this forum thread.
Follow the steps below to manually attach your log and trace files to your email so we may investigate this matter further.- Go to your computer's File Explorer (Windows Key + E) then navigate to the Documents/NinjaTrader 8 folder.
- Left-click on the 'log' and 'trace' folders to highlight them, then right-click and select 'Send To > Compressed (zipped) folder'.
- Send the two compressed folders as attachments to your email.
Brandon H.NinjaTrader Customer Service
Comment
-
When I get this exception next, I will do this. To be clear, I'm thinking you only want the log and trace files from the run that causes the exception? My log and trace folders are pretty big and filled with irrelevant logs, though I could also clear them except for the latest relevant files if that would make it easier on your end.
Comment
-
Hello carnitron,
Thanks for your notes.
Yes, we would like to see the exception in the Log and Trace files so we may report the behavior to the Development team.
If the size of your Log and Trace files are large, you could use the publicly available software WeTransfer linked below to send those files over.
WeTransfer: https://wetransfer.com/Brandon H.NinjaTrader Customer Service
Comment
-
I am beginning to suspect that the frequency of these exceptions correlates to the number of tickers you are trading simultaneously. Which would make obvious sense, given the nature of the issue.
Also, @RealizedProfitLoss.cs has the problem too.Last edited by carnitron; 10-21-2023, 12:22 AM.
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by llanqui, Today, 03:53 AM
|
0 responses
2 views
0 likes
|
Last Post
by llanqui
Today, 03:53 AM
|
||
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
10 views
0 likes
|
Last Post Today, 12:38 AM | ||
Started by AaronKoRn, Yesterday, 09:49 PM
|
0 responses
14 views
0 likes
|
Last Post
by AaronKoRn
Yesterday, 09:49 PM
|
||
Started by carnitron, Yesterday, 08:42 PM
|
0 responses
11 views
0 likes
|
Last Post
by carnitron
Yesterday, 08:42 PM
|
||
Started by strategist007, Yesterday, 07:51 PM
|
0 responses
14 views
0 likes
|
Last Post Yesterday, 07:51 PM |
Comment