+1 888 340 6572
MultiCharts Project Management
previous_open_issue.png
Go to the previous open issue
previous_issue.png
Go to the previous issue (open or closed)
star_faded.png
Please log in to bookmark issues
bug_report_small.png
Open Bug report MC-2577

Performance/ compiler isse

action_vote_minus_faded.png
1
Votes
action_vote_plus_faded.png
next_issue.png
Go to the next issue (open or closed)
next_open_issue.png
Go to the next open issue
Description

I have (again) stumbled upon a performance issue, where a script was taking too long to execute (some 26sec on 7yrs of 20min bars).

Investigating, I copied it block by block to another, fresh script, but it run in <6 sec altogether.

The only block left was the one which should not have been executed anyway (if false then...) - and when I copied it, the time got back to 26sec!

Somehow a block of code that should not have been executed dramatically influences run time!

!! AND - params passed to functions that are not supposed to be executed - influence run times!

Observation: this seems to be a problem with functions that call other functions and use arrays.

The below code takes 11 sec to execute on 7yrs of 1-min bars of EURUSD; if all function calls are commented out - 6+sec.

Steps to reproduce this issue

input: run(False);
vars: hlc(c);

once
begin
cleardebug;
print("Start: ",DateTimeToString_Ms(computerdatetime));
end;

if run then
begin
hlc=(c+h+l)/3;

value3=NumericRank(60,hlc,40,1);

Value1=power(LinearRegSlope(hlc,20),0.34);
value2 = NormDEnsity(hlc,40);

value5=NthHighest(5,c,100);
value13 = theta(20,c[0]*1.1,c[0],0.01,1,1);

end;

if run then
begin
hlc=(c+h+l)/3;
//value12 = skew(hlc,200);
value10 = HighD(0);
//value6 = probAbove(c[0]*1.1,c[0],1,20);

value13 = theta(20,c[0]*1.1,c[0],0.01,1,1);
end;

if LastBarOnChart then print("End at:", DateTimeToString_Ms(computerdatetime));

Comments (3)
#1
user-offline.png  MultiCharts Support (MultiCharts)
Apr 02, 2019 - 07:06
Hi, HighD is a Series function. Series function is called always, disregard the code conditions. You can call it yourself at the beginning of the code if you want to have the values updated, otherwise MC will call it at the end of calculation. The function always keeps its previous values. If you don’t need a series function – use a simple function. It does not store any previous values. It is calculated every time in the execution context (calculated on the bar offset against the current bar for a specified number of bars). Function type is defined in File->Properties, when you open the function code in the PLEditor window.
#2
user-offline.png  Zheka (Zheka)
Apr 03, 2019 - 08:00

Alex,

All other functions in my example except HighD() are simple functions.

If you comment out HighD - script execution still takes 8 sec.

If you comment out both "if run then.." blocks altogether, execution will take 6 sec.

6 sec for Lastbaronchart comparison still seems a lot for a c++ code.

#3
user-offline.png  MultiCharts Support (MultiCharts)
Apr 10, 2019 - 11:52
As previously specified - Series function is called always, disregard the code conditions. Even If you have a series parameter that is used in a simple function, then it is calculated unconditionally on each bar, in order to return a value at any moment. Even though more memory used in this case, the calculation speed is reduced. More information about Series Functions and Series Parameters can be found in “The essential EasyLanguage programming guide” here: https://www.multicharts.com/trading-software/index.php/Additional_Information_Sources

History
Issue basics
  • Type of issue
    Bug report
  • Category
    Not determined
  • Targeted for
    Not determined
  • Status
    Not a bug
  • Priority
    Not determined
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (0)
There are no items
People involved
  • Posted by
    user-offline.png  Zheka (Zheka)
  • Owned by
    Not owned by anyone
  • Assigned to
    Not assigned to anyone
  • Subscribers
    2 subscriber(s)
    Click here to show the list of subscribers
Times and dates
  • Posted at
  • Last updated
Issue details
  • Reproducability
    Not determined
Attachments (0)
There is nothing attached to this issue
Commits (0)
There are no code checkins for this issue
Duplicate issues (0)
This issue does not have any duplicates