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

getTimeForNBarsForward() bug
http://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=16&t=56860
Page 1 of 1

Author:  fxer [ Sun 16 Dec, 2018, 23:47 ]
Post subject:  getTimeForNBarsForward() bug

The following code gives result Friday 1 hour before midnight (i.e. "2018-12-14 23:00:00:000"). I think that the correct result should be Sunday 1 hour before midnight (i.e. "2018-12-16 23:00:00:000").

package jforex;

import com.dukascopy.api.*;
import com.dukascopy.api.util.DateUtils;

import java.text.ParseException;

@RequiresFullAccess
public class test6 implements IStrategy {
    public void onStart(IContext context) throws JFException {
        try {
            context.getConsole().getOut().println(DateUtils.format(context.getHistory().getTimeForNBarsForward(Period.ONE_HOUR, DateUtils.parse("2018-12-14 00:00:00:000"), 24)));
        } catch (ParseException e) {
            e.printStackTrace();
        }

        context.stop();
    }

    public void onAccount(IAccount account) throws JFException {}
    public void onMessage(IMessage message) throws JFException {}
    public void onStop() throws JFException {}
    public void onTick(Instrument instrument, final ITick tick) throws JFException {}
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {}
}


Regards,
FXer

Author:  API Support [ Fri 21 Dec, 2018, 16:41 ]
Post subject:  Re: getTimeForNBarsForward() bug

Hello,

Method getTimeForNBarsForward() implementation doesn't filter bars by Weekends or Flat conditions. Therefore, returned value is correct.

  Page 1 of 1