Stumped by ThinkorSwim Crash

Ecantor

New member
Plus
I have created a small study which basically looks to see if the current close of a stock is higher by some amount than another calculated value. For example, if the calculated value is $190, the study would return a value of 1 if the current close is greater than $196. The study works fine and I can put it on a chart and use a watchlist to switch charts with no problem. however, when I try to set up a scan which scans a small watchlist using this study and finds the stocks with a value of 1, ThinkorSwim actually completely crashes(which I've never had it do before with any scan I've set up). The filter I'm trying to add is: ECTEST1() is equal to 1. I also tried ECTEST1()."Reversed" is equal to 1. I am completely stumped. Can anyone help? I used AI to generate the code, but I can't see anything wrong with the algorithm. As I said, I can put the study onto charts and it runs with no problems. The crash does not occur when I try to run the scan, because I never get that far. It actually occurs when I try to save the new filter. I add a new filter, select the study ECTEST1, choose "Reversed", "Is Equal to",value =1. I go to save it and thinkorswim crashes.
Here is the code:

# P&F Traditional Box Logic Study
# Define the Traditional Box Size Scale

def price = close;
def boxSize = if price < 0.25 then 0.0625
else if price < 1.00 then 0.125
else if price < 5.00 then 0.25
else if price < 20.00 then 0.50
else if price < 100.00 then 1.00
else if price < 200.00 then 2.00
else if price < 500.00 then 4.00
else if price < 1000 then 5.00
else 50.00;

# Calculate the "Current Box" (Rounding down to the nearest box)
# Logic: Price divided by box size, floored to integer, then multiplied back
def currentBox = Floor(price / boxSize) * boxSize;

# Track the Lowest Box reached (to find the reversal point)
# We use a recursive variable to track the 'Floor' of the current move
def lowestBoxInMove = if SecondsTillTime(0930) == 0 then currentBox
else Min(currentBox, lowestBoxInMove[1]);


# Define the 3-Box Reversal Logic
# Target = Lowest Box + (3 * BoxSize)
def reversalTarget = lowestBoxInMove + (3 * boxSize);

# The Condition: Is the current price at or above the 3-box reversal target?
def IsReversed = IF (price >= reversalTarget) THEN 1 else 0;
plot Reversed = isreversed;
Reversed.hide();

# Optional: Display the current Box Size and Level for debugging
#AddLabel(yes, "Box Size: " + boxSize + " | Current Box: " + currentBox, Color.WHITe);
 

Attachments

  • ThinkorSwim Crash 2 16 26.png
    ThinkorSwim Crash 2 16 26.png
    195.1 KB · Views: 7
Last edited:

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