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

[amibroker] Re: Null constant



PureBytes Links

Trading Reference Links

Jerome,

yes you're right, if I do an explore on all data
with
for(i=0;i<BarCount;i++)
{
if(mo[i]) 
test[i] = 1;
else
test[i]=0;
}

AddColumn(test,"test");
AddColumn(mo,"mo");
AddTextColumn(Name(),"Ticker",1.0); 

I have got correct results

but If I ask 
for(i=0;i<BarCount;i++)
{
if(!mo[i]) // NOT mo
test[i] = 1;
else
test[i]=0;
}

I have incorrect results

stephane

> Further step in this "Null" problem : I have inserted a "NZ()" 
function in
> the code example. And it appears that this function doesn't convert 
the
> first 5 bars of the mo array in 0 values. So, the values initialy 
present in
> those first 5 bars are not Null/Nan/Infinity values. So what are 
they ? And
> how can we test them ?
> 
> Hereafter is the modified code example :
> 
> mo = MA(C,5);
> 
> Nz(mo);
> 
> test = 0;
> 
> for(i=0;i<BarCount;i++)
> 
> {
> 
> if(mo[i] == Null) test[i] = 1;
> 
> }
> 
> AddColumn(test,"test");
> 
> AddColumn(mo,"mo");
> 
> Filter = 1;
> 
> 
> 
>   -----Message d'origine-----
>   De : Silvarius [mailto:silvarius@x...]
>   Envoyé : vendredi 28 novembre 2003 19:32
>   À : amibroker@xxxxxxxxxxxxxxx
>   Objet : RE: [amibroker] Re: Null constant
> 
> 
>   stéphane,
> 
>   The problem is not at the end of the loop, but at the beginning, 
where the
> 5 first bars are supposed to hold a "Null" value, and are not 
reported as
> such in the "if" test.
> 
>   Normaly, in the code example, the mo array is calculated as :
> 
>   mo[0] = Null
>   mo[1] = Null
>   ...
>   mo[4] = Null
>   mo[5] = number
>   mo[6] = number
>   ...
>   mo[BarCount - 1] = number
> 
>   So why does the test "mo[0] == Null" return a "false" result ?
> 
>   Your test (mo[i] > 0) returns a "true" result for any bar holding 
a number
> value and a "false" result for the first five bars holding a Null 
value. But
> the inverse test (mo[i] <=0) returns a false result for every bar. 
I would
> like a test that returns "true" for the first bars holding Null 
values, and
> "false" for all the other bars holding number values.
> 
>   We can of course use the array generated by your test, and buid a 
new one
> by inversing the 0 and the 1, but I would like to understand why I 
can't
> test directly a Null value in a for loop.
> 
>   Friendly yours, Jérôme.
>     -----Message d'origine-----
>     De : Stephane Carrasset [mailto:nenapacwanfr@x...]
>     Envoyé : vendredi 28 novembre 2003 17:34
>     À : amibroker@xxxxxxxxxxxxxxx
>     Objet : [amibroker] Re: Null constant
> 
> 
>     jerome,
> 
>     à la fin de l'execution de la boucle ( barcount-1)
>     mo[i] ne sera jamais null sauf si une valeur a 4 jours de data
>     aussi test[i] ne donne jamais 1 mais zero.
>     fais une explore avec
>     for(i=0;i<BarCount;i++)
>     {
>     if(mo[i] >0 )
>     test[i] = 1;
>     }
> 
>     stephane
> 
> 
> 
>     > Hello,
>     >
>     > Until yet, I have not succeeded in using the "Null" constant 
in for
>     loops.
>     > In the simple following code, I would have expected the first 
5
>     bars of the
>     > "test" array to hold a "1" value. This is not the case, so the
>     expression
>     > (mo[i] == Null) does not return a true result even when the MA
(C,5)
>     doesn't
>     > return any value. Is this by design or do I use this constant 
in a
>     wrong way
>     > ?
>     >
>     > Thank you in advance for any piece of help.
>     >
>     > Best regards, Jérôme ULRICH
>     >
>     >
>     > -------------------------
>     > mo = MA(C,5);
>     >
>     > test = 0;
>     >
>     > for(i=0;i<BarCount;i++)
>     >
>     > {
>     >
>     > if(mo[i] == Null) test[i] = 1;
>     >
>     > }
>     >
>     > AddColumn(test,"test");
>     >
>     > AddColumn(mo,"mo");
>     >
>     > Filter = 1;
>     >
>     > --------------------------
> 
> 
> 
>     Send BUG REPORTS to bugs@xxxx
>     Send SUGGESTIONS to suggest@xxxx
>     -----------------------------------------
>     Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
>     (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>     --------------------------------------------
>     Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
>     Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.
> 
> 
>         Yahoo! Groups Sponsor
>               ADVERTISEMENT
>               [AD-IMG]
> 
> 
> 
>   Send BUG REPORTS to bugs@xxxx
>   Send SUGGESTIONS to suggest@xxxx
>   -----------------------------------------
>   Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
>   (Web page: http://groups.yahoo.com/group/amiquote/messages/)
>   --------------------------------------------
>   Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
>   Your use of Yahoo! Groups is subject to the Yahoo! Terms of 
Service.


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/