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.
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.!isNAN(condition)
Read more about isNaN:
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 and is true on the current bar.!condition and condition
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.