NexusFi: Find Your Edge


Home Menu

 





Performance impact of calling multiple instances of an external indicator


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one Big Mike with 4 posts (1 thanks)
    2. looks_two NJAMC with 2 posts (1 thanks)
    3. looks_3 bkool with 2 posts (0 thanks)
    4. looks_4 srgtroy with 2 posts (1 thanks)
    1. trending_up 3,990 views
    2. thumb_up 3 thanks given
    3. group 5 followers
    1. forum 12 posts
    2. attach_file 0 attachments




 
Search this Thread

Performance impact of calling multiple instances of an external indicator

  #1 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,532

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:

private DataSeries bobds1;
private DataSeries bobds2;
private DataSeries bobds3;

bobds1 = new DataSeries(this);
bobds2 = new DataSeries(this);
bobds3 = new DataSeries(this);

bobds1.Set(Bob(value).ds1[0]));
bobds2.Set(Bob(value).ds2[0]));
bobds3.Set(Bob(value).ds3[0]));

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.

Thoughts?

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Are there any eval firms that allow you to sink to your …
Traders Hideout
Deepmoney LLM
Elite Quantitative GenAI/LLM
My NT8 Volume Profile Split by Asian/Euro/Open
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
Battlestations: Show us your trading desks!
26 thanks
NexusFi site changelog and issues/problem reporting
24 thanks
The Program
17 thanks
  #3 (permalink)
 
srgtroy's Avatar
 srgtroy 
Los Angeles, California Republic
Legendary  R.I.P. 1965-2023 
 
Experience: None
Platform: Sierra Chart
Broker: CQG
Trading: ES
Posts: 1,928 since Jan 2011
Thanks Given: 1,375
Thanks Received: 3,722


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.
Reply With Quote
  #4 (permalink)
 
srgtroy's Avatar
 srgtroy 
Los Angeles, California Republic
Legendary  R.I.P. 1965-2023 
 
Experience: None
Platform: Sierra Chart
Broker: CQG
Trading: ES
Posts: 1,928 since Jan 2011
Thanks Given: 1,375
Thanks Received: 3,722


Big Mike View Post

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.

According to the NT help section, there is a StringSeries Class. Search for it in the help section and you will find more info.

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.
Reply With Quote
Thanked by:
  #5 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394


Big Mike View Post
private DataSeries bobds1;
private DataSeries bobds2;
private DataSeries bobds3;

bobds1 = new DataSeries(this);
bobds2 = new DataSeries(this);
bobds3 = new DataSeries(this);

bobds1.Set(Bob(value).ds1[0]));
bobds2.Set(Bob(value).ds2[0]));
bobds3.Set(Bob(value).ds3[0]));

So my question is, since I am calling Bob() three times, is the performance penalty 3x the cost of calling it once?

Mike

Mike,

Are you looking to find out if what you have above is faster (due to the local DataSeries) vs the following?

private DataSeries bobds1;
private DataSeries bobds2;
private DataSeries bobds3;

bobds1 = Bob(value).ds1;
bobds2 = Bob(value).ds2;
bobds3 = Bob(value).ds3;

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

Bars:
MyBob.ds1[0]
MyBob.ds2[0]
MyBob.ds3[0]

Maybe missed your question, but hope this helps.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
Thanked by:
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,532


NJAMC View Post
Mike,

Are you looking to find out if what you have above is faster (due to the local DataSeries) vs the following?

private DataSeries bobds1;
private DataSeries bobds2;
private DataSeries bobds3;

bobds1 = Bob(value).ds1;
bobds2 = Bob(value).ds2;
bobds3 = Bob(value).ds3;

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.

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.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,532


srgtroy View Post
According to the NT help section, there is a StringSeries Class. Search for it in the help section and you will find more info.

Wow, that is awesome. I did a Google search and couldn't find anything! I didn't think of searching NT help file.

That will let me do a single 'call' easily, and then just split a deliminated string locally.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote
  #8 (permalink)
 
NJAMC's Avatar
 NJAMC 
Atkinson, NH USA
Market Wizard
 
Experience: Intermediate
Platform: NinjaTrader 8/TensorFlow
Broker: NinjaTrader Brokerage
Trading: Futures, CL, ES, ZB
Posts: 1,970 since Dec 2010
Thanks Given: 3,037
Thanks Received: 2,394


Big Mike View Post
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.

Mike

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.

Nil per os
-NJAMC [Generic Programmer]

LOM WIKI: NT-Local-Order-Manager-LOM-Guide
Artificial Bee Colony Optimization
Visit my NexusFi Trade Journal Reply With Quote
  #9 (permalink)
 decs0057 
Munich, Germany
 
Experience: Intermediate
Platform: NinjaTrader, TWS
Broker: IB, NinjaTrader Brokerage
Trading: ES,NQ,6E
Posts: 71 since Feb 2010
Thanks Given: 15
Thanks Received: 25

I think following code is fastest

define variable for Bob indicator

private Bob ixBob;

and for dataseries which will become refrence of Bob's dataseries

private DataSeries bobds1;
private DataSeries bobds2;
private DataSeries bobds3;


in OnStartup get reference of Bob

ixBob = Bob(value);

and references of dataseries

bobds1 = ixBob.ds1;
bobds2 = ixBob.ds2;
bobds3 = ixBob.ds3;


in OnBarUpdate call ixBob.Update() before you access bobds1 ... to ensure OnBarUpdate is called in indicator Bob

Reply With Quote
  #10 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,532


Thanks guys.

Mike

We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on Twitter Visit my NexusFi Trade Journal Started this thread Reply With Quote




Last Updated on June 27, 2015


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts