The variables beginning with "Num" are int, as they are used to count something. Variables ending with -Long / -Short include phantom trades, variables ending with -Total do not.
Your script contains a mistake:
numOpenLastCheck = NumOpenLong+NumOpenShort
This is wrong. Correct would be:
numOpenLastCheck = 0; // before the loop
...
numOpenLastCheck += NumOpenLong+NumOpenShort; // inside the loop
and the else-if logic must be likewise corrected.