I am reading the thinkscript manual, tutorials and I can't find where to locate the specific instruction how to deal with conditions changing the color of an addlabel
from this code it is obvious what I want to do, yet it doesn't work.
if you can tell me where I made my mistake in reading the manual, what page, what paragraph, that would be most helpful.
thanks!
AddLabel(yes, if close > Average(close, 20) then "Uptrend", color.green else "Downtrend", color.red); #this code fails and I don't know where in the manual I should have looked. thanks!
hello,
no manual will tell you how to combine functions, they will just list info on each one. it is up to you to learn how to use each function. then figure out how to combine them.
it is possible to use an if then inside of a label, and other functions, to choose a number, text, or a color.
i would suggest looking at the pages of the thinkorswim site and look at the examples. ( i will say most of the examples are overly complicated, so don't get discouraged if they don't make sense at first.)
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/If
label
https://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AddLabel
at the top of the page , and every other function page, will be description of the input parameters. look them over, to help you understand what a function expects for inputs.
AddLabel ( boolean visible, Any text, CustomColor color);
which lists the 3 parameters that are used with addlabel.
the first , boolean visible, tells it when to enable it , when to make it visible.
a 1 will cause an addlabel to be visible all the time.
addlabel(1, "test", color.yellow)
if you want a label visible when the price is more than $50, you can use a boolean statement. close>50.
to change the the words, use an if then,
addlabel( (close > 50), ( if close >= 50 then "above 50" else "below 50", color.yellow)
i have this as the top choice in my google page.
thinkscript color
i keep using the same words to quickly open up a page on the thinkscript site, then search for what i want.
https://tlc.thinkorswim.com/center/reference/thinkScript/Constants/Color