Function call freezes PL-Editor with CPU usage around 50%

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Function call freezes PL-Editor with CPU usage around 50%

Postby piranhaxp » 07 Mar 2011

Hi, a call of the following function in an indicator freezes my PL-Editor without having a chance to compile the indicator. I can define a variable, which is calling this function, but when I write the a plot-statement, the application freezes and I have no chance to do anything.

Here is the function :

// ------------------------------------------------------------------------------------------
// MudeNoise Numeric Function Version 1.03 / Date : 03/04/2010
// ------------------------------------------------------------------------------------------
// Price Input ----------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
input: base(numericseries);
// ------------------------------------------------------------------------------------------
// Period Input ---------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
input: period(numericsimple);
// ------------------------------------------------------------------------------------------
// Variables Declaration ----------------------------------------------------------------
// ------------------------------------------------------------------------------------------
var: p(0);
var: pl(0);
var: b(0);
var: b2(0);
var: b3(0);
var: bs(0);
var: e1(0);
var: e2(0);
var: e3(0);
var: e4(0);
var: e5(0);
var: e6(0);
var: c1(0);
var: c2(0);
var: c3(0);
var: c4(0);
var: n(0);
var: w1(0);
var: w2(0);
// ------------------------------------------------------------------------------------------
// Variable Definitions ------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
b = 0.50000;
b2 = square(b);
b3 = b2*b;
bs = base;
p = bs;
e1 = bs;
e2 = bs;
e3 = bs;
e4 = bs;
e5 = bs;
e6 = bs;
c1 = b3*(-1);
c2 = 3*(b2+b3);
c3 = (3*(-1))*((2*b2)+(b+b3));
c4 = 1+(3*b)+b3+(3*b2);
n = 0;
w1 = 0;
w2 = 0;
// ------------------------------------------------------------------------------------------
// Variable Calculations ----------------------------------------------------------------
// ------------------------------------------------------------------------------------------
pl = period;
n = pl;
if n<1 then n=1;
n = 1+(b*(n-1));
w1 = b*(n+1);
w2 = 1-w1;
e1 = (w1*bs)+(w2*e1);
e2 = (w1*e1)+(w2*e2);
e3 = (w1*e2)+(w2*e3);
e4 = (w1*e3)+(w2*e4);
e5 = (w1*e4)+(w2*e5);
e6 = (w1*e5)+(w2*e6);
// ------------------------------------------------------------------------------------------
// Function Declaration -----------------------------------------------------------------
// ------------------------------------------------------------------------------------------
MudeNoise = (c1*e6)+(c2*e5)+(c3*e4)+(c4*e3);
I try to call the function in an indicator with the following code :
// ------------------------------------------------------------------------------------------
// Period Input ---------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
input: period(13);
input: base(close);
// ------------------------------------------------------------------------------------------
// Variables Declaration ----------------------------------------------------------------
// ------------------------------------------------------------------------------------------
var: var0(0);
var: p(0);
var: b(0);
// ------------------------------------------------------------------------------------------
// Variable Definitions ------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
b = base;
p = period;
var0 = mudenoise(b,p);
// ------------------------------------------------------------------------------------------
// Plot Statement -----------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
if var0<>0 then begin
plot1(var0,"MN");
end;
When I start to write plot1(var0....) then I can't finish the plot-statement, because the PL-Editor is freezing after writing the "0" of "var0". I thought the issue is made by the variblae "var0" and changed it to "var1". But same reaction.

Would be nice if some of you or just one of you would have an idea and/or solution.

Thanks a lot.

Kind regards.

Mike

SP
Posts: 465
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 286 times

Re: Function call freezes PL-Editor with CPU usage around 50

Postby SP » 08 Mar 2011

Mike,

delete the indicator in the PLE, change at the top of PLE from "Fast Execution to
Fast Compilation" or vice versa and create the indicator new.

Regards

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Re: Function call freezes PL-Editor with CPU usage around 50

Postby piranhaxp » 08 Mar 2011

Thanks for sharing this idea. I will try it later.

Mike

User avatar
piranhaxp
Posts: 241
Joined: 18 Oct 2005
Has thanked: 4 times
Been thanked: 30 times

Re: Function call freezes PL-Editor with CPU usage around 50

Postby piranhaxp » 23 Mar 2011

Regarding the described issue I figured out, that every time I use "var0" in the first plot statement as plot1 my PLE freezes and everything what was written is lost. It doesn't matter I use "Fast Execution to Fast Compilation" or not.

May there is another issue (bug).

Regards.

Mike


Return to “User Contributed Studies and Indicator Library”