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.

Get prices for different currency pairs
 Post subject: Get prices for different currency pairs Post rating: 0   New post Posted: Tue 03 Feb, 2009, 19:00 

User rating: -
I'm new with Java and JForex.
Sorry for stupid question but how can i get prices for different currency pairs in case i do use multicurrency strategy.
For example methods tick.getBid() and tick.getAsk() returns current prices for all active instruments.
Please show an example how i should get current price for example for only USDCHF.

One more question from newbie:
How can I get the prices of closed N history bars (open, close, low, high)
I see method getBars(...) which returns a list of history bars but how should i work with them?
A small example will be helpful.

Thanks.


 
 Post subject: Re: Please help to get prices for different currency pairs Post rating: 0   New post Posted: Thu 05 Feb, 2009, 16:45 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Nickola wrote:
how can i get prices for different currency pairs in case i do use multicurrency strategy.
For example methods tick.getBid() and tick.getAsk() returns current prices for all active instruments.
Please show an example how i should get current price for example for only USDCHF.

You can ignore all other currency pairs, by putting this code in start of the onTick method
if (instrument != Instrument.USDCHF) {
    return;
}

Nickola wrote:
I see method getBars(...) which returns a list of history bars but how should i work with them?
A small example will be helpful.

You can iterate through any List with for statement:
List<IBar> listOfBars = getBars(...);
for (IBar bar : listOfBars) {
    //do what you need with bar
}


 

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