|
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.
How to get current jforex platform time? |
fxdiler
|
Post subject: How to get current jforex platform time? |
Post rating: 0
|
Posted: Fri 18 Apr, 2014, 08:40
|
|
User rating: 7
Joined: Thu 05 Sep, 2013, 12:43 Posts: 56 Location: Russian Federation, Tomsk
|
How to get current jforex platform time? When I use Calendar or Date class the time can be different between time you can see in right top corner. Difference can reach 2-5 seconds. I think it is because Calendar or Date class use system time of my computer. But I need to get current jforex platform time in milliseconds.
|
|
|
|
|
hebasto
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Fri 18 Apr, 2014, 09:02
|
|
User rating: 96
Joined: Mon 09 Sep, 2013, 07:09 Posts: 287 Location: Ukraine, SHostka
|
public void onTick(Instrument instrument, ITick tick) throws JFException { long platformTime = tick.getTime(); }
|
|
|
|
|
fxdiler
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Fri 18 Apr, 2014, 09:06
|
|
User rating: 7
Joined: Thu 05 Sep, 2013, 12:43 Posts: 56 Location: Russian Federation, Tomsk
|
hebasto wrote: public void onTick(Instrument instrument, ITick tick) throws JFException { long platformTime = tick.getTime(); } It is not good idea because delay between ticks can be some seconds. Using this code I will get not actual time.
|
|
|
|
|
hebasto
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Fri 18 Apr, 2014, 10:10
|
|
User rating: 96
Joined: Mon 09 Sep, 2013, 07:09 Posts: 287 Location: Ukraine, SHostka
|
fxdiler wrote: It is not good idea because delay between ticks can be some seconds. Using this code I will get not actual time. That code doesn't use instrument filter so time will be as precise as possible.
|
|
|
|
|
fxdiler
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Fri 18 Apr, 2014, 10:59
|
|
User rating: 7
Joined: Thu 05 Sep, 2013, 12:43 Posts: 56 Location: Russian Federation, Tomsk
|
hebasto wrote: That code doesn't use instrument filter so time will be as precise as possible. If strategy subscribed only to one instrument it does not solve the problem. And I don't need to subscribe strategy to other instruments which I don't use. I need correct solve how to get current jforex platform time in milliseconds.
|
|
|
|
|
hashcat
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 1
|
Posted: Sun 20 Apr, 2014, 15:20
|
|
User rating: 1
Joined: Mon 27 Jan, 2014, 14:03 Posts: 7 Location: TaiwanTaiwan
|
Assume that you have 'long baseServerTime' and 'long recordLocalTime' in your class: public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException { if (period.equals(Period.ONE_HOUR)){ baseServerTime = bidBar.getTime() + period.getInterval(); // I'm not sure whether 'bidBar.getTime()' is open time or not recordLocalTime = System.currentTimeMillis(); } }
Then the server time can be calculated by System.currentTimeMillis() - recordLocalTime + baseServerTime;
|
|
|
|
|
fxdiler
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Mon 19 May, 2014, 19:08
|
|
User rating: 7
Joined: Thu 05 Sep, 2013, 12:43 Posts: 56 Location: Russian Federation, Tomsk
|
There is another questions: how to get current jforex platform time without subscribe to any instrument? I found a next way but it works only if strategy run from JForex SDK (from NetBeans, for example) com.dukascopy.dds2.greed.gui.component.ApplicationClock.getInstance().getTime() or com.dukascopy.dds2.greed.gui.component.ApplicationClock.getInstance().getServerTime() return current platform time in milliseconds. Anybody know how to write code that this work from strategy in JForex platform?
|
|
|
|
|
API Support
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Tue 20 May, 2014, 09:19
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
The functionality is not part of JForex-API, thus: - it is subject to change with following JForex-SDK releases, which would make your code fail to compile,
- it is no accessible from strategies.
Therefore please make use of the previously suggested solutions.
|
|
|
|
|
hyperscalper
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Tue 20 May, 2014, 15:44
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
For time synchronization on your local platform, I recommend Meinberg NNTP service. You will never again have to worry about time synchronization on your local system.
Otherwise, your closest to that time would be to get the time of the most recent onTick event.
Then just format it as UTC or GMT time using standard Java.
HyperScalper
|
|
|
|
|
hyperscalper
|
Post subject: Re: How to get current jforex platform time? |
Post rating: 0
|
Posted: Tue 20 May, 2014, 15:48
|
|
User rating: 98
Joined: Mon 23 Jul, 2012, 02:02 Posts: 656 Location: United States, Durham, NC
|
hebasto wrote: fxdiler wrote: It is not good idea because delay between ticks can be some seconds. Using this code I will get not actual time. That code doesn't use instrument filter so time will be as precise as possible. Perhaps for every time that you "grab" the onTick time, as suggested, you *also* grab your local system time. Then you can calculate a Delta Time from your current system time as a precise indication of the "true" time ? You could even average that Delta figure to get rid of "jitter" effects. Network latencies are also a consideration you could think about. System.currentTimeMillis() may be accurate to only 10 msecs, but I think now you can get accuracy down to the msec on the newer Java runtimes. HyperScalper
|
|
|
|
|
|
Pages: [
1
]
|
|
|
|
|