How to format the watchlist


Category:
0
0

Hi Pete, I am wondering if there is a way to format the style in the watch list or the quote. For example, change volume from 1,000,000 to 1M and price from 15.05 to 15, N/A to blank, etc. Thank you :-)!

Marked as spam
Posted by (Questions: 7, Answers: 9)
Asked on September 10, 2017 4:53 am
2877 views
0
Private answer

To format the values displayed in a watchlist is possible to a limited extent. All formatting must be done by writing custom thinkscript. So you cannot apply custom formatting to any of the built in columns. You must create a custom column to display your data, then apply the formatting within the code. There is only one tool provided in Thinkscript for formatting values and that is called AsText(). You can read about that here: http://tlc.thinkorswim.com/center/reference/thinkScript/Functions/Others/AsText.html

There is not a lot there. You can select 2 or 3 decimals places or you can display values as currency.

In order to display 1,000,000 as 1m. You need to take the actual value, multiply it by 0.000001, then concatenate the result with the letter “m”.  The problem is you have a value like 1,000,001 turn out like “1.000001M”. So you would also need to do some rounding. You also have to apply some mathematical gymnastics to address issues created by binary precision.

Have I talked you out of it yet?

Changing 15.05 to 15 is doable with simple rounding. Not a big deal there.

Replacing N/A with a blank should be possible. You simply check the return value using a function named IsNaN(your value here). If true, set to empty quotes “”.

Bottom line is, depending on what you want to do, it’s can be a lot of work. Be sure to check out the solution I provided in this post to get some ideas what is possible: https://www.hahn-tech.com/ans/changing-background-color-to-show-new-day-high-2-day-high/

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on September 10, 2017 8:50 am
0
Private answer

Thanks Pete! But I can’t figure them out :-). I tried the following tests but all not work. Also, NumberFormat.TWO_DECIMAL_PLACES can’t change TWO into ONE or ZERO. Please help~

def a=reference VolumeAvg(length = 5);
plot a=if(IsNaN(a) then “” else a);
AddLabel(1, AsText(If(a>1000000) then a/1000000 + “M” else a)); (I changed + to ‘and’ or ‘.’ still not work);
how to do a round?

Marked as spam
Posted by (Questions: 7, Answers: 9)
Answered on September 10, 2017 5:21 pm
0

I did the best I could to describe the difficulties in a way to convince you there was no perfect solution to the 1,000,000 displayed as 1M. In case that point did not come across. Let me emphasize right here. That is not going to work. There is no perfect solution to that. Certainly not in a form that would permit me to provide this at no charge. I might wrangle with something like this for several hours before coming up with a solution. Worse yet, I may spend several hours and come up with no solution at all. So, move on to another project and save yourself the headache.

( at September 10, 2017 6:53 pm)
0
Private answer

Took me a few hours, but here you go buddy


#Thinkorswim Watchlist Column Volume By Millions
#by DaveDoggyDogg 2019
plot x = (volume);
AddLabel (yes, + Round(x *.000001 , 1) + "M",color.white);

http://tos.mx/zokdvR

Attachments:
Marked as spam
Posted by (Questions: 4, Answers: 13)
Answered on June 15, 2019 11:28 am