where to find how to learn this in thinkscript manual

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!
 
thank you BobMarley,

is there a way I could have found this from the manual?

how did you know this would work other than trial and error, experience, and intuition?

I am still having trouble finding my own solutions after doing all the tutorials and reading the whole manual.

can you or anyone else guide me on a more robust manual for thinkscript that includes all of the possible syntax requirements? It seems this one is missing in that specific section. am I wrong?
 
you are drawing a conclusion within your statement, that is called begging the question.

I am asking because I read the manual and didn't see it and respectfully asking for advice on how to read the manual different than what I did.

if you would be so kind as to copy/paste the section that explained it, I promise I will do my diligence and study it.

I don't think it is there. I can be wrong, that is why I am here.

I disagree with you respectfully. the manual didn't explain it to me.

I will assume it didn't explain it to you either, but you learned it from trial and error and asking others who stumbled upon the solution with good luck.

if you can find it, happily copy/paste what I missed.

thanks for trying! and thanks for your kind answer in the solution. I owe you one.
 

MerryDay

Administrative
Staff member
Staff
VIP
Lifetime
@DanielManahan No thinkscript has no robust manual. ToS started as a simple plot scripting code. What traders have managed to make it do, is mostly undocumented and amazing.

The good news is that the format of the scripting is consistent. Now that you have learn the if--then-else format. You can apply it to labels, watchlists, scans, studies, etc...

@bobmarley gave good advice. The best way to learn the syntax and format is to review scripts on this forum and elsewhere.
A search of this forum came up with over 5000 examples of AddLabel. All of them start with the standard format, you have been given.
 
@DanielManahan No thinkscript has no robust manual. ToS started as a simple plot scripting code. What traders have managed to make it do, is mostly undocumented and amazing.

The good news is that the format of the scripting is consistent. Now that you have learn the if--then-else format. You can apply it to labels, watchlists, scans, studies, etc...

@bobmarley gave good advice. The best way to learn the syntax and format is to review scripts on this forum and elsewhere.
A search of this forum came up with over 5000 examples of AddLabel. All of them start with the standard format, you have been given.
I agree, what I was looking for was not in the manual and the only way to learn it effectively is to ask questions, review scripts, try stuff out, try to improvise.

and this is a nice site to get help.

I hope someday I can offer and return the favor.
 

halcyonguy

Well-known member
VIP
Lifetime
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
 
okay thanks! will do

and thank you for the Copy/Paste where it covers If then Else

every programming language has this kind of statement. it is the syntax that I couldn't get right without already knowing it and how to improvise this within the label.

as the label section failed to cover that.
 

Similar threads

Top