Indicator Help: Error : {EXCEPTION} Opération en virgule

Questions about MultiCharts and user contributed studies.
nuno-online
Posts: 166
Joined: 31 Jan 2006
Has thanked: 72 times
Been thanked: 3 times

Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby nuno-online » 26 Jul 2011

Hi
i created an indicator but i have an error:
"Error un study: {EXCEPTION} Opération en virgule flotante non valide"

Can someone help me ?
thanks

here is the indicator:

Code: Select all

Inputs:
   Price(Close), Macd.Length(5), Wilder.Length(10);

Variables:
   Dema1(0),
   X1(0), X2(0), Hausse(0), Baisse(0), WiMA.Hausse(0), WiMA.Baisse(0);

X1 = Xaverage(Price, Macd.Length);
X2 = Xaverage(Xaverage(Price, Macd.Length), Macd.Length);
Dema1 = X1 * 2 - X2;

Hausse = MaxList(0, Dema1[0]-Dema1[1]);
Baisse = MaxList(0, Dema1[1]-Dema1[0]);

If currentbar <= 1 then
   begin
   WiMA.Hausse = Hausse;
   WiMA.Baisse = Baisse;
   end
else
   begin
   WiMA.Hausse = (((Wilder.Length-1) * WiMA.Hausse[1]) + Hausse) / Wilder.Length;
   WiMA.Baisse = (Baisse + (Wilder.Length-1)*WiMA.Baisse[1])/Wilder.Length;
   end;

Plot1(WiMA.Hausse, "WiMA.Hausse");
Plot2(WiMA.Baisse, "WiMA.Baisse");


Nuno

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby TJ » 26 Jul 2011

nuno-online wrote:Hi
i created an indicator but i have an error:
"Error un study: {EXCEPTION} Opération en virgule flotante non valide"

Can someone help me ?
thanks

here is the indicator:

Code: Select all

Inputs:
   Price(Close), Macd.Length(5), Wilder.Length(10);

Variables:
   Dema1(0),
   X1(0), X2(0), Hausse(0), Baisse(0), WiMA.Hausse(0), WiMA.Baisse(0);

X1 = Xaverage(Price, Macd.Length);
X2 = Xaverage(Xaverage(Price, Macd.Length), Macd.Length);
Dema1 = X1 * 2 - X2;

Hausse = MaxList(0, Dema1[0]-Dema1[1]);
Baisse = MaxList(0, Dema1[1]-Dema1[0]);

If currentbar <= 1 then
   begin
   WiMA.Hausse = Hausse;
   WiMA.Baisse = Baisse;
   end
else
   begin
   WiMA.Hausse = (((Wilder.Length-1) * WiMA.Hausse[1]) + Hausse) / Wilder.Length;
   WiMA.Baisse = (Baisse + (Wilder.Length-1)*WiMA.Baisse[1])/Wilder.Length;
   end;

Plot1(WiMA.Hausse, "WiMA.Hausse");
Plot2(WiMA.Baisse, "WiMA.Baisse");


Nuno


I have compiled and applied it to a HSI 1 min chart with no problem.

What instrument/resolution you have problem with?

I am using MultiCharts Version 7.0 Beta 5 (Build 4456) on VISTA HP64.

User avatar
JoshM
Posts: 2089
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1485 times
Contact:

Re: Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby JoshM » 26 Jul 2011

TJ wrote:I have compiled and applied it with no problem.

I am using MultiCharts Version 7.0 Beta 5 (Build 4456) on VISTA HP64.

Same here - compiled correctly and plots without errors. (I'm using MultiCharts Version 7.0 Release (Build 4510) on Windows 7)

Have you other uncompiled indicators Nuno?

nuno-online
Posts: 166
Joined: 31 Jan 2006
Has thanked: 72 times
Been thanked: 3 times

Re: Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby nuno-online » 26 Jul 2011

TJ and JoshM

here again the code: i forgot one line :
MyValue = WiMA.Hausse / WiMA.Baisse;

Compilation impossible
I use MultiCharts Version 7.0 Release (Build 4510)

Code: Select all

Inputs:
   Price(Close), Macd.Length(5), Wilder.Length(10);

Variables:
   Dema1(0),
   X1(0), X2(0), Hausse(0), Baisse(0), WiMA.Hausse(0), WiMA.Baisse(0), MyValue(0);

X1 = Xaverage(Price, Macd.Length);
X2 = Xaverage(Xaverage(Price, Macd.Length), Macd.Length);
Dema1 = X1 * 2 - X2;

Hausse = MaxList(0, Dema1[0]-Dema1[1]);
Baisse = MaxList(0, Dema1[1]-Dema1[0]);

If currentbar <= 1 then
   begin
   WiMA.Hausse = Hausse;
   WiMA.Baisse = Baisse;
   end
else
   begin
   WiMA.Hausse = (((Wilder.Length-1) * WiMA.Hausse[1]) + Hausse) / Wilder.Length;
   WiMA.Baisse = (Baisse + (Wilder.Length-1)*WiMA.Baisse[1])/Wilder.Length;
   end;
   
MyValue = WiMA.Hausse / WiMA.Baisse;

Plot1(WiMA.Hausse, "WiMA.Hausse");
Plot2(WiMA.Baisse, "WiMA.Baisse");

User avatar
TJ
Posts: 6584
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 970 times
Been thanked: 1907 times

Re: Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby TJ » 26 Jul 2011

nuno-online wrote:TJ and JoshM

here again the code: i forgot one line :
MyValue = WiMA.Hausse / WiMA.Baisse;

Compilation impossible
I use MultiCharts Version 7.0 Release (Build 4510)

Code: Select all

Inputs:
   Price(Close), Macd.Length(5), Wilder.Length(10);

Variables:
   Dema1(0),
   X1(0), X2(0), Hausse(0), Baisse(0), WiMA.Hausse(0), WiMA.Baisse(0), MyValue(0);

X1 = Xaverage(Price, Macd.Length);
X2 = Xaverage(Xaverage(Price, Macd.Length), Macd.Length);
Dema1 = X1 * 2 - X2;

Hausse = MaxList(0, Dema1[0]-Dema1[1]);
Baisse = MaxList(0, Dema1[1]-Dema1[0]);

If currentbar <= 1 then
   begin
   WiMA.Hausse = Hausse;
   WiMA.Baisse = Baisse;
   end
else
   begin
   WiMA.Hausse = (((Wilder.Length-1) * WiMA.Hausse[1]) + Hausse) / Wilder.Length;
   WiMA.Baisse = (Baisse + (Wilder.Length-1)*WiMA.Baisse[1])/Wilder.Length;
   end;
   
MyValue = WiMA.Hausse / WiMA.Baisse;

Plot1(WiMA.Hausse, "WiMA.Hausse");
Plot2(WiMA.Baisse, "WiMA.Baisse");


whenever you have a division by a variable, you should add a check:

Code: Select all

if WiMA.Baisse <> 0 then
MyValue = WiMA.Hausse / WiMA.Baisse
else
MyValue = 0;
These users thanked the author TJ for the post (total 2):
JoshMnuno-online

User avatar
JoshM
Posts: 2089
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1485 times
Contact:

Re: Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby JoshM » 26 Jul 2011

Edit: TJ beat me too it. :) Below is practically the same post as he made.


nuno-online wrote:TJ and JoshM

here again the code: i forgot one line :
MyValue = WiMA.Hausse / WiMA.Baisse;

Compilation impossible
I use MultiCharts Version 7.0 Release (Build 4510)

Hi Nuno,

The error I receive with your indicator is a "division by zero" error. This error is not hard to spot, given that there's one division that's added in your latest version:

Code: Select all

MyValue = WiMA.Hausse / WiMA.Baisse;

You can work around this by providing a check for these zero values, for example by checking if one of these is zero, and if that's the case, use the previous value of MyValue:

Code: Select all

if WiMA.Baisse = 0 or WiMA.Hausse = 0 then
   MyValue = MyValue[1];   
else
   MyValue = WiMA.Hausse / WiMA.Baisse;

If you use Print() statements to check where these zeros occur, it shows that these happen on the first bar (on the data I tested), when neither one of these variables has any value. In that case, you could instead use the following to prevent division by zero:

Code: Select all

if CurrentBar > 10 then
   MyValue = WiMA.Hausse / WiMA.Baisse;
These users thanked the author JoshM for the post:
nuno-online

nuno-online
Posts: 166
Joined: 31 Jan 2006
Has thanked: 72 times
Been thanked: 3 times

Re: Indicator Help: Error : {EXCEPTION} Opération en virgule

Postby nuno-online » 26 Jul 2011

JoshM and TJ

thank you very much for your help

Nuno


Return to “MultiCharts”