Dukascopy
 
 
Wiki JStore Search Login

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

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

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

getTimeForNBarsForward() bug
 Post subject: getTimeForNBarsForward() bug Post rating: 0   New post Posted: Sun 16 Dec, 2018, 23:47 

User rating: 1
Joined: Tue 24 Apr, 2012, 13:41
Posts: 37
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


 
 Post subject: Re: getTimeForNBarsForward() bug Post rating: 0   New post Posted: Fri 21 Dec, 2018, 16:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6081
Hello,

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


 

Jump to:  

cron
  © 1998-2011 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