Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-19T15:50:03.267Z
Answers.Text: Hi! Very interesting and not obvious solution. Thank you!
Answers.UserDisplayName: Elina Polishchuk
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-19T20:25:21.793Z
Answers.Text: please mark as answered!
Answers.UserDisplayName: tomh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-15T11:55:24.603Z
Answers.LastActivityDate: 2021-05-15T18:09:20.167Z
Answers.LastEditDate: 2021-05-15T18:09:20.167Z
Answers.UserDisplayName: tomh
Body: <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>
  
Tags: <after-effects-expressions><color>
Title: Changing color of numbers in stock exchange AE template with expressions
UserDisplayName: Elina Polishchuk
ThreadText: # 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:
  
  1. Make a null layer with a slider
  2. Make a text layer with green text
  3. 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};
  
  ```
  
  5. Now duplicate the green text layer
  6. Rename it "red text"
  7. Change the text colour to red
  8. 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:
  [![screen shot](https://i.sstatic.net/9xrlq.jpg)](https://i.sstatic.net/9xrlq.jpg)
  
  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!  
  
  ---
  
  