Hide plot for X number of bars

Human

Member
I would like to stop plotting an indicator plot before the data bars stop. I can shift the plot back to get a similar result, but that miss-aligns the plot. I want my indicator to stop plotting before the last bar or two. Does anyone know how to do this?
 
Solution
If you are just wanting to hide the last bar plot then this example would work:
Ruby:
def SMA = SimpleMovingAvg(close,5);
def LastBar = !isnan(close) and isnan(close[-1]);
def Cut_Off = if LastBar then double.nan else SMA;
plot Cut_Off_Plot = Cut_Off;

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

Yes, this is related to my primary use case for the ability to hide the indicator's last trace until the last price is set for the aggregation period. When the bar is changing, it can affect the indicator. Part of the day can generate a signal or a trading decision influence, that would not be true later in the day. I want to avoid these possible temporary "answers". I have other indicators that would not be affected this way. I also don't want some indicators to be a day short and others to be plotted on the last bar that is still changing. I just want to trim them all the same length. I have some ideas that might actually bend the indicator line further back from the last two bars which is still changing before the final close. Let's say I am using a 5 min aggregation period. I want to hide the last changing bar and the indicators so all I see are my indicators that have the final shape that will not change. In some cases, I don't even want to see the bars or candles at all. I know how to get rid of the bars completely. I just don't know how to control exactly where the indicator lines will stop plotting.
 
If you are just wanting to hide the last bar plot then this example would work:
Ruby:
def SMA = SimpleMovingAvg(close,5);
def LastBar = !isnan(close) and isnan(close[-1]);
def Cut_Off = if LastBar then double.nan else SMA;
plot Cut_Off_Plot = Cut_Off;
 
Solution
I incorporated your code into my project and it is working like a charm. This is exactly what I needed. I will be able to use the lessons from this in the future also. Thank you.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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