Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Ninjatrader Threading issue with Custom columns, can anyone help?
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:
to:
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.
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
issue.
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.
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.
Something must be there in that code...
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...
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...
if it never comes up with 1 column 1 instrument
then it's the indicator that is not thread safe
it's worth doing the test to eliminate that possibility