Welcome! Log In Create A New Profile

Get Earnings and Seasonal Trends - Subscribe Today!


Custom Volume Indicator for TOS

Posted by robert 
Custom Volume Indicator for TOS
October 22, 2013 06:49AM
I've been reading about how volume can be an important indicator to show the strength of a move. In doing some research, I came across the idea of averaging volume across the same time periods each day rather than averaging the past [n] candles. Doing so will better show whether the volume is atypical for a specific time of day such as lunch time, or the market open.

For instance, many stocks will show a large volume spike at market open as all of the amateur orders which were submitted overnight are filled. A normal volume average will include the volume from the past 20 candles (which incorporates all times of the day) so that the opening volume will always look like a large spike. Conversely, with the time-based volume indicator, only the opening candles (for this example) would be included in the average so that it becomes easy to see if the opening volume is higher or lower than the average for that same time.

Read the description and watch the short video at this website as they do a much better job of explaining than I'm managing.

Another example. A large upswing in volume may be seen at the end of the day in the chart below. However, the time based volume reveals that the end of day volume is only about 92% of the normal end-of-day volume; so it is actually a little low.

At any rate, I liked the concept and thought that it could be a useful indicator. So I coded my own for ThinkOrSwim. This indicator will work for any intra-day time frame.

If you are interested in this one, the code is presented below. The default look-back period is set to 20 days (one trading month), but can be changed in the study settings.

# Time Based Volume
# Robert Payne
declare lower;
input LookBack = 20;
def nMinutes = GetAggregationPeriod() / 60000;
def nBars = RoundUp(390 / nMinutes, 0);

def pvSum = fold idx = 1 to LookBack + 1 with a=0 do a + GetValue(volume, idx * nBars, LookBack * nBars);

def pvAvg = pvSum / LookBack;
def VolPct = (volume / pvAvg) * 100;

plot avgLine = 100;

def lastUp = if IsNaN(lastUp[1]) then 0 else if (close > open) then VolPct else lastUp[1];
def lastDn = if IsNaN(lastDn[1]) then 0 else if (close < open) then VolPct else lastDn[1];

plot Vol = VolPct;
Vol.DefineColor("Bullish", Color.CYAN);
Vol.DefineColor("Bullish Smaller", CreateColor(0, 128, 128));
Vol.DefineColor("Bearish", Color.MAGENTA);
Vol.DefineColor("Bearish Smaller", CreateColor(128, 0, 128));
Vol.AssignValueColor(if (close > open) and (VolPct > lastUp[1]) then Vol.Color("bullish" ) else if close > open then Vol.Color("bullish smaller" ) else if close < open and VolPct > lastDn[1] then Vol.Color("bearish" ) else Vol.Color("bearish smaller" ));

Edited 2 time(s). Last edit at 10/22/2013 08:28AM by robert.
Re: Custom Volume Indicator for TOS
October 22, 2013 01:28PM
Thanks for sharing that Robert, will give it a try
Sorry, only registered users may post in this forum.

Click here to login