Dukascopy
 
 
Wiki JStore Search Login

JFOREX-2348 getBar returning an IBar == null
 Post subject: JFOREX-2348 getBar returning an IBar == null Post rating: 0   New post Posted: Thu 21 Oct, 2010, 20:49 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
Hello Support,

due to this bug https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=17&t=23835 I have been forced to do my setup of indicators in the onTick of the strategy instead of the onStart(). In doing this work around I have noticed that getBar function will return the most recent bar as null if the following strategy is run in the main.java from my IDE (and not from the JForex frontend). If this if statement is moved to the onBar then a null bar will not be returned. And if the .getBar shift is set to 1 instead of 0, null will also not be returned.

Any chance this bug could be fixed? And also when will the API with the above mentioned fixed bug be released?

Thanks for your help,
jForexUser

import java.util.*;

import com.dukascopy.api.*;

public class Strategy implements IStrategy {

    private IEngine engine;
    private IConsole console;
    private IHistory history;
    private IContext context;
    private IIndicators indicators;
    private IUserInterface userInterface;
    boolean runJustOnce = true;

    public void onStart(IContext context) throws JFException {
        this.engine = context.getEngine();
        this.console = context.getConsole();
        this.history = context.getHistory();
        this.context = context;
        this.indicators = context.getIndicators();
        this.userInterface = context.getUserInterface();
    }

    public void onAccount(IAccount account) throws JFException {
    }

    public void onMessage(IMessage message) throws JFException {
    }

    public void onStop() throws JFException {
    }

    public void onTick(Instrument instrument, ITick tick) throws JFException {
        if (runJustOnce) {
            IBar current_TEN_SECS = context.getHistory().getBar(instrument, Period.TEN_SECS, OfferSide.BID, 0);
            console.getOut().println("close: " + current_TEN_SECS.getClose());
            runJustOnce = false;
        }
    }

    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
    }
}


 
 Post subject: Re: JFOREX-2348 getBar returning an IBar == null Post rating: 0   New post Posted: Fri 22 Oct, 2010, 10:07 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
jForexUser wrote:
Any chance this bug could be fixed? And also when will the API with the above mentioned fixed bug be released?

This is not a bug and will not be fixed. The reason why it returns null is simple. Lets say we start our strategy at 12:05:17, our platform connects to the server and starts to receive ticks. You request current in progress candle with time 12:05:10, but we don't have full information for it as we started to receive ticks on 17 seconds. We send the request for the missing 7 seconds once platform starts, but it takes some time to load. Instead of returning incorrect candle we decided to return null while data is loading


 
 Post subject: Re: JFOREX-2348 getBar returning an IBar == null Post rating: 0   New post Posted: Fri 22 Oct, 2010, 17:31 
User avatar

User rating: 0
Joined: Thu 16 Jun, 2011, 21:37
Posts: 98
Location: SwitzerlandSwitzerland
what's the best method to then load data from the current car (shift 0) when the strategy first loads up?
read bars returns ""to" parameter can't be greater than time of the last formed bar for this instrument". Should I simply have a loop with getBar (using shift 0) until it doesn't equal null?
You say: "You request current in progress candle with time 12:05:10, but we don't have full information for it as"...why doesn't your system have full information for a candle in progress? I'm assuming your system has all tick information for since 12:05:10 up until 12:05:17?...then why can't you just update the most recent bar on each tick?

Also if I do shift 1 then the bars return immediately...is this because they are getting pulled from your server?

When will the API with said fixed bug: viewtopic.php?f=17&t=23835
be released?


 

Jump to:  

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