|
Historical Tester |
us_copiosus
|
Post subject: Historical Tester |
Post rating: 0
|
Posted: Mon 12 Jan, 2015, 19:10
|
|
User rating: 2
Joined: Fri 02 Mar, 2012, 22:08 Posts: 200 Location: New Zealand, Dunedin
|
Hi
I wish to use the Historical tester to capture details of trades several years ago and save these in a file The following is my label subroutine ********************************************** private String getLabel (Instrument instrument) throws JFException{ String label; String stripSlash = instrument.toString(); String[] stripped = stripSlash.split("/"); String instrumentName = stripped[0] + stripped[1]; Calendar now = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
String nowYear = "" + now.get(Calendar.YEAR); String nowMonth = "00" + (now.get(Calendar.MONTH) + 1); //leading 0 if needed String nowDay = "00" + now.get(Calendar.DAY_OF_MONTH); String nowHours = "00" + now.get(Calendar.HOUR_OF_DAY);
label = instrumentName + "_" + nowDay.substring(nowDay.length() - 2) + // get only the last nowMonth.substring(nowMonth.length()- 2) + // two digits of nowYear + "_" + nowHours.substring(nowHours.length() - 2); // the string return label; } *****************************************
what do I need to change so that each trade's label reflects the date range I choose when running the Historical Tester rather than the current date ? (i.e. 1/1/2004 - 31/12/2008)
Bob M
|
|
|
|
|
tcsabina
|
Post subject: Re: Historical Tester |
Post rating: 0
|
Posted: Tue 13 Jan, 2015, 09:12
|
|
User rating: 164
Joined: Mon 08 Oct, 2012, 10:35 Posts: 676 Location: NetherlandsNetherlands
|
You could try to use the date of the last formed candle, or the date of the last tick at the time of order submission.
Use the onTick(), onBar() functions to create the label, and use the bar/tick that comes with these functions to get the date of the bar/tick.
|
|
|
|
|
us_copiosus
|
Post subject: Re: Historical Tester |
Post rating: 0
|
Posted: Tue 13 Jan, 2015, 09:53
|
|
User rating: 2
Joined: Fri 02 Mar, 2012, 22:08 Posts: 200 Location: New Zealand, Dunedin
|
|
|
|
|
us_copiosus
|
Post subject: Re: Historical Tester |
Post rating: 0
|
Posted: Tue 13 Jan, 2015, 19:56
|
|
User rating: 2
Joined: Fri 02 Mar, 2012, 22:08 Posts: 200 Location: New Zealand, Dunedin
|
In the onBar function, I have the following code
// set current time in milliseconds Calendar calendar2 = Calendar.getInstance(TimeZone.getTimeZone("GMT")); calendar2.setTimeInMillis(askBar.getTime()); int year2 = calendar2.get(Calendar.YEAR); int month2 = calendar2.get(Calendar.MONTH); int day2 = calendar2.get(Calendar.DAY_OF_MONTH); int day_of_week2 = calendar2.get(Calendar.DAY_OF_WEEK); int hour2 = calendar2.get(Calendar.HOUR_OF_DAY);
Am I not getting the date of the last formed candle here ?
Bob M
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|