Horizontal Lines In ThinkOrSwim

describe your interpretation of "bounced off or rejected off".
For example, over the last few months CRSR has had a strong resistance at 35 and support at around 42. I want it to automatically place lines because it's bounced off the price point of around 34-35.5 and been rejected at around 42 - 43. So practically I want it to plot lines at ranges in which it's repeatedly hit over a period of time.
 

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

you need to be able to tell the code what you want it to do, in coding terms all you said was draw a line at 35 and around 42-43. If you tell the code to draw lines that price repeatedly hits it would draw lines all over the chart.
 
you need to be able to tell the code what you want it to do, in coding terms all you said was draw a line at 35 and around 42-43. If you tell the code to draw lines that price repeatedly hits it would draw lines all over the chart.
That's part of my issue. I want it near the bottom but I don't know how to tell make it so It could do that. I want it so it draws lines near the bottom of the pattern.
 
once you have a way to explain it that it can be written into code then someone can possibly code it.
 
I want it to pre place lines like this.

art_analysis:support_and_resistance:suppresis-3hal.png
 
@jackbarnes You have to draw them yourself using the Price Levels tool in TOS or have those levels plotted as horizontal lines using the script posted on the first page of this example. Either way, you still need to have those price levels figured out first.

Based on the screenshot you attached, it seems like you're looking for an auto S/R indicator. We don't have anything close to that, but you can try some of these options https://usethinkscript.com/p/best-support-resistance-indicators-for-thinkorswim/
 
@jackbarnes You have to draw them yourself using the Price Levels tool in TOS or have those levels plotted as horizontal lines using the script posted on the first page of this example. Either way, you still need to have those price levels figured out first.

Based on the screenshot you attached, it seems like you're looking for an auto S/R indicator. We don't have anything close to that, but you can try some of these options https://usethinkscript.com/p/best-support-resistance-indicators-for-thinkorswim/
That was my biggest worry. Thank you guys so much for helping!
 
Hello, I am looking for an indicator in which I can place a line which has a specific price, say $10 above the stock, but as the stock moves, the line becomes incorrect and I have to redo it. Is there an indicator in which the line adjusts automatically as the stock moves?

Thank you
 
Hello, I am looking for an indicator in which I can place a line which has a specific price, say $10 above the stock, but as the stock moves, the line becomes incorrect and I have to redo it. Is there an indicator in which the line adjusts automatically as the stock moves?

Thank you
This is what I use.. it's dynamic, moves with the price. The code was derived from this site usethinkscript.


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+10); # 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, Round(c));

#plot P = if ThisBar - LineLimit <= bar then HighestAll (cLine) else Double.NaN;

#P.SetStyle(Curve.Short_Dash);

#P.SetLineWeight(1);

#P.SetDefaultColor(CreateColor(100,100,200));

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(Color.Light_Red);

#ExpLine.SetDefaultColor(CreateColor(150,150,150));

# End Code Dynamic Line Mobius • 8:23 PM

input show_bubbles = yes;

def current = !isnan(close) and isnan(close[-1]);

#AddChartBubble(show_bubbles and current, c, Round(c), color.dark_orange, no);

input bubble_mover = 2; #Moves bubbles left/right then number of bars input here

def n = bubble_mover;

def n1 = n +1;

AddChartBubble(show_bubbles ,cline[n1], "Target " +

AsDollars(condi) , Color.dark_orange, yes);

k9emDaA.jpg
 
Hey all, I'm looking for a simple script that helps me accomplish the following:

Every day I manually draw 7 levels on my ES chart: 1 Pivot level (yellow), 3 green levels above, 3 red levels below. Looking for a script that simply allows me to just type in the values of these levels, instead of manually drawing lines for each. Does anyone have something like this?
 
Hey all, I'm looking for a simple script that helps me accomplish the following:

Every day I manually draw 7 levels on my ES chart: 1 Pivot level (yellow), 3 green levels above, 3 red levels below. Looking for a script that simply allows me to just type in the values of these levels, instead of manually drawing lines for each. Does anyone have something like this?

That would be very easy for you to code... You really shouldn't need someone to code it for you... Six inputs and six plots, plus some color assignments... Learning Thinkscript is an expectation here, rather than expecting others to do all of your coding for you... You can do this...
;)(y)
 
@JonPM I moved your request into this thread. Go through it and you should be able to plot the horizontal lines based on your desired levels.
 
Something like this would work

Code:
input level = 100;

plot a = level + 5;

plot b = level + 10;
This is exactly what I was looking for...but how can this be adjusted so that the inputs can contain decimals? Ive tried but they just round to the whole number?
 
This is what I use.. it's dynamic, moves with the price. The code was derived from this site usethinkscript.


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+10); # 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, Round(c));

#plot P = if ThisBar - LineLimit <= bar then HighestAll (cLine) else Double.NaN;

#P.SetStyle(Curve.Short_Dash);

#P.SetLineWeight(1);

#P.SetDefaultColor(CreateColor(100,100,200));

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(Color.Light_Red);

#ExpLine.SetDefaultColor(CreateColor(150,150,150));

# End Code Dynamic Line Mobius • 8:23 PM

input show_bubbles = yes;

def current = !isnan(close) and isnan(close[-1]);

#AddChartBubble(show_bubbles and current, c, Round(c), color.dark_orange, no);

input bubble_mover = 2; #Moves bubbles left/right then number of bars input here

def n = bubble_mover;

def n1 = n +1;

AddChartBubble(show_bubbles ,cline[n1], "Target " +

AsDollars(condi) , Color.dark_orange, yes);

k9emDaA.jpg

Exactly what i´ve been looking for except i need the price levels to stay static instead of dynamic. Do you know how i can modify it to work this way?
 
@zeek, I'm not a coding person, sorry can't help. Just the basics I get by with. Perhaps @BenTen can assist you.

Here is a static line example:
Code:
#Example Static Horizontal Line
#Sleepyz

input price    = 22.00;#Static Line in this example is just a price level.

input use_line_limits = yes;#Yes, plots line from/to; No, plot line across entire chart
input linefrom = 100;#Hint linefrom: limits how far line plots in candle area
input lineto   = 12;#Hint lineto: limits how far into expansion the line will plot


def lastbar    = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else lastbar[1];
def c          = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then price else Double.NaN);

plot Data      = if use_line_limits and BarNumber() >= HighestAll(lastbar - linefrom) and BarNumber() <= HighestAll(lastbar + lineto) then c else if use_line_limits == no then c else Double.NaN;
Data.SetPaintingStrategy(PaintingStrategy.DASHES);

input bubblemover = 12;#moves bubble sideways
def b  = bubblemover;
def b1 = b + 1;
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), Data[b], Data[b1]);
 
Here is a static line example:
Code:
#Example Static Horizontal Line
#Sleepyz

input price    = 22.00;#Static Line in this example is just a price level.

input use_line_limits = yes;#Yes, plots line from/to; No, plot line across entire chart
input linefrom = 100;#Hint linefrom: limits how far line plots in candle area
input lineto   = 12;#Hint lineto: limits how far into expansion the line will plot


def lastbar    = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else lastbar[1];
def c          = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then price else Double.NaN);

plot Data      = if use_line_limits and BarNumber() >= HighestAll(lastbar - linefrom) and BarNumber() <= HighestAll(lastbar + lineto) then c else if use_line_limits == no then c else Double.NaN;
Data.SetPaintingStrategy(PaintingStrategy.DASHES);

input bubblemover = 12;#moves bubble sideways
def b  = bubblemover;
def b1 = b + 1;
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), Data[b], Data[b1]);
Thank you so much @SleepyZ for the modification, it works perfectly!

If i wanted to add more lines, can i simply copy the "input price" and add more rows below it? I need about 10 different price lines in total

Like this:

Code:
input price    = 22.00;
input price    = 23.00;
input price    = 24.00;
etc...
 
Thank you so much @SleepyZ for the modification, it works perfectly!

If i wanted to add more lines, can i simply copy the "input price" and add more rows below it? I need about 10 different price lines in total

Like this:

Code:
input price    = 22.00;
input price    = 23.00;
input price    = 24.00;
etc...

If you just want horizontal lines without the bubbles and line limiters, then your above code will work just fine. If you want to use more price levels like the code I posted, then I have added an additional price level with the changes you need to make. Please note the comments in this code on how to do this.
Code:
#Example Static Horizontal Line
#Sleepyz

input use_line_limits = yes;#Yes, plots line from/to; No, plot line across entire chart
input linefrom = 100;#Hint linefrom: limits how far line plots in candle area
input lineto   = 12;#Hint lineto: limits how far into expansion the line will plot
input bubblemover = 12;#moves bubble sideways
def b  = bubblemover;
def b1 = b + 1;
def lastbar    = if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else lastbar[1];

##Copy and paste this below
input price    = 22.00;#Static Line in this example is just a price level.

def c          = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then price else Double.NaN);
plot Data      = if use_line_limits and BarNumber() >= HighestAll(lastbar - linefrom) and BarNumber() <= HighestAll(lastbar + lineto) then c else if use_line_limits == no then c else Double.NaN;
Data.SetPaintingStrategy(PaintingStrategy.DASHES);
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), Data[b], Data[b1]);

##Here is an example of the changes to the pasted code that is needed to add another price level
input price1    = 22.50;#Static Line in this example is just a price level.

def c1          = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then price1 else Double.NaN);
plot Data1      = if use_line_limits and BarNumber() >= HighestAll(lastbar - linefrom) and BarNumber() <= HighestAll(lastbar + lineto) then c1 else if use_line_limits == no then c1 else Double.NaN;
Data1.SetPaintingStrategy(PaintingStrategy.DASHES);
AddChartBubble(IsNaN(close[b]) and !IsNaN(close[b1]), Data1[b], Data1[b1]);

##
 
Thank you for the code @SleepyZ :)

I am new to thinkScript and struggling with the following modification to your code. On intraday charts only (e.g. 5 min, 15min, etc.) I want to add 3 horizontal lines for Open, Low and, High taken from the daily bar (aggregation) of current day. How do I do that? Thank you in advance
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
369 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