Assign value color to watchlist column field?

R

Rider

New member
I want to assign value colors on my watch list. I am looking at the 50 day volume percent change and 50 day price percent change and assigning a color based on the value being a positive or negative percent. Here is the script that I have so far. The problem seems to be on the last line of script. I need to add a word or something in front of the AssignValueColor. Here is the script.

Code:
input length = 50;
def vol = volume;
def volAvg = Average( volume, length );
def volPctChg = 100 * ( vol - volAvg ) / volAvg;
plot VolumePercentChange = Round( volPctChg, 0 );

input lookback = 50;
def price = close;
def priceAvg = Average( price, length );
def pricePctChg = 100 * ( price - priceAvg ) / priceAvg;
plot pricePercentChange = Round( pricePctChg, 0 );

AssignVallueColor (if pricePctChg >=1 and volPctChg <= 1 then color.Yellow else color.White);
 
rad14733

rad14733

Active member
VIP
Here is an example... I didn't verify your logic...

pricePercentChange.AssignValueColor(if pricePctChg >=1 and volPctChg <= 1 then color.Yellow else color.White);
 
R

Rider

New member
The line of script you wrote worked. However, it now says "Exactly one plot expected"
Any suggestions?
 
rad14733

rad14733

Active member
VIP
Post your current code and we'll take a look...

Edited to add: The following code works for me...

Code:
input length = 50;
def vol = volume;
def volAvg = Average( volume, length );
def volPctChg = 100 * ( vol - volAvg ) / volAvg;
plot VolumePercentChange = Round( volPctChg, 0 );

input lookback = 50;
def price = close;
def priceAvg = Average( price, length );
def pricePctChg = 100 * ( price - priceAvg ) / priceAvg;
plot pricePercentChange = Round( pricePctChg, 0 );

pricePercentChange.AssignValueColor(if pricePctChg >=1 and volPctChg <= 1 then color.Yellow else color.White);
 
Last edited:
MerryDay

MerryDay

Member
VIP
@rad14733 He is doing a Watchlist. Watchlists by definition can only plot one item. The VolumePercentChange or pricePercentChange.
Seeing as he is assigning the color value to pricePercentChange, I am assuming that is the number he wants to see. Therefore he needs to change the plot before VolumePercentChange to def
 
R

Rider

New member
Works! I changed one of the plots to a def. as suggested. Thank you.
 
rad14733

rad14733

Active member
VIP
@rad14733 He is doing a Watchlist. Watchlists by definition can only plot one item. The VolumePercentChange or pricePercentChange.
Seeing as he is assigning the color value to pricePercentChange, I am assuming that is the number he wants to see. Therefore he needs to change the plot before VolumePercentChange to def
True... Forgot he wanted this for a Watchlist rather than on a chart, which is where I tested...
 

Similar threads

Top