Create alert for percent change from previous close


0
0

The goal is to have an alert for a percentage drop in price from yesterday’s close that I can execute at night and have the alert work the next day.  The script that I’ve created, which doesn’t work, is attached.

Attachments:
Marked as spam
Posted by (Questions: 1, Answers: 0)
Asked on January 29, 2025 4:53 pm
6 views
0
Private answer

When writing code its very easy to get "stuck in the weeds". This happens when become so focused on trying to solve the puzzle that we forget to look for the most simple solution.

The alert you describe is something that I have been using for years on Thinkorswim. And the solution is only a single line of code:

low is less than (close[1] * 0.98)

The rest of the are handled further upstream, in the settings you adjust when creating a Study Alert. I could probably do a video on this topic, because there are a lot of ways this tool can be applied. But here are a few screenshots which demonstrate how I create my own alert that triggers when ticker symbol /NQ drops more than 2% below the prior session close.

I'll provide a brief overview to guide you through the screenshots I have included below:

  1. From MarketWatch -- Alerts on the main Thinkorswim window, click the Study Alert button
  2. Click to the select the "thinkScript Editor" section, then enter your code in the code editor
  3. Click the button on the bottom left named "+ Set Alert Rules..."
  4. In that window, you need to make sure to check those two boxes I have noted in the third screenshot below.

Checking these buttons means the alert will be recreated each time after it has been triggered. Create one alert, and let it run for years without any need to touch it again.

Yeah... I know. Sometimes the simplest solutions can really blow our minds. If you enjoyed this solution, please tell everyone you know.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4123)
Answered on January 29, 2025 5:05 pm
0
If you want to set this type of alert to only trigger during market hours, then you simply locate the alert in the MarketWatch tab, right-click over the alert, and select "Alert Notifications". From there you can check boxes to be alerted 1. Only during US market hours AND/OR 2. After US market hours. Those are check-boxes, so you can pick one or the other or both. Keep in mind that if the ticker symbol you have selected only trades during regular session hours (such as SPX, NDX or RUT), the the after market hours checkbox will have no effect.
( at January 29, 2025 7:04 pm)