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.

onBar stops responding
 Post subject: onBar stops responding Post rating: 0   New post Posted: Thu 28 Jul, 2011, 14:07 

User rating: 0
Joined: Tue 19 Jul, 2011, 13:59
Posts: 3
Location: PT
Hi,

not sure if this is a bug or not, anyway, it seems that under certain circunstances, the onbar event appears to stop being called, particullarly when there are order commands involved. Consider the following simple strategy, running on the tester on tick data:

package Strategies;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import com.dukascopy.api.*;

public class BUG implements IStrategy {
    long barNumber = 0;
    IEngine engine;
    IConsole console;
    private static final String DATE_FORMAT_NOW = "yyyyMMdd_HHmmssSSS";
    long counter = 0;
   
    public void onStart(IContext context) throws JFException {
       engine = context.getEngine();
        console = context.getConsole();
    }
       
    public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
       if (period == Period.FIVE_MINS) {
          console.getOut().println(++barNumber);
          IOrder longOrder = engine.submitOrder("LONG" + getCurrentTime() + counter++, instrument, IEngine.OrderCommand.BUY, 0.01);
          waitUntilOrderFilled(longOrder);
          
          IOrder shortOrder = engine.submitOrder("SHORT" + getCurrentTime() + counter++, instrument, IEngine.OrderCommand.SELL, 0.01);
          waitUntilOrderFilled(shortOrder);
       }
       //else
       //   console.getOut().println(period);
    }
   
    public void onTick(Instrument instrument, ITick tick) throws JFException {}          
    public void onAccount(IAccount account) throws JFException {}
    public void onStop() throws JFException {}
    public void onMessage(IMessage message) throws JFException {}
   
    private String getCurrentTime() {
        Calendar cal = Calendar.getInstance();       
        SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
        return sdf.format(cal.getTime());
    }
   
    private void waitUntilOrderFilled(IOrder order) {
       
       while (!order.getState().equals(IOrder.State.FILLED) &&  !order.getState().equals(IOrder.State.CANCELED))
          order.waitForUpdate(1000);
     }
       
}


The print statements are being used for debug, but after certain number of bars the strategy stops printing and the test run cancel button will not respond.

I have deleted my cache and tried again but the results remain the same.

Thanks for your attention,

Regards,


 
 Post subject: Re: onBar stops responding Post rating: 0   New post Posted: Tue 02 Aug, 2011, 11:54 

User rating: 0
Joined: Tue 19 Jul, 2011, 13:59
Posts: 3
Location: PT
Greetings,

support/anyone, have you been able to replicate this issue?, or am I the only one having this problem? I have tried on different computers, instruments, and the issue persists.

Try for example EURUSD, tick data, starting from 2007.03.30 to 2008.03.30 - notice the onbar events stop being called.

Upon further investigation, I have found that this occurs, even in situations where there are no order commands inside onbar - the behaviour appears random but the onbar events stop being called.

Feedback?

Thanks & Regards


 
 Post subject: Re: onBar stops responding Post rating: 0   New post Posted: Wed 03 Aug, 2011, 09:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
There are no historical bars over weekends because the market is closed. Please adjust your strategy accordingly, not to wait indefinitely in while cycle for 2 days when the strategy receives no ticks or bars.


 
 Post subject: Re: onBar stops responding Post rating: 0   New post Posted: Wed 03 Aug, 2011, 20:52 

User rating: 0
Joined: Tue 19 Jul, 2011, 13:59
Posts: 3
Location: PT
Ok,

I see it now,

Thanks!


 

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