I had thought that NT was supposed to cache an indicators if different instances have the same parameter values.
To keep things simple I created a simple indicator with no input parameters, one plot intended for main chart, another intended for a different panel.
If the indicator uses Random then I want the indicator executed only once on the dataseries, so the same random number is used for both instances of the indicator.
If I create an instance of Random at the indicator level, then the caching works fine.
However its supposed to be best practice to access Random via some kind of (per thread) Singleton, because Random is not thread safe.
If I change the indicator code to use an instance of Random from a 'per thread singleton' like the code here put into a library class, then the indicator is no longer cached. So the indicator gets executed for each instance on the chart, resulting in different random numbers being used in different panels, for the same bar.
Has anyone found a work-around for this problem?
I expect that the NT engine already has some kind of singleton for Random, perhaps this could be made available to users in NT8? And perhaps NT engine programmers could ensure that using it did not prevent NT from caching.
Comment