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!
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
NinjaTrader
Collection modified
Collapse
X
-
Hello KINGKODA,
You would do exactly that, you would call the draw syntax to create an object and then on the following line remove it using RemoveDrawObject() with the tag you used.
I look forward to being of further assistance.
-
Hello Jesse,
How would you "Add a dummy drawing object and then remove it immediately after on the next line of syntax to cause OnRender to be called."
Thanks
Leave a comment:
-
Hello,
Thank you for the post.
In this case, the exception is generally telling you what is happening. As the collection is being modified, the loop statement cannot continue correctly. Generally, this occurs with foreach loops over collections. Often this can be resolved by using a for loop with an index instead. You may try to just replace any foreach loops you are using on collections that may be modified. As I have not seen your code this would be an educated guess based on the exception.
Also, you noted "and I call OnRender() to update the chart."
Do you mean that you are physically calling the OnRender override or just mean that you have implemented OnRender?
It would not be advised to call OnRender yourself, but you could do an action like ForceRefresh or Add a dummy drawing object and then remove it immediately after on the next line of syntax to cause OnRender to be called.
Another item could be if the script hits an exception and you have it in a try catch, that may be one reason for this to flicker. An exception should generally stop the script completely so you can correct the problem instead of just catching it. If you are using try-catch, you may try removing it and then resolve the exceptions, that may correct it also.
Without seeing the syntax it would be hard to say exactly what is happening in the script. What I could suggest would be to reduce the code and find what specifically is throwing errors and first correct that. If that does not solve the problem, you could then comment out code until you see it stop and work forward to find the cause.
I look forward to being of further assistance.
Leave a comment:
-
Collection modified
I use BarRequest to load data from a specific different TradingHours than the primary bars.
Now I use a method to manipulate real time bar event. (OnRequestUpdate)
In that method I use the for (int i = e.MinIndex; i <= e.MaxIndex; i++) loop
to do stuff and I call OnRender() to update the chart.
In OnRender() I display stuff based on price and I loop through dictionaries.
I sometimes see a flickering of the chart and get the error message : Collection was modified after the enumerator was instantiated...
I do a ForceRefresh() after the for loop because primary bars are always closed when this second bar series is active.
I was wondering if I get this error because new data comes in before the ForceRefresh() finish its job !
How should I approach this whole problem ?
Thank you !Tags: None
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by Rapine Heihei, Today, 08:19 PM
|
1 response
8 views
0 likes
|
Last Post Today, 08:30 PM | ||
Started by Rapine Heihei, Today, 08:25 PM
|
0 responses
6 views
0 likes
|
Last Post Today, 08:25 PM | ||
Started by f.saeidi, Today, 08:01 PM
|
1 response
9 views
0 likes
|
Last Post Today, 08:17 PM | ||
Change colour of Stop market and limit orders to red and green via indicator script
by Rapine Heihei
Started by Rapine Heihei, Today, 07:51 PM
|
0 responses
8 views
0 likes
|
Last Post Today, 07:51 PM | ||
Started by frslvr, 04-11-2024, 07:26 AM
|
5 responses
98 views
1 like
|
Last Post
by caryc123
Today, 07:47 PM
|
Leave a comment: