Last Price Axis Label for Think or Swim

UPDATE 9 Feb 2009: Think or Swim added this as an option under “Chart Style Settings”, “Show Last Price Bubble”. It’s painted the same color as your candle scheme. My indicator is now obsolete, but I leave the code below for reference, since it shows a useful way to handle indicators that deal with the current bar only.


Think or Swim does not did not originally have a built-in “last price” label on the price axis. You have to look in the upper corner to get the latest print. My focus is always on the right hand side price axis when I trade, and I found it very distracting to have to look away from there to see the current price. Thinkscript time!

The easy answer: Plot last=close;

The problem with that is that you get a plot of some kind (dot, line, etc) on every bar on your chart. Not good. If you simply hide the study, you also hide the axis label, and end up seeing nothing. In the end I found a clean way to get that price to update live on the price axis without any other clutter on the chart. We use your friend and mine, ‘double.nan’ for this. If the current value for an indicator is N/A, then there is no plot on the chart for the current bar. Also, when the current value is N/A, the axis label retains the last known value of the indicator. This is the key. We set up the plot to check the close 1 bar in the future. If the close is a number (valid for every bar except the current bar) then we will plot N/A. If we are in the current bar, then we set the value to the ‘close’ of the bar, or the last tick. It turns out that the bar is not painted with an indicator due to the N/A logic, but the axis label is still there, happily updating away. Just what we wanted!

Here is the code (only two lines of code, lots of other commentary):

# Last Price Axis Label
# By Prospectus @
# Note! If you want your Last price label to be on top of all
# other axis labels, this study must be the first study added
# to your chart, appearing at the top of the list.
# This trickery will plot N/A for all bars, keeping your past bars
# clean, but will set the Y-axis value for the current bar close:
plot Last = if isnaN(close[-1]) then close else double.nan;
# Formatting:

Tags: ,

11 Responses to “Last Price Axis Label for Think or Swim”

  1. Vlad Says:

    Interesting solution. I have found it is quite annoying also. Can you please navigate me where to insert the script to customize last price bubble ( I am new to thinkorswim). Thx in advance.

  2. Prospectus Says:

    This will help you install it:

  3. Vlad Says:

    I’m using PaperMoney version for now and there is a problem with import function – app crashes :-S. BTW, what Last Price Bubble anyway?

  4. Prospectus Says:

    It shows a bubble with the last printed price on the right axis. It’s outdated now because it’s built in to TOS.

  5. Bart Says:

    isnaN(close[-1]) as a way of displaying something only on the last bar is just the solution I was trying to figure out. Thanks for this!

  6. Yen Says:

    Hi, do you know how to make my indicator only show for the latest 4 or 5 bars on chart?

  7. Prospectus Says:

    Use Plot whatevertheplotis = If isnan(close[-4]) then yoursignalplotthatyouwantshown else double.nan;


  8. Jeoffrey Says:

    Your article seams to be the only one on the web addressing this y-axis bubble issue, kudos for that. I have modified the code slightly to do essentially the same thing, but with a syntax that is more readily adapted to using other price types. basically I have replaced close with close(priceType=PriceType.LAST)

    plot price = if isnaN(close(priceType=PriceType.LAST)[-1]) then close(priceType=PriceType.LAST) else double.nan;

    This code works just fine, so in theory I should be able replace LAST with ASK or BID and have it display those prices instead. However, when I do that, nothing is displayed. Do you have any tips for achieving the desired result?

    Thank you.

  9. Prospectus Says:

    Leave the pricetype.last in the If statement, and change the pricetype.last in the then statement and see if that works. Bid and ask might not ever be nan.

  10. Jeoffrey Says:

    I figured out the issue(s). The chart has be an intraday chart aggregated by time, not a tick chart, with history spanning no further than 15 days, because TOS does not support bid and ask for other charts. Also, bid and ask bubbles will been hidden if in close proximity to last price bubble and maybe also when near other study bubbles depending on how you order studies in the “edit studies” window. So you can zoom in the price axis until there is enough separation between bubbles, deactivate bubbles for last price and other studies, and/or change the ordering of studies to control precedence of which bubbles get displayed when there is overlap. Last price bubble seams to always take precedence over everything. Working code below:

    plot a = if isnaN(close[-1]) then close(priceType=PriceType.ASK) else double.nan;

    plot b = if isnaN(close[-1]) then close(priceType=PriceType.BID) else double.nan;

  11. Prospectus Says:

    Thanks for checking back in!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: