As a follow up post to ‘Progress of watchlist‘ and ‘Progress of watchlist 2‘, I have set up the email alert system some time ago by adding the code into Google Sheets. I surfed around the web for the code and finally found a rudimentary one which worked well enough.
For those who are keen, all that needs to be done is to open up the script editor and go into Tools > Script editor. Thereafter, paste the code below and change the variables in red (without having the brackets).
var ss = SpreadsheetApp.getActive();
var sheet = ss.getSheetByName(“[sheetname]“);
var valueToCheck = sheet.getRange(“[cell]“).getValue();
if(valueToCheck > )
MailApp.sendEmail(“[firstname.lastname@example.org]“, “[email title]“, “[content]“);
- [anyNameToIdentifyFunction] – Give it a name without having spacings. This will be needed to identify the function when activating the trigger
- [sheetname] – Name of the sheet/tab
- [cell] – The cell in which the number would change to trigger an alert eg. E7, G6
-  – Number in [cell] to exceed to trigger an email alert
- [email@example.com] – The email which you want the alert to be sent to
- [email title] – Literally what you want the email’s subject to say
- [content] – Email content
Thereafter, click on the icon in the screenshot below to set the triggers.
In my case, I prefer to have the alerts come in just once a day at a certain timing and thus, I have set it as such in the screenshot below.
There are some limitations to it, or rather some hassles involved. For each stock in the watchlist, the code and triggers have to be repeatedly copied and pasted as each function code. It would of course be much better if I could have the coding crafted for a single column so that I could just add on to the watchlist sheet without any further opening up of the script editor and creating a new trigger. However, since I am not much of a programmer, my hands are pretty tied and it’s a small hassle for timely updates when a certain stock crosses the risk-reward ratio I have set.
One of the key question that readers may be – why not just set a stock price alert using some other services such as those brokerages? That is because I try to centralise the running of the calculations of intrinsic values in a single location and in this case, through Google Sheets. By centralising the calculations and alerts in a single place, I would not then have to worry about forgetting to login to a separate service just to change the threshold of the stock price alert each time I had to update the financials of each stock. There will also be greater flexibility in terms of the types of alerts I may want to set in the future, such as thresholds, that I may not be able to do through other simple stock price alert services.
With this, the watchlist’s core functionality is pretty much completed though I’ll definitely be tweaking it along the way from time to time.