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)
Performance impact of calling multiple instances of an external indicator
Can someone more knowledgeable than me comment on the performance impact of calling multiple instances of a single external indicator?
For example, the indicator is 'Bob' and it has three separate DataSeries of DS1, DS2 and DS3.
If the parent indicator or strategy is setup with its own DataSeries to hold the indicator values of 'Bob' dataseries, as most are, it would look like:
So my question is, since I am calling Bob() three times, is the performance penalty 3x the cost of calling it once? Even though the data is identical and I am just retrieving other DataSeries? Judging from my informal testing, the answer is definitely yes - the impact is 3x as costly, but I haven't setup any timer events to actually prove that.
I ask, because if the answer is yes, then wouldn't it be faster to set 'Bob' up to use a single DataSeries and use a deliminator so that the parent indicator could just call the Bob() code once, and then parse the string into the three separate values?
The problem is, I know there is BoolSeries and DataSeries but there is no StringSeries, so I am trying to figure out the best way to accomplish that.
Of course, the fastest way would be to localize Bob() inside of the parent. But that is not always practical.
I don't know the answer but I have a related question:
Is there a performance difference if you call an instance of an external indicator versus localizing it? It seems the way NT is built, its all part of the same code so there shouldn't be a difference, but I don't know enough to be sure.
P.S. -- I don't intend in anyway to hijack this thread so please go ahead and delete this post if you feel it does that!
R.I.P. Roy Goldberg (srgtroy), 1965-2023.
Please visit [url="https://nexusfi.com/off-topic/60226-srgtroy-r-i-p-brotha.html[/url] for more information.
This should be overall faster as there should still be a pointer passed back to the indicator that already has the data series defined and built. Also, you don't need to copy each bars value to the new series with each OnBarUpdate() call. This would also be better memory handling.
Certainly, if you need to perform an operation on Bob's data, you structure would be better, such as zeroing out certain values due to other logic.
I haven't used the above structure, but it should work, I would tend to define a "Bob" variable and access the members:
private Bob MyBob;
in Init (Strategy), startup (indicator):
MyBob=Bob(value);
Then access the DataSeries:
MyBob.ds1
MyBob.ds2
MyBob.ds3
Yes I am aware that can be done as well, but doesn't it still make three separate calls? I am not sure how NT handles caching the data, if all exported DataSeries is cached on call 1, so call 2 and call 3 are instant, or if everything has to be looked up again on subsequent calls.
I believe this is "pointer" based so with a little luck, you are accessing memory as allowed through the "Public" variable interface. This is definitely faster than moving a copy of the current bar from the same location into a local data structure, just access it directly.