That all makes sense, esp. Tuzo's last explanation. Thanks for the comprehensive feedback guys.
--- In [email protected], "tuzo_wilson" <[EMAIL PROTECTED]> wrote: > > --- In [email protected], "ozzyapeman" <zoopfree@> wrote: > > > 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? > > Some good posts on this so I won't repeat what has been said. > In your example, variables that will be assigned to later (e.g. > valueAtBuy) are initialized to Null. Variables that are going to be > incremented (e.g. longContractCount) are initialized to 0. > > That makes sense from a common sense point of view. What is the > valueAtBuy before there is a buy? Who knows -- there is no value yet. > How many long contracts do you have before you enter into any long > contracts? This is known -- you have zero contracts. > > > Tuzo > > > 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++) > > { > > >
