|
SOLVING DIVISION BY ZERO CODE ERRORS IN EASY LANGUAGE
<>
Dear Roger
I bought many your products these years. I'm an user of TradeStation2000i.
When I apply one indicator on TS2000i, sometimes following small window happened:
"Floating point invalid numbers in calculation. This error sometimes indicates a division
be zero error with a zero also in the numerator. Incorrect example: Value1=Value2/Value3;
Correct example: Value1=IFF(Value2=0,0, value2/value3):
Since all your indicators I bought are codes protected, I remember you post a solution
somewhere on your site but I couldn't find it. Please help me.
I would appreciate your quick response.
Regards
<< ANSWER >>
Division by zero is a frequent problem experienced in programming. The answer is always infinity, so we have to prevent anything getting divided by zero in the first place.
There are two methods of doing this.
Method 1
If value1 = 0 then value1=value1+0.0000000001;
So we simply add a tiny number to it, which is so tiny it will not make too much difference to the outputs.
Method 2
If value1 <> 0 then value2 = value3 / value1
This forces the computer to ask if the value1 is 0 or not before doing its calculations. If it is 0 it will return the default value that was assigned to value1 in the variables when you created it.
Voila.
So to be exactly clear if a value can be zero you have to stop it being zero or you will get this error in all programming situations.
There are more programming code examples here
http://www.precisiontradingsystems.com/easylanguage_code.htm
Hope this helps
Dear Roger
I bought many your products these years. I'm an user of TradeStation2000i.
When I apply one indicator on TS2000i, sometimes following small window happened:
"Floating point invalid numbers in calculation. This error sometimes indicates a division
be zero error with a zero also in the numerator. Incorrect example: Value1=Value2/Value3;
Correct example: Value1=IFF(Value2=0,0, value2/value3):
Since all your indicators I bought are codes protected, I remember you post a solution
somewhere on your site but I couldn't find it. Please help me.
I would appreciate your quick response.
Regards
<< ANSWER >>
Division by zero is a frequent problem experienced in programming. The answer is always infinity, so we have to prevent anything getting divided by zero in the first place.
There are two methods of doing this.
Method 1
If value1 = 0 then value1=value1+0.0000000001;
So we simply add a tiny number to it, which is so tiny it will not make too much difference to the outputs.
Method 2
If value1 <> 0 then value2 = value3 / value1
This forces the computer to ask if the value1 is 0 or not before doing its calculations. If it is 0 it will return the default value that was assigned to value1 in the variables when you created it.
Voila.
So to be exactly clear if a value can be zero you have to stop it being zero or you will get this error in all programming situations.
There are more programming code examples here
http://www.precisiontradingsystems.com/easylanguage_code.htm
Hope this helps