|
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.
Filtering days |
filson
|
Post subject: Filtering days |
Post rating: 0
|
Posted: Mon 07 May, 2012, 22:06
|
|
User rating: 0
Joined: Mon 09 Apr, 2012, 23:30 Posts: 14
|
I think I need an explanation of how the time works in JForex. Im running a filter in onBar() on weekends as non valid trading days, like this: if (isValidDay(askBar.getTime(), Calendar.SATURDAY,Calendar.SUNDAY)) { ... }
private boolean isValidDay(long lastTickTime, int ... days) throws JFException { GregorianCalendar gCal = new GregorianCalendar(); gCal.setTimeInMillis(lastTickTime); gCal.setTimeZone(TimeZone.getTimeZone("GMT"));
for (int day: days) { if (day == gCal.get(Calendar.DAY_OF_WEEK)) { print("Bad day! No trade!"+gCal.getTime()); return false; } } return true; } That seems to check out in backtesting. Yet heres what i got running real between sunday/monday night: 2012-05-07 00:00:00 Bad day! No trade!Sun May 06 02:00:00 CEST 2012 And before that: 2012-05-05 13:48:45 Order BUY 10000 EUR/USD @ MKT is sent at 2012-05-05 13:48:45.766 GMT by the strategy "Strategy8_4dfEURUSD": from the local computer Where your server correctly responds with: 2012-05-05 13:48:35 System is currently unavailable. Please try later or contact Support Desk So, from what i understand from the above code, the EA should not be able to get past the isValidDay() check, unless the date embedded in the askBar.getTime() is 1 day "off". Could you verify/explain all this?
|
|
|
|
 |
API Support
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Fri 11 May, 2012, 09:41
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
In the print method local time zone is used to format the time. To be consistent GMT should be used to format time: public String toStr(Long time) { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss") {
{ setTimeZone(TimeZone.getTimeZone("GMT")); } }; return sdf.format(time); }
|
|
|
|
 |
filson
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Sat 12 May, 2012, 21:12
|
|
User rating: 0
Joined: Mon 09 Apr, 2012, 23:30 Posts: 14
|
Thanks for the suggested method but the server is not running past the date line, so I see little explanation for a 26 hour gap. I'd be suspecting a 2 hour gap given the server is on daylight savings time + GMT+1.
Additionally, theres no different enumeration of the days between Calendar and GregorianCalendar, that I've been able to find.
|
|
|
|
 |
API Support
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Tue 15 May, 2012, 09:26
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
summer time trading hours are Sunday 21:00 - Friday 21:00 GMT.
|
|
|
|
 |
filson
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Tue 15 May, 2012, 18:10
|
|
User rating: 0
Joined: Mon 09 Apr, 2012, 23:30 Posts: 14
|
Yes i realize that, only that GMT dont have summer time. So when you query the server for what time it is, itll respond in true GMT times. Or at least such is the ways of Java and by the looks of it, your server too. Anyway, thats not the issue at hand. The thread was started due to this: 2012-05-07 00:00:00 Bad day! No trade!Sun May 06 02:00:00 CEST 2012 Which is a good day discrepancy in the date. Never mind the hour/timezone. And that line came back from the server on a Monday, not a Sunday as the test is reporting. It came from this bit of code that to my knowledge sets the time of the calendar to the tick time and tests if its a Saturday or a Sunday. Not a Monday. And since its on a dayly chart in the onBar() event, i recon something needs to be explained. Why do I get a "Sunday" from the system when the current weekday was a Monday? if (isValidDay(askBar.getTime(), Calendar.SATURDAY,Calendar.SUNDAY)) { ... } private boolean isValidDay(long lastTickTime, int ... days) throws JFException { GregorianCalendar gCal = new GregorianCalendar(); gCal.setTimeInMillis(lastTickTime); gCal.setTimeZone(TimeZone.getTimeZone("GMT")); for (int day: days) { if (day == gCal.get(Calendar.DAY_OF_WEEK)) { print("Bad day! No trade!"+gCal.getTime()); return false; } } return true; }
|
|
|
|
 |
API Support
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Wed 16 May, 2012, 08:19
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
|
|
|
 |
filson
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Fri 18 May, 2012, 21:41
|
|
User rating: 0
Joined: Mon 09 Apr, 2012, 23:30 Posts: 14
|
Have you?
Put the programmer on the line, please. Hes got cargo pants and a t-shirt on. Cant miss him. Its a bad idea to mock you customers and even more so when we somehow have wind up paying you to debug your own software.
|
|
|
|
 |
API Support
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Sat 19 May, 2012, 18:18
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
First of all, we referenced the wiki example, because it is close to what you need and we have tested it to process the weekdays properly. Second, work with dates is java.util functionality not JForex API, hence, if it does not work as you expect then it can't be JForex bug. Third, when you encounter a problem, for more efficient assistance please provide: - Full example strategy and launch scenario. The more concise the strategy, the better.
- Describe the behavior that you find to be wrong. Describe the behavior that you expect instead.
|
|
|
|
 |
filson
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Tue 29 May, 2012, 11:37
|
|
User rating: 0
Joined: Mon 09 Apr, 2012, 23:30 Posts: 14
|
First of all, its not the wiki example thats wrong, but the day you return in JForex. Second, your conclusion is wrong due to "First of all". Third, you have received both code and explanation of what is expected of it.
|
|
|
|
 |
API Support
|
Post subject: Re: Filtering days |
Post rating: 0
|
Posted: Tue 29 May, 2012, 12:05
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
filson wrote: First of all, its not the wiki example thats wrong, but the day you return in JForex. JForex API works neither with days, nor dates. All date values get represented in milliseconds and the way you process them is what makes the difference. Thus you have to make sure you parse the dates properly. filson wrote: Third, you have received both code and explanation of what is expected of it. Thus far we have received a code snippet which has nothing to do with JForex API. Hence, we have received neither a full example strategy nor a precise launch scenario, which makes it impossible to assist you on the matter.
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|