I have logic in an indicator that initializes some variables on each new bar, as in
int lastBar = -99;
if (lastBar != CurrentBar)
{
// -- do something...
I am processing bid/ask data, so I override both OnBarUpdate and OnMarketData. As I understand it, it's non-determinstic for any given incoming tick whether one or the other is called first. So my thinking is that code like the above needs to be in both. That should be fine as long as it's not possible for both to execute simultaneously on different threads. That would cause some problems and would require synchronization. Synchronization is expensive performance-wise, and I'd prefer not to do it. Also, while I don't believe it would happen here, it is possible to dead-lock when using synchronization.
I'd appreciate it if someone from NT could respond as to whether or not OnBarUpdate and OnMarketData can execute simultaneously on different threads, and if so, share any tips on synchornization in a NT indicator.
Regards,
Gordon
Comment