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.
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.
Claude.ai took me quite far. Turns out that I just needed my price lines with accurate price levels. Creating alerts from those just takes a few seconds. Automating the alerts is next, but a lower priority than before.You mean manually? Please point me in the direction of making a script for this.
Are you open to sharing what the chart looks like with what you came up with ? Curious what this looks like on a chart. Thanks!Claude.ai took me quite far. Turns out that I just needed my price lines with accurate price levels. Creating alerts from those just takes a few seconds. Automating the alerts is next, but a lower priority than before.
# 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);
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
Start a new thread and receive assistance from our community.
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.
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.