Last Price Tracker for ThinkOrSwim

korygill

korygill

Member
VIP
Warehouse
One some charts, it is hard to discern the last price among all the other indicators and bubbles on the axis. Sometimes one wants to see the last price relative to other meaningful values like prev lows, reversal points, etc. This indicator draws a horizontal line across the chart area for the last price. I find it useful on VolumeProfile and TPO charts and many more.

Image of LinePriceTracker
(Orange line at 2981.5 on the sample charts below)



Code for LinePriceTracker

Code:
# LastPriceTracker
#
# Author: Kory Gill, @korygill
#
# Shows the last price as horizontal line across entire chart area.
#
# VERSION HISTORY  - Sortable date and time (your local time is fine), and your initials.
# 20190910-2200-KG - Created.
# ...
# ...

def vClose = close;
def nan = double.NaN;

def highestClose = HighestAll(if IsNaN(vClose[-1]) then vClose else nan);
plot hc = highestClose;
hc.SetPaintingStrategy(PaintingStrategy.DASHES);
hc.SetDefaultColor(Color.Orange);
hc.HideBubble();
hc.HideTitle();
Link to LastPriceTracker study

http://tos.mx/SkUZpR


Happy trading,
Kory Gill, @korygill
 
S

soary

New member
Hi Kory and community, this looks interesting but since I'm not a programmer and just a beginner learning thinkscript I didn't understand it at first but I think I do now, however I wonder why this code would be useful since the last price is on the platform. I do see visual benefit of having a line for the last price even though it will keep moving with every last price. Did I interpret your code correctly.?

I have been looking for something similar for a long time to put a horizontal line on my daily and intraday charts with the prior days market close that occurs at 1600 Eastern time. I found a code in TOS and tried to modify it twice. In my first attempt it was similar to your code here and the close horizontal line on the charts moved with every last close candle which is not what I wanted. This is my most recent attempt which shows no red mistakes in the code in TOS but it doesn't show the price graph on the charts. I have no idea how to fix it. I would greatly appreciate your help or the community to help me add the market close to my charts. Thanks in advance

def marketClose = 1600.00;
plot yesterday = marketClose;
input aggregationPeriod = AggregationPeriod.DAY;
input showOnlyLastPeriod = yes;
input Close = 1600.00;
#hint Close: End of Period, Market close 1600 EST.
input length = 1;
input displace = -1;
def closeByPeriod = close(period = “DAY”)[-1];
def prevPrice = close(period = aggregationPeriod)[-1];
def price = close(period = aggregationPeriod);
plot DailyClose = if showOnlyLastPeriod and !IsNaN(prevPrice) then Double.NaN else price;
DailyClose.SetDefaultColor(GetColor(3));
DailyClose.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
 
Last edited:

Top