Volume Based Candles Identifier for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
Note: For this ThinkorSwim version, I have made changes to the coloring a bit.
  • LIGHT GREEN = WHITE and Orange = BLUE

d35CP2B.png


Most of the time traders are confused about if the price movements were supported by VOLUME. This indicator colors the bars into volume weighted signals...When prices go down bars are red and controversially when up, bars are green. Additionally we have two more colors for each situation:
  • DARK RED when prices go down and VOLUME is bigger than 150% of its (default 21 day) average, that indicates us price action is supported by a strong BEARISH VOLUME
  • RED when prices go down and VOLUME is BETWEEN 50% AND 150% of its (default 21 day) average, at this situation we can think that volume is neither strong nor weak
  • ORANGE when prices go down and VOLUME is just less than 50% of its (default 21 day) average, so the volume is weak and doesn't support the price action much
  • DARK GREEN when prices go UP and VOLUME bigger than 150% of its (default 21 day) average, that indicates us price action is supported by a strong BULLISH VOLUME
  • GREEN when prices go UP and VOLUME is BETWEEN 50% AND 150% of its (default 21 day) average, at this situation we can think that volume is neither strong nor weak
  • LIGHT GREEN when prices go UP and VOLUME is just less than 50% of its (default 21 day) average, so the volume is weak and doesn't support the price action much

thinkScript Code

Code:
# Volume Based Coloured Bars
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/8RPiMMmn-Volume-Based-Coloured-Bars/

# Note: LIGHT GREEN = WHITE and Orange = BLUE

input length = 21;

def avrg = simpleMovingAvg(volume, length);

def vold1 = volume > avrg * 1.5 and close<open;
def vold2 = volume >= avrg*0.5 and volume<=avrg*1.5 and close<open;
def vold3 = volume < avrg *0.5 and close<open;

def volu1 = volume > avrg*1.5 and close>open;
def volu2 = volume >= avrg * 0.5 and volume<=avrg*1.5 and close>open;
def volu3 = volume < avrg * 0.5 and close>open;

assignPriceColor(if vold1 then color.dark_red else if vold2 then color.red else if vold3 then color.blue else if volu1 then color.dark_green else if volu2 then color.uptick else if volu3 then color.white else color.CYAN);
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I like the idea but find it a bit confusing especially with the color white and blue. maybe it is because I am not catching its use from a day trading perspective. I wonder if it is possible to eliminate some colors or somehow correlate them with the distance of VWAP or some type of relation to the 50 and 200 EMA?
 
Is there a way to show volume by increasing decreasing the width of the candle i.e. fatter candles would represent increase volume and vice versa TY
 
@BenTen, could you possibly add to the code the ability to color the candles based on the average of the last 3 candles let's say (you can leave that open for everyone to put their own number). I think this will help us "Smooth" the noise that may come from just 1 candle/print. And if we can combine that with what @DeusMecanicus shared, I think we would have a GREAT indicator. Much appreciated and thank you for your help in advance.
 
This indicator was requested by a member of ours. Here is his concept of the script:
  • When volume is drying up while the RSI is overbought = bearish
  • When volume is rising while the RSI is oversold = bullish
Test it out and let us know if it helps. Give the candles sometime to play the trend out even if it's already in overbought or oversold territory.

Paintbars and arrows are being plotted by default. You can easily turn either one off via the indicator's setting. No need to touch the code.

KARuTuV.png


thinkScript Code

Code:
# Volume Based Reversal Candles
# When volume is drying up while it's overbought = bearish
# When volume is rising while it's oversold = bullish
# Assembled by BenTen at useThinkScript.com

input paintbar = yes;
input arrows = yes;

# Start RSI
input length = 14;
input over_Bought = 65;
input over_Sold = 35;
input price = close;
input averageType = AverageType.WILDERS;
def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;
def RSI = 50 * (ChgRatio + 1);
def OverSold = over_Sold;
def OverBought = over_Bought;

def bearish_vol = VOLUMEAVG(LENGTH = 20) < VOLUMEAVG(LENGTH = 20)[5];
def bullish_vol = VOLUMEAVG(LENGTH = 20) > VOLUMEAVG(LENGTH = 20)[5];

def bullish_signal = RSI(length = length, averageType = averageType) < over_Sold and bullish_vol;
def bearish_signal = RSI(length = length, averageType = averageType) > over_Bought and bearish_vol;

assignPriceColor(if paintbar and bullish_signal then color.green else if paintbar and bearish_signal then color.red else if paintbar then color.white else color.current);

# Plot Signals
plot bullish = if arrows and bullish_signal then bullish_signal else double.nan;
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish.SetDefaultColor(Color.CYAN);
bullish.SetLineWeight(1);
plot bearish = if arrows and bearish_signal then bearish_signal else double.nan;
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish.SetDefaultColor(Color.CYAN);
bearish.SetLineWeight(1);
 
Last edited:
I really like this idea, thanks for making it!

I've customized it just a bit to my liking to make the highest volume bars the brightest, and the lowest volume bars the darkest - along with adding Volume type option (exponential by default) and volume average line in the volume area.

GMEnX2L.png


CICXqNg.png


Code:
# Volume Based Coloured Bars
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/8RPiMMmn-Volume-Based-Coloured-Bars/
# Modified by Wiinii
# Version 1.0
# https://usethinkscript.com/threads/vpa-candles-bars-with-anomaly-detector-for-thinkorswim.13831/

#hint: Indicates candles with high volume (bright green/red), candles with low volume (dark green/red) average volume (standard red/green).

declare on_volume;

input Tall_Candle_X = 1.2;
input Short_Candle_X = 1.2;
input VolAvg_X = 1.0;
input Volume_Candles_Average = 10;
input volAvgType = averageType.exponential;

def AverageCandle = SImpleMovingAvg(price = (high[1] - low[1]), length =Volume_Candles_Average);

def CurrentCandle = high - low;

plot Vol = volume;
vol.sethiding (1 ==1 );
plot VolAvg = movingAverage(volAvgType,volume,Volume_Candles_Average);
VolAvg.SetPaintingStrategy(PaintingStrategy.line);
VolAvg.SetDefaultColor(Color.CYAN);

def UVolHi = volume > VolAvg * 1.2 and close > open;
def UVolMed = volume >= VolAvg * 0.8 and volume <= VolAvg * 1.2 and close > open;
def UVolLow = volume < VolAvg * 0.8 and close > open;

def DVolHi = volume > VolAvg * 1.2 and close < open;
def DVolMed = volume >= VolAvg * 0.8 and volume <= VolAvg * 1.2 and close < open;
def DVolLow = volume < VolAvg * 0.8 and close < open;

Vol.DefineColor("UVolHi", CreateColor(0,255,0));
Vol.DefineColor("UVolMed", CreateColor(0,175,0));
Vol.DefineColor("UVolLow", CreateColor(0,40,0));
Vol.DefineColor("DVolHi", CreateColor(255,0,0));
Vol.DefineColor("DVolMed", CreateColor(175,0,0));
Vol.DefineColor("DVolLow", CreateColor(60,0,0));
Vol.DefineColor("NoVol", Color.gray);

assignPriceColor(if UVolHi then Vol.Color("UVolHi") else if UVolMed then Vol.Color("UVolMed") else if UVolLow then Vol.Color("UVolLow") else if DVolHi then Vol.Color("DVolHi") else if DVolMed then Vol.Color("DVolMed") else if DVolLow then Vol.Color("DVolLow") else Vol.Color("NoVol"));
 
Last edited:
I like it a lot, thanks.
Can you put a label box for a volume for sell and buy, especially week and month volume?
 

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
287 Online
Create Post

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top