color text for opening gap


Category:
0
0

Pete, I’m trying to color text for gap up/down, what am I missing ?

plot c = open – close[1];
AssignColor (if open > close then Color.GREEN else Color.RED);

Thanks, AJ

Marked as spam
Posted by (Questions: 2, Answers: 1)
Asked on July 18, 2019 12:50 pm
111 views
0
Private answer

Well for one I can see a disconnect between the value you are plotting and the test you are using to change the color.

The plot statement is subtracting the previous bar's close from the current bar's open:

plot c = open – close[1];

However your statement that is trying to change the color of the text is testing if the current bar's open is greater than the current bar's close. But there is a much greater problem preventing this from working. Which is you are trying to use a function that does not exist.

Here is your statement that is trying to set the text color:

AssignColor (if open > close then Color.GREEN else Color.RED);

You can search the language reference for Thinkorswim and you will not find a function named "AssignColor()". In order to change the color of the value displayed in a watchlist column you would use the function named "AssignValueColor()". Details on how to use this function are listed here:

http://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Look---Feel/AssignValueColor.html

So what you really need here is:

c.AssignValueColor(if open > close[1] then Color.GREEN else Color.RED);

Notice that just as in the example shown in that link I provided, the name of the plot must precede the name of the function, with a '.' inserted between them.

Final thought. You may want to adjust your code to measure the current day's low against the previous day's high. This would more cleanly fit the common definition of a stock that has gapped up from the previous day. Once today's low is less than or equal to previous day's high, the gap is considered closed and is not longer actionable.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on July 19, 2019 9:51 am