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

get current bar always null?
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=65&t=56603
Page 1 of 1

Author:  i_hate_java [ Wed 27 Jun, 2018, 14:20 ]
Post subject:  get current bar always null?

i try to get the current bar at Friday GMT 17:00
but it is always null, why?

code:
final Period myPeriod = Period.createCustomPeriod(Unit.Week, 1, JFTimeZone.EET);
final IBar myBar = this.history.getBar(instrument, myPeriod , OfferSide.ASK, 0);

^
myBar are always null

Author:  API Support [ Thu 28 Jun, 2018, 10:10 ]
Post subject:  Re: get current bar always null?

If you want get InProgress Candles for custom period, you need to specify feeddescriptor and subscribe to feed.

public class MyStrategy implements IStrategy, IFeedListener {
    IConsole console;
    IHistory history;

    @Configurable("Instrument")
    public Instrument instrument = Instrument.EURUSD;

    @Configurable("OfferSide")
    public OfferSide offerSide = OfferSide.ASK;

    @Override
    public void onStart(IContext context) throws JFException {
        console = context.getConsole();
        history = context.getHistory();

        Period myPeriod = Period.createCustomPeriod(Unit.Week, 1, JFTimeZone.EET);
        IFeedDescriptor feedDescriptor = new TimePeriodAggregationFeedDescriptor(instrument, myPeriod, offerSide, Filter.WEEKENDS);

        context.subscribeToFeed(feedDescriptor, this);

        IBar myBar = history.getBar(instrument, myPeriod, offerSide, 0);
        console.getOut().println(myBar);
    }

  Page 1 of 1