In any event. I appreciate tradersmarts sharing of his testing and his testing of 5 scenarios of iterating through dictionaries. I have a similar situation where i collect data in onmarketdate() and add to dictionaries and in Onrender am output the data in the dictionary,
I also over time get intermittent error message very similar to tradersmarts ;
collection was modifed ......
but also my OnRender is only outputting the data and not modifying the content in the foreach loop, tradersmarts confirmed this was the case but Ninja support still advised using for loop or the foreach with a tolist() operation on the dictionary.
Now i note in the standard ninja provided samples namely VolumeProfile which i did reference in the past as a guide to perhaps 'best practices' and this uses foreach over dictionaries. So my question is why this is illustrated in a ninja provided sample when it is perhaps not the best practice as the onmarketdata() in that code could be updating information that onRender is iterating over?
I just wanted to be clear on this and i will review and perhaps modify to for loops using for my onrender processing.
Does the toList() option actually copy the dictionary so whilst processing it it has no effect on the original dictionary? are there memory considerations to using this when there are many dictionaries to iterate for each of the bars in the window in onrender?
Again this error appears now and again and like tradersmarts is difficult to reproduce.
Would the lock statement he tried .. make a difference if used in the onmarketdata or where the dictionary is being modified vs just looped through as in onrender?
Again the lock is not used in your sample VolumeProfile; so was just wondering on that.
I occassionally am getting Onrender issues and from tradersmarts post it has given me an insight perhaps to the foreach potential issue and whether this triggers other errors too.
over time through beta the subtleties of the errors and the vague incomplete error logging make it challenging to narrow down the issue - especially when the errors are intermittent.
thanks
Comment