Look up "conditional formatting" in FMP Help.
My take on it would use the Let function, Case function and TextColour function. (You don't need the Let but I think it makes things easier to read.) It would need to be unstored in order to recalculate each day.
Let ( var.daysTodeadline = deadline - Get(CurrentDate) ;
Case ( var.daysTodeadline > 5 ; TextColor ( var.daysTodeadline ; RGB ( 0 ; 255 ; 0 ) ) ; //green
2 < var.daysTodeadline and var.daysTodeadline ≤ 5 ; TextColor ( var.daysTodeadline ; RGB ( 255 ; 128 ; 0 ) ) ; //orange
TextColor ( var.daysTodeadline ; RGB ( 255 ; 0 ; 0 ) ) // red
you might want to think about the orange colour, it looks very much like red.
for conditional formatting you'd break it down into three conditions (daysTodeadline being the name of the calculation field "deadline - Get(CurrentDate)" )
daysTodeadline > 5 // apply green formatting
2 < daysTodeadline and var.daysTodeadline ≤ 5 // apply orange formatting
daysTodeadline ≤ 2 // apply red formatting
You can more easily set up formats using conditional formatting and apply it to much more than just a single calculation result. You could colour a headline or change background colours as well. However it gets a little more fiddly setting it to several fields on several layouts.
--another edit-- changed formula
not sure why "2 < daysTodeadline ≤ 5" doesn't evaluate the same as "2 < daysTodeadline and var.daysTodeadline ≤ 5"
....probably because 2 is always less than 5 and my maths skills are weaker than I'd like !
Belton suggested, "(daysTodeadline being the name of the calculation field "deadline - Get(CurrentDate)" )"
No need for calculation at all - eliminate this field unless it is really needed somewhere else that can't be handled via conditional format or layout-level variables.
"green if over 5 days, orange between 2 and 5 days and red if 2 or under including negatives."
You have included 2 in two conditions (see portion I bolded in sentence above). Anyway, you can adjust as needed. Without knowing your FM version, we cannot truly say what you should do. If you use conditional formatting, only two calculations are needed:
Create first condition as: "Value is" and "Less than x days ahead" and specify 5. Make the text orange.
Create second condition as: "Value is" and "Less than x days ahead" and specify 3. Make the text red.
Make the regular text color of the field green.