Automated Weekly Stock Analysis with n8n & GPT-4o

This workflow automates weekly stock analysis by combining technical chart data and news sentiment into a detailed Hebrew report. It solves time-consuming, error-prone manual stock research by generating actionable investment insights and sending them via email.
agent
openAi
httpRequest
+13
Workflow Identifier: 1233
NODES in Use: memoryBufferWindow, agent, stickyNote, outputParserStructured, lmChatOpenAi, html, emailSend, code, httpRequest, toolThink, set, merge, openAi, toolWorkflow, scheduleTrigger, formTrigger

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

1. Opening Problem Statement

Meet Daniel, an independent investor juggling multiple stocks listed on NASDAQ. Each week, he spends countless hours scouring through charts, technical indicators, and the latest financial news articles to make informed decisions. This manual method is not only time-consuming—sometimes taking up to 6 hours weekly—but also prone to human errors and bias. Daniel often misses critical news sentiment sways or misinterprets technical patterns, costing him potential profits and increasing financial risk.

This is exactly where this comprehensive n8n workflow steps in: an automated, data-driven stock analysis system that synthesizes technical chart data and real-time market news to generate detailed, actionable reports in Hebrew, delivered right into Daniel’s inbox. It eliminates repetitive manual tasks, improves accuracy, and saves precious time.

2. What This Automation Does

At its core, this automation workflow does the following things every week, triggered manually or scheduled:

  • Analyzes weekly candlestick charts with advanced technical indicators like RSI, EMA, Bollinger Bands, MACD, and Fibonacci retracements.
  • Combine visual chart pattern recognition powered by GPT-4o with quantitative market data fetched from APIs including Chart-img, Twelve Data API, and Alpha Vantage.
  • Performs sentiment analysis on recent financial news articles related to the stock, extracting trending topics and scoring market sentiment from bullish to bearish.
  • Generates a structured, professional Hebrew report that includes a detailed technical analysis explanation understandable even to beginners.
  • Sends a beautifully formatted HTML email report with RTL support directly to an email address provided by the user.
  • Includes a final recommendation section with careful advice to buy, hold, or sell based on combined technical and sentiment inputs.

By automating these steps, investors save approximately 5-6 hours weekly and gain more reliable decision-making insights.

3. Prerequisites ⚙️

  • n8n account (cloud or self-hosted at platforms like Hostinger).
  • OpenAI API key for GPT-4o model to power AI-based analysis and language generation.
  • Chart-img API key to fetch weekly candlestick chart images.
  • Twelve Data API key for historical price data and technical indicators.
  • Alpha Vantage API key for fetching recent financial news and sentiment data.
  • SMTP credentials to send final email reports.

4. Step-by-Step Guide

Step 1: Trigger the Workflow with Stock Symbol and Email (Form Trigger)

Start by importing the workflow template into your n8n instance. The entry point is the Form Trigger node, where users input a NASDAQ ticker symbol (e.g., “TSLA”) and their email address. This node also appends attribution and responds with a success message.

Navigation: Open n8n → Import Workflow → Edit the “On form submission” node → Customize form fields if needed.

Outcome: The workflow starts running using the submitted stock ticker and email.

Common mistake: Entering invalid or NASDAQ-unlisted ticker symbols will cause errors downstream; verify ticker accuracy before submitting.

Step 2: Generate API Variables for News Data

The Generate Variables For API Code node calculates yesterday’s date formatted for the Alpha Vantage news sentiment API query.

Navigation: Check the JavaScript code in the node, no changes usually needed unless timezone adjustments are desired.

Outcome: Outputs a date timestamp used for fetching recent news.

Step 3: Set Stock Symbol and API Keys

The Set Variables node passes down the user ticker and API keys (Twelve Data, Alpha Vantage) for use in subsequent API calls.

Navigation: Input your API keys and map variables accordingly here.

Common mistake: Forgetting to add your personal API keys or leaving placeholders empty.

Step 4: Fetch News Sentiment Data from Alpha Vantage

The Get News Data HTTP Request node calls the Alpha Vantage NEWS_SENTIMENT endpoint using the ticker and date parameters, retrieving recent financial news articles tied to the stock with sentiment metrics.

Navigation: Verify URL construction with URL parameters ticker, time_from, and apikey.

Outcome: Returns JSON including articles and sentiment scores.

Step 5: Analyze and Structure News Data

The Analyse API Input Code node processes the news articles JSON, filters by stock relevance, calculates sentiment distributions, ranks top impactful articles, and determines hot trending topics. It outputs a clean JSON that will be merged into the final analysis.

Navigation: Review the node’s JavaScript code and understand the filtering and scoring criteria.

Common mistake: Attempting to modify this node without understanding the complex data mapping can corrupt output formatting.

Step 6: Get Stock Chart URL for Technical Analysis

The Get Chart URL HTTP Request node sends a POST request to Chart-img’s API with parameters for a weekly candlestick chart, indicators like Volume, EMA(200), and RSI to generate a chart image URL.

Navigation: Check the API keys and request body to match your stock ticker and visual style.

Outcome: Receives a URL to download the chart.

Step 7: Download Chart Image

The Download Chart HTTP Request node downloads the image at the URL provided above, converting it to Base64 for AI analysis.

Navigation: Uses the URL from the previous step; verify response format.

Common mistake: Not ensuring proper image response format; this blocks the AI analysis.

Step 8: Run AI Visual Chart Analysis with GPT-4o

The First Technical Analysis node, an AI-powered node using GPT-4o, analyzes the Base64-encoded chart image. It returns a structured JSON describing RSI values, trend direction, candlestick patterns, EMA position, and volume notes derived solely from the image data.

Navigation: Verify the input is base64 image from the Download Chart node, set analysis prompt accordingly.

Outcome: A detailed JSON capturing visual technical insights.

Step 9: Fetch Additional Technical Indicators: Price History, Bollinger Bands, MACD

Three HTTP Request nodes fetch data from Twelve Data API: historical prices (Get Price History), Bollinger Bands, and MACD values for the stock.

Navigation: Configure API key and ticker in URL queries.

Outcome: Returns structured technical indicator data.

Step 10: Calculate Support and Resistance Levels

The Calculate Support Resistance Code node uses historical price data to detect local minimums and maximums, determining key support and resistance levels. It also calculates Fibonacci retracement levels for reference.

Navigation: Check the code verifying minimum data points and price extraction.

Common mistake: Supplying insufficient price data (<30 points) yields no meaningful support/resistance.

Step 11: Organize and Synthesize Technical Data

The Organizing Data Code node merges all technical indicator results (Fibonacci, Support/Resistance, Bollinger Bands, MACD) and creates a summary. This node outlines key bullish or bearish signals detected for recommendation usage.

Navigation: Review merging logic and technical factor interpretations.

Step 12: Combine Technical and Trends Data for AI Agent

The Merge nodes join the technical data stream with news sentiment data. This combined input is sent to the AI Agent, a LangChain-powered GPT-4o agent that synthesizes all information into a comprehensive stock analysis report in Hebrew, including recommendation logic guided by detailed instructions.

Navigation: Ensure correct mapping of the combined data and system messages within the AI Agent node.

Step 13: Refine AI Report Text

The Refine Text node runs a subsequent GPT-4o OpenAI call to improve the Hebrew grammar and presentation of the technical analysis and recommendation text, ensuring a professional tone.

Navigation: Set prompt messages to rewrite fields “technicalAnalysis” and “recommendationText” properly in Hebrew.

Step 14: Generate Responsive Hebrew HTML Report

The Generate HTML node creates the final email-ready HTML report using dynamic data from the AI Agent’s structured JSON output. The layout is RTL and includes sections for recommendation, detailed technical analysis, market sentiment graphs, influential articles, and trending topics.

Navigation: Edit the HTML template node to customize styling or text layout.

Step 15: Adjust HTML Colors and Clean Report

The Adjust HTML Colors Code node applies color coding based on sentiment (positive, neutral, negative). It also removes articles and topics that are irrelevant or undefined to keep the email report clean and professional.

Navigation: Review and test the JavaScript code handling color updates and article/topic filtering.

Step 16: Send the Final Stock Analysis Email

The Send Stock Analysis Email node uses SMTP credentials to send the composed email to the user’s input address with a subject line containing the stock ticker and analysis date.

Navigation: Ensure SMTP credentials are correct and emails are tested with spam checks.

Common mistake: SMTP misconfiguration can cause email delivery failures.

5. Customizations ✏️

  • Change Chart Interval: In the Get Chart URL node, modify the “interval” parameter (e.g., from “1W” to “1D”) to analyze daily charts instead of weekly for more granular insights.
  • Adjust Sentiment Translation: In the AI Agent node, update the mapping rules for Hebrew sentiment labels to suit different languages or sentiment granularity.
  • Update Email Template: Customize the Generate HTML node’s template to add personalized branding, logos, or additional sections like competitor comparisons.
  • Add More Indicators: Integrate other APIs or add nodes to fetch indicators like Moving Average Convergence Divergence with different parameters or volume analysis to deepen technical insight.
  • Change Recommendation Thresholds: Edit the AI Agent system message logic to change how strictly it recommends buy or sell actions based on input confidence.

6. Troubleshooting 🔧

Problem: “Invalid API Key” errors from Twelve Data or Alpha Vantage nodes.
Cause: Wrong or expired API keys.
Solution: Go to Settings → Credentials in n8n → Update or regenerate the API keys and paste them into the correct nodes.

Problem: “Image format not supported” or AI chart analysis failures.
Cause: Improper response format from Chart-img API or failed download.
Solution: Verify the Get Chart URL and Download Chart responses. Ensure the image is base64 encoded or properly supplied to the AI analysis node.

Problem: Emails not delivering to inbox.
Cause: SMTP misconfiguration or spam filtering.
Solution: Test SMTP node with different settings, confirm user email, and check spam folders.

7. Pre-Production Checklist ✅

  • Verify all API keys are correctly entered and active.
  • Test the form trigger input with valid tickers and email addresses.
  • Ensure the AI Agent node runs without errors on sample data.
  • Review sample email content and design by sending test emails.
  • Backup your workflow configuration before deployment.

8. Deployment Guide

Activate the workflow by enabling the form trigger or scheduling the Schedule Trigger1 node for regular runs. Monitor workflow executions using n8n’s built-in logs to catch errors early. Adjust API keys or email settings as needed over time.

9. FAQs

  • Q: Can I use another AI language model instead of GPT-4o?
    A: Yes, but functionality and report quality may vary depending on the model’s capabilities.
  • Q: Does this workflow consume many API credits?
    A: It makes multiple API requests weekly; consider API plan limits and caching strategies.
  • Q: Is the data secure?
    A: Yes, as long as you secure your API keys and n8n instance.
  • Q: Can this scale to hundreds of stocks?
    A: The workflow is designed for individual or small batch use; scaling requires optimization and API plan upgrades.

10. Conclusion

You’ve now built a powerful automated stock analysis assistant using n8n and GPT-4o. This system transforms manual research into a streamlined weekly report combining technical and news sentiment insights, saving you hours and improving your investment decisions. Next, consider expanding to multi-stock batch processing, adding real-time alerts, or integrating portfolio performance tracking too. Keep experimenting and happy investing!

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation in n8n

A complete beginner guide to building an AI-powered SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free