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

Re: [amibroker] Re: Basic programming error



PureBytes Links

Trading Reference Links

Hello,

Discussed to death already. 0.2 does not have exact representation
in ANY binary computer.
http://en.wikipedia.org/wiki/IEEE_754

http://www.cygnus-software.com/papers/comparingfloats/comparingfloats.htm

You should better use AlmostEqual function
http://www.amibroker.com/f?almostequal

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "si00si00" <si00si00@xxxxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, May 07, 2008 5:12 PM
Subject: [amibroker] Re: Basic programming error


> Thanks for the answer Bill.
> 
> PriceChange should return 0.02 actually quite often (about 12% of the
> time). 
> 
> I have just seen that when I imported my historical data into excel,
> the PriceChange value was giving me strange results, e.g.
> -0.010000000000005. Now in AFL, I rounded the PriceChange array to 3
> decimal places and it works.
> 
> I don't think I'll ever figure out why the array was returning these
> strange values in both AFL and Excel. In my historical data all Close
> prices are give with two decimal places!
> 
> Very strange (and very time consuming trying to figure out the error!)
> 
> Thanks again.
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "wavemechanic" <timesarrow@xxx> wrote:
>>
>> You will only get a response for pricechangetwo when pricechange is
> exactly equal to .02.  How often does that happen?  Maybe never.  You
> can use a range of values such as pricechangetwo = pricechange >= .02.
>> 
>> Bill
>>   ----- Original Message ----- 
>>   From: si00si00 
>>   To: amibroker@xxxxxxxxxxxxxxx 
>>   Sent: Wednesday, May 07, 2008 9:21 AM
>>   Subject: [amibroker] Basic programming error
>> 
>> 
>>   Hi all,
>> 
>>   I'm making some basic programming error that I can't figure out and
>>   was wondering if someone could help me. The code is as follows:
>> 
>>   PriceChange = C - Ref(C,-1);
>>   PriceChangeTwo = PriceChange == 0.02;
>> 
>>   When I plot PriceChange I get some values that are equal to 0.02.
>>   However, the array PriceChangeTwo is always zero. Why is this?
>> 
>>   Thanks in advance for any help!
>> 
>>   Simon
>> 
>> 
>> 
>> 
>>   ------------------------------------
>> 
>>   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
>>   Yahoo! Groups Links
>> 
>> 
>> 
>> 
>> 
>>   -- 
>>   No virus found in this incoming message.
>>   Checked by AVG. 
>>   Version: 7.5.524 / Virus Database: 269.23.9/1418 - Release Date:
> 5/6/2008 5:17 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
> Yahoo! Groups Links
> 
> 
> 

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

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
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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