Speed of Compiled Indicator/Strategy

Questions about MultiCharts and user contributed studies.
AdrianP
Posts: 46
Joined: 02 Sep 2014
Has thanked: 2 times
Been thanked: 1 time

Speed of Compiled Indicator/Strategy

Postby AdrianP » 11 Apr 2021

Can someone tell me please if it makes any difference to the speed of a compiled indicator when being used in real time under the 2 scenarios' below.

1. Code has the same indicator formula repeated multiple times within the code;
2. The same formula is allocated to a Variable, and that Variable is repeated instead;

Is 2 faster than 1?
Under 1, is MC doing the same calcuation and over again, whereas in 2 it only needs to do it once?

Thanks

AdrianP
Posts: 46
Joined: 02 Sep 2014
Has thanked: 2 times
Been thanked: 1 time

Re: Speed of Compiled Indicator/Strategy

Postby AdrianP » 14 Apr 2021

Perhaps MC Support can respond to my question please, since no one else seems to know.

User avatar
rrams
Posts: 128
Joined: 10 Feb 2011
Location: USA
Has thanked: 7 times
Been thanked: 70 times
Contact:

Re: Speed of Compiled Indicator/Strategy

Postby rrams » 14 Apr 2021

2 is always faster than 1 in every computer language. However in practical terms it doesn't make much difference. For MC it matters more that you don't do heavy file I/O or large array processing or reference the whole dataset every incoming tick.

Under 1, MC is doing the same calcuation each time the function is called in the code at the close of each bar.
Under 2, MC is doing the calulation once every time a new close of a bar occurs unless you used the IntraBarPersist declaration, in which case it updates on every new tick.

AdrianP
Posts: 46
Joined: 02 Sep 2014
Has thanked: 2 times
Been thanked: 1 time

Re: Speed of Compiled Indicator/Strategy

Postby AdrianP » 14 Apr 2021

Thanks for the feedback rrams.

What would you classify as referencing the whole dataset?
I have all my indicators set to NOT update on every tick. It only invites disaster whe you hit fast market conditions.

I assume 2 was correct, but as you say, in practice for MC users, its sort of immaterial.


Return to “MultiCharts”