Candle Color by Volume For ThinkOrSwim

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

find below as requested
#// This source code is subject to the terms of the Mozilla Public License 2.0 at
#// © the_MarketWhisperer
#// Version 1.0
#// (Based on a code that I found somewhere in the TV world)
#// A simple indicator that paints candles with different shades of colors based on the volume transacted.
#// Supports 6 levels of sensitivity at present.
#// Darkest indicates the most volume transacted. Lightest, the least.
#// Use it for your Volume Spread Analysis and/or in conjunction with any other strategies that you employ.
#// Relative volume is calculated based on EMA (set to 20 period by default)
#study(title="Candle Color by Volume", shorttitle="VolumeColoredCandles", overlay=true)

input emaPeriod = 20; # Volume EMA Period
input PaintBar = yes;

def volumeRatio = volume / ExpAverage(volume, emaPeriod);
def isUp = close > open ;

#//Green and red color repository. 6 is darkest. 1 is lightest.
DefineGlobalColor("g_01" , CreateColor(223,245,223));
DefineGlobalColor("g_02" , CreateColor(200,230,201));
DefineGlobalColor("g_03" , CreateColor( 3,247, 3));
DefineGlobalColor("g_04" , CreateColor( 68,198, 73));
DefineGlobalColor("g_05" , CreateColor( 12,168, 12));
DefineGlobalColor("g_06" , CreateColor( 0,103, 0));
DefineGlobalColor("r_01" , CreateColor(244,229,229));
DefineGlobalColor("r_02" , CreateColor(249,205,205));
DefineGlobalColor("r_03" , CreateColor(247,155,155));
DefineGlobalColor("r_04" , CreateColor(230, 97, 97));
DefineGlobalColor("r_05" , CreateColor(243, 0, 0));
DefineGlobalColor("r_06" , CreateColor(159, 0, 0));

AssignPriceColor(if PaintBar then if volume and isUp then if volumeRatio > 2 then GlobalColor("g_06") else
if volumeRatio > 1.5 then GlobalColor("g_05") else
if volumeRatio > 1.2 then GlobalColor("g_04") else
if volumeRatio > 0.8 then GlobalColor("g_03") else
if volumeRatio > 0.4 then GlobalColor("g_02") else GlobalColor("g_01")
else if volume then if volumeRatio > 2 then GlobalColor("r_06") else
if volumeRatio > 1.5 then GlobalColor("r_05") else
if volumeRatio > 1.2 then GlobalColor("r_04") else
if volumeRatio > 0.8 then GlobalColor("r_03") else
if volumeRatio > 0.4 then GlobalColor("r_02") else GlobalColor("r_01")
else color.current else color.current);

###### END ####
Last edited by a moderator:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
358 Online
Create Post

Similar threads

Similar threads

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.