The exclamation mark (!) in thinkScript code is used as a logical NOT operator. It helps you negate or reverse the condition it's applied to.
Usage
def condition = close < open ;
plot Data = !condition ;
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
There are many many ways to code the above statement.
Another example would be:
def condition = close < open ;
plot Data = condition != 1 ;
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
So the above statement says plot an up arrow whenever the condition is not true.
A more complex example
plot Data = ! ((close > open) and close > average(close,9)) ;
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
Other Common Examples
mathematical expressions vomit when there is missing data; so it is common in coding to test if the data field has a valid numeric expression.
Read more about isNaN:
https://usethinkscript.com/resources/thinkscript-double-nan-function-in-thinkorswim.14/
used when you want to find the first bar where the condition turned true. This statement says when the condition was !not true on the previous bar[1] and is true on the current bar.
So, remember, when you want to reverse the logic of a condition in ThinkScript, simply place the "not" operator (!) in front of it to achieve your desired outcome.