Indicators repeated an extra time on each new bar

Questions about MultiCharts and user contributed studies.
janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Indicators repeated an extra time on each new bar

Postby janus » 11 Jul 2010

I'm still using v5.5 of MC. I'm seeing my indicators that have "Update on every tick" enabled, are being executed twice at the start of each new bar. This can be shown by printing the reserved word barstatus, which shows the following results. Has this been fixed in 6.0?

1
1
1
2 <-- end of a bar
0 <-- start of next bar
0 <-- repeated
1
1
1

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 11 Jul 2010

if you post your code and settings,
we can use the same code/setting to make a print out for you.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 11 Jul 2010

if you post your code and settings,
we can use the same code/setting to make a print out for you.
I see it with just this simple study:

if LastBarOnChart_s then print (barstatus);

Of course the study is set to update on every tick. The chart's resolution is 1 minute.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 11 Jul 2010

I have modified the code:

Code: Select all

if LastBarOnChart_s then print (currenttime_s, barstatus);
I am using MC Version 6.0 Beta 4 (Build 3445)

this is the print out from KSU0 at 1 min bar interval:
211350.00 1.00
211353.00 1.00
211400.00 1.00
211400.00 2.00
211400.00 0.00
211400.00 0.00
211401.00 1.00
211402.00 1.00
211402.00 1.00

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 11 Jul 2010

Thanks. So the bug is not fixed so I'll have to code around it. I know how but I shouldn't have to in the first place. Oh well. :(

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 11 Jul 2010

here's another print out, with another modified code:

Code: Select all

if LastBarOnChart_s then print (currenttime_s, barstatus, c, ticks);

this print out is on KSU0 15 sec bar interval:
212325.00 1.00 225.80 145.00
212327.00 1.00 225.85 150.00
212328.00 1.00 225.80 151.00
212330.00 2.00 225.80 151.00 <-- barstatus=2, same volume count
212330.00 0.00 225.80 16.00
212330.00 0.00 225.80 16.00 <-- duplicate barstatus=0
212331.00 1.00 225.80 20.00
212332.00 1.00 225.75 21.00
212336.00 1.00 225.75 41.00
212337.00 1.00 225.75 170.00
212337.00 1.00 225.75 171.00
212338.00 1.00 225.80 176.00
212339.00 1.00 225.80 181.00
212339.00 1.00 225.80 186.00
212340.00 1.00 225.80 191.00
212342.00 1.00 225.80 193.00
212343.00 1.00 225.80 195.00
212344.00 1.00 225.80 196.00
212345.00 1.00 225.75 197.00
212346.00 2.00 225.75 197.00 <-- barstatus=2, same volume count
212346.00 0.00 225.80 5.00
212346.00 0.00 225.80 5.00 <-- duplicate barstatus=0
212347.00 1.00 225.75 47.00
212348.00 1.00 225.75 49.00
212348.00 1.00 225.75 50.00
212349.00 1.00 225.75 54.00
212351.00 1.00 225.75 55.00
212352.00 1.00 225.75 56.00
212352.00 1.00 225.75 57.00
212353.00 1.00 225.75 61.00
212356.00 1.00 225.75 62.00
212356.00 1.00 225.80 68.00
212357.00 1.00 225.80 74.00
212358.00 1.00 225.80 75.00
212359.00 1.00 225.75 76.00
212359.00 1.00 225.80 77.00
212400.00 1.00 225.80 78.00
212400.00 2.00 225.80 78.00 <-- barstatus=2, same volume count
212400.00 0.00 225.75 1.00
212400.00 0.00 225.75 1.00 <-- duplicate barstatus=0
212405.00 1.00 225.75 2.00
212405.00 1.00 225.75 3.00
212406.00 1.00 225.75 5.00
212407.00 1.00 225.75 232.00
212408.00 1.00 225.70 236.00
212409.00 1.00 225.70 238.00
212410.00 1.00 225.75 248.00
212410.00 1.00 225.70 249.00
212411.00 1.00 225.70 250.00
212414.00 1.00 225.70 251.00
212414.00 1.00 225.70 252.00
212415.00 1.00 225.70 254.00
212416.00 2.00 225.70 254.00 <-- barstatus=2, same volume count
212416.00 1.00 225.75 4.00 <--- note no barstatus=0
212416.00 1.00 225.75 4.00
212416.00 1.00 225.70 5.00
212417.00 1.00 225.70 6.00

looks like barstatus=0 was printed twice, but no addition to the volume.

.
Last edited by TJ on 12 Jul 2010, edited 1 time in total.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 11 Jul 2010

Yes, I noticed that too - occasionally there is no 0. I don't understand why it's not recognised these two bugs are major ones as they will have a significant impact on studies that rely on the barstatus value. I'm certain this has been flagged some time ago and I'm disappointed it's still not fixed.

SUPER
Posts: 646
Joined: 03 Mar 2007
Has thanked: 106 times
Been thanked: 84 times

Postby SUPER » 12 Jul 2010

It needs to be fixed ASAP

I think "bowlesj3" had also mentioned about it in one of his threads.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 12 Jul 2010

It needs to be fixed ASAP

I think "bowlesj3" had also mentioned about it in one of his threads.
I agree. I just coded a function to check whether a tick update is real or not. To take into the two bugs shown above, the code is so complex it's not funny. I'll test it some more before posting it.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 12 Jul 2010

The other thing you will notice is when the barstatus = 2 the tick is a repeat of the the previous one as shown by the same volume figure. So, I've simplified my routine to check when the current and previous values of barstatus are the same and the current and previous volume counts are the same (the previous values are stored in intrabarpersit variables). When both conditions are satisfied, I will treat the tick update as a repeat and so ignore it in some of my studies. Also, if barstatus = 2 and the current and previous volume counts are the same I will ignore that tick as well. I think this fixes all three issues. Note, all this is pertinent only when the study is set to update on every tick. I think this all works.

User avatar
TJ
Posts: 7740
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2221 times

Postby TJ » 12 Jul 2010

The other thing you will notice is when the barstatus = 2 the tick is a repeat of the the previous one as shown by the same volume figure. So, I've simplified my routine to check when the current and previous values of barstatus are the same and the current and previous volume counts are the same (the previous values are stored in intrabarpersit variables). When both conditions are satisfied, I will treat the tick update as a repeat and so ignore it in some of my studies. Also, if barstatus = 2 and the current and previous volume counts are the same I will ignore that tick as well. I think this fixes all three issues. Note, all this is pertinent only when the study is set to update on every tick. I think this all works.
Good eyes. I did not even see that.
I have updated the notes on my print out to reflect the observation.

kiasom
Posts: 32
Joined: 30 Jun 2010
Has thanked: 49 times
Been thanked: 3 times

Postby kiasom » 12 Jul 2010

... I think this all works.
Yes, if the bug is a stable one... if it's a 'real' bug, or just a 'reporting' one...

Would you mind pasting your code fix here, it will save us all some time. Thanks!

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 12 Jul 2010

... I think this all works.
Yes, if the bug is a stable one... if it's a 'real' bug, or just a 'reporting' one...

Would you mind pasting your code fix here, it will save us all some time. Thanks!
Yes, I will post the code once I'm satisfied it works. I'm almost certain it does but I like to give it a decent run through today.

I'm not sure what you mean by a "reporting bug". Some might say it's not a real bug but simply the way studies are executed around the roll-over from one bar to the next. The issue though is the study is repeated with the same quote field values (OHLC, bid, ask, volume, etc.) under certain conditions, which presents a real problem for studies that perform intrabar computations and order executions. So, extra care must be taken to accommodate those situations. I can very well understand that it would require a major alteration to the way MC functions to "fix" these issues. So, I do not expect nor do I want them to fix them as I'm sure they have other pressing issues on their plate. Longer term though I do wish they rethink how studies are executed. As was discussed on another thread, a suggestion was made that studies be allowed to run at set intervals even when there is no tick update (eg, every 5 seconds). Barstatus could then be expanded so a study can decide to take the appropriate course of action.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 13 Jul 2010

Here is my function (zipped) to check if the latest tick update is real or not. It includes instruction on its use.
Attachments
check_duplicate_tick.zip
(1.84 KiB) Downloaded 124 times

User avatar
Dave Masalov
Posts: 1712
Joined: 16 Apr 2010
Has thanked: 51 times
Been thanked: 489 times

Postby Dave Masalov » 15 Jul 2010

Dear Sirs,

We plan to fix these issues in version 7.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 15 Jul 2010

Dear Sirs,

We plan to fix these issues in version 7.
I'm glad to hear it. I also hope you take seriously the suggestion for and option to trigger a study at regular time intervals.

User avatar
geizer
Posts: 375
Joined: 16 Jun 2008
Has thanked: 40 times
Been thanked: 38 times

Postby geizer » 15 Jul 2010

I also hope you take seriously the suggestion for and option to trigger a study at regular time intervals.
Agree, this will add value to MultiCharts. On the other hand there is finite frequency at which studies can be reliably and consistently triggered, since Windows is Not a Real-Time Operating System - we may be looking at seconds triggering interval, at best.

janus
Posts: 835
Joined: 25 May 2009
Has thanked: 63 times
Been thanked: 104 times

Postby janus » 15 Jul 2010

I agree, Windows is one of the worst operating systems for true real-time and multi-tasking. However, a trigger interval of even 10 seconds is acceptable to get closer to what a human person would do when manually trading intraday where the market is quiet and tick updates can be minutes apart.


Return to “MultiCharts”