Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Calling another indicator and CPU usage
Collapse
X
-
Calling another indicator and CPU usage
Let's say I have an indicator XYZ on my chart. And I added another indicator ABC that calls XYZ with same parameters I use XYZ on my chart. Does NT8 calculate XYZ values twice in this situation?Tags: None
-
Hello Leeroy_Jenkins,
Thanks for your question.
As long as the parameters are the same and the input data is the same and the indicator is called from the same host, a cached indicator will be created and used.
Please let us know if you have any additional questions.Last edited by NinjaTrader_Jim; 12-23-2020, 03:39 PM.
-
Which information does the cached indicator hold? Does it cache only the Series<> objects, or does it cache every class property?
Also, if I have a Multi-Instrument indicator with 2 instruments, which calls a specific indicator for each instrument, and add it to both of them using the Market Analyzer (so they have the same start and end dates)... does it reuse the indicators, or does it run them again? I'm asking this because have an indicator in these conditions, but with 28 instruments instead of 2, and according to the memory profiler, the indicator it's calling for each instrument is being instantiated 28^2 (784) times, when I believe it should only have 28 instances if it were being properly cached. Is this expected behaviour or is it a bug in the auto-generated cache?
During debugging I've noticed the Input equality check always fails, so it might not know that these inputs are actually equal, for some reason.
Comment
-
Hello Matheusfx,
Thanks for your question and patience. I wanted to consult Product Management and Development for specifics so we can give you the right answer.
I did have to correct my post above. It now mentions "As long as the parameters are the same and the input data is the same and the indicator is called from the same host, a cached indicator will be created and used." I'll mention Leeroy_Jenkins so he sees my updated post.
To answer your other questions:
The whole indicator is cached.
Regarding the case with the Market Analyzer, we have tried looking into this so this would not be the case, but there were a lot of gotcha's to make it feasible.
We look forward to assisting.
- Likes 1
Comment
-
Thanks for the answer, Jim!
I have a few more questions though...
What does it mean to have the same host? Is it the same window? The same Instrument?
If it makes a cache of the whole indicator for each bar, does it fully clone Series<> objects for each bar? From the tests I've done, this seems to be the case, that's useful to prevent strategies from seeing the future by accident... but doesn't that mean the cache takes up O(n^2) space if MaximumBarsLookback is set to Infinity? If it's set to 256, and no optimizations are being done behind the scenes, Series<> objects would also take 256 times more space than needed in most cases.
If that's the case, is there a way to tell the cache that I won't ever change a plot value of the past, thus allowing it to reuse the same Series<> in the cache? If no other optimizations are already in place, I believe this would significantly decrease memory usage and it might even help a bit with performance by removing the need to clone the whole Series<> on every bar.
The next question is about processing, if an Input series is different by just one bar, like when a new bar is processed... does it get the last cached Indicator and send just the new bars for it to process, or does it recalculate everything every bar? I'm pretty sure it works like the former example. since it would render the cache almost useless otherwise, but it's always good to be sure.
My last question is about additional data series... do they have any influence on the caching? Is it possible for a cache to not be used because of an additional series? If so, what could cause this to happen?
Comment
-
Hello Matheusfx,
Same host would mean the the same window or the same hosting script.
If we add two identical indicators to the same chart, I would expect a cached indicator to be used.
If a script calls an indicator with X parameters and later calls that indicator with X parameters on another bar, a cached instance will be used.
If a script calls an indicator with different parameters on a same or later bar, a new indicator instance would be used.
We would not have duplicate cached indicator instances (and thus would not have copied Series<t>) for each bar if the parameters are the same.
If you change the input series, then we are working with a new indicator (I.E. switching from Close to High for the input series.) If you keep the same input series and there is another bar within that input series, we are still working with the same input series and a cached indicator would be used.
I would not expect additional data to affect caching. If you call an indicator that uses an additional data series, and later on call that indicator with the same parameters, but perhaps reference a different BarsAgo, the additional data would still be the same, and we are just fetching a different plot value from the cached indicator.
We look forward to assisting.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
608 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
355 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
105 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
560 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
561 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment