Created
March 16, 2026 00:26
-
-
Save jweinst1/ea194589a1ee48060ce01f310f021491 to your computer and use it in GitHub Desktop.
google app script RSI email alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function checkRSIAndAlert() { | |
| const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); // Change to your sheet name | |
| // RSI cell - e.g., if your RSI is in J25 (adjust!) | |
| const rsiCell = sheet.getRange("J25"); | |
| const currentRSI = rsiCell.getValue(); | |
| // Your thresholds | |
| const overbought = 70; | |
| const oversold = 30; | |
| // Track previous RSI value (stored in a hidden cell or PropertiesService) | |
| const properties = PropertiesService.getScriptProperties(); | |
| const prevRSIKey = "previousRSI"; | |
| let previousRSI = parseFloat(properties.getProperty(prevRSIKey)) || null; | |
| // Only alert on a CROSS (not just if it's already there) | |
| let message = ""; | |
| if (previousRSI !== null) { | |
| if (currentRSI > overbought && previousRSI <= overbought) { | |
| message = `RSI crossed OVERBOUGHT: ${currentRSI.toFixed(2)} (was ${previousRSI.toFixed(2)}) for ${sheet.getRange("A1").getValue() || "your ticker"}`; | |
| } else if (currentRSI < oversold && previousRSI >= oversold) { | |
| message = `RSI crossed OVERSOLD: ${currentRSI.toFixed(2)} (was ${previousRSI.toFixed(2)}) for ${sheet.getRange("A1").getValue() || "your ticker"}`; | |
| } | |
| } | |
| // Update stored previous value | |
| properties.setProperty(prevRSIKey, currentRSI.toString()); | |
| // Send email if crossed | |
| if (message) { | |
| const email = "your.email@example.com"; // Change this! | |
| const subject = "RSI Alert: " + message; | |
| MailApp.sendEmail(email, subject, message + "\n\nCheck sheet: " + SpreadsheetApp.getActiveSpreadsheet().getUrl()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment