Bad behaviour of volume on charts based on seconds data

Questions about MultiCharts and user contributed studies.
User avatar
CrazyNasdaq
Posts: 265
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 78 times
Been thanked: 80 times

Bad behaviour of volume on charts based on seconds data

Postby CrazyNasdaq » 14 Oct 2011

I've reported this issue in this post on the PM section
http://www.multicharts.com/pm/viewissue.php?issue_no=MC-658

I've find a bug in MC 7.0.4510.400 official release about volume calculation on charts based on "seconds" data.
I've coded a very simple code about Volume Acceleration which sums the volume of the last N seconds but it gives me always too big values even when the market is very slow and poor of volume. I've plotted the same indicator on a 1 minute chart and set the same time lap (5 minutes or 300 seoncds). The indicator always gives me 2 different values. How could it be ?
This is the code of Volume acceleration plotted on a 1 second chart (300 seconds LapTime) or on a 1 minute chart ( 5 minutes LapTime):

Code: Select all

Code:

Inputs:
laptime(300);
value1 = summation(volume,laptime);
Plot1(value1, "VolumeAcceleration");


it's the same if you use ticks instead of "volume" with checked "build volume on "tade volume"

This is the picture of my chart
http://img192.imageshack.us/img192/4976/bugvolume.gif
How could it be those differences ?
Please make a deep control on Volume calculation about charts with differents resolution.
The indicator plotted different values and it's not possible on the same Time Lap. How could it be ?
The volume calculation gives high values even during poor periods of volume and this demonstrate a BUG on the volume calculation.
Please check it.
Thanks

bowlesj3
Posts: 2028
Joined: 21 Jul 2007
Has thanked: 174 times
Been thanked: 405 times

Re: Bad behaviour of volume on charts based on seconds data

Postby bowlesj3 » 14 Oct 2011

It sounds a bit like this thread but I am not sure. Bruce Devault tried to explain that the 1 minute bars and 10 second bars are actually a different data source (and it is the same everywhere). I went ahead and wrote a script to find the differences out of curiosity. For the way I trade it does not have a major impact.

viewtopic.php?f=1&t=7273&p=32055&hilit=minute#p32055
These users thanked the author bowlesj3 for the post (total 2):
TJJoshM

User avatar
TJ
Posts: 6609
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 971 times
Been thanked: 1912 times

Re: Bad behaviour of volume on charts based on seconds data

Postby TJ » 14 Oct 2011

MultiCharts collects data in 3 fractals:

1. 1 tick
2. 1 minute
3. 1 day

All the chart resolutions are built from these streams.
e.g. a 1 second chart will be built from tick data,
while a 5 minute chart will be built from minute data.

Using your code,
if you apply the indicator to a 1 minute chart with and a laptime of 5,
and 5 minute chart with a laptime of 1,
you will see the volume data are the same.

Conversely,
if you apply the indicator to a 1 second chart with and a laptime of 5,
and 5 second chart with a laptime of 1,
you will see the volume data are the same.

I don't know why the tick volume data are different from the minute data.



[edit] just noticed that Bruce Devault explained the same thing.
These users thanked the author TJ for the post (total 2):
JoshMbowlesj3

User avatar
CrazyNasdaq
Posts: 265
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 78 times
Been thanked: 80 times

Re: Bad behaviour of volume on charts based on seconds data

Postby CrazyNasdaq » 15 Oct 2011

Last night has been a good counselor for me and maybe I've the answer of that difference.
Minute data is built on time based on the PC clock and it collects volume within the same single minute data.
Tick data collects volume based on the event each time there is a trade, so 1 second data works in the same way. The problem is that we don't have trades all seconds and we don't have 1 second bar for each second of a minute, one trade could be after N seconds based on the time stamp of the PC clock at that time which not necessary is the second time after the previous bar, so if you sum volume for N seconds based on a chart with resolution of 1 second, you don't sum the last N seconds volume, but you sum the volume of the last N events recorded on bars of 1 second resolution and the sum of the absolute time could be greater of N seconds you want. This way the sum of volume could be different and could be greater than the actual volume.
The solution is to create a vector of variable dimension and calculate the dimension of that vector every each event, then calculate the volume of that vector on each new event to have the real volume in the last N seconds of absolute time.
Multicharts as many other trading software is not a time based software, but is an event based software, which calculate on each new event.
These users thanked the author CrazyNasdaq for the post (total 2):
TJbowlesj3

bowlesj3
Posts: 2028
Joined: 21 Jul 2007
Has thanked: 174 times
Been thanked: 405 times

Re: Bad behaviour of volume on charts based on seconds data

Postby bowlesj3 » 15 Oct 2011

Multicharts as many other trading software is not a time based software, but is an event based software, which calculate on each new event.


Just incase you are not aware of it, there is a request (with 7 votes so far) to have MC also execute studies based upon time intervals. MC now has a command I have not used yet that can re-execute after X seconds of no ticks. The request below is more powerful in some ways I think. I think the original detail thread has similar features as this new command. Josh points out below that the new command can execute without tick data coming in. This command is not the same as "recalculate" which causes the study to restart basically (that is very useful too).

More methods to execute a study (currently has 7 votes).
https://www.multicharts.com/pm/viewissue ... _no=MC-423

If you can not remember if you voted for this just vote anyway and it will ignore your vote if you already voted (hoping my request for improvements to the bug tracker get done some day).
Last edited by bowlesj3 on 15 Oct 2011, edited 2 times in total.
These users thanked the author bowlesj3 for the post:
CrazyNasdaq

User avatar
JoshM
Posts: 2089
Joined: 20 May 2011
Location: The Netherlands
Has thanked: 1525 times
Been thanked: 1486 times
Contact:

Re: Bad behaviour of volume on charts based on seconds data

Postby JoshM » 15 Oct 2011

Good feature request, more possibilities with coding is always (well, almost always ;)) good - I voted for it.

But..
bowlesj3 wrote:Just incase you are not aware of it, there is a request (with 7 votes so far) to have MC also execute studies based upon time intervals. MC now has a command I have not used yet that can re-execute after X seconds of no ticks. The request below is more powerful in that you could execute specialized scripts on weekends when there is no tick data (I have on example of how to use this in the request comments). (..)

The RecalcLastBarAfter() command also works on weekends and when they're is no tick data. It works when you work with "old" price charts (so no recent data/ticks needed) and when MultiCharts is in "offline" mode. It also doesn't requires that the user is in "Playback mode".

Currently, here it's Saturday, and with the following code...

Code: Select all

if LastBarOnChart_s = true then begin


   Print("Date and time of bar: ", FormatDate("d-M-yyyy", el_datetodatetime(Date)), Spaces(3),
      FormatTime("HH:mm:ss", el_timetodatetime_s(time_s)));
      
   Print(Spaces(3), "Current date and time: ", FormatDate("d-M-yyyy", el_datetodatetime(CurrentDate)), Spaces(3),
      FormatTime("HH:mm:ss", el_timetodatetime_s(currenttime_s)));


   RecalcLastBarAfter(10);

end;

..I get the following output:

Code: Select all

Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:37:05
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:37:15
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:37:25
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:37:35
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:37:45
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:37:55
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:38:06
Date and time of bar: 26-7-2011   14:01:00
   Current date and time: 15-10-2011   14:38:16


Regards,
Josh
These users thanked the author JoshM for the post:
bowlesj3

bowlesj3
Posts: 2028
Joined: 21 Jul 2007
Has thanked: 174 times
Been thanked: 405 times

Re: Bad behaviour of volume on charts based on seconds data

Postby bowlesj3 » 15 Oct 2011

Great, Thanks, I have it in my todo list to try it. I will have to bump it. My original request for a timer was made a lot earlier but probably takes a lot more work since it is more elaborate. However it would save some coding. Both are good to have I think.

By the way, I did not get an error when I gave you thanks. Maybe TJ needs to increase his name length to TJ-Cool or maybe TJ-CoolGlasses (if you can do that).

User avatar
CrazyNasdaq
Posts: 265
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 78 times
Been thanked: 80 times

Re: Bad behaviour of volume on charts based on seconds data

Postby CrazyNasdaq » 15 Oct 2011

Great feature request in the PM. I've voted for it
Add your vote to this request. It would increase the Multicharts capability in a way that no other trading platform actually do now.
http://www.multicharts.com/pm/viewissue.php?issue_no=MC-423

Thanks to bowlesj3

bowlesj3
Posts: 2028
Joined: 21 Jul 2007
Has thanked: 174 times
Been thanked: 405 times

Re: Bad behaviour of volume on charts based on seconds data

Postby bowlesj3 » 15 Oct 2011

I realize that the bug-tracker and maybe the forum itself too are 3rd party software and votes at the link below for these two areas may not get heard, however maybe if there were some votes for the features I requested for the bug tracker in the 2nd post of the thread below we could more easily scan for feature request for MC and the really good requests would get more attention from the MC Staff. At least the MC-Staff could (maybe) pass on our wishes to the 3rd party.


The summary post of bug tracker improvements
viewtopic.php?f=1&t=9252#p43883
Instructions if we want to vote or add a feature.
viewtopic.php?f=1&t=9252

User avatar
Henry MultiСharts
Posts: 8521
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2741 times

Re: Bad behaviour of volume on charts based on seconds data

Postby Henry MultiСharts » 17 Oct 2011

Hello CrazyNasdaq.
There is no bug in volume calculation in MultiCharts.
You are having different calculation results using seconds and minute bars because the symbol does not tick every second.
300 of 1 second bars are summed up, including empty periods, which brings discrepancy in calculation.
You can activate the empty periods on the 1 second chart making a right click on the chart->Format window->X-time scale->Show empty periods.
Please have a look at the screenshot EmptyPeriod.png
If you plot 1 minute and 30 seconds chart for comparison-you can see that the calculation is correct and the same.
Please have a look at the Volume_compare.png screenshot.
Attachments
Volume_compare.png
Volume_compare.png (85.46 KiB) Viewed 408 times
EmptyPeriod.png
EmptyPeriod.png (63.08 KiB) Viewed 405 times
These users thanked the author Henry MultiСharts for the post:
TJ

User avatar
CrazyNasdaq
Posts: 265
Joined: 02 Sep 2009
Location: ITALY
Has thanked: 78 times
Been thanked: 80 times

Re: Bad behaviour of volume on charts based on seconds data

Postby CrazyNasdaq » 17 Oct 2011

Henry Multicharts wrote:Hello CrazyNasdaq.
There is no bug in volume calculation in MultiCharts.
You are having different calculation results using seconds and minute bars because the symbol does not tick every second.
300 of 1 second bars are summed up, including empty periods, which brings discrepancy in calculation.
You can activate the empty periods on the 1 second chart making a right click on the chart->Format window->X-time scale->Show empty periods.
Please have a look at the screenshot EmptyPeriod.png
If you plot 1 minute and 30 seconds chart for comparison-you can see that the calculation is correct and the same.
Please have a look at the Volume_compare.png screenshot.


I've activated the "show empty period" in the chart format, and the chart is different showing the time periods where you don't have trades, but anyway I can't have the real volume traded in the last N seconds because of the "empty periods without trades".
Showing empty periods anyway don't permit me to sum the volume of the last N seconds. The option "show empty periods" doesn't influence the calculation of the indicator.
How can I calculate the volume of the last 300 seconds with a resolution of 1 second and not of the last 300 events ?
How can I refer to a past period as last 300 seconds and sum the volume of the last 300 seconds without reference to the last 300 events instead of last 300 seconds ?
Even if I show the "empty periods", the value of the volume summed is the same as "NOT show Empty periods".
Can you suggest a way ?

Thanks

User avatar
Henry MultiСharts
Posts: 8521
Joined: 25 Aug 2011
Has thanked: 1213 times
Been thanked: 2741 times

Re: Bad behaviour of volume on charts based on seconds data

Postby Henry MultiСharts » 18 Oct 2011

I am sorry if I was not clear.
"Show empty periods" should not make the calculation on 1 sec and 1 min chart the same.
This option demonstrates why the calculation is different in your case.
With this option enabled you can see that the symbol is not traded every second, it has empty periods which cause the difference in calculation.
To achieve your goal you need to write a custom script that will check the bar time and decide to which 300 seconds this bar should be related.
And then summarize only the appropriate bars.
These users thanked the author Henry MultiСharts for the post:
TJ


Return to “MultiCharts”