Mentis course
Lesson 3. Values, types and colors
30 min, foundation level
Every value has a type: int (whole numbers), float (decimals), bool (true or false), string (text) and color. Zscript usually works the type out for you.
= creates a value. := changes one that already exists. x ? a : b picks a when x is true, else b.
//@zscript 1
indicator("Up or down volume")
up = close >= open
plot(volume, "Volume", color=up ? color.green : color.red, style=plot.style_columns)
Colors: #03c988, color.red, or color.new(base, transparency) where 0 is solid and 100 invisible.
Exercises
- Three colors. Color volume green on up bars, red on down bars, and gray when close equals open.
- Soft color. Use color.new(...) to make the green 60 percent transparent.
Quick quiz
Which creates a brand new value?
A single = creates. := only changes something that exists.
What does color.new(color.red, 100) look like?
Transparency 100 is fully see-through.
Education only. Not financial advice. Examples are teaching samples, not trading results.
