# Warning 505 isn't an Error

Hi,

I get an error in second line because it is being divided by zero. I want to calculate if volume increased by 50% from previous day. Which is the best way to go about this ?

``````Cond1 = Close/Ref(Close,-1) > 1.05;
Cond2 = Volume/Ref(Volume, -1) > 1.50;
Filter = Cond1 AND Cond2;
``````

i think you can add a small number, like in this example:

``````HiC = HHV( Close, Range );
LoC = LLV( Close, Range );
Stoc = ( Close - LoC ) / ( HiC - LoC + 1e-9 );
``````

but Iâ€™d say you could also use (although not sure if it works since your code did not give a 505 warning to me)

``````Cond2 = IIf( Ref( Volume, -1 ) != 0, Volume / Ref( Volume, -1 ) > 1.50, 0 );
``````
1 Like
``````Cond1 = Close/Ref(Close,-1) > 1.05;
PrevVolume = Ref(Volume, -1);
Cond2 = iif(PrevVolume>0, Volume/PrevVolume > 1.50, false);
Filter = Cond1 AND Cond2;
``````
1 Like

Firstly, a warning is not an error. You donâ€™t need to get â€śrid of itâ€ť.

You can do this WITHOUT division at all:

``````Cond2 = ROC( Volume, 1 ) > 50;
``````

If you want to use division, you can simply use

``````Nz( Volume/PrevVolume );
``````

it is a lot faster than `IIF` suggested by others.

2 Likes

Thank you @Tomasz. Didnâ€™t know about the nz function.

I tried using Nz(), but I am still getting the warning.

``````Cond1 = Close/Ref(Close,-1) > 1.05;
Cond2 = Nz(Volume/Ref(Volume, -1)) > 1.50;
Filter = Cond1 AND Cond2;
``````

In the meantime you can try this code which should eliminate your warning (Cond2 as suggested by Tomasz, and Cond1 re-coded based on that idea).

``````//Cond1 = Close/Ref(Close,-1) > 1.05;
//Cond2 = Nz(Volume/Ref(Volume, -1)) > 1.50;

Cond1 = ROC( Close, 1 ) > 5;
Cond2 = ROC( Volume, 1 ) > 50;

Filter = Cond1 AND Cond2;
The point is not â€śgetting rid of warningâ€ť. It is not an error. The warning 505 is informational message that you should watch for Not-a-numbers (infinity) in the results. What IS important is to convert those Not-a-numbers to zero (or whatever number you want). That is what `Nz()` function does. It takes care of results of division by zero.