What is the "do nothing" function in thinkScript?

lmk99

Active member
VIP
How to tell an indicator to plot nothing if a condition or variable is not met? In other words, I can't make the "else" condition something like "0" because then the plot will still appear with a 0 value. I just want the plot to only appear if the condition given in parenthesis after the "if" clause is met. "![Variable Name]" doesn't work and "false" doesn't work either. And I can't just daisy-chain the plots together since if I call the next plot that hasn't been defined yet (e.g. "else StrongBull" in the WeakBull plot script line) that doesn't work.

I have tried a number of ways to make this work but I can't figure it out. I haven't been able to find an answer in the Learning Center either.

Does anyone know how to accomplish what I'm trying to do? I imagine it would be simple if I wasn't missing something fundamental or obvious to how Thinkscript works.

Code:
plot Neutral = if (Score >= 4 and Score <= 6) then Score else !Neutral;
plot WeakBull = if (Score[0] > 7 and Score[0] < 11) then Score else !WeakBull;
plot StrongBull = if (Score[0] >= 11) then Score else !StrongBull;
plot WeakBear = if (Score[0] <= 3 and Score[0] >= -2) then Score else !WeakBear;
plot StrongBear = if (Score[0] < -2) then Score else !StrongBear;


Neutral.SetPaintingStrategy(PaintingStrategy.Values_above);
Neutral.SetDefaultColor(Color.Gray);
Neutral.SetLineWeight(5);

WeakBull.SetPaintingStrategy(PaintingStrategy.Values_above);
WeakBull.SetDefaultColor(Color.Plum);
WeakBull.SetLineWeight(5);

StrongBull.SetPaintingStrategy(PaintingStrategy.Values_above);
StrongBull.SetDefaultColor(Color.Magenta);
StrongBull.SetLineWeight(5);

WeakBear.SetPaintingStrategy(PaintingStrategy.Values_above);
WeakBear.SetDefaultColor(Color.Dark_Red);
WeakBear.SetLineWeight(5);

StrongBear.SetPaintingStrategy(PaintingStrategy.Values_above);
StrongBear.SetDefaultColor(Color.Light_Orange);
StrongBear.SetLineWeight(5);
 

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.
Top