Round Up Zero digits after decimal

GPM

New member
I am new to this forum and also new to Think Or Swim. I did a search and could not find answers to my questions so trying a new post. Hope someone can help me.

1) In my watchlist, I am using there pre-built %Change column. It shows me percentage change in price since previous trading days' close. But I cannot find the prebuilt column names for "previous day close price" and "dollar change" since yesterday's close.

2) I want to create custom columns for "dollar change" and "%Change" and want to show rounded up values.. How do I round up so that my custom columns show zero digits after the decimal. Thus for example, if I have a number 123.45 I want to show it as 123, and if I have 12345.67 I want to show it as 12346. If zero digits is not possible, I can live with 123.0 (which seems to work when I say round (num, 0)

3) Same thing with PE ratio. Is there a way to refer to the pre-built watch list column called Price/Earnings Ratio when I am writing a custom think Script column?


thank you.
 

rlohmeyer

Active member
VIP
Hi,

I am looking for coding that given the following formula would stipulate that the remainder be a whole number:

xnumber / 5 = whole number remainder

For instance: 40/5 = 8 (meets criteria)
39/5 = 7.8 (does not meet criteria)

This I would use to stipulate a specific color for a specific price level.

Thanks for any help.

Bob
 

rlohmeyer

Active member
VIP
@generic

It was exactly what I was looking for. And thankyou for your offer. I am working to learn Thinkscript as I use it on my trading charts. Your code I used in this indicator:

https://usethinkscript.com/threads/auto-significant-price-levels-for-thinkorswim.4867/post-56809

It was used to identify and color price levels that are rounded to integers of 5, so they are clearly identifiable on the minute chart I trade for a specific stock. The interval (integer) might change based on the instrument, but the indicator gives me a way to specify the integer, (and thus price level) I am looking to emphasize.

Again, thanks. This was the last thing I needed in order finish the indicator and post.

Regards,
Bob
 

Zero-Sums

New member
I am new to this forum and also new to Think Or Swim. I did a search and could not find answers to my questions so trying a new post. Hope someone can help me.

1) In my watchlist, I am using there pre-built %Change column. It shows me percentage change in price since previous trading days' close. But I cannot find the prebuilt column names for "previous day close price" and "dollar change" since yesterday's close.

2) I want to create custom columns for "dollar change" and "%Change" and want to show rounded up values.. How do I round up so that my custom columns show zero digits after the decimal. Thus for example, if I have a number 123.45 I want to show it as 123, and if I have 12345.67 I want to show it as 12346. If zero digits is not possible, I can live with 123.0 (which seems to work when I say round (num, 0)

3) Same thing with PE ratio. Is there a way to refer to the pre-built watch list column called Price/Earnings Ratio when I am writing a custom think Script column?


thank you.
Use this type of styling, this is an example for showing volume average of 10 days

def avgVol = Average(volume, 10);
AddLabel(yes, Round(avgVol, 0));
 

trader_

New member
To piggyback off of this older conversation, I am trying to round price lines on my chart to the nearest tick value (for futures).

Right now I am using:
Code:
Round(value, ticksize());

The value seems to round to the nearest point, not tick.

Any suggestions?
 

SleepyZ

Well-known member
VIP
Lifetime
To piggyback off of this older conversation, I am trying to round price lines on my chart to the nearest tick value (for futures).

Right now I am using:
Code:
Round(value, ticksize());

The value seems to round to the nearest point, not tick.

Any suggestions?

Here is one way

Capture.jpg
Ruby:
#Example_MovingAverage_Round_to_Ticksize
plot x = ExpAverage(close, 9);
#Normal rounding
AddLabel(1, Round(x), Color.YELLOW);
#Round to Ticksize
AddLabel(1, Round((x / TickSize()), 0) * TickSize(), Color.WHITE);
 

GoldCrazy

New member
Hello Everyone
I am new at coding, I know enough to be very dangerous, My question is there a way to round up to the nearest whole number in the code like you can in Excel ?
 

mbrennan5

New member
For anyone who wants zero decimal places in your watchlist column, just replace your Plot with AddLabel and then utilize the Round function.
The downfall is the text appears white and can't be changed. It prevents me from using it on a column with dynamic background coloring.
EDIT- it also seems to mess up the sort, so not very useful.
 
Last edited:

halcyonguy

Well-known member
VIP
Lifetime
For anyone who wants zero decimal places in your watchlist column, just replace your Plot with AddLabel and then utilize the Round function.
The downfall is the text appears white and can't be changed. It prevents me from using it on a column with dynamic background coloring.
EDIT- it also seems to mess up the sort, so not very useful.

please research before posting

sort text in a column
https://usethinkscript.com/threads/...tion-from-addlabel-function.10456/#post-92584
post2

font color in a column
https://usethinkscript.com/threads/moving-average-crossovers-for-thinkorswim.229/page-6#post-64703
post103
 
Last edited:

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Top