Not valid float point operation  [SOLVED]

Questions about MultiCharts and user contributed studies.
User avatar
andriuking
Posts: 24
Joined: 16 Jun 2016
Has thanked: 6 times
Been thanked: 3 times

Not valid float point operation

Postby andriuking » 19 Apr 2017

Hello.

The next sintaxis returns me not valid float point operation:

Code: Select all

If Close of data11 > 0 and (Close of data10 / Close of data11) cross above (0.25*MI_Parameter) then begin
modeSHORT = false; modeLong = true;
end;
I suposse than the error is for dividing by 0, but I don´t understand why because I´m putting Close data11 > 0 and MI_Parameter is defined between 1 and 15, alwais positive.

Anybody could help me?

Thanks in advance.
Last edited by andriuking on 19 Apr 2017, edited 1 time in total.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Not valid float point operation

Postby TJ » 19 Apr 2017

Please see post #1 and post #2
viewtopic.php?t=11713

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: Not valid float point operation

Postby evdl » 19 Apr 2017

Please try:

Code: Select all

If (Close of data11 > 0) then begin

If (Close of data10 / Close of data11) cross above (0.25*MI_Parameter)
then begin
ModeShort = false;
ModeLong = true;
end;

end; // end of If (Close of data11 > 0) then begin

User avatar
andriuking
Posts: 24
Joined: 16 Jun 2016
Has thanked: 6 times
Been thanked: 3 times

Re: Not valid float point operation

Postby andriuking » 19 Apr 2017

Thanks to both.

Thanks evdl, but didnt work :(.

Image

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Re: Not valid float point operation

Postby TJ » 19 Apr 2017

andriuking:

You need to develop some good coding habits.

The most important being... do one thing at a time.
You need to layout your variables in detail.
This is especially important when you are dealing with multiple data in your logic.

Here's how I would code it:

Code: Select all


var:
c10( c, data10 );
c11( c, data11 ),
c1011( 0 ),
MI_Par25( 0 );

if c11 > 0 then c1011 = c10 / c11
else c1011 = 0;

MI_Par25 = 0.25*MI_Parameter;

If C11 > 0 and ( C1011 cross above MI_Par25 ) then
begin
modeSHORT = false;
modeLong = true;
end;

User avatar
andriuking
Posts: 24
Joined: 16 Jun 2016
Has thanked: 6 times
Been thanked: 3 times

Re: Not valid float point operation

Postby andriuking » 19 Apr 2017

thanks TJ,

the original code has more than 1000 lines... is only a little part so I didn´t declare vars.

Anyway It would be like this:

Code: Select all

Inputs:
MI_Parameter(1)
;

Vars:
modeLong(false),
modeShort(false)
;


If (Close of data11 > 0) then begin
If (Close of data10 / Close of data11) cross above (0.25*MI_Parameter) then begin
ModeShort = false;
ModeLong = true;
end;

end;
Also gives error.

The code than you proposed don´t compile and correcting the mistakes it worked well.

Code: Select all

var:
c10( c, data10 ),
c11( c, data11 ),
c1011( 0 ),
MI_Par25( 0 ),
modeSHORT(false),
modeLong (false),
MI_Parameter(1)
;

if c11 > 0 then c1011 = c10 / c11
else c1011 = 0;

MI_Par25 = 0.25*MI_Parameter;

If C11 > 0 and ( C1011 cross above MI_Par25 ) then
begin
modeSHORT = false;
modeLong = true;
end;
I never had needed to declare each variable to calculate it, in EasyLanguage works well but not in PowerLanguage.

Thanks for the lesson, it appears very important.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: Not valid float point operation

Postby evdl » 19 Apr 2017

Do you know for sure the error is in the code you provided, and not somewhere in the other 950+ lines of code?

Does the code compile after you exclude the code you provided?

One last thing I can think of, is that sometimes (although very rare) compiling stops working on all indicators or signals. You need to restart everything (also PC) to get it working again.

User avatar
andriuking
Posts: 24
Joined: 16 Jun 2016
Has thanked: 6 times
Been thanked: 3 times

Re: Not valid float point operation  [SOLVED]

Postby andriuking » 19 Apr 2017

No, I think than TJ has reason.

If you take both codes in my last post (both compile well), the first one gives error on execution and the second no. Appears It´s necessary to declare variables first.

I don´t understand completly why, but it´s necessary...


Return to “MultiCharts”