Horizontal Lines In ThinkOrSwim

ic. i sorta figured that, but didnt see it in the code.

but does anyone know how to make the line stop at todays price and not go into the expansion area?
 
@eugchen

Code:
input start_time = 0930;
input endtime = 1600;

def selected_time = if GetLastDay() == GetDay() and SecondsFromTime(start_time) >= 0 and SecondsFromTime(endtime) <
0 then 1 else 0;
plot p1 =

if (GetSymbol() == "AAON") and selected_time then 48.95 else
if (GetSymbol() == "AAPL") and selected_time then 85 else
if (GetSymbol() == "ABBV") and selected_time then 97 else

double.nan;

p1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
p1.SetLineWeight(5);
p1.SetStyle(Curve.POINTS);
p1.AssignValueColor(if close > p1 then color.Dark_red else color.Dark_orange);

if you found this post useful, dont forget to hit the thumbs up!
 
ic. i sorta figured that, but didnt see it in the code.

but does anyone know how to make the line stop at todays price and not go into the expansion area?

Not if you use expansion area... Is this an OCD issue or what is the problem with the cyan color...???

@XeoNoX I don't think that code will help during trading hours, only afterhours...
 
not an OCD issue. and i do like using the expansion area.

since i cycle through hundreds of stocks a day, i want to see an easy way if the current price is above or below the price line. and i have a color scheme that i like where if i see a certain color, it means one thing. opposite for other color. the cyan just distracts me and annoys me.

and yea, i think that code only works on an intraday chart, not a 6month daily chart like i have :(
 
@eugchen say go Tampabay! if it works
Code:
plot p1 =
if (GetSymbol() == "AAON") and close  then 48.95 else
if (GetSymbol() == "AAPL") and close  then 85 else
if (GetSymbol() == "ABBV") and close then 97 else
double.nan;

p1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
p1.SetLineWeight(5);
p1.SetStyle(Curve.POINTS);
p1.AssignValueColor(if close > p1 then color.Dark_red else color.Dark_orange);
 
i couldnt get it to work on a daily 6 month chart XeoNoX. :(. looks like this is for an intraday chart?

Brady is ridiculous. but Rodgers making a run right now!
 
Looks like it works to me on Day - Six Months

hLDgpQu.png
 
Hmmm so weird....im using this code

Code:
input start_time = 0930;
input endtime = 1600;

def selected_time = if GetLastDay() == GetDay() and SecondsFromTime(start_time) >= 0 and SecondsFromTime(endtime) <
0 then 1 else 0;
plot p1 =

if (GetSymbol() == "AAON") and selected_time then 48.95 else
if (GetSymbol() == "AAPL") and selected_time then 85 else
if (GetSymbol() == "ABBV") and selected_time then 97 else

double.nan;

p1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
p1.SetLineWeight(5);
p1.SetStyle(Curve.POINTS);
p1.AssignValueColor(if close > p1 then color.Dark_red else color.Dark_orange);

and chart shows this for AAPL

nothing on the 85 strike. whats interesting is that when i put the chart on a 1 day 1 min chart, i see the 85 red line! weird!

Capture6.jpg


Capture5.jpg


congrats TB by the way. stanley cup, world series appearance, Super bowl
 
@eugchen the code you posted is not the last code i posted in post #19
use the code from post#19 (i take if you were so caught up in the game you missed the code, lol)
 
On a few symbols such as /ES, /NQ, SPY, QQQ, I mark high, low, close, overnight high and low every morning before the open. So after several days, I have a collection of horizontal lines, which I relabel or remove as necessary.

Could I automate the initial horizontal line creation, where once a day, at say 9am, the script draws horizontal lines at prior day high, low, close and overnight high and low (to that point in time)? Importantly, these lines should persist - i.e., when script runs the next day, the prior day's lines should remain (I will remove those as necessary).

So I guess what I want isn't a plot but a way to recreate via script what the horizontal drawing tool does, so I can go and relabel when desired and also so the lines persist after the day they are initially drawn.

Can someone point me in the right direction?
 
TOS does not support arrays, so you have to hard code a set # of them to plot. Each day at 9am "bubble sort" them.

Example:

Code:
#prior day High 5 days ago
pdHigh5 = high(period = Aggregation.Day)[5]
...

once bar number > 5 and at 9am
pdHigh5 = pdHigh4
pdHigh4 = pdHigh3
pdHigh3 = pdHigh2
pdHigh2 = pdHigh1
pdHigh1 = high(period = Aggregation.Day)

plot all of them....

Something like that at least. Will be a lot of copy/paste to duplicate this logic for HLC and ON HL.

Note: sierra chart has stuff like this built in and it's easy to add them as indicators.
 
Thanks @korygill. Yeah, arrays would certainly simplify the process of tracking and accessing values. But it would still be a plot. From doing a little searching, it looks like thinkscript does not provide a means of accessing drawing tools. In the above example, depending on subsequent price action, I may want to remove pdHigh3 from the plot. Or append pdHigh2's name/label with "resistant" because price was rejected from there on a subsequent day. Plot lines don't provide that kind of manual flexibility.
 
@BenTen Is there a way to keep these plots on one chart, move to another chart, set it up with new plots without cancelling the first charts plots?

Is there a way to keep these plots on one chart, move to another chart, set it up with new plots without cancelling the first charts plots?
I've used that but it plots the same on all charts and cancels the last chart inputs. Is there a way to hold plots on each chart?
 
Anyone know a script where you enter price levels, and it will draw levels on the chart. Manually enter support and resistance. 4 or 5 levels of each. Perhaps a script that will draw for or 5 levels above and 4 or 5 below after you enter the value in the script for the instrument?
 
Anyone know a script where you enter price levels, and it will draw levels on the chart. Manually enter support and resistance. 4 or 5 levels of each. Perhaps a script that will draw for or 5 levels above and 4 or 5 below after you enter the value in the script for the instrument?

Something like the following...??? Just add more lines with different plot names and values... Basically just a Thinkscript method of manually drawing lines...

Ruby:
plot line123 = 123;
plot line124 = 124;
plot line125 = 125;
 
Hey guys, using thinkscript I want to make it so a horizontal line is placed at a price point that's been bounced off or rejected off.
 

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