[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] Difference between 0 and Null for variables?



PureBytes Links

Trading Reference Links

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
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 quite
pinpoint an explanation:

What is the difference, if any, between 0 and Null when assigning
non-boolean variables? When should we use Null instead of plain old 0?

For example, all of the six variables below are real numbers, yet some
are 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 prices

valueAtBuy = valueAtShort = Null;
profitLevel = profitLevel2 = Null;


// Number of open contracts

longContractCount = 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
__._,_.___

Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___