Volume saga

Questions about MultiCharts and user contributed studies.
janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Volume saga

Postby janus » 19 Jun 2009

According to the documentation, the "Volume" keyword returns the volume of the current bar as follows.

For tick and volume-based charts, and time-based charts with resolutions of 24 hours or less:
- the volume traded on Up ticks will be returned if Build Volume On is set to Trade Volume
- the number of Up ticks in the current bar will be returned if Build Volume On is set to Tick Count

For time-based charts with resolutions of 1 day or more:

- the total volume traded will be returned if Build Volume On is set to Trade Volume
- the total number of ticks in the current bar will be returned if Build Volume On is set to Tick Count

When I compare the raw 1 minute trade data using QuoteManager with what I see on a 1 minute chart, I can see that the "Volume" keyword in a study returns the values stored in the "UpVol" column, which agrees with the above. I can tell this is so because sometimes the UpVol is not the total volume and the DownVol has the remaining volume. At other times it has the UpVol equal to all the volume and DownVol is 0. Why this happens I don't know - perhaps IB is doing something odd. In any case, it makes the Volume keyword useless. So, I have to resort to writing a function that makes sure the real volume is returned. I also note that the built-in Volume study plots the correct total volume always. So, I checked the code and sure enough it uses Volume for daily and longer, and Ticks for everything else. So, Ticks is equal to the sum of UpVol and DownVol (not UpTicks and DownTicks, which adds more to the confusion but no matter).

So I wonder how many people are using the Volume keyword in their studies when they should be checking the BarType and using "Volume" or "Ticks" accordingly? Wouldn't it be common sense to make the Volume keyword return the real volume always regardless of the BarType, as the name implies?

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Postby TJ » 19 Jun 2009

hahaha... I was caught early on... I learned my lesson, so all my codes are clean.


this volume thing is an EasyLanguage legacy issue that goes back years in history.

but nobody can do anything about it now...
otherwise many legacy codes will not work.


like the old IBM main frame that could be replaced by a Q6600, but can't, because of the legacy software.


:-(
Last edited by TJ on 19 Jun 2009, edited 2 times in total.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 19 Jun 2009

I thought that was the reason. Why not introduce a new keyword called say TrueVolume? Issue fixed for all newcomers. It's a simple and sensible fix at least to highlight the distinction and avoid repeating the same mistake over and over again. Common sense does work you know even in programming.

User avatar
TJ
Posts: 6551
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 966 times
Been thanked: 1892 times

Postby TJ » 19 Jun 2009

just a side note...

be careful with the upticks and downticks keywords...


depending on your data provider,
they might not exactly produce uptick volumes and downtick volumes.

That's because most of the data providers stream aggregated quotes.

if there are 2 trades happened between the sending of quote packets,
the 2 trades will be aggregated as ONE tick.

if the first trade is an uptick, the 2nd trade is a downtick, the aggregated trades might be reported as a downtick.

I say "might", because there is an algorithm to "determine" the uptick/downtick interpretation... it is not a clear cut as most people would assume.

janus
Posts: 747
Joined: 25 May 2009
Has thanked: 41 times
Been thanked: 83 times

Postby janus » 19 Jun 2009

Thanks for the warning; I'll remember that. I don't look at tick data at the moment, although I did a long time ago. I'm now more of a medium term trader using 2 and 5 minute data.

I suppose one way around that dilemma is to introduce millisecond time stamping.


Return to “MultiCharts”