Advanced Volume Indicator for ThinkorSwim

Welkin

Welkin

Active member
VIP
@Necr0sis it looks to me like the oscillating red/green line (plot named VxNet) at the bottom is going into the negative causing the study to be automatically resized to fit the volume pane, rather than remaining at zerobase. this would be one of those volume indicators that you'd have set as lower study and disable the volume subgraph on because of that aspect, that is if you consider the dark volume bars the indicator is floating above an eyesore.
 
N

Necr0sis

New member
VIP
@Necr0sis it looks to me like the oscillating red/green line (plot named VxNet) at the bottom is going into the negative causing the study to be automatically resized to fit the volume pane, rather than remaining at zerobase. this would be one of those volume indicators that you'd have set as lower study and disable the volume subgraph on because of that aspect, that is if you consider the dark volume bars the indicator is floating above an eyesore.
Awesome Awesome. Again, thanks for answering a question about an unrelated indicator. Your advanced volume doesn't seem to have the same issue though, great indicator!
 
N

Necr0sis

New member
VIP
I've got some more questions on this indicator:

Is there any downside to setting my time frame much lower than the second aggregation. For instance, I have my aggregation as 1D, so when I use the 1D time frame I get the message to "Check aggregation". Let's say I increase it to a week, will that cause the lower time frames (from 1D and lower) to be innacurate?

Next, I'm kind of new to trading, and I was wondering what the buy/sell strength is?

Finally, I noticed on the iphone app there is a pink line sitting ontop of the bars.



I find that to be very useful, and was wondering how to enable that on the desktop version of the indicator?

Thank you!
 
Welkin

Welkin

Active member
VIP
I've got some more questions on this indicator:

Is there any downside to setting my time frame much lower than the second aggregation. For instance, I have my aggregation as 1D, so when I use the 1D time frame I get the message to "Check aggregation". Let's say I increase it to a week, will that cause the lower time frames (from 1D and lower) to be innacurate?

Next, I'm kind of new to trading, and I was wondering what the buy/sell strength is?

Finally, I noticed on the iphone app there is a pink line sitting ontop of the bars.



I find that to be very useful, and was wondering how to enable that on the desktop version of the indicator?

Thank you!
Sorry, I didn't script this with mobile in mind. And honestly, I've never tried to view it in mobile, lol. Pretty sure most of its features won't work on mobile.
I can see that the volume bars aren't even being repainted to indicate if above or below average volume bars. The pink line that you are referencing is actually the volsignal plot, on the desktop it shows up as a triangle plotted above each volume bar depending on whether its above average or above a sigma filter. if you wish for it to be a line instead you can change it in the study settings under the VolSignal tab.
Setting your chart's aggregation to a lower aggregation than the buy sell str agg2 will not affect or cause any inaccuracies in the volume data displayed.
The buy/sell strength is explained in the main post with all of the other listed features. the aggregation set in the indicator for buy sell str agg2 are for the labels, and the buy sell str background clouds if toggled on. clouds and labels don't show up on mobile.

I did create a 'Lite' version of the Advanced Volume script which has the buy/sell str features removed, because it was causing issues when viewing custom time frames that aren't commonly used (such as 195 min chart aggregation for example).
if anyone wishes to use it instead it can be found here: https://tos.mx/1c4C3S6
 
N

Nick

Active member
2019 Donor
VIP
I created this indicator to accompany the main volume indicator for those who use VSA (Volume Spread Analysis), what this does is draws a line across at high and low of bars with high interest volume.


https://tos.mx/ak3uWTh
Code:
#Companion indicator to the Advanced Volume Study for Volume Spread Analysis
#[email protected]
declare upper;
input PaintPriceAsVol = no;
input AvgDayVolLength = 5;
input AvgVolLength = 20;
input ShowDayVolLabel = yes;
input ShowBarVolLabel = yes;
input ShowEthTotalVolLabel = no;
input ShowTickLabel = yes;
input VolAverageType = AverageType.SIMPLE;
input PaintAboveAvgVolBars = yes;
input PaintAccordingToRelPrevVol = yes;
input RelativetoPrevVolTolerance = 1.25; #if volume is 1.25x greater than previous bar it will paint even if it is still below the average/sigma2/sigma3
input PaintBelowAvgVol = yes;

input ShowVerticalTickLines = yes;
def ShowVertLines = if ShowVerticalTickLines and GetAggregationPeriod() < AggregationPeriod.DAY then 1 else 0;
input TickLevel = 1000;



def NA = Double.NaN;

def DayVolAgg = if GetAggregationPeriod() < AggregationPeriod.DAY then AggregationPeriod.DAY else GetAggregationPeriod();
def DayVol = volume("period" = DayVolAgg);
def AvgDayVol = Average(DayVol, AvgDayVolLength);
def Start = 0930;
def End = 1600;
def conf = SecondsFromTime(Start) >= 0 and SecondsFromTime(End) <= 0;

plot VolColor = NA;
VolColor.DefineColor("Bullish", Color.GREEN);
VolColor.DefineColor("Bearish", Color.RED);
VolColor.DefineColor("VolAvg", CreateColor(0, 100, 200));
VolColor.DefineColor("VolSigma2", Color.DARK_ORANGE);
VolColor.DefineColor("VolSigma3", Color.MAGENTA);
VolColor.DefineColor("Relative to Prev", Color.YELLOW);
VolColor.DefineColor("Below Average", Color.GRAY);
VolColor.DefineColor("ETH TVOL", Color.GRAY);
VolColor.DefineColor("TICK Vert", Color.GRAY);
def Vol = volume;

def VolAvg = MovingAverage(VolAverageType, volume, AvgVolLength);

#2Sigma and 3Sigma Vol Filter
def Num_Dev1 = 2.0;
def Num_Dev2 = 3.0;
def averageType = AverageType.SIMPLE;
def sDev = StDev(data = Vol, length = AvgVolLength);

def VolSigma2 = VolAvg + Num_Dev1 * sDev;
def VolSigma3 = VolAvg + Num_Dev2 * sDev;

#####
#VSA start test
#####
def VSig3H = if volume > VolSigma3 then high else VSig3H[1];
def VSig2H = if volume > VolSigma2 and volume < VolSigma3 then high else VSig2H[1];
def VSigAH = if volume > VolAvg and volume < VolSigma2 then high else VSigAH[1];
def VSig3L = if volume > VolSigma3 then low else VSig3L[1];
def VSig2L = if volume > VolSigma2 and volume < VolSigma3 then low else VSig2L[1];
def VSigAL = if volume > VolAvg and volume < VolSigma2 then low else VSigAL[1];

plot VSig3Hc = Vsig3H;
plot VSig2Hc = Vsig2H;
plot VSigAHc = VSigAH;
plot VSig3Lc = Vsig3L;
plot VSig2Lc = Vsig2L;
plot VSigALc = VSigAL;


VSig3Hc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VSig2Hc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VSigAHc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VSig3Lc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VSig2Lc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VSigALc.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
VSig3Hc.SetDefaultColor(Color.MAGENTA);
VSig2Hc.SetDefaultColor(Color.DARK_ORANGE);
VSigAHc.SetDefaultColor(CreateColor(0,125,225));
VSig3Lc.SetDefaultColor(Color.MAGENTA);
VSig2Lc.SetDefaultColor(Color.DARK_ORANGE);
VSigALc.SetDefaultColor(CreateColor(0,125,225));


#####
def RelDayVol = DayVol / AvgDayVol[1];
def RelPrevDayVol = DayVol / volume("period" = DayVolAgg)[1];
#Daily aggregation volume labels
AddLabel(if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else if ShowDayVolLabel then 1 else 0, "DayVol: " + DayVol + " / " + Round(RelDayVol, 2) + "x Avg(" + AvgDayVolLength + ") / " + Round(RelPrevDayVol, 2) + "x Prev", if DayVol > AvgDayVol then VolColor.Color("VolAvg") else VolColor.Color("Below Average"));

def RelVol = Vol / VolAvg[1];
def RelPrevVol = volume / volume[1];

#Triangle Vol Signal
def VolSignal = if Vol > VolSigma3 then volume else if Vol > VolSigma2 then volume else if Vol > VolAvg then volume else if RelPrevVol >= RelativetoPrevVolTolerance then volume else NA;

#current aggregation's volume labels
AddLabel(ShowBarVolLabel, "Vol: " + volume + " / " + Round(RelVol, 2) + "x Avg(" + AvgVolLength + ") / " + Round(RelPrevVol, 2) + "x Prev",  if Vol > VolSigma3 then VolColor.Color("VolSigma3") else if Vol > VolSigma2 then VolColor.Color("VolSigma2") else if Vol > VolAvg then VolColor.Color("VolAvg") else VolColor.Color("Below Average"));

#ETH Total Vol Label
def ETH_VOL = if !conf and conf[1] then volume else if !conf then CompoundValue(1, ETH_VOL[1] + volume, volume) else ETH_VOL[1];

AddLabel(if !ShowEthTotalVolLabel then 0 else if GetAggregationPeriod() >= AggregationPeriod.DAY then 0 else 1, "ETH TVOL: " + ETH_VOL, VolColor.Color("ETH TVOL"));

#$TICK Vertical Lines
def tickc = close("$TICK");
def tickh = high("$TICK");
def tickl = low("$TICK");

AddVerticalLine(if ShowVertLines and (tickh > TickLevel) or ShowVertLines and (tickl < -TickLevel) then 1 else 0, if (tickh > TickLevel) then tickh else if (tickl < -TickLevel) then tickl else Double.NaN, VolColor.Color("TICK Vert"));

#$TICK Label
AddLabel(if ShowTickLabel then 1 else 0,"$TICK: " + tickc, if tickc > 0 then Color.GREEN else Color.RED);


AssignPriceColor(if PaintPriceAsVol and PaintAboveAvgVolBars and volume > VolSigma3 then VolColor.Color("VolSigma3") else if PaintPriceAsVol and PaintAboveAvgVolBars and volume > VolSigma2 then VolColor.Color("VolSigma2") else if PaintPriceAsVol and PaintAboveAvgVolBars and volume > VolAvg then VolColor.Color("VolAvg") else if PaintPriceAsVol and PaintAccordingToRelPrevVol and RelPrevVol >= RelativetoPrevVolTolerance then VolColor.Color("Relative to Prev") else if PaintPriceAsVol and PaintBelowAvgVol and volume < VolAvg then VolColor.Color("Below Average") else Color.CURRENT);

@Welkin Hi, thank you for this awesome indicator. I have downloaded the script and this is the image i am seeing, without the lower indicator, is that correct? I have two requests and like to seek your help, is there any way we can scan the orange or magenta candles ? 2. What will be the ideal way to trade with this indicator? Is it that a breakout above the Top of orange will imply greater momentum? I would like to know the concept behind so that it can be more effective utilised. Thank you
 
Welkin

Welkin

Active member
VIP

@Welkin Hi, thank you for this awesome indicator. I have downloaded the script and this is the image i am seeing, without the lower indicator, is that correct? I have two requests and like to seek your help, is there any way we can scan the orange or magenta candles ? 2. What will be the ideal way to trade with this indicator? Is it that a breakout above the Top of orange will imply greater momentum? I would like to know the concept behind so that it can be more effective utilised. Thank you
Yes, the VSA upper indicator is complimentary to the lower indicator, but it can be utilized on its own. though I'd like to recommend the following changes:
1. in the indicator settings toggle 'paint price as vol' to yes.
2. because you have both up and down bars set to fill in your chart appearance settings, I recommend unchecking one so that ones solid and one is hollow, this way you can better distinguish if a repainted bar is bullish or bearish because they will no longer be just green or red candles.

The orange or magenta candles would have a volume that exceeds the sigma2(orange) or sigma3(magenta) filter. you can set a scan for those candles as follows:
Create a scan and add a study filter


Edit the study filter here


Delete the existing condition under the condition wizard panel, then click Add Condition with the following condition settings


Trading with VSA and volume in general is a big topic. I suggest searching and learning about Wyckoff Volume Spread Analysis and methodology as well as Dow Theory of Volume confirmation. This video should act as a good starting point:

There are tons of free resources online, just try looking around on youtube and google. Hope this helps.
 
N

Nick

Active member
2019 Donor
VIP
Yes, the VSA upper indicator is complimentary to the lower indicator, but it can be utilized on its own. though I'd like to recommend the following changes:
1. in the indicator settings toggle 'paint price as vol' to yes.
2. because you have both up and down bars set to fill in your chart appearance settings, I recommend unchecking one so that ones solid and one is hollow, this way you can better distinguish if a repainted bar is bullish or bearish because they will no longer be just green or red candles.

The orange or magenta candles would have a volume that exceeds the sigma2(orange) or sigma3(magenta) filter. you can set a scan for those candles as follows:
Create a scan and add a study filter


Edit the study filter here


Delete the existing condition under the condition wizard panel, then click Add Condition with the following condition settings


Trading with VSA and volume in general is a big topic. I suggest searching and learning about Wyckoff Volume Spread Analysis and methodology as well as Dow Theory of Volume confirmation. This video should act as a good starting point:

There are tons of free resources online, just try looking around on youtube and google. Hope this helps.
@Welkin Thank you so much for the detailed and prompt reply. Will definitely check them out.
 
Welkin

Welkin

Active member
VIP
@Welkin - thanks - this is a really good indicator. Is it possible to enable it on a watchlist as well? It will be easy to see the big movers and their volume info without opening each chart separately. Thanks a lot
I created a watchlist column to show relative to average vol as well as relative vol to previous bar, the background will also paint accordingly if volume is below/above averages on at the set aggregation.


Code:
#[email protected]
#Advanced Volume Watchlist Column
#Add-on to https://tos.mx/jIx0x2n
#Relative to Avg Vol / Relative to Previous Volume bar

input VolAverageType = AverageType.SIMPLE;
input AvgVolLength = 20;
input RelativetoPrevVolTolerance = 1.25;

def Vol = volume;
def Num_Dev1 = 2.0;
def Num_Dev2 = 3.0;
def averageType = AverageType.SIMPLE;
def sDev = StDev(data = Vol, length = AvgVolLength);
def VolAvg = MovingAverage(VolAverageType, volume, AvgVolLength);
def VolSigma2 = VolAvg + Num_Dev1 * sDev;
def VolSigma3 = VolAvg + Num_Dev2 * sDev;
def RelVol = Vol / VolAvg[1];
def RelPrevVol = volume / volume[1];
AssignBackgroundColor(if Vol > VolSigma3 then Color.MAGENTA else if Vol > VolSigma2 then Color.DARK_ORANGE else if Vol > VolAvg then CreateColor(0, 100, 200) else if RelPrevVol >= RelativetoPrevVolTolerance then Color.YELLOW else Color.GRAY);

AddLabel(1, Round(RelVol, 2) + "x / " + Round(RelPrevVol, 2) +"x", Color.BLACK);
And here is a strength column


Code:
#Buy/Sell Strength Column
def o = open;
def h = high;
def l = low;
def c = close;
def PR = h - l;
def BuyStr = ((c - l) / PR) * 100;

AddLabel(1,Round(BuyStr,1)+" | " + Round(100-BuyStr,1)+"%", Color.BLACK);

AssignBackgroundColor(if BuyStr >= 70 then Color.Green else if BuyStr > 50 then Color.DARK_GREEN else if BuyStr <= 30 then Color.RED else if BuyStr < 50 then Color.DARK_RED else Color.GRAY);
 
Z

Zoomer

New member
VIP
@Welkin Thanks a lot for these watchlist columns. This is really helpful.
 
N

Necr0sis

New member
VIP
@Welkin I want to actually ask about the VSA addon again. I was wondering if it would be possible to make the VSA lines coming from the bars to have the shaded transparent background (Kind of like the Supply Demand zones on the AMM 2.0)
 
N

Necr0sis

New member
VIP
You know, I just had another good idea for this. The triangles indicating an increasing in volume is awesome, and it makes me wonder if you can create another similar addition that places a triangle (or any boolean) on a volume bar that meets the condition of a long top or bottom wick, and the volume is less than the previous two volumes (for testing supply and demand)

@Welkin Also, I was wondering if you could perhaps provide some sort of guide at interpreting the indicator and the VSA addon?
 
Last edited:
R

rogtrader

New member
How to split After-hours and Pre-market volumes separately? The following gives both the volumes combined.. the logic is a bit cryptic.. Can someone help? Thanks!

def conf = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) <= 0;
def ExtVol = if !conf and conf[1] then volume else if !conf then CompoundValue(1, ExtVol[1] + volume, volume) else ExtVol[1];
 
Welkin

Welkin

Active member
VIP
How to split After-hours and Pre-market volumes separately? The following gives both the volumes combined.. the logic is a bit cryptic.. Can someone help? Thanks!

def conf = SecondsFromTime(0930) >= 0 and SecondsFromTime(1600) <= 0;
def ExtVol = if !conf and conf[1] then volume else if !conf then CompoundValue(1, ExtVol[1] + volume, volume) else ExtVol[1];
try this
Code:
input showAftermarket = yes;
input showPremarket = yes;

input rthStart = 0930;
input rthEnd = 1609;
input pmStart = 0400;
input amEnd= 1959;

def NA = Double.NaN;
def amConf = SecondsFromTime(rthEnd) >= 0 and SecondsFromTime(amEnd) <= 0;
def pmConf = SecondsFromTime(pmStart) >= 0 and SecondsFromTime(rthStart - 1) <= 0;

def amVol = if amConf and !amConf[1] and showAftermarket then volume else if amConf and showAftermarket then CompoundValue(1, amVol[1] + volume, volume) else NA;
def pmVol = if pmConf and !pmConf[1] and showPremarket then volume else if pmConf and showPremarket then CompoundValue(1, pmVol[1] + volume, volume) else NA;

plot amV = amVol;
plot pmV = pmVol;

amV.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
pmV.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
amV.AssignValueColor(if close > open then Color.GREEN else Color.RED);
pmV.AssignValueColor(if close > open then Color.GREEN else Color.RED);
 
Welkin

Welkin

Active member
VIP
@Welkin I want to actually ask about the VSA addon again. I was wondering if it would be possible to make the VSA lines coming from the bars to have the shaded transparent background (Kind of like the Supply Demand zones on the AMM 2.0)
I've tried adding clouds to the indicator, ends up making the chart nearly unreadable at times IMO, that is why I left them out.

You know, I just had another good idea for this. The triangles indicating an increasing in volume is awesome, and it makes me wonder if you can create another similar addition that places a triangle (or any boolean) on a volume bar that meets the condition of a long top or bottom wick, and the volume is less than the previous two volumes (for testing supply and demand)

@Welkin Also, I was wondering if you could perhaps provide some sort of guide at interpreting the indicator and the VSA addon?
I put this together according to your criteria, I find that current volume greater volume than the prior 2 bars shows some better signals when rejecting a level with a large top or bottom wick as these bars are usually above the volume average. but of course what is happening in higher time frames or the current trending environment will also determine if you see exhaustion or increase in volume. There is a switch for either option. color is determined by if it is the top wick (red) or bottom wick (green) is largest. wickThreshold is set to 100%, so if the wick is greater than the body + top or bottom wick combined then it will signal. adjust and play around with it, change the colors. apply the indicator twice with both modes active and see what it is able to tell you.
Code:
declare on_volume;

input wickThreshold = 100;
input prevVolMode = {default GreaterThan, LessThan};
def NA = Double.NaN;
def o = open;
def h = high;
def l = low;
def c = close;
def range = h-l;
def topwick = if c > o then h - c else h - o;
def botwick = if c > o then o - l else c - l;
def body = Max(o,c) - Min(o,c);

def topwtest = if topwick > (body + botwick) and (topwick/(body + botwick))*100 > wickThreshold then 1 else 0;
def botwtest = if botwick > (body + topwick) and (botwick/(body + topwick))*100 > wickThreshold then 1 else 0;

def VolTest;

switch(prevVolMode){
case GreaterThan:
VolTest = volume > volume[1] and volume > volume[2];
case LessThan:
VolTest = volume < volume[1] and volume < volume[2];
}

plot topwsig = if topwtest and VolTest then volume else NA;
plot botwsig = if botwtest and voltest then volume else NA;

topwsig.SetPaintingStrategy(PaintingStrategy.SQUARES);
botwsig.SetPaintingStrategy(PaintingStrategy.SQUARES);
topwsig.SetDefaultColor(Color.RED);
botwsig.SetDefaultColor(Color.GREEN);
topwsig.SetLineWeight(3);
botwsig.SetLineWeight(3);
As for interpreting volume and VSA, there are plenty of resources for this. In response to nicks post above:

Trading with VSA and volume in general is a big topic. I suggest searching and learning about Wyckoff Volume Spread Analysis and methodology as well as Dow Theory of Volume confirmation. This video should act as a good starting point:

There are tons of free resources online, just try looking around on youtube and google. Hope this helps.
 
Last edited:
YungTraderFromMontana

YungTraderFromMontana

Well-known member
@Welkin you seem code savvy. Would there be a way to make the current volume bar a projection of the close, depending on the aggregation this could be done differently but for example on 1 min if the current volume is 1 million 10 seconds into the bar then 60/10 = 6 so projected volume is 1 million * 6 = 6 million. This would be difficult on higher aggregations because of increased volume at certain points in a day but on lower aggregations it would work well.
 
N

Necr0sis

New member
VIP
@Welkin Sincere thanks! Is this code to be used for a new indicator, or do I combine it to the VSA?
 
V

Vimal Mittal

Member
I created a watchlist column to show relative to average vol as well as relative vol to previous bar, the background will also paint accordingly if volume is below/above averages on at the set aggregation.


Code:
#[email protected]
#Advanced Volume Watchlist Column
#Add-on to https://tos.mx/jIx0x2n
#Relative to Avg Vol / Relative to Previous Volume bar

input VolAverageType = AverageType.SIMPLE;
input AvgVolLength = 20;
input RelativetoPrevVolTolerance = 1.25;

def Vol = volume;
def Num_Dev1 = 2.0;
def Num_Dev2 = 3.0;
def averageType = AverageType.SIMPLE;
def sDev = StDev(data = Vol, length = AvgVolLength);
def VolAvg = MovingAverage(VolAverageType, volume, AvgVolLength);
def VolSigma2 = VolAvg + Num_Dev1 * sDev;
def VolSigma3 = VolAvg + Num_Dev2 * sDev;
def RelVol = Vol / VolAvg[1];
def RelPrevVol = volume / volume[1];
AssignBackgroundColor(if Vol > VolSigma3 then Color.MAGENTA else if Vol > VolSigma2 then Color.DARK_ORANGE else if Vol > VolAvg then CreateColor(0, 100, 200) else if RelPrevVol >= RelativetoPrevVolTolerance then Color.YELLOW else Color.GRAY);

AddLabel(1, Round(RelVol, 2) + "x / " + Round(RelPrevVol, 2) +"x", Color.BLACK);
And here is a strength column


Code:
#Buy/Sell Strength Column
def o = open;
def h = high;
def l = low;
def c = close;
def PR = h - l;
def BuyStr = ((c - l) / PR) * 100;

AddLabel(1,Round(BuyStr,1)+" | " + Round(100-BuyStr,1)+"%", Color.BLACK);

AssignBackgroundColor(if BuyStr >= 70 then Color.Green else if BuyStr > 50 then Color.DARK_GREEN else if BuyStr <= 30 then Color.RED else if BuyStr < 50 then Color.DARK_RED else Color.GRAY);
what time frame this can be used? i do intraday trading . Can i use in 3, 5 or 15 minutes time frame? Not clear about color codes. can you be more descriptive please. I am noob. Thanks.
 
Welkin

Welkin

Active member
VIP
what time frame this can be used? i do intraday trading . Can i use in 3, 5 or 15 minutes time frame? Not clear about color codes. can you be more descriptive please. I am noob. Thanks.
any time framecan be used though I recommend just using daily, and read the main post to understand the color coordination as that is what the custom column is based on...
 
Last edited:
M

mrmac

New member
VIP
I'm almost embarrassed to ask this question, it feels really basic but here we go...
I trade forex and have tried to add this and many other volume studies to my charts but not a single one actually displays.
I have enabled / disabled the "show volume subgraph" in the settings but that does not help either.
Thank you
 

Similar threads

Top