This is probably an oversimplification, but I think of 0 as an integer with a 
value of zero and Null as "no value."  As an example, suppose you had an array 
of C with holes in the data.  Those holes are Nulls.   Take a look at the Nz 
function which converts Null values to 0.  I believe, in general, calculations 
involving Null produce Null and conditional statements containing Null produce 
False.  As for the variables, I would initialize all to 0.  (I'm sure if this 
is not correct someone will jump in and straighten things out).

Bill
  ----- Original Message ----- 
  From: ozzyapeman 
  To: [email protected] 
  Sent: Friday, September 12, 2008 9:03 PM
  Subject: [amibroker] Difference between 0 and Null for variables?


Tried to do a search in the User's Guide for this, but can't quitepinpoint an 
explanation:What is the difference, if any, between 0 and Null when 
assigningnon-boolean variables? When should we use Null instead of plain old 
0?For example, all of the six variables below are real numbers, yet someare 
initially set to Null and others to 0. I copied this snippet from an example 
AFL that works properly:// Set up variables for our entry values, as our stops 
will test// against the initial entry pricesvalueAtBuy = valueAtShort = 
Null;profitLevel = profitLevel2 = Null;// Number of open 
contractslongContractCount  = 0;shortContractCount = 0;for (i = start; i < 
BarCount; i++){ 


------------------------------------------------------------------------------



  No virus found in this incoming message.
  Checked by AVG - http://www.avg.com 
  Version: 8.0.169 / Virus Database: 270.6.21/1669 - Release Date: 9/12/2008 
2:18 PM

Reply via email to