Posts Tagged ‘Last_price’

Last Price Axis Label for Think or Swim

February 3, 2009

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.

lastpriceaxislabel3

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): (more…)