Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

how to access tick instrument inside other instrument
 Post subject: how to access tick instrument inside other instrument Post rating: 0   New post Posted: Wed 27 Nov, 2013, 04:39 
User avatar

User rating: 9
Joined: Sun 18 Dec, 2011, 03:31
Posts: 160
Location: Egypt, Cairo
how can i get tick of instrument inside other instrument

like that :

public void onTick(Instrument instrument, ITick tick) throws JFException {

if (instrument== Instrument.USDCHF)
{
//how can get current tick for EURUSD here


}

}


 
The Best Answer  Post subject: Re: how to access tick instrument inside other instrument Post rating: 0   New post Posted: Wed 27 Nov, 2013, 08:23 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Use IHistory.getLastTick, see examples:
https://www.dukascopy.com/wiki/#History_ticks
Mind that this instrument has to be subscribed, see:
https://www.dukascopy.com/wiki/#Subscribe_to_an_instrument


 
 Post subject: Re: how to access tick instrument inside other instrument Post rating: 0   New post Posted: Thu 28 Nov, 2013, 10:04 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
API Support wrote:


That seems to be a bit redundant, since onTick will be called at every tick, and the ITick object received as parameter is the latest tick on the Instrument.
The "tick" object is the last tick. To get the bid and ask, one has to refer tick.getBid() and tick.getAsk() .

Later edit:

Now I understand better. You must also subscribe EUR/USD and store latest EUR/USD tick in an Itick variable
if (instrument== Instrument.EURUSD)  { latestEURUSDtick=tick }

Of course, that would require a null check.


 
 Post subject: Re: how to access tick instrument inside other instrument Post rating: 0   New post Posted: Thu 28 Nov, 2013, 12:15 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
It might be more convenient to call IHistory.getLastTick, than to fetch the last tick of each instrument of interest in a specific variable and then before using this variable to check if it's null.


 
 Post subject: Re: how to access tick instrument inside other instrument Post rating: 0   New post Posted: Thu 28 Nov, 2013, 21:41 
User avatar

User rating: 9
Joined: Sun 18 Dec, 2011, 03:31
Posts: 160
Location: Egypt, Cairo
Thanks you


 

Jump to:  

  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com