Limit Script Execution Condition

Glefdar

Active member
I have a very resource intensive script that is related to options volume plotting. I would like the script to automatically stop running past a certain line if a null condition is met, in this case, that the stock is not optionable. For example, something like this:

def stoprunning = if [not optionable] then [function that will stop running the script after this line of code] else double.nan;

Since I haven't seen anything like this before I'm assuming that it doesn't exist in thinkscript. On the other hand, it might help if there is a simple way to check whether a stock is optionable and to put an "if [not optionable] then double.nan else" condition in the beginning of every variable definition in the script. I expect that doing this would still save resources by preventing the rest of the variable definition's code from running for each of the variables.
 
Solution
Good suggestion about how to go about this, thanks! Do you have an idea if there's a straightforward way, which doesn't require a lot of CPU resources, to check if a stock is optionable? If not then what I can do in this script is just check if the options volume == 0 the first time, for setting the master disable switch variable, but even doing that check requires a lot of resources because it involves time related functions for concatenating the name of the option with the symbol name.

no , not really.
i looked over my prev post and edited it.

a while ago i tried to do something similar, have a condition control many formulas. i think all the added formulas bogged it down and i gave up on it and separated it into different...
I have a very resource intensive script that is related to options volume plotting. I would like the script to automatically stop running past a certain line if a null condition is met, in this case, that the stock is not optionable. For example, something like this:

def stoprunning = if [not optionable] then [function that will stop running the script after this line of code] else double.nan;

Since I haven't seen anything like this before I'm assuming that it doesn't exist in thinkscript. On the other hand, it might help if there is a simple way to check whether a stock is optionable and to put an "if [not optionable] then double.nan else" condition in the beginning of every variable definition in the script. I expect that doing this would still save resources by preventing the rest of the variable definition's code from running for each of the variables.
if you can test for a condition, then you can set a variable true or false. after it, add the variable into every logic formula you want to disable, with AND , like a master disable.
you will have to check if it has been set , then keep it set.

EDIT.... add cond

def cond = ...
def dis = if barnumber() ==1 then 0
else if cond then 1 else dis[1];

use an inverse of variable in other formulas , with a !.
def z = x and !dis;
 
Last edited:
if you can test for a condition, then you can set a variable true or false. after it, add the variable into every logic formula you want to disable, with AND , like a master disable.
you will have to check if it has been set , then keep it set.
def dis = if barnumber() ==1 then 0 else if dis[1] <> dis then 1 else dis[1];
may have to use inverse of variable in other formulas , with a !.
def z = x and !dis;

Good suggestion about how to go about this, thanks! Do you have an idea if there's a straightforward way, which doesn't require a lot of CPU resources, to check if a stock is optionable? If not then what I can do in this script is just check if the options volume == 0 the first time, for setting the master disable switch variable, but even doing that check requires a lot of resources because it involves time related functions for concatenating the name of the option with the symbol name.
 
Good suggestion about how to go about this, thanks! Do you have an idea if there's a straightforward way, which doesn't require a lot of CPU resources, to check if a stock is optionable? If not then what I can do in this script is just check if the options volume == 0 the first time, for setting the master disable switch variable, but even doing that check requires a lot of resources because it involves time related functions for concatenating the name of the option with the symbol name.

no , not really.
i looked over my prev post and edited it.

a while ago i tried to do something similar, have a condition control many formulas. i think all the added formulas bogged it down and i gave up on it and separated it into different scripts.
 
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
333 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