ThinkScript 'return' equivalent

jrob0124

New member
Does ThinkScript have an equivalent to the keyword 'return' or 'break'? If not, maybe some can help me. I have an if\else statement, that I would like the else statement to do nothing. Here is a sample of the code. I am plotting sup\res lines based off a stock symbol, however, when I view a stock not defined in the code, I would like the study to plot nothing. Any help would be greatly appreciated.

Code:
def KeyLevel;
def Support01;
def Support02;
def Resistence01;
def Resistence02;

if (GetSymbol() == "AAPL") then {
    KeyLevel = 382.75;
    Support01 = 381.5;
    Support02 = 378.75;
    Resistence01 = 384.75;
    Resistence02 = 386.5;
} else {
    KeyLevel = 0;
    Support01 = 0;
    Support02 = 0;
    Resistence01 = 0;
    Resistence02 = 0;

}

plot Sup01 = Support01;Sup01.SetDefaultColor(Color.GRAY);Sup01.setStyle(Curve.LONG_DASH);Sup01.HideBubble();
plot Sup02 = Support02;Sup02.SetDefaultColor(Color.GRAY);Sup02.setStyle(Curve.LONG_DASH);Sup02.HideBubble();
plot Key = KeyLevel;Key.SetDefaultColor(Color.RED);Key.setStyle(Curve.LONG_DASH);Key.HideBubble();
plot Res01 = Resistence01;Res01.SetDefaultColor(Color.GRAY);Res01.setStyle(Curve.LONG_DASH);Res01.HideBubble();
plot Res02 = Resistence02;Res02.SetDefaultColor(Color.GRAY);Res02.setStyle(Curve.LONG_DASH);Res02.HideBubble();
 

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