Entry at exact time different with tick or minute bar

Questions about MultiCharts and user contributed studies.
evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Entry at exact time different with tick or minute bar

Postby evdl » 13 Feb 2017

When using this with IOG / Barmagnifier (1tick):

Code: Select all

If Time = 1613 then begin
Buy ("LE") 1 contract next bar market;
end;

If Time = 2130 then begin
Sell ("LX") next bar market;
end;

//(use of Time_s or Time does not make a difference)

it will give a different entry (and exit) when backtesting or in realtime on a minute timeframe. With a tick timeframe it is the same (the next tick).

On the minute chart in backtest, the entry takes place at the opening of next bar (open of 1614). And in realtime it gives the open of 1613. This is only with a minute chart. Normally I use tick charts, so it never occured to me. Now with a minute timeframe, the barmagnifier in backtest does not seem to work for the entry and does not trigger the entry at next tick after hitting 1613 but next minute.

Is this expected behaviour?

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 14 Feb 2017

Did some testing today

If you want to enter a trade, next tick after 9.00:00 in realtime you need to code

Code: Select all

If time = 901 then begin
to match the entry made in realtime and you want the same results in backtest you need to code:

Code: Select all

If time = 900 then begin
With this you can cover both situations:

Code: Select all

If ifflogic(GetAppInfo(aiRealTimeCalc)= 1, (time = 901), (Time = 900) ) then begin
The above is with minute charts.

It seems, with minute charts, there is a difference in using the keyword time between backtest and realtime. With tick charts there is no difference.

That brings up the question which keywords are also behaving differently without logically expecting this when using same keywords on a minute or tick chart.


This is probably related:
viewtopic.php?t=50235

User avatar
ABC
Posts: 633
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: Entry at exact time different with tick or minute bar

Postby ABC » 16 Feb 2017

evdl,

this appears to happen only when you check "Enable access to intra-bar time..." in the backtest. In my opinion this shouldn't be expected behavior as this results in the code behaving different in a backtest compared to the same code in realtime and that can be a problem.

Can someone from Multicharts explain if this intended, please?

Regards,

ABC

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 16 Feb 2017

Hello evdl,

This case is being analyzed. We will get back to you with the answer.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 24 Feb 2017

Hi evdl,

With IOG enabled, "next bar" is not the actual bar but next tick (next calc point).

With 1 minute resolution both in backtesting and in realtime it there are more than 1 ticks per minute, orders will be generated and sent intrabar. Here is a short video: https://yadi.sk/d/1Hboipgm3EWuQ4

User avatar
ABC
Posts: 633
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: Entry at exact time different with tick or minute bar

Postby ABC » 24 Feb 2017

Angelina,

can you please elaborate the differences that occur in the above example, when "Enable access to intra-bar time..." is checked versus when it's unchecked (everything else is the same i.e. IOG enabled, bar magnifier with 1 tick resolution, the code, the data etc.)? Why is the execution occurring at 16:14 with "Enable access to intra-bar time..." checked versus 16:13 when it's not checked?

I used a 1 minute chart for @ES# from IQFeed for the test (the times in the example are EST times).

Regards,

ABC

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 27 Feb 2017

Hi evdl,

With IOG enabled, "next bar" is not the actual bar but next tick (next calc point).

With 1 minute resolution both in backtesting and in realtime it there are more than 1 ticks per minute, orders will be generated and sent intrabar. Here is a short video: https://yadi.sk/d/1Hboipgm3EWuQ4
Hi Angelina,

What you are mentioning, is not what is happening. With IOG, barmagnifier set to 1 tick and "Enable access to intra-bar time...", the entry should take place next tick. But this behaviour is not the same in backtest and realtime if you use the same time for entry.

User avatar
ABC
Posts: 633
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: Entry at exact time different with tick or minute bar

Postby ABC » 09 Mar 2017

Hi Angelina,

is there an update to the questions raised in viewtopic.php?t=50519#p125102 and viewtopic.php?t=50519#p125124?

Thank you,

ABC

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 10 Mar 2017

It is still being analyzed. I am expecting an answer for the engineering team.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 30 Mar 2017

Evdl,

Please send us an export of your signal and the workspace it is applied to, so we could test out your environment.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 31 Mar 2017

Hi Angelina,

The signal I use, is in the opening post.

Please try it at your end.

First do a live trade on 1 minute chart on the FDAX with IOG and Barmagnifier on 1 tick and use this code:

Code: Select all

If Time = 1613 then begin // adjust time to a couple of minutes from your current time
Buy ("LE") 1 contract next bar market;
end;
Save the entry price and time of the live trade.

Then do a backtest with the same time on 1 minute chart on the FDAX with IOG and Barmagnifier on 1 tick.

You will see in this example, that the live trade is taken next tick after 161200 (because that is when MC is creating the 1613 timestamp). The bar of 1613 is the bar from 161200 till 161259.

In backtest the trade will be taken the next tick after 161300.

The time keyword in live trading is related to the timestamp mc is creating before the actual time is there. And in backtesting it is related to the actual time you coded. What I would expect is the trade to take place at 1613 in realtime and backtest.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 31 Mar 2017

evdl,

This setup works properly on our end. Can you please check if your PC time is in sync with world time server?

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 01 Apr 2017

Yes, sync of time is automated and is ok.

Both the trades, realtime and backtest, are the same at your side? And you got IOG on, BM on 1 tick and Enable access to intra-bar time?

To be sure, you did the test like this:

For example: your current time is 9:15. Then do a realtime(live) trade with time = 918. After this trade backtest the same code with time = 918.

On my side, the realtime trade is taken on the moment the bar of 918 is created on the chart and that is next tick after the pc clock is 9:17:00. The timestamp of the 918 bar is created, but the bar is still in progress and it is not 9:18:00 yet. But trade already took place.

In backtest the trade is taken the next tick after the bar of 918 is closed, as coded. The realtime trade is taken a minute earlier than in backtest.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 03 Apr 2017

evdl,

Yes, in our tests both trades were the same in backtesting and in realtime. We have managed to reproduce the issue only once, and it happened because PC time was about 3 seconds off.
Would it be possible to demonstrate this behavior through the remote connection? If so, please come to our Live Chat from 6:30 am to 12 pm EST.

User avatar
ABC
Posts: 633
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: Entry at exact time different with tick or minute bar

Postby ABC » 04 Apr 2017

Hi Angelina,

as your are currently looking into this, can you please explain the questions raised in here: viewtopic.php?t=50519#p125102. As the difference is only in using "Enable access to intra-bar time..." once and one time testing without that (everything else is the same!), the cause might be related to what evdl is experiencing (as in his tests "Enable access to intra-bar time..." is also checked according to what he posted).
You should be able to reproduce this easily with the information and test code here in this thread.

Edit: To clarify it further, you can see the different outcome in a backtest, just use the code from post 1, 1 minute chart @ES# from IQFeed (for example), IOG enabled and bar magnifier with 1 tick resolution. The only difference between the two tests should be checking "Enable access to intra-bar time..." for one test and unchecking it for the other.

Regards,

ABC
Last edited by ABC on 04 Apr 2017, edited 1 time in total.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 04 Apr 2017

Did the tests again today.

What ABC also noticed and what is happening is this:

For example: time = 915 with IOG on, BM(1 tick) and "Enable access to intra-bar time" checked, Then there will be a difference between backtest and realtime as described above.

When using the same setting but now with "Enable access to intra-bar time" UNchecked, Then backtest and realtime is the same. BUT the time the trade is taking is 1 minute earlier, at next tick after actual time 9:14:00 when the timestamp of 915 is created. So when using time = 915 it is not taking the trade at the actual time 9:15:00.

There are two issues with this. The first one is the different behaviour in backtest and realtime when "Enable access to intra-bar time" is checked and UNchecked. This will cause different result in realtime compared to backtest.

The second issue is that when you use the time keyword with a certain time, this will not use this coded time as the trigger to do something at that actual time, but triggers something at the opening of the bar of 915, which is actual time 9:14:00. One would expect to trigger something at the exact actual time 9:15:00. MC uses EOB (end of bar) as time reference. With using the time keyword you should get the close price of the 915 bar and not the open, because that will not match the actual time. Once you know, you can use barstatus(1) = 2 to get the close and match the coded time, although it is not intuitive. And do all keywords act the same?

I don't have screenrecorder software, so I can't make a video of this. Will go to live chat today to demonstrate this to MC.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 04 Apr 2017

Just did a live chat with Angelina and demonstrated the issue. MC will investigate and will post an update.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 07 Apr 2017

Dear users,

Let's take this script as an example:

Code: Select all

If Time = 1613 then begin
Buy ("LE") 1 contract next bar market;
end;
IOG is on, Bar Magnifier - 1 tick precision.

So, there are three possible scenarios:

Scenario #1: realtime calculation. "Enable access to intra-bar time" mode does not affect the process.
Current bar: bar with 1-minute resolution and 16:13 timestamp (bar closing time).
Trade is taken at about 16:12:01 - first ticks of the bar with 16:13 time stamp (bar closing time).

Scenario #2: backtesting, "Enable access to intra-bar time" is off.
Current bar: bar with 1-minute resolution and 16:13 timestamp.
In this situation trade is also taken at first ticks of the current bar.

Scenario #3: backtesting, "Enable access to intra-bar time" is on.
Current bar: bar with 1-tick resolution (Bar Magnifier precision).
Trade is generated on the first tick that satisfies the condition, and executed on the next one. Time of the order in this case would be 16:13+, therefore it is displayed on 16:14 bar.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 07 Apr 2017

Angelina, there are not 3 but 4 scenarios and the scenario you forgot is causing the problem:

"Enable access to intra-bar time" is off. Backtest and realtime = 2 scenarios ---> realtime and backtest are the same --> no problem
"Enable access to intra-bar time" is on. Backtest and realtime = 2 scenarios ---> realtime and backtest are NOT the same --> problem

That is what I demonstrated you and is a problem for everyone that uses strategies with "Enable access to intra-bar time" is on. There is no way you can get the same results in backtest in realtime and vice versa.

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 07 Apr 2017

Actually, there are still three, as this option affects backtesting only.
"Enable access to intra-bar time" option makes intra-bar time (timestamps of the detailed data series selected in Bar Magnifier) available from PowerLanguage script (Date, Time and Time_s keywords).

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 07 Apr 2017

Honestly, I'm trying to get my head around this.

Been using "Enable access to intra-bar time" for some time now, 6 years, Mainly in tick charts, but the problem is the same. Made a great effort to get the backtest and realtime as close as possible. Never got the same results. But I thought that was part of life.

So what you are saying is that MC by design created a button to create a situation that only works in backtesting and does not have the same behaviour in realtime?

The option "Enable access to intra-bar time" only works in backtest. If you say 3 scenarios, ok. That is not the problem in my opinion.

Can we agree, that creating difference between backtest and realtime is not what a typical user wants.

What is the use for this setting, if you create different results with it. How can we use this?

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 14 Apr 2017

While awaiting the answer of MC about the use of the feature "Enable access to intra-bar time".

In the meantime, I would like to ask if there are MC users that have a purpose for this feature. If or how they use this. Do they see the described issue as a problem or not.

Thanks for any response!

User avatar
Angelina MultiСharts
Posts: 260
Joined: 28 Dec 2016
Has thanked: 28 times
Been thanked: 66 times

Re: Entry at exact time different with tick or minute bar

Postby Angelina MultiСharts » 14 Apr 2017

Sorry for the delay in responding.

Bar Magnifier feature allows detalizing base series resolution into a more detailed one for more precise backesting. Before introducing "Enable access to intra-bar time" only the prices of the detailed data series were available from the script, but one could not refer to the timestamps of detailed bars. So, after numerous requests from our users we have added this option.

We do not have a luxury of adding a feature that is not requested/anticipated by MC users. We also try to give our users a variety of options to adjust the platform to a specific trading style. Right now, there is a solution for those who need detailed bar timestamp and for those who don't. And which one to use depends entirely on the strategy/setup/preferences etc.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 123 times

Re: Entry at exact time different with tick or minute bar

Postby evdl » 15 Apr 2017

I known I'm not the only one with inquiries. So thank you for the response.

Reading between the lines, it seems hard for MC to acknowledge issues with MC. Not only in this topic. Although MC does a great job, there are ofcourse issues with this software. As any software has. I don't want to convince you of my opinion of a feature. I demonstrated the issue and it is a fact there is an inconsistancy.

Not really sure if your reply is an answer to my question. Because my question was about the usefullness of this feature and how to use it.
You can not have a feature that is creating difference between backtest and realtime. I doubt that this is requested by anyone. The whole idea of backtesting is to find a trading plan, you can use realtime. Every feature that can be used in backtesting should be reproducable in realtime. Otherwise it has no purpose and is not a solution we can use IMO.

This has nothing to do with a specific trading style or luxury of adding user specific features. The point is, it looks like there is a solution in place for people who want access to detailed bartime stamps, but that does not do what you would expect in realtime. Namely the same behaviour as in backtest and vice versa. Therefor not useable. Or you know a way of using this?

The inconsistencies in MC, also with this feature, is something that is not good and should be addressed sometime. Also in the wiki, so users get a heads up about all the particulars of the software. Without first having to gain years of experience with the software to find out. Better to be transparant about it. And ideally prevent it.

The issue/inconsistancy is probably not easy to solve. I understand this. Will try to work around it (although I doubt if this is possible) or not use the feature anymore.

McGeorge
Posts: 26
Joined: 22 Jun 2018
Has thanked: 8 times
Been thanked: 1 time

Re: Entry at exact time different with tick or minute bar

Postby McGeorge » 28 Feb 2019

Sorry for the delay in responding.

Bar Magnifier feature allows detalizing base series resolution into a more detailed one for more precise backesting. Before introducing "Enable access to intra-bar time" only the prices of the detailed data series were available from the script, but one could not refer to the timestamps of detailed bars. So, after numerous requests from our users we have added this option.

We do not have a luxury of adding a feature that is not requested/anticipated by MC users. We also try to give our users a variety of options to adjust the platform to a specific trading style. Right now, there is a solution for those who need detailed bar timestamp and for those who don't. And which one to use depends entirely on the strategy/setup/preferences etc.

To everyone who reads this post, I share the same frustration as the users creating and replying to this post. I looked into Project Management and found that another user had raised a feature request https://www.multicharts.com/pm/public/m ... mment_8718 concerning this issue. In my opinion, it is totally unacceptable to generate different outcome between backtesting and playback/real-time, just because the time keywords return different values when intra-bar time is enabled in signal setting. If a user wants to get the time of a tick, he should use a different keyword (e.g. DateTime_Tick, Time_Tick, etc., rather than enabling intra-bar time. Such practice is so important for ensuring consistency in outcome between backtesting and playback/real-time and should not be compromised. As keyword accessing time of tick is currently not available in PowerLangauge. It is badly needed for MC to create these new keywords.

Please everyone help vote in Project Management https://www.multicharts.com/pm/public/m ... mment_8718 to make the new feature happen.

Thanks,
McGeorge

User avatar
Anna MultiCharts
Posts: 457
Joined: 14 Jul 2017
Has thanked: 31 times
Been thanked: 112 times

Re: Entry at exact time different with tick or minute bar

Postby Anna MultiCharts » 05 Mar 2019

Hello, McGeorge!

Our developers have considered this feature request and new keywords for returning the tick timestamp/last bar update time might be added in future versions of MultiCharts.

User avatar
ABC
Posts: 633
Joined: 16 Dec 2006
Has thanked: 120 times
Been thanked: 358 times
Contact:

Re: Entry at exact time different with tick or minute bar

Postby ABC » 06 Mar 2019

Hello Anna,

if possible these keywords should also be available in real time i.e. we need the ability to access the current time of a tick within a real time bar (regardless of the bar type).

Regards,

ABC
Hello, McGeorge!

Our developers have considered this feature request and new keywords for returning the tick timestamp/last bar update time might be added in future versions of MultiCharts.


Return to “MultiCharts”