Several forum members requested a study to compare the current price bar’s volume to historical volume in the same bar on previous days. The resulting study displays the current bar’s volume as a percentage of the historical average for as much data is available in your chart. The 20 day charts will provide the most usable data. This study can be used on any intraday charts (i.e. anything less than daily charts) BUT WILL NOT WORK ON TICK CHARTS. Let me say this again, this study DOES NOT WORK ON TICK CHARTS. Ok, that’s enough yelling. It should be obvious why this won’t work on tick charts but furthermore, we still have a bug in TOS that crashes the study any time the getAggregationPeriod() function is called on a tick chart.
You’ll need to enter the number of hours in the trading cycle. Normally this is 6.5 hours for stocks (0930-1600) and 6.75 for index futures (0930-1615). This study is designed to be used on trading hours charts (i.e. “Show trading hours only” checked).
Lastly, you’ll need to select if you are using the chart on an index future like the /ES. When TOS plots an hourly chart of an index future, there is one extra bar in the chart because of the partial hour up front and partial hour in back. I put in a particularly inelegant kludge to work around this until something more aesthetically pleasing comes to mind.
# TS_RelativePercentVolume # http://www.thinkscripter.com # thinkscripter@gmail.com # Last Update 26 JUL 2009 ##### DO NOT USE ON TICK CHARTS ##### declare lower; # Use the number of hours from market open to market open the following # session (6.5 for stocks, 6.75 for index futures etc) input hoursPerCycle = 6.75; # Must select YES for /ES, /NQ etc since and extra bar appears on hourly charts input indexFuture = YES; input averagePeriod = 10; input threshold = 25.0; rec cycle = compoundValue(1, if getDay() != getDay()[1] then cycle[1]+1 else cycle[1],1); def barLength = getAggregationPeriod()/60000; def barsPerCycleV = round100(hoursPerCycle*60/barLength); def barsPerCycleR = round100((hoursPerCycle*60/barLength)/100)*100; def barsPerCycle = if barsPerCycleV > barsperCycleR then barsPerCycleR+1 else barsPerCycleR; # This 'kludge' is in here since index futures plotted on a one hour chart add an extra bar # Not elegant but it works until something hits me def kludge = if indexFuture and barsPerCycle==7 then 1 else 0; rec aggVolume = volume + aggVolume[barsPerCycle+kludge]; def aveVolume = aggVolume/(cycle+1); plot percentDiff = ((volume/aveVolume))*100.0; percentDiff.setpaintingStrategy(paintingStrategy.HISTOGRAM); percentDiff.setLineWeight(3); percentDiff.assignValueColor(if percentDiff < 100-threshold then color.red else if percentDiff > 100+threshold then color.green else color.white); plot zero = 100; zero.setDefaultColor(color.white); zero.setStyle(curve.SHORT_DASH); plot highMark = 200; highMark.setDefaultColor(color.dark_gray); plot lowMark = 0; lowMark.setDefaultColor(color.dark_gray); plot ave = average(percentDiff,averagePeriod); ave.setDefaultColor(color.yellow);






So. Does this work on tick charts?
Cheerio !
So the percentage is relative to the same period average of the other days in the chart? For example if one uses 60 min 20 days and 10 o´clock shows 150%, that means its 150% of the averge for 10 o´clock the last 20 days?
Does compare in 60 min or if one uses 5-min chart, does it compare to other 5-min periods?
And lastly, if one would put 24h per cycle would it work premaket as well on a indexfuture?
Lots of questions but it seems to be an interesting indicator… Thankx
Yes – Percentage is relative to the same period average over all the bars in the chart. I have not tried it on 24 hours but can’t think of any reason why it wouldn’t work.
Eric
Wouldn’t that be 23.25 hours, assuming index futures are closed 4.15 to 4.30 and 5.30 to 6 eastern time?
And what would the considerations be for currency futures that trade all but 5 to 6.
I presume it would work with 23.25 and 23 respectively. Not quite savy enough to fully understand the code but guessing the code just counts bars from some anchor point each day to find the volume bar it needs to tally – and doesn’t care otherwise.
Can you please tell me what the average period input does, along with the threshold input? Also what is the purpose of the zero indicator?
thanks
The average period input is the period for the yellow average line you see running through the study. It is an average of the volume percentage. The threshold tells the study what percentage above or below the 100% line to color the bar. So, if set at 25%, a bar with a 75% or less will be colored red while a 125% or more will be green. The zero line is set at 100% indicating that bar is at the average for that time bar (100%).
-Eric
I’m not sure I understand this. Lets looks at the /NQ chart on TOS
Style= 3-months, Day
If I look at volume on the /NQ on 1/18/2009 I get a Volume number of 268,934 with an average number of 51.07 and a percentDiff number of 75.985. If my volume was above the average, shouldn’t the percentDiff value be over 100%? What am I missing here? Something does not seem to be correct here, but I may also may not be understanding it correctly. For instance if you use QuoteTracker and bring up the 3-month relative percent average for QQQQ on Friday it was near 130% of the 3-month average. I would think that the percentDiff would give me a similar number to indicate how much higher the volume was compared to the overall average. Please correct me if I am wrong.
Thanks
You are misunderstanding the purpose of this study. This study is not designed to work on daily charts – only intraday charts (see the description above). It is designed to show you the relative volume compared to the same bar in other trading days. So, on an hourly chart, it will compare the volume in the 10:30-11:30 bar to all the other 10:30-11:30 bars present on your chart. The most you can use is 20 days of data which is the TOS limit for intraday charts.
-Eric
Thanks Eric,
Sorry for the misunderstanding. I did look at the 5 minute intraday on the /NQ for Friday and it did not look right either. I’m sure you are busy but take a look at say the 5 minute 3:40 bar on 1/8/2010 vs. the 5 minute 3:40 bar on 1/7/2010. Do you feel its producing the proper data values?