<p>This is probably not the shortest way of doing it, but it's quick and easy:</p>
<ol>
<li>Make a null layer with a slider</li>
<li>Make a text layer with green text</li>
<li>Link the source text in your text layer to the slider in the null layer.</li>
</ol>
<p>You should see an expression like this:</p>
<pre><code>thisComp.layer(&quot;slider null&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)
</code></pre>
<p>Now add an expression to the Opacity control in your text layer. This is going to make the Opacity go to 0 if the slider value is below zero, or 100 if it is zero or above:</p>
<pre><code>if(thisComp.layer(&quot;slider null&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)&gt;=0) {100} else {0};
</code></pre>
<ol start="5">
<li><p>Now duplicate the green text layer</p>
</li>
<li><p>Rename it &quot;red text&quot;</p>
</li>
<li><p>Change the text colour to red</p>
</li>
<li><p>Edit the expression on the red text layer's Opacity control to this:</p>
<p>if(thisComp.layer(&quot;slider null&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)&lt;0) {100} else {0};</p>
</li>
</ol>
<p>Now the red text layer should only be visible when the slider value is lower than zero.</p>
<p>Screenshot of the whole thing below:
<a href="https://i.sstatic.net/9xrlq.jpg" rel="nofollow noreferrer"><img src="https://i.sstatic.net/9xrlq.jpg" alt="screen shot" /></a></p>
<p>If you want a leading &quot;+&quot; before the positive values, you could also make an &quot;if/else&quot; statement in the green Source text control, so you only see a &quot;+&quot; when the value is above zero - something like this:</p>
<pre><code>if(thisComp.layer(&quot;slider null&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)&gt;0) {&quot;+&quot; + thisComp.layer(&quot;slider null&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)} else {thisComp.layer(&quot;slider null&quot;).effect(&quot;Slider Control&quot;)(&quot;Slider&quot;)};
</code></pre>

CC BY-SA 4.0
2020-12-19T15:50:03.267Z
Hi! Very interesting and not obvious solution. Thank you!
Elina Polishchuk
CC BY-SA 4.0
2020-12-19T20:25:21.793Z
please mark as answered!
tomh
CC BY-SA 4.0
2020-12-15T11:55:24.603Z
2021-05-15T18:09:20.167Z
2021-05-15T18:09:20.167Z
tomh
<p>I just wondering if there a way to optimize the way of changing color of numbers in stock exchange template by using expressions? When I put the +before the number it turns green and if -,it turns red.</p>

<after-effects-expressions><color>
Changing color of numbers in stock exchange AE template with expressions
Elina Polishchuk
# Changing color of numbers in stock exchange AE template with expressions

(Asked by: username_0 on 2020-12-14)

I just wondering if there a way to optimize the way of changing color of numbers in stock exchange template by using expressions? When I put the +before the number it turns green and if -,it turns red.

**Tags:** after-effects-expressions, color


---

## 1 answers

### Answer by username_1 on 2020-12-15. Score: 0

This is probably not the shortest way of doing it, but it's quick and easy:

Make a null layer with a slider
Make a text layer with green text
Link the source text in your text layer to the slider in the null layer.

You should see an expression like this:
thisComp.layer("slider null").effect("Slider Control")("Slider")

Now add an expression to the Opacity control in your text layer. This is going to make the Opacity go to 0 if the slider value is below zero, or 100 if it is zero or above:
if(thisComp.layer("slider null").effect("Slider Control")("Slider")>=0) {100} else {0};


Now duplicate the green text layer

Rename it "red text"

Change the text colour to red

Edit the expression on the red text layer's Opacity control to this:
if(thisComp.layer("slider null").effect("Slider Control")("Slider")<0) {100} else {0};


Now the red text layer should only be visible when the slider value is lower than zero.
Screenshot of the whole thing below:

If you want a leading "+" before the positive values, you could also make an "if/else" statement in the green Source text control, so you only see a "+" when the value is above zero - something like this:
if(thisComp.layer("slider null").effect("Slider Control")("Slider")>0) {"+" + thisComp.layer("slider null").effect("Slider Control")("Slider")} else {thisComp.layer("slider null").effect("Slider Control")("Slider")};

> **Comments:**
> **username_0**: Hi! Very interesting and not obvious solution. Thank you!  
> **username_1**: please mark as answered!  

---

