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.
 
I see. ok, thanks.

I am hoping someone else has figured out a solution for displaying this. Perhaps make it a text or something like that, and then substring it till the decimal point or some such trick.
 
I see. ok, thanks.

I am hoping someone else has figured out a solution for displaying this. Perhaps make it a text or something like that, and then substring it till the decimal point or some such trick.
Unfortunately, Thinkorswim does not have text manipulation functions... It is designed for working with numbers...
 
Ok, here are the answers I found using my own research. Posting it here just in case anyone else can find it useful in the future.

For 1) The column names are "Close" and "Net Change"

For 2) Many many web sites have suggested ToS has a limitation. It treats everything as a double, and there is no way to display values without a trailing decimal point (even if you round it to a precise integer it will still show as 123.0)

For 3) I still have not figured out how to refer to built in columns like Net Change, PE etc in my own ToS code. For a program so rich in functionality, I have to give Kudos the programmers. However, I feel that the reference manual for the program needs to be beefed up a lot. It would make this offering much stronger than it is.
 
Hello,
Is there a line of code that can be added to an indicator to drop the numbers to the right of the decimal point? Keep it a whole number, i.e. 123545 and not 12345.678.
Thank you.
 
Hello,
Is there a line of code that can be added to an indicator to drop the numbers to the right of the decimal point? Keep it a whole number, i.e. 123545 and not 12345.678.
Thank you.
No, that would require text string manipulation functions that TOS does not have, as mentioned previously... If it did have them you could display as text and use substr() type of function...
 
No, that would require text string manipulation functions that TOS does not have, as mentioned previously... If it did have them you could display as text and use substr() type of function...
Thank you all once again. Since I was using this in a label, I added this to the start "AddLabel(yes, "RSI: " + Round(RSI, 0)" and it worked and gave me a whole number.(y)
 
I like working with Monkey Bars to establish potential entries. I have added labels to the built-in script, but I cannot get the VPOC to plot to four decimals for Forex. It just prints 1 digit with no decimals. I wonder if someone can help me.

Here's what I added to the existing Monkey Bars Script:

Code:
AddLabel(yes,"MBar:" + MBar, Color.GREEN);
AddLabel(yes,"PGHigh:" + hPG, Color.MAGENTA);
AddLabel(yes,"PGLow:" + lPG, Color.MAGENTA);
AddLabel(yes,"PHigh:" + hProfile, Color.LIGHT_GRAY);
AddLabel(yes,"PLow:" + lProfile, Color.LIGHT_GRAY);
AddLabel(yes,"VPOC:" + showVolumePoc, Color.Blue);

Thank you so much.
 
@Ian_Tai We would need to see the code that produces the numbers you are trying to display in your labels... By default there should be decimals so perhaps they are being manipulated elsewhere... Can you please post the entre script...???
 
Code:
# ATR Daily Range
# tomsk
# 12.17.2019

# V1.0 - 12.16.2019 - tomsk   - Initial release ATR Daily Range
# V1.1 - 12.16.2019 - tomsk   - Added performance relative to ATR range
# V1.2 - 12.17.2019 - tomsk   - Added plot lines for ATR High/Low on the chart

# Displays ATR High/Low thresholds relative to daily open

input length = 14;
input averageType = AverageType.WILDERS;

def o = open(period = AggregationPeriod.DAY);
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
def c = close(period = AggregationPeriod.DAY);
def R = (c - l) / (h - l);
def DTR = h - l;

def ATRD = MovingAverage(averageType, TrueRange(h, c, l), length);
def ATRH = o + ATRD;
def ATRL = o - ATRD;
def DTRpct = Round((DTR / ATRD), 0);
AddLabel(close > 0, Concat( "ATR: ", round(ATRD) * 10000), Color.GREEN);
#AddLabel(1, "ATR Daily High/Low Level = [ " + Round(ATRH,2) + " / " + Round(ATRL,2) + " ]", Color.PINK);
#AddLabel(1, "["+AsPercent(r)+"]", Color.green);

def LBN = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN;
plot ATR_High = if BarNumber() >= HighestAll(LBN)
                then HighestAll(if IsNaN(close[-1]) then ATRH else Double.NaN)
                else Double.NaN;
ATR_High.SetLineWeight(2);
ATR_High.SetDefaultColor(Color.GREEN);

plot ATR_Low = if BarNumber() >= HighestAll(LBN)
               then HighestAll(if IsNaN(close[-1]) then ATRL else Double.NaN) else Double.NaN;
def mid = (h + l) / 2;
input showOnlyLastPeriod = yes;
plot ATR_H;
plot ATR_L;
if showOnlyLastPeriod and !IsNaN(close(period = AggregationPeriod.DAY)[-1]) {
    ATR_H = Double.NaN;
    ATR_L = Double.NaN;
} else {
    ATR_L = mid - (ATRD / 2);
    ATR_H = mid + (ATRD / 2);
}
ATR_H.SetDefaultColor(Color.GREEN);
ATR_L.SetDefaultColor(Color.GREEN);
ATR_Low.SetLineWeight(2);
ATR_Low.SetDefaultColor(Color.GREEN);
# End ATR Daily Range
I currently trade futures and I'm using ATR. is there any way to round .0123 to .012?

Whenever I use the Round function it rounds to .01
 
Hi All, I made a label for ATR and was wanting to round that number to the hundreds...ie ATR = 0.0248 change to ATR= 0.03 or 0.02. Any help would be appreciated.

Code:
declare upper;

input length = 14;
input averageType = AverageType.WILDERS;

def ATR = MovingAverage(averageType, TrueRange(high, close, low), length);

#Label
AddLabel(yes, ("ATR = "+(ATR)), Color.YELLOW);
 
@kmg526 Here is the code I use for my ATR Chart Label...

Ruby:
# ATR_Label
input atrLength = 13;
input atrAverageType = AverageType.WILDERS;
def atr = Round(MovingAverage(atrAverageType, TrueRange(high, close, low), atrLength), 2);
AddLabel(yes, "ATR: " + Round(atr, 2), Color.LIGHT_GRAY);
# END ATR_Label
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
366 Online
Create Post

Similar threads

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.
Back
Top