Seeking coding help with Volume Value Color Indicator.

Kuza

New member
Was wondering if it was possible to show each Histogram bar of Volume on a Lower study as a different color depending on the range of volume. I basically copy/pasted the code from the "VolumeAvg" study and tried to edit it.

Code:
# Volume Value Color

declare lower;

input length = 50;

plot Vol = volume;

def rng1 = Vol >= 1;
def rng2 = Vol <= 49999;
def rng3 = Vol >= 50000;
def rng4 = Vol <= 99999;
def rng5 = Vol >= 100000;
def rng6 = Vol <= 999999;
def rng7 = Vol >= 1000000;

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("rng1 && rng2", Color.LIGHT_RED);
Vol.DefineColor("rng3 && rng4", Color.blue);
Vol.DefineColor("rng5 && rng6", Color.green);
Vol.DefineColor("rng7", Color.YELLOW);

These are my current results:
eLsDtes.jpg


Thanks in advance!
 
@Kuza You might want to explore using the between() construct. The following study which is based on your partitioning of the volume size might be close to what you're looking for. You can then add bells and whistles to the code as you wish

Code:
# Volume Color Coded

declare lower;

plot Vol = volume;
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.AssignValueColor(if volume >= 1000000 then Color.Yellow
                     else if between(volume, 100000, 999999) then Color.Green
                     else if between(volume, 50000, 99999) then Color.Blue
                     else Color.Light_Red);
# End Volume Color Coded
 
Last edited:
@Kuza Here is another example using DefineColor, in case you'd like to see how this is being used

Code:
# Volume Color Coded
# tomsk
# 1.19.2020

declare lower;

plot Vol = volume;
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Volume Low", Color.Light_Red);
Vol.DefineColor("Volume Moderate", Color.blue);
Vol.DefineColor("Volume High", Color.Green);
Vol.DefineColor("Volume Spike", Color.Yellow);
Vol.AssignValueColor(if volume >= 1000000 then Vol.Color("Volume Spike")
                     else if between(volume, 100000, 999999) then Vol.Color("Volume High")
                     else if between(volume, 50000, 99999) then Vol.Color("Volume Moderate")
                     else Vol.Color("Volume Low"));
# End Volume Color Coded
 
@tomsk Thanks so much! The between() construct was definitely a more simplified (and functional) route. I wanted to use this for pre-market and open market gap-ups that are seeing high volatility and price action. Usually these segments are fluff news, press releases, and other news related factors. I'm still working on my RSS Feed and News bookmarks, so I more than likely don't get alerted to news releases in time to catch the action. Basically, by the time I hover over the volume value, look up the "cause" of the volatility, and the stock float, I end up in a FOMO position. I'm hoping this indicator, along with my pm and open scanners, will help me find quicker positions to get in and scalp off the "hype" of the moment, rather than ending up in a short position.

Edit: Ohhh okay. Thank you for showing the proper way of using DefineColor with If/Then/Else statements.
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
490 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.
Back
Top