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

RE: [amibroker] Re: Treament of Null Value



PureBytes Links

Trading Reference Links

Tomasz and Brian

 

Thank you for your detailed answer.  This advice will save many hours of
trouble shooting - especially those functions like ibc.GetPositionInfo that
returns both a "NULL" value and a number (unlike "ibc.GetPositionSize" which
returns the size (numeric) or zero).  Null is not the same as a number.  The
NZ function is another good function that I will begin to use that converts
NULL values to zero - so we are comparing numbers with numbers. 

 

 I have been using AmiBroker for about 2 years and started out by just doing
some testing and modifying existing examples which I recommend is a great
way to start.  I am now stretching my wings a bit further and developing and
testing several new systems to do analysis and also to help me with some of
the work in placing an order in IB. The "null" situation will crop up for
others when they begin using all of the system capabilities and testing
their own systems    Brian - thank you for your extra efforts and possibly
saving others valuable time. 

 

Dave

 

  _____  

From: amibroker@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx] On Behalf
Of brian.z123
Sent: Wednesday, October 04, 2006 6:29 AM
To: amibroker@xxxxxxxxxxxxxxx
Subject: [amibroker] Re: Treament of Null Value

 

Thanks Tomasz,

Your comments always provide clarity.

I am really enjoying Ami.
ATC and IIF are favourites already.
Nz is a nice little extra as well.
I am sure there are plenty more gems for me to find yet.

Cheers,

BrianB2.

P.S For the benefit of others I should have also mentioned in my 
opening post that there are some interesting points to be found by 
searching the PDF help file for null.

--- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> ps.com,
"Tomasz Janeczko" <groups@xxx> 
wrote:
>
> Hello,
> 
> In AFL general rule is:
> Null if included in any part of _arithmetic_ expression produces 
Null result.
> 
> Null when placed in conditional expression is equivalent to False.
> 
> Caveat:
> By default (for speed reasons) AmiBroker checks for nulls that 
appear in the beginning of the array
> and in the end of the array and once non-null value is detected it 
assumes no further holes (nulls) in the middle).
> If you want to perform Null calculations
> where Nulls are spread in random places throughout entire array 
you need to use
> 
> SetOption("EveryBarNullCheck", True);
> 
> Note however that turning it on gives huge performance penalty 
(arithmetic operations are performed even 4x slower when this option 
> is ON, so don't use it unless you really have to).
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "brian.z123" <brian.z123@xxx>
> To: <amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> ps.com>
> Sent: Wednesday, October 04, 2006 4:37 AM
> Subject: [amibroker] Re: Treament of Null Value
> 
> 
> Hello David,
> 
> This is a very good question that deserves a good answer.
> Truly this is a question for the alpha-techs but all you got was 
me.
> 
> At the moment I limit myself to no more than one topic a week and
> you are the lucky, or unlucky, chosen one.
> After this I may change to one a month.
> 
> Here are my credentials so you can decide if it is worth your while
> to read on:
> 
> I am a free man first and trading comes somewhere after that (along
> with husband, father, grandfather, cook, gardener, handyperson 
etc).
> As a trader I only learn the math/programming/computer techs that I
> am obliged to.
> In my answers I aim to provide enough leads to enable the forum to
> prove me right or wrong, if they so choose.
> I don't provide answers; only directions towards them (you have to
> climb the mountain yourself).
> I seldom elaborate, except to correct my errors or clarify my 
points.
> This may seem harsh but anyone who can't follow some simple
> guidelines is highly unlikely to make a good trader so it is in
> their best interests if they are knocked out of the game early.
> I like to assist people to succeed but I leave them to fail alone.
> 
> There has been a lot of interesting dicussion on this or related
> subjects in this forum in the past.
> It is a topic best considered as part of group rather than as a
> standalone.
> I used the advanced search feature of this forum to search subject
> headings for NAN, NULL, EMPTY, IEEE, FINITE, TRUE.
> There are additional messages with these topics in the body but I
> found sufficient information even when limiting the search to
> subject only.
> There are some good links in the messages that go to advanced or
> tech level references if required.
> They also include posts by Tomasz that explain the AB philosophy, 
so
> I will not repeat that information here.
> 
> Over the years AB's handling of null has evolved so you have to 
keep
> that in mind when reading back posts.
> 
> As a result of reading the archives and using Explorer to test
> specific cases I believe I now have a reasonable laymans
> understanding of the subject as it applies to AB.
> In any case, I always triple check my projects for any exceptional
> behaviour, including null/zero effects.
> As a caution I would advise you to check my results for yourself 
and
> be careful of null exceptions in your work.
> Obviously I have not checked all possible scenarios.
> 
> 
> For the benefit of my laybrothers and laysisters I provide the
> following definitions:
> 
> http://www.webopedi <http://www.webopedia.com/TERM/N/null_character.html>
a.com/TERM/N/null_character.html
> 
> A character that has all its bits set to 0. A null character,
> therefore, has a numeric value of 0, but it has a special meaning
> when interpreted as text. In some programming languages, notably C,
> a null character is used to mark the end of a character string. In
> database and spreadsheet applications, null characters are often
> used as padding and are displayed as spaces.
> 
> http://en.wikipedia <http://en.wikipedia.org/wiki/Null_%28computer%29>
.org/wiki/Null_%28computer%29
> 
> Null has several meanings in computer programming.
> In many disciplines, the concept of null allows a three-valued
> logic, with null indicating "unknown value". The SQL database query
> language uses Null in this way, as do Visual Basic
> (Termed "Nothing") and its derivatives. In this model, an 
expression
> that depends on the value of a Null operand will evaluate to Null
> (VB) or "unknown" (SQL).
> 
> 
> 
> For this discussion Null == Empty == Traders speak for no data
> == ; (?)
> 
> Null is not a reserved variable.
> Neither is it a function.
> AB uses it without complaint however e.g.
> 
> AddColumn(IIf( DayOfWeek() == 5, Null,1),"NullTest",1.5);//produces
> Null every Friday when used in explore.
> 
> Using combinations of the following code I was able to test current
> null and zero behaviour in some typical AB applications:
> 
> //allows Explorer testing of Null behaviour
> 
> N = IIf( DayOfWeek() == 5, Null,1);
> P = 1 - N ;// formula P alternative is 1 - Null
> //P = N/0; // formula P alternative is Null/0
> AddColumn(IsNull(N),"IsNullFri",1.5);
> AddColumn(P,"IsNullMath",1.5);
> 
> //allows Explorer testing of zero behaviour
> 
> AddColumn(1/0,"Math",1.5);
> 
> My findings are as follows (use at your own risk):
> 
> Substituting the word Null for N in formula P produces Null as the
> result of all */+- combinations including o cases.
> 
> For all cases of */+- using N:
> 
> Null + 1 == Null
> Null - 1 == Null
> 1 - Null == 10,000,000,000 OR (+1 E10?)
> 1 + Null == Null
> 
> 0/Null == 0
> Null/0 == -1.#INFO
> Null/1 == Null
> 1/Null == -0.0000
> 
> 1 * Null == Null
> Null * 1 == Null
> 0 * Null == 0
> Null * 0 == 0
> 
> N * N == 100,000,002,004,087,730,000
> N/N == 1
> N + N == -20,000,000,000
> N - N == 0
> 
> The maths test 1/0 produces the result 1.#INFO
> 
> 
> 
> That's all from me and it's all from him.
> 
> BrianB2 ::-) (sunglasses on forehead)
> 
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxx <mailto:amibroker%40yahoogroups.com> ps.com,
"David Weller" <wellerdr@>
> wrote:
> >
> > How does AmiBroker treat Null values?
> >
> >
> >
> > When there is no current position then following code does not
> execute as
> > the return value is a Null. But I think it should. When there 
are
> open
> > positions the value is greater than 0 then this piece code
> executes fine.
> >
> >
> >
> >
> >
> > if (ibc.GetPositionInfo(Name(),"Avg. cost") <=
> > LastValue(C))
> >
> >
> >
> > I fixed this situation by first checking if( ibc.GetPositionSize
(
> Name() )
> > == 0 ) meaning no existing positions and routing only open
> positions > than
> > 0 to the above code.
> >
> >
> >
> > In Hex Null is 000 which is less than all other numbers. Just 
not
> > understanding the situation. Working with the IB Interface and
> really like
> > this capability.
> >
> >
> >
> > Dave
> >
> 
> 
> 
> 
> 
> 
> 
> 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 other support material please check also:
> http://www.amibroke <http://www.amibroker.com/support.html>
r.com/support.html
> 
> 
> Yahoo! Groups Links
>