Dukascopy Support Board
http://www.dukascopy.com/swiss/english/forex/jforex/forum/

instrument.toString()
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=231
Page 1 of 1

Author:  [bedaine] [ Mon 15 Dec, 2008, 15:12 ]
Post subject:  instrument.toString()

Hello !!

In the function public void onTick(Instrument instrument, ITick tick) throws JFException

I put "if (instrument.toString() == "EUR/GBP")" but my condition it's never true.. why ??

thank you for your help !! :D

Author:  API Support [ Mon 15 Dec, 2008, 15:34 ]
Post subject:  Re: instrument.toString()

Hello,
When you compare two objects with ==, you compare not the content of the objects, but objects themself. You can think of it as comparing two pointers to the memory. Even if two strings have the same text, they are still different objects and have different pointers and == with give false. You should use:
if (instrument.toString().equals("EUR/GBP"))

  Page 1 of 1