Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
5 registered members (Quad, TipmyPip, degenerate_762, AndrewAMD, Nymphodora), 997 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Problem with series and/or LowPass? #429107
09/09/13 07:14
09/09/13 07:14
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, I can get some behavior when making series, particularly using LowPass. Often, a series of a series doesn't display on the plot and returns a value of -1. This is more frequent with LowPass. An example with two very similar series functions that give different results:

var fxn1(var* Data,int Period) {
return (Data[0]-MidPoint(Data,Period))/(MaxVal(Data,Period)); }

var fxn2(var* Data,int Period) {
return (Data[0]-MidPoint(Data,Period))/(MaxVal(Data,Period)-MidPoint(Data,Period)); }

function run() {
StartDate = 2002;
LookBack=1440;
set(PLOTPRICE+PLOTNOW);
PlotBars = 20000;
var* Price = series(price());
vars M1=series(fxn1(Price,1440));
vars M2=series(fxn2(Price,1440));
vars M3=series(LowPass(M1,100));
plot("M1",M1[0],NEW,BLUE);
plot("M2",M2[0],NEW,BLUE);
plot("M3",M3[0],NEW,BLUE); }

These all plot fine. However, if you change M3 to be a LowPass series of M2 (instead of M1, ie. fxn2 instead of fxn1), the plot is blank with -1. M1 and M2 are still fine in this case.

Is this user error, or a bug somewhere? Thanks for any help you can provide.

Re: Problem with series and/or LowPass? [Re: CL1] #429143
09/09/13 12:43
09/09/13 12:43
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
This should make it more clear. Now both fxn1 and fxn2 have series (M1, M2) and these are then passed through a LowPass filter (M3, M4). Why does M3 plot, but M4 is blank with -1?

var fxn1(var* Data,int Period) {
return (Data[0]-MidPoint(Data,Period))/(MaxVal(Data,Period)); }

var fxn2(var* Data,int Period) {
return (Data[0]-MidPoint(Data,Period))/(MaxVal(Data,Period)-MidPoint(Data,Period)); }

function run() {
StartDate = 2002;
LookBack=1440;
set(PLOTPRICE+PLOTNOW);
PlotBars = 20000;
var* Price = series(price());
vars M1=series(fxn1(Price,1440));
vars M2=series(fxn2(Price,1440));
vars M3=series(LowPass(M1,100));
vars M4=series(LowPass(M2,100));
plot("M1",M1[0],NEW,BLUE);
plot("M2",M2[0],NEW,BLUE);
plot("M3",M3[0],NEW,BLUE);
plot("M4",M4[0],NEW,BLUE); }

Re: Problem with series and/or LowPass? [Re: CL1] #429217
09/10/13 11:15
09/10/13 11:15
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
The reason is that your second function, fxn2, can return an invalid floating point value when both dividend and divisor are 0. This disables the lowpass filter, so it does not work for the rest of the data.

This is not really your fault, but a flaw of the lowpass filter indicator which should be able to deal with such situations. I've forwarded a notice to the developers and this will be fixed in the next update.

Anyway when you have a division in your script, always make sure that a division by zero can not happen.

Re: Problem with series and/or LowPass? [Re: jcl] #429313
09/11/13 11:32
09/11/13 11:32
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, thanks I see the issue here, although I am a bit confused how this can happen since the second function will never return 0 (except for massive price gaps, which I don't think I have). Is it more that the function could return 0 in some circumstances?

Additionally, I also see this with DomiantPeriod using some series I have made. These series span the interval [-100,100], and have all values in this range. Using "vars DomPer=series(DominantPeriod(Series_Name,100));" I get a blank graph with -1.

Any thoughts??

Re: Problem with series and/or LowPass? [Re: CL1] #429318
09/11/13 12:23
09/11/13 12:23
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
This might be the same problem. Print the output of your series at any bar for checking. Especially at the begin at bar 0, when prices are not yet loaded and indicators are 0, subtracting two values can cause a division by zero.

Re: Problem with series and/or LowPass? [Re: jcl] #429465
09/12/13 18:44
09/12/13 18:44
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, thanks and indeed you are correct that my custom series will have division by zero if all values of pairs are zero (ie. in the beginning during the LookBack period).

Do you know when the next update will be available?

Is there any way to avoid this until the next update arrives? I was thinking a quick check of (if Data[0]==0, return 0; otherwise calculate series). However, this didn't seem to work.

Thanks

Re: Problem with series and/or LowPass? [Re: CL1] #429707
09/17/13 06:05
09/17/13 06:05
Joined: Aug 2013
Posts: 28
--Select a State--
C
CL1 Offline OP
Newbie
CL1  Offline OP
Newbie
C

Joined: Aug 2013
Posts: 28
--Select a State--
Hi, just to update this works if you use Bar instead of Data.

if (Bar<=LookBack) {
return 0.0;
}
else {
Calculate
}


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1