• The price of VIP membership is increasing to $199 beginning June 1. Click here to lock in the current rate of $149.

AssignValue Color to Watchlist Data

Rider

New member
I have the following script for a watch list column. My problem is when VolPctChg values are between 0% and -49% they display a red rather than yellow color. Iam trying to have values above zero display green and values between 0 and -50% display yellow and values below -50% display red. I would appreciate any help. Thanks.

Input length = 21;
Def vol = volume;
Def volAvg = Average(volume, length);
def volPctChg = 100 * ( vol - volAvg ) / volAvg;
plot VolumePercentChange = Round( volPctChg, 0 );

VolumePercentChange.AssignValueColor(if Volpctchg >.01 then color.GREEN else color.Yellow);

VolumePercentChange.AssignValueColor (if Volpctchg <-.50 then color.red else color.yellow);
 

rad14733

Well-known member
VIP
You need to put the comparison logic all in one assignment command...
Code:
VolumePercentChange.AssignValueColor(if Volpctchg >.01 then color.GREEN else if Volpctchg <-.50 then color.red else color.yellow );
 

Similar threads

Top