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.

Indicator nt working after set ITesterClient setDataInterval
 Post subject: Indicator nt working after set ITesterClient setDataInterval Post rating: 0   Post Posted: Thu 29 Sep, 2011, 01:57 

User rating: 0
Joined: Thu 29 Sep, 2011, 01:53
Posts: 2
Location: SG
The indicator fails to display any value within onBar/onTick method after setting the ITesterClient object's data interval as below:

client.setDataInterval(ITesterClient.DataLoadingMethod.ALL_TICKS, startDate, endDate);


To give an example. We take the singlejartest package that comes with the API. if we set the Data Interval within "TesterMain.java", the code will not work as indicator in onBar/onTick will output invalid values.


(TesterMain.java)
...
//set instruments that will be used in testing
Set<Instrument> instruments = new HashSet<Instrument>();
instruments.add(Instrument.EURUSD);
LOGGER.info("Subscribing instruments...");
client.setSubscribedInstruments(instruments);
//setting initial deposit
       
//when inserted the code below, the tester will not work
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
long startDate = sdf.parse("10.09.2011 00:00:00").getTime();
long endDate = sdf.parse("11.09.2011 00:00:00").getTime();       
client.setDataInterval(ITesterClient.DataLoadingMethod.ALL_TICKS, startDate, endDate);//set date

client.setInitialDeposit(Instrument.EURUSD.getSecondaryCurrency(), 50000);
//load data
LOGGER.info("Downloading data");
Future<?> future = client.downloadData(null);
//wait for downloading to complete
future.get();
...



Regards


 
 Post subject: Re: Indicator nt working after set ITesterClient setDataInte Post rating: 0   Post Posted: Thu 29 Sep, 2011, 12:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
wei3hua2 wrote:
the code will not work as indicator in onBar/onTick will output invalid values.
1) IIndicator does not have onBar and onTick callback methods, IStrategy does.
2) What do you mean by "invalid values"? Could you please provide a code fragment which outputs these values? And please describe what you expect these values to be.


 
 Post subject: Re: Indicator nt working after set ITesterClient setDataInte Post rating: 0   Post Posted: Thu 29 Sep, 2011, 14:03 

User rating: 0
Joined: Thu 29 Sep, 2011, 01:53
Posts: 2
Location: SG
I found the problem. The error occurs because i use weekend data.
It was my mistake. Thanks for your response and sorry about that.


 

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