PDA

View Full Version : Rounding error on Euro


cunparis
01-02-2010, 02:49 AM
It seems there is a rounding error when doing OHLC calculations with the euro.

Here I print out the Close & Open, the same value is printed.

Then I print out Close - Open, which shows they're not equal exactly.


12/7/2009 3:31:13 AM C=1.4831 O=1.4831
12/7/2009 3:31:13 AM C-O=-4.44089209850063E-16


Here's the code:


Print(Time[0] + " C=" + Close[0] + " O=" + Open[0]);
Print(Time[0] + " C-O=" + (Close[0] - Open[0]));


Any way to get around this problem? It's really messing me up.

NinjaTrader_Bertrand
01-02-2010, 02:57 AM
Which broker / feed and which Pip settings are you using?

Have you tried casting the values to doubles for example and then substracting?

Also please check into this link below -

http://www.ninjatrader-support2.com/vb/showthread.php?t=3929

Thanks

cunparis
01-02-2010, 03:04 AM
Which broker / feed and which Pip settings are you using?

Have you tried casting the values to doubles for example and then substracting?

Also please check into this link below -

http://www.ninjatrader-support2.com/vb/showthread.php?t=3929

Thanks

I can't believe you just answered my question in less than a few minutes on a holiday weekend. You guys are amazing. Thank you very much.

This worked:


Instrument.MasterInstrument.Compare(Close[1],Open[1]) == -1


I just realized that if I press F5 on my chart to update the indicators, it seems to erase my annotations that are off screen. Is this possible? I'm trying to figure it out. in the meantime I use Control-I and then press close and that seems to be ok.

NinjaTrader_Bertrand
01-02-2010, 08:41 AM
Hi cunparis, thanks for the kind words great this helped - where are those annotations placed, sorry not following you here...

cunparis
01-04-2010, 04:01 AM
Hi cunparis, thanks for the kind words great this helped - where are those annotations placed, sorry not following you here...

I drew on my chart, hit F5, and then noticed my drawings were gone. It could be that I did something else but it happened several times and I just started using F5. I went back to control-I close and haven't lost a drawing since.

it seems to happen to the drawings that are not visible (like from a previous day).

NinjaTrader_Bertrand
01-04-2010, 05:22 AM
Thanks cunparis - unfortunately wasn't able to see if happening in my testing so far...