I'm not sure how much tweaking you've done to the original version in this thread, but I was able to make a few changes to resolve both of these issues.
The first thing that I noticed is that VolAskTot and VolBidTot begin at 0. So, the first time you try to divide the two, you are dividing 0 by 0. To fix this, I just added the condition "if(VolAskTot > 0 && VolBidTot > 0)" to make sure the division is never done when either value is 0.
Also, I noticed that the condition "if (e.Operation == Operation.Update)" was just floating out there all by itself. It didn't have either brackets or a single statement. The way it was coded, it looks like it would only govern the very next "if" statement, which I don't think was intended. I added brackets under this condition to encapsulate all of the e.Position checks, and all seems to be working now.
I've attached an updated version of the script to this post, with Prints showing the VolAsk0, VolBid2, etc. values and other important values throughout.
Please let me know if I can assist further.
Comment