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.

parameter can't be greater than time of the last formed bar
 Post subject: parameter can't be greater than time of the last formed bar Post rating: 0   New post Posted: Tue 23 Nov, 2010, 09:25 

User rating: -
Hello support,

I have this in my code:

IBar bar0=history.getBar(instrument, Period.ONE_MIN, OfferSide.BID, 0);
long a=bar0.getTime();
java.util.Date d=new java.util.Date(a);
console.getOut().println( instrument.toString()+" "+ d.toString());

After the Stritegy run normally for a while an error occur and the stategy is stoped:
here is the message:

08:15:25 com.dukascopy.api.JFException: "to" parameter can't be greater than time of the last formed bar for this instrument @ jforex.Strategy12.onTick(Strategy12.java:149)
I want to know how could this happen? and how to slove it?


 
 Post subject: Re: parameter can't be greater than time of the last formed Post rating: 0   New post Posted: Fri 26 Nov, 2010, 13:25 

User rating: 0
Joined: Tue 23 Nov, 2010, 10:03
Posts: 4
I am sorry, I tried many times and finally I find the error comes from the code on calling indicators.
this error comes occasionally when it is running. and I got the message
"12:12:32 "to" parameter can't be greater than time of the last formed bar for this instrument"


public void onTick(Instrument instrument, ITick tick) throws JFException {
try{

IBar m15bar0=history.getBar(instrument, Period.THIRTY_MINS, OfferSide.BID, 0);
IBar m05bar0=history.getBar(instrument, Period.FIVE_MINS, OfferSide.BID, 0);
IBar m01bar0=history.getBar(instrument, Period.ONE_MIN, OfferSide.BID, 0);

double cci15=indicators.cci(instrument, Period.FIFTEEN_MINS, OfferSide.BID, 14, Filter.WEEKENDS, 1, m15bar0.getTime(), 0)[0];
double cci5=indicators.cci(instrument, Period.FIVE_MINS, OfferSide.BID, 14, Filter.WEEKENDS, 1, m05bar0.getTime(), 0)[0];
double cci1=indicators.cci(instrument, Period.ONE_MIN, OfferSide.BID, 14, Filter.WEEKENDS, 1, m01bar0.getTime(), 0)[0];

///.....
}
catch (Exception e) {
print(e.getMessage());
}

return;
}


 
 Post subject: Re: parameter can't be greater than time of the last formed Post rating: 0   New post Posted: Sun 28 Nov, 2010, 14:00 

User rating: -
is this a BUG of JForex? because there is no "to" parameter in the code.

if there is no Try ...Catch .. ,the stragegy will stop on this error.


 
 Post subject: Re: parameter can't be greater than time of the last formed Post rating: 0   New post Posted: Tue 30 Nov, 2010, 08:57 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
Does this problem persist?
We have tested the code posted above without try-catch and exception doesn't occurs.


 
 Post subject: Re: parameter can't be greater than time of the last formed Post rating: 0   New post Posted: Tue 30 Nov, 2010, 11:09 

User rating: 0
Joined: Tue 23 Nov, 2010, 10:03
Posts: 4
Sure it persist. I am using the version JForex 2.6.23
the whole code is attached.


package jforex;

import java.util.*;

import com.dukascopy.api.*;

public class test1 implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;

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 {
try{
IBar m15bar0=history.getBar(instrument, Period.FIFTEEN_MINS, OfferSide.BID, 0);
IBar m05bar0=history.getBar(instrument, Period.FIVE_MINS, OfferSide.BID, 0);
IBar m01bar0=history.getBar(instrument, Period.ONE_MIN, OfferSide.BID, 0);

double cci15=indicators.cci(instrument, Period.FIFTEEN_MINS, OfferSide.BID, 14, Filter.WEEKENDS, 1, m15bar0.getTime(), 0)[0];
double cci5=indicators.cci(instrument, Period.FIVE_MINS, OfferSide.BID, 14, Filter.WEEKENDS, 1, m05bar0.getTime(), 0)[0];
double cci1=indicators.cci(instrument, Period.ONE_MIN, OfferSide.BID, 14, Filter.WEEKENDS, 1, m01bar0.getTime(), 0)[0];
///.....
}
catch (Exception e) {
console.getOut().println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>"+e.getMessage());
}

return;

}

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


Attachments:
test1.java [1.71 KiB]
Downloaded 344 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 
 Post subject: Re: parameter can't be greater than time of the last formed Post rating: 0   New post Posted: Thu 02 Dec, 2010, 10:26 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please download the last jnlp file version from Dukascopy Bank site and try to run the test1 strategy posted above and reply stack trace if any exceptions occurs. We have tested this strategy for about 2 hours and everything seems to work fine.


 

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