Timestamps for tick data in replay always 00 seconds.

Questions about MultiCharts .NET and user contributed studies.
AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 23 Sep 2013

[IOGMode(IOGMode.Enabled)]
...
protected override void CalcBar(){

Output.WriteLine(Bars.Time[0]);
...


I then replay tick-by-tick, but the timestamps always show e.g. 15:29:00 for every tick between 15:29-15:30. How do I get the second timestamp for each tick?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 23 Sep 2013

I then replay tick-by-tick, but the timestamps always show e.g. 15:29:00 for every tick between 15:29-15:30. How do I get the second timestamp for each tick?
I'm not 100% sure how it works for replay, but I thought you'll need to enable the option 'Enable access to intra-bar time for calculation in intra-bar order generation mode' from the Backtesting tab of the Strategy Properties. See point 6 from this page.

AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 24 Sep 2013

"Bar Magnifier is unavailable during data playback"

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 24 Sep 2013

If you format the DateTime string with millisecond output, it does work in Replay:

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;

namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class TimestampTickData : SignalObject
{
private IOrderMarket buy_order;

public TimestampTickData(object _ctx):base(_ctx){}

protected override void Create()
{
Output.Clear();
}

protected override void StartCalc()
{
}

protected override void CalcBar()
{
Output.WriteLine(Bars.Time[0].ToString("HH:mm:ss.fff"));
}
}
}
Gives as output:

Code: Select all

09:13:25.948
09:13:26.088
09:13:26.237
09:13:26.260
09:13:26.270
09:13:26.313
09:13:26.447
09:13:26.456
09:13:26.508
09:13:26.576
09:13:26.617
09:13:26.853

AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 24 Sep 2013

Thanks!
Hmmn, this must be the way I have something setup, as my output on tick-by-tick replay looks like:

15:35:00.000
15:35:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:37:00.000
15:37:00.000
15:37:00.000
15:37:00.000
15:38:00.000
.....

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 24 Sep 2013

Thanks!
Hmmn, this must be the way I have something setup, as my output on tick-by-tick replay looks like:

15:35:00.000
15:35:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:36:00.000
15:37:00.000
15:37:00.000
15:37:00.000
15:37:00.000
15:38:00.000
.....
Hm, odd. It looks like you don't even have second data, let alone millisecond data.

Do you have tick data for that selected symbol?

I tested it on a 250 tick bar chart, with the Replay set to 'tick by tick'.

AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 24 Sep 2013

Ah yes, I just realised the reason for my confusion.

My chart is on minute data, but I am replaying tick-by-tick. However, I would like to know the timestamp for seconds, for each tick, but from a minute chart.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 24 Sep 2013

Ah yes, I just realised the reason for my confusion.

My chart is on minute data, but I am replaying tick-by-tick. However, I would like to know the timestamp for seconds, for each tick, but from a minute chart.
You're right, on a minute chart it doesn't display seconds nor milliseconds.

I got this on the same symbol (same data) but with a five minute chart (with data replay set to 'tick by tick'):

Code: Select all

03:05:00.000
03:05:00.000
03:05:00.000
03:05:00.000
03:05:00.000
03:05:00.000
03:05:00.000
03:05:00.000
And if the chart is switched to a 300 second chart (which is build out of ticks), second and millisecond data is still not available (with data replay set to 'tick by tick'):

Code: Select all

07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
07:35:00.000
So apparently, it only seems to work on tick charts. Perhaps it's data source dependent? Otherwise I think it would be beneficial if this behaviour can be changed, @MultiCharts Support.
Last edited by JoshM on 24 Sep 2013, edited 1 time in total.

AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 24 Sep 2013

Is there any sort of workaround? I could really do with second timestamps for tracking purposes....

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 24 Sep 2013

Is there any sort of workaround? I could really do with second timestamps for tracking purposes....
If you're backtesting your strategy, you could use

Code: Select all

Bars.BarUpdateTime.ToString("HH:mm:ss.fff")
In combination with that Bar Magnifier setting I mentioned above. (That should work)

If you're autotrading your strategy, you could use

Code: Select all

DateTime.Now.ToString("HH:mm:ss.fff")
to get the current computer time. (Or use the Bars.StatusLine.Time, but that does not include milliseconds - only seconds).

--------------
@MultiCharts Support, I noticed that second and millisecond timestamps also aren't available when the strategy is run on real-time data (when the chart is a minute chart), while on tick charts the above code runs as expected. So this limitation is not only with the Data Replay.

This limitation probably stems from the original MultiChart, where Time_s returns the closing time of the bar. However, as the above shows, this is also limiting.

Could we get a DateTime property that returns the time of the last tick in real-time data and Data Replay calculation? That would be very useful.

The already existing Bars.BarUpdateTime could be used for this, so that it will always return the DateTime with milliseconds; in backtesting with Bar Magnifier, in Data Replay, and in real-time calculation. The Bars.Time[0] can then be used to get the closing time of the bar (as it is now).

-------------------
Issue #2:
Speaking of a workaround, I thought that retrieving the Status Line timestamp will include the milliseconds (as it is displayed with milliseconds on the chart). But that doesn't work:

250 tick chart on real-time data:

Code: Select all

using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using ATCenterProxy.interop;

namespace PowerLanguage.Strategy
{
[IOGMode(IOGMode.Enabled)]
public class TimestampTickData : SignalObject
{
public TimestampTickData(object _ctx):base(_ctx){}

protected override void CalcBar()
{
Output.WriteLine("Bars.Time: {0}, Bars.BarUpdateTime: {1}, Bars.StatusLine.Time: {2}",
Bars.Time[0].ToString("HH:mm:ss.fff"),
Bars.BarUpdateTime.ToString("HH:mm:ss.fff"),
Bars.StatusLine.Time.ToString("HH:mm:ss.fff"));
}
}
}
Gives:

Code: Select all

Bars.Time: 13:57:33.506, Bars.BarUpdateTime: 13:57:33.506, Bars.StatusLine.Time: 13:57:33.000
Bars.Time: 13:57:33.605, Bars.BarUpdateTime: 13:57:33.605, Bars.StatusLine.Time: 13:57:33.000
Bars.Time: 13:57:33.658, Bars.BarUpdateTime: 13:57:33.658, Bars.StatusLine.Time: 13:57:33.000
Bars.Time: 13:57:35.315, Bars.BarUpdateTime: 13:57:35.315, Bars.StatusLine.Time: 13:57:35.000
Bars.Time: 13:57:35.800, Bars.BarUpdateTime: 13:57:35.800, Bars.StatusLine.Time: 13:57:35.000
Bars.Time: 13:57:35.982, Bars.BarUpdateTime: 13:57:35.982, Bars.StatusLine.Time: 13:57:35.000
Bars.Time: 13:57:37.722, Bars.BarUpdateTime: 13:57:37.722, Bars.StatusLine.Time: 13:57:37.000
Bars.Time: 13:57:43.508, Bars.BarUpdateTime: 13:57:43.508, Bars.StatusLine.Time: 13:57:43.000
Bars.Time: 13:57:44.076, Bars.BarUpdateTime: 13:57:44.076, Bars.StatusLine.Time: 13:57:44.000
Bars.Time: 13:57:44.931, Bars.BarUpdateTime: 13:57:44.931, Bars.StatusLine.Time: 13:57:45.000
Bars.Time: 13:57:45.020, Bars.BarUpdateTime: 13:57:45.020, Bars.StatusLine.Time: 13:57:45.000
Bars.Time: 13:57:45.112, Bars.BarUpdateTime: 13:57:45.112, Bars.StatusLine.Time: 13:57:45.000
Bars.Time: 13:57:45.208, Bars.BarUpdateTime: 13:57:45.208, Bars.StatusLine.Time: 13:57:45.000
Bars.Time: 13:57:45.587, Bars.BarUpdateTime: 13:57:45.587, Bars.StatusLine.Time: 13:57:45.000
Bars.Time: 13:57:45.906, Bars.BarUpdateTime: 13:57:45.906, Bars.StatusLine.Time: 13:57:45.000
Bars.Time: 13:57:46.141, Bars.BarUpdateTime: 13:57:46.141, Bars.StatusLine.Time: 13:57:46.000
Bars.Time: 13:57:46.437, Bars.BarUpdateTime: 13:57:46.437, Bars.StatusLine.Time: 13:57:46.000
Bars.Time: 13:57:49.335, Bars.BarUpdateTime: 13:57:49.335, Bars.StatusLine.Time: 13:57:49.000
Bars.Time: 13:57:50.707, Bars.BarUpdateTime: 13:57:50.707, Bars.StatusLine.Time: 13:57:50.000
Bars.Time: 13:57:50.839, Bars.BarUpdateTime: 13:57:50.839, Bars.StatusLine.Time: 13:57:50.000
Bars.Time: 13:57:51.705, Bars.BarUpdateTime: 13:57:51.705, Bars.StatusLine.Time: 13:57:51.000
Bars.Time: 13:57:51.736, Bars.BarUpdateTime: 13:57:51.736, Bars.StatusLine.Time: 13:57:51.000
Bars.Time: 13:57:52.031, Bars.BarUpdateTime: 13:57:52.031, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:52.325, Bars.BarUpdateTime: 13:57:52.325, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:52.412, Bars.BarUpdateTime: 13:57:52.412, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:52.528, Bars.BarUpdateTime: 13:57:52.528, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:52.613, Bars.BarUpdateTime: 13:57:52.613, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:52.712, Bars.BarUpdateTime: 13:57:52.712, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:52.924, Bars.BarUpdateTime: 13:57:52.924, Bars.StatusLine.Time: 13:57:52.000
Bars.Time: 13:57:53.007, Bars.BarUpdateTime: 13:57:53.007, Bars.StatusLine.Time: 13:57:53.000
Bars.Time: 13:57:53.125, Bars.BarUpdateTime: 13:57:53.125, Bars.StatusLine.Time: 13:57:53.000
Bars.Time: 13:57:53.427, Bars.BarUpdateTime: 13:57:53.427, Bars.StatusLine.Time: 13:57:53.000
Bars.Time: 13:57:54.183, Bars.BarUpdateTime: 13:57:54.183, Bars.StatusLine.Time: 13:57:54.000
Bars.Time: 13:57:54.420, Bars.BarUpdateTime: 13:57:54.420, Bars.StatusLine.Time: 13:57:54.000
Bars.Time: 13:57:56.514, Bars.BarUpdateTime: 13:57:56.514, Bars.StatusLine.Time: 13:57:56.000
Why isn't the Status Line accessible in milliseconds, or am I doing it wrong?

AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 24 Sep 2013

Thanks a lot!

Just to clarify, for myself as much as other people:

Bars.BarUpdateTime - provides second/millisecond timestamps on a e.g. minute chart. We need to use the Bar Magnifier and "Enable access to intra-bar time calculation in Intra-Bar Order Generation mode."

However, Bars.BarUpdateTime does not provide second/millisecond timestamps in replay mode.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 24 Sep 2013

A) There seems no way to get the time of the last real-time trade (since Bars.Time[0] gives the bar closing time on a time-based chart).

B) The Status Line Time property does not include milliseconds.

AntiMatter
Posts: 60
Joined: 03 Mar 2011
Has thanked: 9 times
Been thanked: 2 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby AntiMatter » 24 Sep 2013

Hello AntiMatter,

This issue has been confirmed. It will be resolved in MultiCharts .NET 8.8 Beta 1.
Out of interest, where can I find/download the latest beta?

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 24 Sep 2013

Out of interest, where can I find/download the latest beta?
On the download page (after it's available, of course). The link to this page can be found in the links at the top of every page: MultiCharts .NET --> Download.

New beta versions will normally be communicated on the forum and the blog. The blog will also have the changelog for the new version.

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Timestamps for tick data in replay always 00 seconds.

Postby Henry MultiСharts » 25 Sep 2013

Bars.BarUpdateTime - provides second/millisecond timestamps on a e.g. minute chart. We need to use the Bar Magnifier and "Enable access to intra-bar time calculation in Intra-Bar Order Generation mode." However, Bars.BarUpdateTime does not provide second/millisecond timestamps in replay mode.
That is correct. Bars.BarUpdateTime is a feature for Bar Magnifier only. It works disregard the "Enable access to intra-bar time calculation in Intra-Bar Order Generation mode" option.
A) There seems no way to get the time of the last real-time trade (since Bars.Time[0] gives the bar closing time on a time-based chart).
Could we get a DateTime property that returns the time of the last tick in real-time data and Data Replay calculation? That would be very useful.
That is correct, unfortunately there is no way to do that at the moment. Please submit a feature request to the Project Management of our web site so other users can vote for it: https://www.multicharts.com/pm/
B) The Status Line Time property does not include milliseconds.
This issue has been confirmed. It will be resolved in MultiCharts .NET 8.8 Beta 1.

User avatar
JoshM
Posts: 2195
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1544 times
Been thanked: 1565 times
Contact:

Re: Timestamps for tick data in replay always 00 seconds.

Postby JoshM » 25 Sep 2013

Thanks Henry.
A) There seems no way to get the time of the last real-time trade (since Bars.Time[0] gives the bar closing time on a time-based chart).
Could we get a DateTime property that returns the time of the last tick in real-time data and Data Replay calculation? That would be very useful.
That is correct, unfortunately there is no way to do that at the moment. Please submit a feature request to the Project Management of our web site so other users can vote for it: https://www.multicharts.com/pm/
I've added a feature request here:
Please vote for it if you also like to see this implemented. Thanks. :)


Return to “MultiCharts .NET”