
Daily Swing Trade Ideas: Automating Market Analysis with n8n and AI
How I built an n8n workflow that pulls US market data after the close, computes technical indicators, and uses Gemini to draft structured swing-trade ideas—delivered by email.
Why this project exists
Markets move fast, but routine technical prep is often the same story: pull yesterday’s prices, check a few indicators, and write down what might be worth watching. This project automates that research rhythm—not to replace judgment, but to save time and keep notes consistent.
The workflow is called “Daily 5 Swing Trade Signal Bot”. On each US trading day, shortly after the market closes, it analyses five randomly chosen US stocks from a curated list and sends a formatted HTML email with structured ideas. Everything is driven by technical data only (prices, volume, indicators)—no news feed, no macro dashboard, no “hot tips.”
n8n-workflow
The idea in plain language
- Schedule: Run on weekdays after the US close (the README uses 16:05 Eastern as an example—your n8n timezone should match how you deploy it).
- Sample: Pick five tickers from your own universe so the watchlist rotates.
- Fetch: Pull historical bars and a fresh quote snapshot from broker and market-data APIs.
- Compute: Derive common indicators (for example RSI, MACD, ATR, Bollinger Bands, moving averages, MFI).
- Interpret with AI: Send a detailed prompt—plus optional user preferences—to Google Gemini and receive JSON trade ideas.
- Deliver: Render an HTML email and send it via Gmail.
If that sounds like a small fintech pipeline, that is intentional: clear inputs, reproducible steps, and an audit trail you can re-run tomorrow.
What flows through the system
The README documents the sequence end-to-end. Here is a compact overview you can skim in under a minute:
| Stage | What happens (high level) |
|---|---|
| Trigger | Weekday run after the close |
| Stock list | Random draw from your curated list |
| Market data | Daily OHLCV (e.g. Alpaca) + quote snapshot (e.g. Yahoo via RapidAPI) |
| Indicators | Normalised feature set for the prompt |
| Prompt | German-language strategy explanation + data (and optional profile) |
| Model | Gemini returns structured JSON recommendations |
| Output | Split, validate, and send HTML email |
system architecture
Retries are configured for flaky network calls, and the workflow is written to cope with empty or invalid LLM responses without crashing your instance.
What lands in your inbox
The repository ships with n8n-swing-email-template.html, which shapes the daily report into a readable layout: each idea gets space for context (what the chart “says”), risk framing, and next steps—without pretending to be a bank-grade research note. That separation—raw numbers in the workflow, polished wording in the template—is a practical pattern for any automation that touches email: you can tweak copy and CSS without re-exporting the whole n8n graph.
If you later connect the optional profile API, the same template can reflect personalised tone or constraints while the underlying data pipeline stays unchanged.
Finance meets engineering (without drowning in jargon)
From a trader’s perspective, the bot is a disciplined scanner: same indicators, same reporting format, every session. That makes comparisons across days easier than scrolling through screenshots.
From an engineer’s perspective, the interesting part is separation of concerns:
- APIs deliver facts (bars, last price, fundamentals snippet from the quote endpoint).
- Your code turns those facts into numbers the model can reason about.
- The model turns numbers into human-readable trade ideas with guardrails defined in
system-prompt.js.
The repository stresses that outputs are educational / technical-analysis signals, not investment advice. Treat them like lab notes: useful for learning workflows and risk language, not a substitute for your own research and compliance context.
Optional personalization (the “product” angle)
There is a Next.js front end under web/ that stores trader profiles in Supabase—email, selected symbols, and preferences such as risk profile, capital sensitivity, or entry style. n8n can call GET /api/profile?email=... and merge that JSON into the prompt so stops, time horizons, and wording adapt per user.
That is the bridge from automation demo to something that feels closer to a lightweight fintech subscription—still a side project, but structurally similar to how real products separate identity + preferences from batch analytics.
Operations and security (the boring bits that matter)
Sensitive values stay out of the exported workflow. You configure environment variables (Alpaca keys, RapidAPI key, recipient list, and optionally Gemini/Gmail if you prefer env over n8n’s credential store). In n8n you reference them as {{ $env.VARIABLE_NAME }}, which keeps Git history clean when you share the JSON workflow.
For anything exposed on the public internet, use the usual hardening checklist: protect your n8n host, rotate keys, and never commit .env.
What I learned
- Automation shines when the spec is boring. If the indicator set and prompt rules are clear, the workflow becomes dependable.
- LLMs are better as “structured report writers” than oracles. JSON output + email templates keeps the UX tight.
- Disclaimers are part of the design. Finance + AI projects should state limits up front; this one does.
A note on indicators
Indicators are heuristics, not laws of physics. RSI can stay “overbought” in a strong trend; ATR tells you about volatility, not direction. The workflow does not claim to solve that ambiguity—it surfaces a consistent snapshot so you spend time on interpretation, not on copy-pasting prices into spreadsheets.
Resources
-
GitHub repository (workflow, prompts, email template, web app):
github.com/hd2386/n8n-automation-swing-trade-ideas -
Presentation video (walkthrough):
Watch on Google Drive -
Project documentation (PDF):
The full project report is available as the complete project report (PDF) in the KI in der Kundenkommunikation repository.
If you are building something similar, start with the README’s environment template, import the workflow JSON, and adjust the stock universe in stocks_list.js before you touch anything fancy. Happy automating—and remember: past prices do not guarantee future results.