This example shows how to correct division by zero errors in Tradestation Easy language or MultiCharts
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.