Energy stocks moved 12% collectively during the first 48 hours of Iran's latest Strait of Hormuz escalation. Most traders learned about it from CNBC. You can build a system that alerts you the moment $XOM or $CVX spike 5%+, giving you the 20-minute edge that separates profit from FOMO.
What You Will Build
- Real-time monitoring for 15 energy tickers that reacts within 20 minutes of major moves
- Automated email alerts triggered by 5%+ single-day swings correlated with geopolitical keywords
- Zero-cost system using Google Sheets that runs 24/7 with 2-hour setup time
The Energy-Volatility Playbook
Create your tracking sheet in Google Sheets. Name it "Energy Volatility Monitor." Column A: Ticker symbols. Column B: Current price. Column C: Previous close. Column D: Percentage change.
Your core holdings: $XOM, $CVX, $COP, $EOG, $SLB, $OXY, $VLO, $MPC, $PSX, $KMI, $OKE, $EPD, $ET, $WMB, $FANG. These cover upstream, downstream, and midstream — the entire energy value chain that moves when geopolitics heats up.
In cell B2: =GOOGLEFINANCE(A2,"price"). Copy down to B16. Cell C2: =GOOGLEFINANCE(A2,"closeyest"). Copy down. Cell D2: =(B2-C2)/C2*100. Format column D as percentage.
Google Finance updates every 20 minutes during market hours. That's your edge window.
The Alert Trigger System
Select D2:D16. Format > Conditional Formatting. First rule: cells greater than 5 turn bright red. Second rule: cells less than -5 turn bright red. Third rule: cells between 2 and 5 turn yellow.
Test immediately: type 6.5 in D2. Should flash red.
Extensions > Apps Script. Delete default code. Paste this:
function checkEnergyVolatility() {
const sheet = SpreadsheetApp.getActiveSheet();
const data = sheet.getRange(2, 1, 14, 4).getValues();
let alerts = [];
for (let i = 0; i < data.length; i++) {
const ticker = data[i][0];
const change = data[i][3] * 100;
const price = data[i][1];
if (Math.abs(change) >= 5) {
alerts.push(`$${ticker}: ${change.toFixed(2)}% (${price.toFixed(2)})`);
}
}
if (alerts.length > 0) {
const timestamp = new Date().toLocaleString('en-US', {timeZone: 'America/New_York'});
const subject = `ENERGY ALERT: ${alerts.length} stocks 5%+ [${timestamp}]`;
const body = alerts.join('\n');
MailApp.sendEmail('your-email@gmail.com', subject, body);
}
}
Replace the email address. Save as "EnergyVolatilityChecker." The interesting part isn't the basic alert — it's what comes next.
Geopolitical Keyword Integration
Create tab "News Triggers." Column A gets these keywords: "Iran sanctions," "Strait of Hormuz," "OPEC production cut," "Saudi refinery," "pipeline sabotage," "Houthis," "Russian energy," "China oil embargo."
But here's what most tutorials miss: the correlation timing. Energy stocks often move 15-30 minutes before mainstream news breaks the story. Your system catches the price action first, then you investigate the catalyst.
Enhanced monitoring function:
function checkNewsAndPrices() {
checkEnergyVolatility();
const timestamp = new Date();
const hour = timestamp.getHours();
// After-hours volatility gets different treatment
if (hour < 9 || hour > 16) {
checkOvernightGaps();
}
}
function checkOvernightGaps() {
// Framework for pre-market monitoring
Logger.log('Scanning overnight energy moves');
}
The real alpha comes from overnight gaps — when Asian markets react to Middle Eastern developments before NYSE opens.
Automation Setup
Apps Script > Triggers (clock icon). Add trigger: Function checkNewsAndPrices, Time-driven, Hour timer, Every 1 hour from 9 AM to 4 PM EST.
Second trigger: Function checkEnergyVolatility, Day timer, 6-7 AM daily. This catches overnight Asia-driven moves before you check your phone.
During the current Iran crisis, expect 3-5 alerts per week. Normal market periods: 1-2 per month.
Advanced Configuration
Add timestamp tracking: Column E, formula =NOW(). This identifies stale data during market hours — critical when Google Finance occasionally lags.
Differentiate alert thresholds: Large caps like $XOM and $CVX use 3% triggers. Smaller names like $FANG use 7% — they naturally swing wider.
Pre-market formulas: Add =GOOGLEFINANCE(A2,"priceopen") to catch overnight gaps. A 3%+ gap between previous close and opening price often signals major catalyst.
Backup notification via Slack webhook prevents missed alerts during Gmail outages:
const webhookUrl = 'https://hooks.slack.com/your-webhook';
UrlFetchApp.fetch(webhookUrl, {
method: 'POST',
payload: JSON.stringify({text: alertMessage})
});
What You're Really Building
This isn't just an alert system. You're building information arbitrage. When $XOM spikes 6% at 10:23 AM, your phone buzzes. You check the news — nothing yet. You investigate: Iran closed shipping lanes 30 minutes ago, Reuters hasn't reported it, but oil futures jumped.
That 20-minute window? That's where money gets made. The system pays for itself the first time you catch $CVX before the crowd does. Everything after that is pure alpha.