Plot Only The FIRST Arrow In ThinkOrSwim

apeck

New member
I am trying to code a indicator which plots an arrow if certain conditions are met but I am not sure how I only plot the arrow on the first candle that closes equal to or higher from previous candle and not plot any more arrows after that. Here is the code but it plots arrows every time the new candle goes higher than previous candle (I only want to plot on first candle that does that only). I also want to do this if current candle closes equal to or lower than previous candle only.
 
Last edited:

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

I am trying to code a indicator which plots an arrow if certain conditions are met but I am not sure how I only plot the arrow on the first candle that closes equal to or higher from previous candle and not plot any more arrows after that. Here is the code but it plots arrows every time the new candle goes higher than previous candle (I only want to plot on first candle that does that only). I also want to do this if current candle closes equal to or lower than previous candle only.

Since you did not provide your code, here is an example that might help
Set input show_multiplearrows = yes; to no to hide the multiple arrows on the chart image
The large arrows remaining are the first arrow in each direction change
Screenshot 2024-04-22 105714.png
Code:
#need help removing extra arrows

input show_multiplearrows = yes;
def ema8  = ExpAverage(close, 8);
def ema21 = ExpAverage(close, 21);

#Multiple arrows in one direction
plot up = if show_multiplearrows and ema8 > ema21 then low else Double.NaN;
plot dn = if show_multiplearrows and ema8 < ema21 then high else Double.NaN;
up.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
dn.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);

#One arrow in each direction until a reversal arrow in the opposite direction
def cond = if ema8 crosses above ema21 then 1 else if ema8 crosses below ema21 then -1 else cond[1];
plot arrowup = cond[1] != 1 and cond == 1;
arrowup.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
arrowup.SetLineWeight(5);

plot arrowdn = cond[1] != -1 and cond == -1;
arrowdn.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
arrowdn.SetLineWeight(5);

#
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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