SPX Alerts for certain prices during the day

Imaginativeone

New member
VIP
I like to set up alerts for when SPX reaches certain prices during the day. It's only 6 alerts, well, 12 for paper also. Is it possible to set them all up with a script?
 

Attachments

  • Screen Shot 2025-11-21 at 8.07.40 AM.png
    Screen Shot 2025-11-21 at 8.07.40 AM.png
    164.1 KB · Views: 31
Solution
So, essentially, you're going for percentage of cushion remaining? Something like...

100 - 100 * AbsValue(CurrentPrice - ShortStrike) / AbsValue(EntryPrice - ShortStrike)
(with "price" being of the underlying)

Does that look somewhat correct? If so, then yeah, you would only need to input the price of the underlying at the time of entry, and the strike price. The alerts could be auto/dynamic, plus we could easily do all sorts of other things like active labels to track it on screen.

If not, then give me the correct formula in somewhat similar format to what I provided.
Yeah, easily, you can hard-code the price levels, or use inputs. Then you can check for Close being above or below them, or crossing them, respectively. Then you plug those into ThinkScript's Alert() function.

Before bothering with that, I noticed that the image has "notes" with percentages. These percentages are of what exactly? If I knew what those are, there is a possibility that it could be fully automatic, and you wouldn't need to type anything in.

Alternatively, you could also leave the real alerts on the screen and arm the reversing alert. You can drag them visually on the screen to adjust prices with the Show Alerts option, if you prefer that over typing.

It depends... Describe what the alerts are for, and how you're coming up with the numbers.
 
Yeah, easily, you can hard-code the price levels, or use inputs. Then you can check for Close being above or below them, or crossing them, respectively. Then you plug those into ThinkScript's Alert() function.

Before bothering with that, I noticed that the image has "notes" with percentages. These percentages are of what exactly? If I knew what those are, there is a possibility that it could be fully automatic, and you wouldn't need to type anything in.

Alternatively, you could also leave the real alerts on the screen and arm the reversing alert. You can drag them visually on the screen to adjust prices with the Show Alerts option, if you prefer that over typing.

It depends... Describe what the alerts are for, and how you're coming up with the numbers.

This is really interesting . Super interested on how you could automate the notes portion and will wait for the OP’s response since I would implement something similar based on levels drawn from the open.
 
Last edited:
First, thank you all for responding to my post.

I'm setting up Verticals at 3, 2, or 1 Deltas (my favorite distance from The Money). I don't mind risking a lot for that comfortable distance, and often enough, my small profit comes in just fine. On no-profit days, the price of the underlying breaches my Vertical no matter how far-away/safe I think I might be.

The alerts let me know things are going South. I'm setting the alerts as percentages of the Short Strike Price: 85% - Category A responses, 65% - Category B responses, 50% - Category C responses (the price might be on its way to a breach!). The Notes make it clear which price-level has been reached.

I'm doing all this prep at 4:30 am to 6:00 am. While it "only takes 40 minutes", that's a lot of prime-early-morning-time working on alerts. I'd like to trim that time down by being able to set up the alerts on my live account and on paper by clicking a button in the respective environments.

Postscript: If I could automatically restore the alert, that would be a giant bonus.
 
Last edited:
First, thank you all for responding to my post.

I'm setting up Verticals at 3, 2, or 1 Deltas (my favorite distance from The Money). I don't mind risking a lot for that comfortable distance, and often enough, my small profit comes in just fine. On no-profit days, the price of the underlying breaches my Vertical no matter how far-away/safe I think I might be.

The alerts let me know things are going South. I'm setting the alerts as percentages of the Short Strike Price: 85% - Category A responses, 65% - Category B responses, 50% - Category C responses (the price might be on its way to a breach!). The Notes make it clear which price-level has been reached.

I'm doing all this prep at 4:30 am to 6:00 am. While it "only takes 40 minutes", that's a lot of prime-early-morning-time working on alerts. I'd like to trim that time down by being able to set up the alerts on my live account and on paper by clicking a button in the respective environments.

Postscript: If I could automatically restore the alert, that would be a giant bonus.

Will you be on your TOS all the time? If you are, using @Joshua's suggested method could work.

But from the sound of it, you won't be able to monitor and have TOS running in the background. In that case, setting up price level alerts would work better.
 
So, essentially, you're going for percentage of cushion remaining? Something like...

100 - 100 * AbsValue(CurrentPrice - ShortStrike) / AbsValue(EntryPrice - ShortStrike)
(with "price" being of the underlying)

Does that look somewhat correct? If so, then yeah, you would only need to input the price of the underlying at the time of entry, and the strike price. The alerts could be auto/dynamic, plus we could easily do all sorts of other things like active labels to track it on screen.

If not, then give me the correct formula in somewhat similar format to what I provided.
 
Solution
Need names for the lines. Also, my Alerts don't work yet.

Code:
# Dynamic Strike Calculator Based on Straddle Price
# Calculates short and long strike levels based on ATM straddle multiples
# Creates strikes for both Call and Put sides with percentage markers

declare upper;

# ===== INPUTS =====
input underlyingStock = "SPX";
input curr_price = 6590.50;
input curr_straddle = 86.70;
input spreadPoints = 15;
input strikePoints = 5;
input straddle_factor = 3;
input tradeDate = 112224;  # Manual date input in MMDDYY format

# Enable/disable alerts
input enableAlerts = yes;

# ===== CALCULATIONS =====
# Calculate mega straddle (straddle_factor times current straddle)
def megaStraddle = straddle_factor * curr_straddle;

# ===== CALL SIDE =====
# Calculate raw short strike for calls
def shrtStrikeRaw_Call = megaStraddle + curr_price;

# Round short strike to NEAREST strikePoints increment
def shrtStrikeNew_Call = Round(shrtStrikeRaw_Call / strikePoints, 0) * strikePoints;

# Calculate long strike (short strike + spread)
def longStrikeNew_Call = shrtStrikeNew_Call + spreadPoints;

# ===== PUT SIDE =====
# Calculate raw short strike for puts (multiply megaStraddle by -1)
def shrtStrikeRaw_Put = (megaStraddle * -1) + curr_price;

# Round short strike to NEAREST strikePoints increment
def shrtStrikeNew_Put = Round(shrtStrikeRaw_Put / strikePoints, 0) * strikePoints;

# Calculate long strike (short strike - spread for puts)
def longStrikeNew_Put = shrtStrikeNew_Put - spreadPoints;

# ===== PERCENTAGE STRADDLE CALCULATIONS =====
def pStraddle85 = curr_straddle / 0.85;
def pStraddle65 = curr_straddle / 0.65;
def pStraddle50 = curr_straddle / 0.50;

# ===== PERCENTAGE LEVELS - CALL SIDE =====
def call_85_percent = curr_price + pStraddle85;
def call_65_percent = curr_price + pStraddle65;
def call_50_percent = curr_price + pStraddle50;

# ===== PERCENTAGE LEVELS - PUT SIDE =====
def put_85_percent = curr_price - pStraddle85;
def put_65_percent = curr_price - pStraddle65;
def put_50_percent = curr_price - pStraddle50;

# ===== PLOTS - CALL SIDE =====
# Plot names can be manually edited in Study Settings after adding to chart
plot SLT_BCS_S = shrtStrikeNew_Call;
SLT_BCS_S.SetDefaultColor(Color.RED);
SLT_BCS_S.SetLineWeight(2);
SLT_BCS_S.SetStyle(Curve.FIRM);

plot SLT_BCS_L = longStrikeNew_Call;
SLT_BCS_L.SetDefaultColor(Color.GREEN);
SLT_BCS_L.SetLineWeight(2);
SLT_BCS_L.SetStyle(Curve.FIRM);

# ===== PLOTS - PUT SIDE =====
plot SLT_BPS_S = shrtStrikeNew_Put;
SLT_BPS_S.SetDefaultColor(Color.RED);
SLT_BPS_S.SetLineWeight(2);
SLT_BPS_S.SetStyle(Curve.FIRM);

plot SLT_BPS_L = longStrikeNew_Put;
SLT_BPS_L.SetDefaultColor(Color.GREEN);
SLT_BPS_L.SetLineWeight(2);
SLT_BPS_L.SetStyle(Curve.FIRM);

# ===== PLOTS - PERCENTAGE MARKERS CALL SIDE =====
plot Call_85pct = call_85_percent;
Call_85pct.SetDefaultColor(Color.LIGHT_GREEN);
Call_85pct.SetLineWeight(1);
Call_85pct.SetStyle(Curve.LONG_DASH);

plot Call_65pct = call_65_percent;
Call_65pct.SetDefaultColor(Color.YELLOW);
Call_65pct.SetLineWeight(1);
Call_65pct.SetStyle(Curve.LONG_DASH);

plot Call_50pct = call_50_percent;
Call_50pct.SetDefaultColor(Color.DARK_ORANGE);
Call_50pct.SetLineWeight(1);
Call_50pct.SetStyle(Curve.LONG_DASH);

# ===== PLOTS - PERCENTAGE MARKERS PUT SIDE =====
plot Put_85pct = put_85_percent;
Put_85pct.SetDefaultColor(Color.LIGHT_GREEN);
Put_85pct.SetLineWeight(1);
Put_85pct.SetStyle(Curve.LONG_DASH);

plot Put_65pct = put_65_percent;
Put_65pct.SetDefaultColor(Color.YELLOW);
Put_65pct.SetLineWeight(1);
Put_65pct.SetStyle(Curve.LONG_DASH);

plot Put_50pct = put_50_percent;
Put_50pct.SetDefaultColor(Color.DARK_ORANGE);
Put_50pct.SetLineWeight(1);
Put_50pct.SetStyle(Curve.LONG_DASH);

# ===== PLOT CURRENT PRICE =====
plot Current = curr_price;
Current.SetDefaultColor(Color.CYAN);
Current.SetLineWeight(2);
Current.SetStyle(Curve.SHORT_DASH);

# ===== ALERTS =====
# Get actual current price of the underlying
def actualPrice = close;

# Alert conditions
def call_85_crossed = enableAlerts and actualPrice crosses above call_85_percent;
def call_65_crossed = enableAlerts and actualPrice crosses above call_65_percent;
def call_50_crossed = enableAlerts and actualPrice crosses above call_50_percent;
def put_85_crossed = enableAlerts and actualPrice crosses below put_85_percent;
def put_65_crossed = enableAlerts and actualPrice crosses below put_65_percent;
def put_50_crossed = enableAlerts and actualPrice crosses below put_50_percent;

# Call side alerts
Alert(call_85_crossed, "Call 85% Breached", Alert.BAR, Sound.Bell);
Alert(call_65_crossed, "Call 65% Breached", Alert.BAR, Sound.Ding);
Alert(call_50_crossed, "Call 50% Breached", Alert.BAR, Sound.Ring);

# Put side alerts
Alert(put_85_crossed, "Put 85% Breached", Alert.BAR, Sound.Bell);
Alert(put_65_crossed, "Put 65% Breached", Alert.BAR, Sound.Ding);
Alert(put_50_crossed, "Put 50% Breached", Alert.BAR, Sound.Ring);

# ===== LABELS =====
AddLabel(yes, "Trade Date: " + tradeDate, Color.GRAY);
AddLabel(yes, "CALL Short: " + shrtStrikeNew_Call, Color.RED);
AddLabel(yes, "CALL Long: " + longStrikeNew_Call, Color.GREEN);
AddLabel(yes, "Current: " + curr_price, Color.CYAN);
AddLabel(yes, "PUT Short: " + shrtStrikeNew_Put, Color.RED);
AddLabel(yes, "PUT Long: " + longStrikeNew_Put, Color.GREEN);
AddLabel(yes, "Straddle: " + curr_straddle, Color.GRAY);
 

Attachments

  • Screen Shot 2025-11-22 at 4.07.22 PM.png
    Screen Shot 2025-11-22 at 4.07.22 PM.png
    301.9 KB · Views: 22
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
598 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