ELD Floating Point Error (TS vs MC)

Questions about MultiCharts and user contributed studies.
RickAce
Posts: 15
Joined: 10 Apr 2013
Has thanked: 23 times

ELD Floating Point Error (TS vs MC)

Postby RickAce » 10 Apr 2013

Hello,

I am trying out MultiCharts64 v8.5. I imported my .eld file and I get the dreaded "Floating-point division by zero" error which does not occur with TS 9.1 ~ does anyone have any insight why this would be?

Rick

User avatar
Henry MultiСharts
Posts: 9132
Joined: 25 Aug 2011
Has thanked: 1260 times
Been thanked: 2929 times

Re: ELD Floating Point Error (TS vs MC)

Postby Henry MultiСharts » 10 Apr 2013

Hello Rick,

Please refer to the following article to resolve that issue: Floating-Point Division by Zero Error Message

RickAce
Posts: 15
Joined: 10 Apr 2013
Has thanked: 23 times

Re: ELD Floating Point Error (TS vs MC)

Postby RickAce » 10 Apr 2013

Henry,

I have already reviewed that link but really have no idea how to implement it in my code... like TS, there are really no good examples of how to implement the code for the neophyte like myself.

Can you give an example of how and where to place in indicator code?

Also, there is only one division equation used I could find in the indicator (I have not looked into the functions yet).

Why would TS have no issues with the code but MC does?

Thank you.

Rick

User avatar
ABC
Posts: 634
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: ELD Floating Point Error (TS vs MC)

Postby ABC » 10 Apr 2013

Henry,

I have already reviewed that link but really have no idea how to implement it in my code... like TS, there are really no good examples of how to implement the code for the neophyte like myself.

Can you give an example of how and where to place in indicator code?

Also, there is only one division equation used I could find in the indicator (I have not looked into the functions yet).

Why would TS have no issues with the code but MC does?

Thank you.

Rick
Rick,

MC is slightly more sensible when it comes to division by zero issues than TS is, but
it's pretty simple to overcome. To make sure that you don't run into a floating point error with a study, check every division for cases where the denominator could be zero.

For example:

Code: Select all

Value1 = Value2/Value3;
This would raise a floating point error, whenever Value3 = 0. Even if it only happens on the very first tick.
To avoid this, you do the following check:

Code: Select all

if Value3 <> 0 then //meaning Value 3 is not 0
Value1 = Value2/Value3
else
Value1 = 0; //or whatever makes sense
In case it's a bit more complex, like for example

Code: Select all

Value1 = Value2/(Value3-Value4);
the check would have to be like this:

Code: Select all

if (Value3-Value4) <> 0 then //meaning (Value 3-Value4) is not 0
Value1 = Value2/(Value3-Value4)
else
Value1 = 0; //or whatever makes sense
To sum things up, you always check:

Code: Select all

if denominator <> 0 then
do the regular calculation
else
assign a value like 0 to your variable

Regards,
ABC

RickAce
Posts: 15
Joined: 10 Apr 2013
Has thanked: 23 times

Re: ELD Floating Point Error (TS vs MC)

Postby RickAce » 10 Apr 2013

ABC,

The line in the INDICATOR code that has the division is as follows:

Code: Select all

Variables: DOTS (0)
DOTS = hy_average ((CLOSE+HIGH+LOW) /3, 5) ;
and the FUNCTION hy_average is as follows:

Code: Select all

Inputs: Price(NUMERICSERIES), Length(NUMERIC);

hy_Average = hy_Summation (Price, Length)/Length ;
Do you think it is the INDICATOR code or FUNCTION code that is giving the floating point error?

Thank you for your time ~ it is sincerely appreciated!

Rick

User avatar
ABC
Posts: 634
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: ELD Floating Point Error (TS vs MC)

Postby ABC » 11 Apr 2013

Rick,

did you try it with checking for each of the expressions alone and see what happens?

Theoretically it could be both. But as the denominator in the indicator is fixed, I would guess the problem comes from the function (and if it's not within the hy_Summation function).
Although your length input is different than zero, too, I would guess that this is creating the problem. It would be enough if MC doesn't read the Length input as 5 on the very first time the function gets executed.
As I mentioned MC is very sensitive to this error compared to TS.

Regards,
ABC

RickAce
Posts: 15
Joined: 10 Apr 2013
Has thanked: 23 times

Re: ELD Floating Point Error (TS vs MC)

Postby RickAce » 11 Apr 2013

Thanks ABC,

Yes, I noticed there was a function within a function (hy_Summation) that contain more division equations... oh boy! Nothing is easy!

Lets see what I can do...

Thanks again!

Rick

SP
Posts: 455
Joined: 06 Feb 2006
Has thanked: 36 times
Been thanked: 283 times

Re: ELD Floating Point Error (TS vs MC)

Postby SP » 11 Apr 2013

Rick,

isnt it easier to replace the line with removing the hy_:
DOTS = average ((CLOSE+HIGH+LOW) /3, 5) ;
and take a look if you get the same results as in TS.

RickAce
Posts: 15
Joined: 10 Apr 2013
Has thanked: 23 times

Re: ELD Floating Point Error (TS vs MC)

Postby RickAce » 11 Apr 2013

SP... tried that to no avail...

Why can't MultiCharts tell me were the floating-point division by zero error is ?

It just states {EXCEPTION}
fpdz_error.jpg
fpdz_error
(14.21 KiB) Downloaded 771 times
Rick

User avatar
TJ
Posts: 7231
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 991 times
Been thanked: 2056 times

Re: ELD Floating Point Error (TS vs MC)

Postby TJ » 11 Apr 2013

Henry,

I have already reviewed that link but really have no idea how to implement it in my code... like TS, there are really no good examples of how to implement the code for the neophyte like myself.

Can you give an example of how and where to place in indicator code?

Also, there is only one division equation used I could find in the indicator (I have not looked into the functions yet).

Why would TS have no issues with the code but MC does?

Thank you.

Rick
>Why would TS have no issues with the code but MC does?

Most likely because the data is different.
you might have a bad tick somewhere that causes the calculation to hang.


Return to “MultiCharts”