Script{} definition error

mark.917

Member
VIP
ThinkScript Drives Me Crazy
Why is it that the compiler does not complain about top1 and bot1 but it complains about st?

1692548804110.png
 
Last edited by a moderator:
Solution
Variable assignment is obligatory in all cases. That error means that you've failed to assign a value to St in one or more logical branches. At minimum, you would have to assign Double.NaN to St in the Else clauses.
Thanks to both of you. I blew away the code and started over. Not sure what is different from the first time other than there must have been some type of syntax error somewhere else in the code.

I did try the DEF inside the conditional statement and IIRC, it said that was not allowed.

I also find it disappointing that ThinkScript will now allow plot statements, AddVertical, AddCloud, etc as part of conditional statements.
 
I also find it disappointing that ThinkScript will not allow plot statements, AddVertical, AddCloud, etc as part of conditional statements.
Think of it this way.
The Condition Widget is uniform across watchlists, scans, conditional orders, etc...

The formatting statements such as plot statements, AddVertical, AddCloud can't be used in any of the other modules.
That is why the Condition Wizard requires all conditions be defined before formatting.

This way all the logic is interchangeable throughout all modules.
After that, the unique simple straight-forward formatting statements can be appended when the condition script is used for displaying on a chart.
 
Think of it this way.
The Condition Widget is uniform across watchlists, scans, conditional orders, etc...

The formatting statements such as plot statements, AddVertical, AddCloud can't be used in any of the other modules.
That is why the Condition Wizard requires all conditions be defined before formatting.

This way all the logic is interchangeable throughout all modules.
After that, the unique simple straight-forward formatting statements can be appended when the condition script is used for displaying on a chart.
You know, I've tried to access that wizard but it is always grayed out.

My background is C++, EasyLanguage, MQL4 and a little Pine Script and so far ThinkScript just hasn't impressed. Even the editor is lacking and buggy (try to arrow quickly to a piece of code and it jumps to line 1). Once I get more experience maybe my opinion will change. I hate asking for help and trust me I try to solve things on my own before posting but I do appreciate the community here and their willingness to help.
 
Last edited:
Thanks to both of you. I blew away the code and started over. Not sure what is different from the first time other than there must have been some type of syntax error somewhere else in the code.

I did try the DEF inside the conditional statement and IIRC, it said that was not allowed.

I also find it disappointing that ThinkScript will now allow plot statements, AddVertical, AddCloud, etc as part of conditional statements.
You can define conditions on the plot statement itself, like every scripting language, TOS scripting has its limitations.
 
You know, I've tried to access that wizard but it is always grayed out.

My background is C++, EasyLanguage, MQL4 and a little Pine Script and so far ThinkScript just hasn't impressed. Even the editor is lacking and buggy (try to arrow quickly to a piece of code and it jumps to line 1). Once I get more experience maybe my opinion will change. I hate asking for help and trust me I try to solve things on my own before posting but I do appreciate the community here and their willingness to help.

don't ever feel bad for asking questions. ask all the questions you can come up with. many great people here willing to help.
i see that cursor jumping to line 1 too, drives me bonkers.

-------------------

guessing you haven't studied these yet.
save the following info for a future day, info on fold and script
https://usethinkscript.com/threads/simple-explanation-of-fold-trying-to-learn.8044/#post-76663

fold (looping)
https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/fold

script (sub routine)
https://tlc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/script
 
Variable assignment is obligatory in all cases. That error means that you've failed to assign a value to St in one or more logical branches. At minimum, you would have to assign Double.NaN to St in the Else clauses.
 
Solution

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