Try providing a lock for the indicator call you are making. At the top of the class (or anywhere outside a method) declare a variable that you can use as a lock:
Then change this line of code:
This will ensure that only one thread at a time can call that piece of code. Please just note that this may have a bit of a performance impact on your code as it effectively creates a "one call at a time queue" basically into that call. It does correctly ensure that only one thread at a time calls the code though.
If this does not fix the issue, you might have code in your indicator that recursively calls itself which is a totally different beast to solve.
Hope this helps,
The following 2 users say Thank You to Popsicle for this post:
I don't think it's a good idea to put a lock and serialize the 'on market data' event
this will create a single bottle neck in your system
If you read your indicator, that does not come from OnMarketData anyway
It would be good to know, what is happening when you are reading the value
of your indicator... and why there is a conflict
Normaly (according to my understanding)
you need a lock, when two threads are accessing the same data
and more precisely, if at least one of the two threads is changing
the data. If two thread are 'reading' the data, that is not a concurrency
Here i think you are doing something in the code for 'reading' your indicator
i would be interested to see your 'getter' piece of code, what happens there..
Thank you for your helping.. I really appreciate it.
The code calls my indicator that is quite complex, it datamines various bar patterns and uses all sorts of intelligent filtering to come up with setups. I like to use it to trade forex, and I basically have about 17 or so pairs I trade. I have the custom column on the market analyzer such that it will act as a scanner and tell me how many bars ago the setup was, what direction the setup is, and a rating of the setup.
The cool thing is I can put in several columns with different time frames, thereby having my scanner show me my setups on dozens of charts, and its really quite handy.
Just on another direction, if you only have one single column for one single instrument, are you also running into the same issue ? or is it only, when multiple columns for multiple instruments are updating simultaneously ?
i checked it with one column with 18 instruments... I didnt check with 1 column with 1 instrument, should I try that? it might take a while for the problem to come up , if it will come up with just 1 instrument...