Limiting Plots In ThinkOrSwim

Pensar

Expert
VIP
Lifetime
Here are a few examples of how to show or hide sections of plots in ThinkScript, mainly using IsNaN(). There are other ways to limit plots, of course, but these are the basic methods I usually use. Anyone else, please feel free to post additional ways.

Plotting only on a single price bar -
Code:
plot a = !isnan(close[-5]) and isnan(close[-6]);
a.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
a.setdefaultcolor(color.cyan);
example-a.png


Plotting only in a certain defined area -
Code:
plot b = !isnan(close[-11]) and isnan(close[-17]);
b.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
b.setdefaultcolor(color.cyan);
example-b.png


Plotting from a defined point and continuing left -
Code:
plot c = !isnan(close[-20]);
c.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
c.setdefaultcolor(color.cyan);
example-c.png


Plotting from a defined point and continuing right -
Code:
plot d = isnan(close[-50]);
d.setpaintingstrategy(paintingstrategy.boolean_arrow_up);
d.setdefaultcolor(color.cyan);
example-d.png


Plotting a certain distance into the expansion area -
Code:
input plot_line_here = 55;
input length_of_line = 5;
def x = !isnan(close) && isnan(close[-1]);
plot e = if isnan(close) and barnumber() <= HighestAll(if x then barnumber() + length_of_line else double.nan) then plot_line_here else double.nan;
e.setpaintingstrategy(paintingstrategy.horizontal);
e.setdefaultcolor(color.cyan);
example-e.png


Hope this helps!
 
Any chance you're able to do this with an entry price? currently it shows each plot the entire time i'm in the trade and it would be awesome if it would just plot it on the one candle where I entered.

Currently the code just looks like this, but i can't understand how to modify it with my lack of coding skills lol

plot openCost = GetAveragePrice();

Thank you so much!!
 

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