Current Price Line Indicator for ThinkorSwim

korygill

Well-known member
VIP
This indicator displays a horizontal line across your ThinkorSwim chart to show the current value of the price.

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)

qfAALiw.png


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

https://tos.mx/SkUZpR


Happy trading,
Kory Gill, @korygill
 

Attachments

  • qfAALiw.png
    qfAALiw.png
    376.6 KB · Views: 273
Last edited by a moderator:
Very useful, thanks for sharing it (y)

Code:
# Horizontal Price Line
# Mobius
# 2.20.2018

plot priceLine = highestAll(if isNaN(close[-1])
                            then if high >= close(period = AggregationPeriod.day) then close else double.nan
                            else Double.NaN);
priceline.SetPaintingStrategy(PaintingStrategy.line);
priceLine.SetLineWeight(1);
priceLine.SetDefaultColor(CreateColor(50,250,150));
priceline.HideTitle();
 
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

Code:
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:
Hi, I noticed E-trade and Tradingview have a static price line indicator in their charts but TOS did not. TOS help desk made such an indicator for me but they could not or did not have the time to make it work with extended hours, only works with extended hours set to 0. Thus it does not work with any study such as Ichimoku. Was wondering if such an indicator already exist or can someone code this one https://tos.mx/5OkZ8GE to work with extended hours. Thanks in adavance .
 
Noticed that this indicator does not work in extended hours, is there any way to modify the code to make that work?
 
If you are working with only the daily chart then no. In order to see if with extended hours you would have to be on an intraday chart.
 
If you are working with only the daily chart then no. In order to see if with extended hours you would have to be on an intraday chart.

It’s the intraday chart i was trying it with. The line was showing in pre-market but it was not moving along as the price changed.
 
This is a basic chart from TradingView. I really like how there is a simple line that tracks with the market price across the chart. Is there anybody who can help me implement this into TOS?

IxBZ5uv.png
 
This is a basic chart from TradingView. I really like how there is a simple line that tracks with the market price across the chart. Is there anybody who can help me implement this into TOS?

IxBZ5uv.png
#Plots a Horizontal Line that follows the price value selected
input price=close;
input offset=0;
input length = 300;

def sma = SimpleMovingAvg(price, 1, length);
rec line = if IsNaN(sma) then line[1] else sma[offset];
plot priceline=if isnan(sma) then line else double.nan;
priceline.setpaintingStrategy(paintingStrategy.LINE);
priceline.setlineWeight(3);
priceline.setdefaultColor(color.green);
priceline.hideBubble();
 

Attachments

  • IxBZ5uv.png
    IxBZ5uv.png
    33 KB · Views: 181
#Plots a Horizontal Line that follows the price value selected
input price=close;
input offset=0;
input length = 300;

def sma = SimpleMovingAvg(price, 1, length);
rec line = if IsNaN(sma) then line[1] else sma[offset];
plot priceline=if isnan(sma) then line else double.nan;
priceline.setpaintingStrategy(paintingStrategy.LINE);
priceline.setlineWeight(3);
priceline.setdefaultColor(color.green);
priceline.hideBubble();

Brilliant code without using "highestall() (supposedely time consuming in timescript) ! Thanks man!
 
another simpple but very good code to draw the line across the chart for the current price... works with the current price across all time frames and you can change the color or style of the line

Code:
plot priceLine = highestAll(if isNan(close[-1]) and !isNAN(close) then close else double.nan);
 
New to Thinkorswim. I asked their support about pricelines and chart order. Is there anyway to have priceline that draws behind the price bars? TOS support advised not.
Alternatively, is there a way to have the grid on TOS be in quarter increments. My observation is that crude trades from quarter to quarter very often and I use the pricelines to denote the quarter increments.
I spent some time on the OneNote cloud looking for a zone drawing tool also. I am not looking for an indicator to draw the zones for me automatically. I would like to be able to draw the zone and input the border color and the color, and preferably have it drawn behind the price bars.
I can accomplish most of that with the rectangle tool, which unlike the priceline draws behind the price bars. The rectangle tool will not draw forward in time on tick and renko charts, although it does keep stepping forward as the new bars print.
Thanks, Poc
 
This is a must for any /ES or SPX Day Trader although I use it on my daily chart.

Code:
#  Posted from Mobius 1/15/18 - This puts a Horizontal Line at Price to see price level at potential Support / Resistance
#  Here is a code Snippet that gives you all you need to limit a line both forward and backward
# Dynamic_Line
# Mobius
# V01.09.2012
input LineLimit = 100;
input OnExpansion = yes;
input OnExpansionLimit = 30;
def c = close; # Replace close with any conditional value that meets your requirement
def barNumber = barNumber();
def bar = if IsNaN(c) then Double.NaN else BarNumber();
def ThisBar = HighestAll(bar);
def cline = if bar == ThisBar then c else Double.NaN;
def condi = CompoundValue(1, if IsNaN(c) then condi [1] else c, c);
plot P = if ThisBar - LineLimit <= bar then HighestAll (cLine) else Double.NaN;
P.SetStyle(Curve.Short_Dash);
P.SetLineWeight(1);
P.SetDefaultColor(CreateColor(75,250,150));
plot ExpLine = if OnExpansion and barNumber < HighestAll (bar + OnExpansionLimit) and IsNaN(c) then condi else Double.NaN;
ExpLine.SetStyle(Curve.Short_Dash);
ExpLine.SetLineWeight(1);
ExpLine.SetDefaultColor(CreateColor(150,150,150));
# End Code Dynamic Line Mobius • 8:23 PM
 
Last edited by a moderator:
I am semi-new to trading and completely at a loss when it comes to ThinkScript coding. I have tried my hand at it multiple times and it appears I am just not able to grasp coding even at it's simplest level.

I am looking for assistance in creating a study that would allow me to open the indicator and input two seperate types of pricelines. It shouldn't be too difficult to do for someone with a good working knowledge of ThinkScript since it would just be very redundant.

There would be a total of 40 inputs (yeah I know that's a lot :)). There are only two styles though, with 20 of each.

20 with dashed price lines colored orange with the name Key and 20 dashed lines colored red with the name Critical.

tJWNRm0.png


Any thoughts or assistance would be greatly appreciated.

Thanks!
 
Apologies for not clarifying the details on the screenshot. This is the basic input box style I am looking for and the green highlighted area is the input style I am hoping for. The bottom plot area would be enabled for all inputs.

I would also like for the name on the priceline to display on the left side.
 

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
425 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