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.

history.getBar(...) for custom periods
 Post subject: history.getBar(...) for custom periods Post rating: 0   New post Posted: Thu 03 Mar, 2011, 11:28 

User rating: 0
Joined: Wed 13 Jul, 2011, 01:19
Posts: 8
Location: DE
When I call history.getBar(...) with a custom period, the method returns null.
IBar bar = history.getBar(instrument, Period.createCustomPeriod(Unit.Hour, 12), offerSide, shift);

the history.getBars(...) method works just fine with custom periods:
List<IBar> bars = history.getBars(instrument, Period.createCustomPeriod(Unit.Hour, 12), offerSide, Filter.ALL_FLATS, 10, history.getStartTimeOfCurrentBar(instrument, period), 0);


 
 Post subject: history.getBar(...) for custom periods Post rating: 0   New post Posted: Thu 03 Mar, 2011, 13:20 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You have to subscribe to this period in onStart method

import com.dukascopy.api.listener.*;


        context.subscribeToBarsFeed(
            Instrument.EURUSD,
            Period.createCustomPeriod(Unit.Hour, 12),
            OfferSide.ASK,
            new IBarFeedListener() {
                    public void onBar(
                        Instrument instrument,
                        Period period,
                        OfferSide offerSide,
                        IBar bar
                    ) {
                       
                    }
            }
        );

For the details please take a look at the following JForex Wiki page: viewtopic.php?f=61&t=29379


 

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