P/L OPEN and P/L DAY: Color coded on Watchlist


Category:
0
0

I would like to change the background (or the font color) of my P/L OPEN and P/L DAY with GREEN being a profit, RED, being a loss, and black (white) being no change. I have not been able to figure out how to add a ThinkScript to implement it. Many thanks.

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on August 14, 2023 3:26 pm
510 views
0
Private answer

First detail I must explain is that it is not possible to modify any of the built-in quote fields you may add to a watchlist gadget. And there is no way to write any script which can change the color of another column. So the only viable solution would be to create new custom watchlist columns from scratch.

Thinkorswim provides several functions we can use to display data based on the user's portfolio. You find them listed here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Portfolio

From that list, the one that reports the data needed for these two values is named "GetOpenPL()". If you apply that function to a plot statement on a chart study it works perfectly. And you can compute the values you specified and display them in labels on a chart:

declare lower;
plot openPL = GetOpenPL();
def data = openPL - openPL[1];
AddLabel(yes, Concat("P/L Day: ", data), if data > 0 then Color.GREEN else if data < 0 then Color.RED else Color.WHITE); AddLabel(yes, Concat("P/L Open: ", openPL), if openPL > 0 then Color.GREEN else if openPL < 0 then Color.RED else Color.WHITE);

The problem is this function does not work when applied to a watchlist. When you take the code that works on a chart study and apply it to a watchlist column it generates an error: "No such function: GetOpenPL".

With the current version of Thinkorswim, this solution only works for a chart study but it does not work for a custom watchlist column. For those users of Thinkorswim who feel this is an essential feature, you may consider submitting a feature request to the developers of Thinkorswim.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 14, 2023 4:07 pm
0
Thanks so much for your clear and detailed answer, Pete. Yes, I am interested in changing colors in my WATCHLISTS, not charts. I had tried something along those lines and always got the error message you mentioned. Regardless, your effort is appreciated.
( at August 14, 2023 10:33 pm)