Need assistance creating basic alert

SoTypical

New member
Greetings,

I am looking to create an alert that will notify me when the price of a selected equity drops below the previous high.

This seems like a basic request for price action and I'd like to know if a script already exists, if this can be accomplished with a TOS alert based on a study, or if this will need to coded from scratch.

Any assistance will be appreciated.

Thank you
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

I don't see how to set the alert to trigger based on a percentage change in the price.
Not sure what you mean. You asked for an alert that triggers after a stock falls past its high from yesterday- assuming it closed above or below it- doesn't matter for this. That can be set up manually under alerts. Just set a price alert to yesterday's high?
 
Greetings,

I am looking to create an alert that will notify me when the price of a selected equity drops below the previous high.

This seems like a basic request for price action and I'd like to know if a script already exists, if this can be accomplished with a TOS alert based on a study, or if this will need to coded from scratch.

Any assistance will be appreciated.

Thank you
If you right click on any chart in TOS you can select create alert and you can set an alert. I use MARK is At or above (or at or below) at price all the time and I have notify with: sound, SMS, Mobile automatically defaulted within TOS. If you are looking for something else we will need you to be a lot more specific
 
Thank you for the replies. I understand that I can set an alert using price target and that is not what I need assistance with.

I would like add to my position on a stock each time it pulls back from its previous high by X%. This does not mean yesterday's high or an all time high - just the previous high since the alert was triggered or since I recreate the alert.

I want to set the alert once on either an entire watchlist or on individual stocks and then have TOS notify me when the condition is met. This is able to be accomplished with a study then it will be easy to apply to individual charts.

I am somewhat flexible with my requirements and perhaps there is another way to reach my objectives.
 
@SoTypical You will be better off using Chart Study Alerts due to the inherent lag time associated with Custom Watchlist Columns of 3 - 7 minutes... I had added more here but need to rethink the logic...
 
Last edited:
@SoTypical You will be better off using Chart Study Alerts due to the inherent lag time associated with Custom Watchlist Columns of 3 - 7 minutes... I had added more here but need to rethink the logic...
Thank you for the recommendation. I know the basics about creating alerts and nothing about TOS custom scripts or functions. I was provided with the following suggestions but am even limited to understand how to test them:

< /9*high[1] or low M .9*high[1] - it believe this is 2 options and includes typos in the syntax

Two more suggestions follow. Based on my limited knowledge of coding, neither are very close to what I am looking for.
1.) close crosses below (Highest(HIGH,30))*.90;
2.) def newday = getday()!=getday()[1];
def allhigh = if newday then high else if high>allhigh[1] then high else allhigh[1];
plot alert = close < (allhigh*.90);

My thanks
 
@SoTypical There are ample examples of how to monitor previous high here in the forums... Many Studies use that logic including Daily Highs and Lows, Wave Trends, ZigZagHighLow, etc... If you study those types of scripts you'll no doubt learn more than enough to accomplish your task, and most likely much more... In every language I've used over the years I've learned more from existing code than from technical manuals... Reference manuals only teach what functions do but actual working code shows the many more ways they can be implemented and/or combined... But I digress...
 
Thank you for the recommendation. I know the basics about creating alerts and nothing about TOS custom scripts or functions. I was provided with the following suggestions but am even limited to understand how to test them:

< /9*high[1] or low M .9*high[1] - it believe this is 2 options and includes typos in the syntax

Two more suggestions follow. Based on my limited knowledge of coding, neither are very close to what I am looking for.
1.) close crosses below (Highest(HIGH,30))*.90;
2.) def newday = getday()!=getday()[1];
def allhigh = if newday then high else if high>allhigh[1] then high else allhigh[1];
plot alert = close < (allhigh*.90);

My thanks
Code: change"def Alert = .99" to .98 if you want an alert 2% off the high, .95 if you want 5% off the high
Also if you use this study and name it and use it in multiple charts they will all have the same Alert setpoint unless you make duplicate studies with a different name. Like you could have a study named DEEPWATER_HIGH1percent with def Alert set at .99
DEEPWATER_HIGH5percent would be a second study with def Alert set at .95. You might want different alarm points for different stocks. Hope this is what you wanted. It also plots the high as a line. This may have code you don't need but I was in a hurry and stripped it out of something else and quick modified it so don't judge me.



Code:
# Change Alert to .95 if you want an alert 5% off the high
# DEEPWATER
input timeFrame = {default day};
input showOnlyToday = no;
input show_label = yes;
input show_bubble = no;
def day = GetDay();
def lastday = GetLastDay();
def isToday = If(day >= lastday, 1, 0);
def Alert = .99; #default alert 1% off the high for the day

def today = GetDay() == GetLastDay();
def highprice = if !today then Double.NaN else high(period = "day" );
plot dailyHigh = if !today then Double.NaN else high(period = "day" );
#plot dailyLow = if !today then Double.NaN else low(period = "day" );
def priceattarget = close <= (highprice * Alert); sets a price alert below the high price

Alert(priceattarget, Concat(GetSymbolPart(), " Buy Signal" ), Alert.BAR, Sound.Ring);
AddLabel(priceattarget > 0,  " Buy Signal  ", Color.LIGHT_GREEN);
#End Code
 
Last edited:
Code: change"def Alert = .995" to .99 if you want an alert 1% off the high, .95 if you want 5% off the high
Also if you use this study and name it and use it in multiple charts they will all have the same Alert setpoint unless you make duplicate studies with a different name. Like you could have a study named DEEPWATER_HIGH1percent with def Alert set at .99
DEEPWATER_HIGH5percent would be a second study with def Alert set at .95. You might want different alarm points for different stocks. Hope this is what you wanted. It also plots the high as a line. This may have code you don't need but I was in a hurry and stripped it out of something else and quick modified it so don't judge me.


Code:
# Change Alert to .95 if you want an alert 5% off the high
# DEEPWATER
input timeFrame = {default day};
input showOnlyToday = no;
input show_label = yes;
input show_bubble = no;
def day = GetDay();
def lastday = GetLastDay();
def isToday = If(day >= lastday, 1, 0);
def Alert = .99; #default alert 1% off the high for the day

def today = GetDay() == GetLastDay();
def highprice = if !today then Double.NaN else high(period = "day" );
plot dailyHigh = if !today then Double.NaN else high(period = "day" );
#plot dailyLow = if !today then Double.NaN else low(period = "day" );
def priceattarget = close <= (highprice * Alert);

Alert(priceattarget, Concat(GetSymbolPart(), " Buy Signal" ), Alert.BAR, Sound.Ring);
AddLabel(priceattarget > 0,  " Buy Signal  ", Color.LIGHT_GREEN);
#End Code
Thank you very much for this and it is too late to judge you based on your generous actions.

I've entered the code provided as a study to my chart and have a couple more questions regarding the platform.
1. once the study is created - can I then edit the code if I want to change the ALERT value from .99 to .95 e.g. It appears that I need to delete the study and then create a new study and edit the value before saving it.
2. once the study is entered - how do I create an alert to send the notice to my phone? When I create a new alert as I typically do, the study does not appear on my list.
3. I believe this study will only be entered for the active chart. Once entered, can I scroll through my linked watchlist and have the study process?

My continued thanks.
 
Thank you very much for this and it is too late to judge you based on your generous actions.

I've entered the code provided as a study to my chart and have a couple more questions regarding the platform.
1. once the study is created - can I then edit the code if I want to change the ALERT value from .99 to .95 e.g. It appears that I need to delete the study and then create a new study and edit the value before saving it.
2. once the study is entered - how do I create an alert to send the notice to my phone? When I create a new alert as I typically do, the study does not appear on my list.
3. I believe this study will only be entered for the active chart. Once entered, can I scroll through my linked watchlist and have the study process?

My continued thanks.
Go to studies menu item, edit studies, and when you see your study name there is a scroll looking icon to the left of the name. double click on the scroll and you can change the value. hit apply and OK to save the new code. I do not use the TDAmeritrade App so someone else might be able to help you but if you open the app and chart area there is a way to add a study. I would encourage you to search youtube for adding study to your phone or adding study to a watchlist. You basically need to add a custom column to your watchlist and add the code to it so the code is a part of the watchlist. kind of complicated to explain it without video. See youtube.
 
I can relate. I feel that I've sacrificed a significant portion of my life to the YT gods stumbling from one rabbit hole to another in an effort to learn TOS and trading strategies. There are many great resources available though so I feel fortunate.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
238 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