• Get $40 off VIP by signing up for a free account! Sign Up

AssignValueColor and TakeValueColor issues


New member
I've got the following code where I'm trying to paint histogram bars on a gradient with a low average magenta and a high average cyan, but the bars aren't painting the right color. They just paint cyan and I'm honestly not sure where it's getting cyan because if I change dynamic colors away from cyan and magenta the bars still paint cyan.

If I comment out the SumTick.hide(); line I can see that SumTick is using the correct colors, but for TL and TH the plot doesn't seem to be pulling the colors correctly and using them.

Any suggestions?

declare lower;

plot SumTick = (close("$TICK") + high("$TICK") + low("$TICK")) /3;
SumTick.AssignNormGradientColor(14, Color.MAGENTA, color.CYAN);

def TickHigh = high("$TICK");
def TickLow = low("$TICK");
def TickDiff;

if TickHigh > 0 and TickLow > 0 {
    TickDiff = TickLow;
} else if TickHigh < 0 and TickLow < 0  {
    TickDiff = TickHigh;
} else {
    TickDiff = 0;

plot ZL = 0;

plot ZLfill = 0;
ZLfill.AssignValueColor(if TickDiff != 0 then color.BLACK else color.ORANGE);

plot TD = TickDiff;

plot TH = TickHigh;

plot TL = TickLow;
You can change colorNormLength to anything you want. Try 2 for what I think you want

declare lower;
input colorNormLength = 25;

plot SumTick = (close("$TICK") + high("$TICK") + low("$TICK")) /3;

def TickHigh = high("$TICK");
def TickLow = low("$TICK");

SumTick.DefineColor("Highest", CreateColor(0,255, 255));
SumTick.DefineColor("Lowest", CreateColor(255, 0, 255));
SumTick.AssignNormGradientColor(colorNormLength, SumTick.color("Lowest"), SumTick.color("Highest"));
I've tried various values for the length in the original code and it didn't seem to make any difference. If I add the plots for TD and TH to your code I get basically what I was getting before. Without those plots your code plots bars that are colored nicely but doesn't show anything above the 0 line for low readings or below the 0 line for high readings. I'd still like the highs and lows included for the bars. The idea is show cyan if $TICK is running high and magenta if it's running low, but encompass the whole range for the $TICK values in a particular bar.
Basically I have a 5 minute /MES chart. At the bottom I want to see $TICK, the full bar from low to high, and I want it colored based on whether the summation ((high+low+close)/3) is high or low.
The way I have it right now TH plots the high value for $TICK and TL plots the low value for $TICK. If I plot them as histograms then I get a bar that goes from low to high. Now I want to use the summation gradient as the colors for those plots, which should come from SumTick. The SumTick is just there to create the color gradient, the plot is hidden off the chart. If I don't hide the SumTick plot I can see that it's doing the colors right. Those colors just don't seem to be translating to the TL and TH like they should by using AssignValueColor and TakeValueColor. The TL and TH plots seem to just be using a default color of cyan and I don't understand why.
I am not seeing any cyan.
But there is an issue with your code. You can't use the TakeValue function to assign a color from the AssignGradient function. TakeValue can only be used where a defined color value exists. Gradients by definition do not have specific assigned values.

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

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
230 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.