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

Questions about MultiCharts and user contributed studies.
nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

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

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

TJ
Posts: 7319
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 992 times
Been thanked: 2085 times

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

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.

JoshM
Posts: 2127
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1531 times
Been thanked: 1521 times
Contact:

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

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: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

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

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");```

TJ
Posts: 7319
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 992 times
Been thanked: 2085 times

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

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;```

JoshM
Posts: 2127
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1531 times
Been thanked: 1521 times
Contact:

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

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

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,

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; ```

nuno-online
Posts: 174
Joined: 31 Jan 2006
Has thanked: 74 times
Been thanked: 5 times

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

JoshM and TJ

thank you very much for your help

Nuno