Advanced Volume Indicator for ThinkorSwim

twitty_twit

New member
@Welkin

I think I figured it out.

I changed "PaintingStrategy.HISTOGRAM" to ".HISTOGRAM" in your code.

Appearance wise, it looks right.

But did I do it correctly? Just want to make sure I didn't mess up your perfect code. Thanks :)

Hc4ms6K.png
 

twitty_twit

New member
@Welkin

I have a couple of questions:

Question #1: How can I flip the buy (green) and red (sell) colors in each volume bar?

Currently, the buy (green) part is located on the bottom and the red (sell) is on top of the bar.

I want to reverse them (=the buy part goes to the top of the bar & the sell part is on bottom).

Can you guide me where in the code I need to change?

kbz48Ok.png


Question #2: I saw you gave out the code for the cumulative volume between 930 - 1030.

Where can I add the code? I tried to add it (below) at the end of your original code for the indicator, but received the following error message.

nEuAY75.png


The code from #69:

Code:
declare lower;
def T1Start = 0930;
def T1End = 1029;

def NA = Double.NaN;
def conf = SecondsFromTime(T1Start) >= 0 and SecondsFromTime(T1End) <= 0;

def cvolT1 = if conf and !conf[1] then volume else if conf then cvolT1[1] + volume else cvolT1[1];

plot cvol = if conf then cvolT1 else NA;

cvol.SetDefaultColor(Color.YELLOW);
cvol.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
 
Last edited:

Welkin

Active member
VIP
@Welkin

I have a couple of questions:

Question #1: How can I flip the buy (green) and red (sell) colors in each volume bar?

Currently, the buy (green) part is located on the bottom and the red (sell) is on top of the bar.

I want to reverse them (=the buy part goes to the top of the bar & the sell part is on bottom).

Can you guide me where in the code I need to change?

kbz48Ok.png


Question #2: I saw you gave out the code for the cumulative volume between 930 - 1030.

Where can I add the code? I tried to add it (below) at the end of your original code for the indicator, but received the following error message.

nEuAY75.png


The code from #69:

Code:
declare lower;
def T1Start = 0930;
def T1End = 1029;

def NA = Double.NaN;
def conf = SecondsFromTime(T1Start) >= 0 and SecondsFromTime(T1End) <= 0;

def cvolT1 = if conf and !conf[1] then volume else if conf then cvolT1[1] + volume else cvolT1[1];

plot cvol = if conf then cvolT1 else NA;

cvol.SetDefaultColor(Color.YELLOW);
cvol.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
here you go, this should have the changes you wanted:
http://tos.mx/cas8sK8

also the cumulative vol is best left as a separate script, because when it plots it'll skew the normal volume data too much and make it difficult to read.
 
@Welkin Thank you for all you do! This is really good stuff!

I have a question.....If I just wanted to pull out the Sigma 1, Sigma 2 and Sigma 3 concept from this script, what would that portion of the script look like?

In other words, I would just want to see the 3 lines (average (blue), sigma 2 (orange) and sigma 3 (magenta) on a regular volume graph and a label telling me which line it is on. Would want this to work for any timeframe (1M to D)

Hope this makes sense. Thank you for your time!
 

Welkin

Active member
VIP
@Welkin Thank you for all you do! This is really good stuff!

I have a question.....If I just wanted to pull out the Sigma 1, Sigma 2 and Sigma 3 concept from this script, what would that portion of the script look like?

In other words, I would just want to see the 3 lines (average (blue), sigma 2 (orange) and sigma 3 (magenta) on a regular volume graph and a label telling me which line it is on. Would want this to work for any timeframe (1M to D)

Hope this makes sense. Thank you for your time!
this should do it
Code:
declare on_volume;
input AvgVolLength = 20;
input VolAverageType = AverageType.SIMPLE;
input ShowLabel = yes;
DefineGlobalColor("VolAvg", CreateColor(0, 100, 200));
DefineGlobalColor("Sigma2", Color.DARK_ORANGE);
DefineGlobalColor("Sigma3", Color.MAGENTA);
def Vol = volume;
plot VolAvg = MovingAverage(VolAverageType, Vol, 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);
plot VolSigma2 = VolAvg + Num_Dev1 * sDev;
plot VolSigma3 = VolAvg + Num_Dev2 * sDev;
def avgtest = Vol > VolAvg;
def sig2test = Vol > VolSigma2;
def sig3test = Vol > VolSigma3;

VolAvg.SetDefaultColor(GlobalColor("VolAvg"));
VolSigma2.SetDefaultColor(GlobalColor("Sigma2"));
VolSigma3.SetDefaultColor(GlobalColor("Sigma3"));
AddLabel(ShowLabel, if sig3test then "     Vol > Sigma3     " else if sig2test then "     Vol > Sigma2     " else if avgtest then "    Vol > Avg     " else "                  ", if sig3test then GlobalColor("Sigma3") else if sig2test then GlobalColor("Sigma2") else if avgtest then GlobalColor("VolAvg") else Color.DARK_GRAY);
 
This is awesome!!!
hey ben, is there a way that the zangler volume accumulation study would work correctlty with just the labels when integrated with the Advanced Volume Indicator lower study? i can provide the codes if need be!

basically, just take away the oscillator and just keep the labels? any help would be appreciated!
 
Last edited by a moderator:

itsthefriz

New member
VIP
@Welkin This is probably one of the best volume analysis things I've seen but have some ideas regarding how it might be improved if you're interested!

Lastly when using the VSA Accompanying indicator it's dropping a zero line on the chart, any idea why that could be? If it didn't throw off the chart scaling I wouldn't have an issue with it

 
@Welkin

I think I figured it out.

I changed "PaintingStrategy.HISTOGRAM" to ".HISTOGRAM" in your code.

Appearance wise, it looks right.

But did I do it correctly? Just want to make sure I didn't mess up your perfect code. Thanks :)

Hc4ms6K.png
@twitty_twit I tried to change "PaintingStrategy.HISTOGRAM" to ".HISTOGRAM" in the code but I keep getting errors. Would you mind copying and pasting your version here for me? I'd really like to use it also. I appreciate any help you can offer.
 

malone1020

Member
VIP
@twitty_twit I tried to change "PaintingStrategy.HISTOGRAM" to ".HISTOGRAM" in the code but I keep getting errors. Would you mind copying and pasting your version here for me? I'd really like to use it also. I appreciate any help you can offer.
There are two spots within the code where 'Squared.Histogram' is used. Just change both to 'Histogram.' This will reduce the widths of both the buy/sell colored bars. Note: there should not be a period before Histogram.
 

cucumbertony

New member
@Welkin Hey. thanks for the indicator, it's amazing but I was wondering if there is a way for the indicator to only work within market hours. For example, I was looking at the daily chart to see if I can start a trade and the volume bar was still gray at 3:59 so I didn't get in the trade however at like 4:10 pm, the volume bar turned blue and I was unable to trade at that time.

Thank you in advance.
 
Last edited:

Mbaker333

New member
VIP
i am not a coder but i have been trying (and failing) to create a scan parameter where buy vol > sell vol. since theres no plot for sell volume, i tried to write it to search for " buy vol > (vol-buyvol)" but it doesnt seem to work. Any suggestions?
 

RegularRob

New member
VIP
Do you think a total of the sell volume compared to a total of the buy volume over the past 5 bars would be beneficial? I was thinking that might give you some indication of recent trend direction. Would love to have that added. Thanks for the great indicator!

@Welkin Thank you very much! Maybe it's a newbie question. What's the difference btw buy/sell one and buy/sell two?

Buy/Sell Str for current aggregation and a 2nd aggregation. Note that this does not provide the true buy and sell volume, as this data is not available through TOS for individual stocks, although there are market internals that show up and down volume available for the different exchanges.
 

RegularRob

New member
VIP
Do you think a total of the sell volume compared to a total of the buy volume over the past 5 bars would be beneficial? I was thinking that might give you some indication of recent trend direction. Would love to have that added. Thanks for the great indicator!
Any thoughts on this? I've done some minor back testing and there seems to be a clear edge.
 

Lgh7vst

New member
2019 Donor
VIP
1) this is due to script that calls for higher aggregation data (vol strength, and the dayvol labels) here is a lite version with all of that stripped out:
http://tos.mx/xEluGZf
I plan on reworking the indicator at some point to fix all of this... but for now you'll have to use the lite version
2) do not plot volume bars if volume is less than a user specified std dev AND rvol is below a specified value? is this correct? just clarifying
3) correct, it would be nice if we could play around with the t&s data
Hi Welkin, thanks for the great indicator. Can you please post the "lite" version again so i may use it on a tick chart? the link isnt working
 

sparhawk

New member
Hey @Welkin, great indicators you have put together here. Volume and Price are the two most important things to analyze in trading. I have a suggestion for something to add that would enhance it even more. The idea is to add a signal for what I call an "anomaly candle".

An anomaly candle is when volume and the spread of the candle are not in agreement. For instance, on high volume we should see either a green or red candle print with large body (spread). An anomaly happens when there is high volume on a candle, but a low spread or at least a lower spread than we would expect to see.

This is one of the key things to look for to determine when either a pullback or potential reversal may be coming. There is higher than average volume, but the candle spread still remains relatively small. In an uptrend it would mean new buyers are entering, but also buyers are exiting at the same time so Price is not increasing on the volume. It's also a clue as to when the market makers may be getting ready to sell on an uptrend or buy on a downtrend.

The opposite is also considered an anomaly. When there is low volume the spread of the candle should be small. If there is a large spread on a candle with low volume this is not normal and signals that we should pay attention and look for a potential pullback or reversal soon.

Let me know if you think this is possible to code into the indicator!
 
Last edited:

Similar threads

Top