Data Processing & Analysisintermediate
November 10, 2025
7 min read
35 minutes
Build an AI Stock Analysis Agent with n8n
AI-powered n8n workflow that delivers automated stock analysis with charts, MACD interpretation, sentiment, and integrated outlook — all from 1 query.
By Mahedi Hasan Nadvee

Ever tried to analyze a stock and found yourself drowning in a sea of charts, news articles, and technical indicators? You check the price, jump to Twitter for sentiment, open TradingView for technicals, then scramble to piece it all together. It's exhausting, time-consuming, and honestly, a bit chaotic.
What if you could ask a single AI agent about any stock and get back a comprehensive analysis that includes live technical charts, MACD indicator breakdowns, recent news sentiment, and an integrated outlook? That's exactly what this n8n workflow delivers. No more tab-switching. No more manual synthesis. Just ask, and the AI does the heavy lifting.
Prerequisites: What You'll Need to Get Started
Before diving into the workflow build, make sure you have these APIs and accounts ready:
- OpenAI API Key: This workflow uses GPT-4.1 for both the main AI agent and the chart analysis. You'll need access to OpenAI's API with vision capabilities enabled.
- Chart-img.com API Key: This service generates TradingView-style stock charts. Sign up at their platform to get your API key.
- Tavily Search API: For fetching recent news and sentiment data. Tavily offers developer accounts with API access for advanced search capabilities.
- n8n Instance: Either self-hosted or cloud-based. This workflow uses several n8n-langchain nodes, so ensure your instance has these installed.
Key Components: The Building Blocks
This workflow is actually two workflows working in harmony. Here are the critical n8n nodes you'll be using:
Main Chat Interface Nodes
- Chat Trigger Node: Webhook-based chat interface where users interact with the AI agent
- AI Agent Node: The orchestrator that decides which tools to use and synthesizes all information
- OpenAI Chat Model: Powers the AI agent with GPT-4.1
- Memory Buffer Window: Maintains conversation context across messages
- Tool Workflow Node: Connects to the technical analysis sub-workflow
- HTTP Request Tool: Configured for Tavily sentiment search
Technical Analysis Sub-Workflow Nodes
- Execute Workflow Trigger: Receives ticker symbol from main agent
- Edit Fields Nodes: Format data for API calls and responses
- HTTP Request Nodes: Generate and fetch chart images
- Basic LLM Chain: Analyzes chart images using AI vision
- OpenAI Chat Model: Provides vision capabilities for MACD analysis
Building the Workflow: Step by Step
Step 1: Set Up Your Chat Interface and AI Agent
Start by creating the main workflow canvas. Add a Chat Trigger node as your entry point. This creates a webhook that users can interact with through chat.
Connect it to an AI Agent node. This is where the magic happens. The agent receives a detailed system prompt that instructs it on how to analyze stocks. The prompt tells it to identify ticker symbols, call the appropriate tools, and structure its output into five distinct sections: overall summary, quantitative snapshot, detailed technical analysis, qualitative context, and integrated outlook.
Wire in an OpenAI Chat Model node (set to GPT-4.1) to power the agent, and add a Memory Buffer Window node so the agent remembers previous messages in the conversation.
Step 2: Create the Technical Analysis Sub-Workflow
Now for the clever part. Create a separate workflow that will act as a tool for your main agent. Start with an Execute Workflow Trigger node that accepts a ticker symbol as input.
Add an Edit Fields node to extract and format the ticker. Then connect an HTTP Request node configured to hit the Chart-img.com API. The request body should specify your chart preferences: dark theme, one-week interval, NASDAQ symbol format, and most importantly, include Volume overlay and MACD indicator studies with custom styling.
The API returns a URL to the generated chart. Add another HTTP Request node to fetch the actual image from that URL.
image_1.png
Step 3: Add AI Vision for Chart Analysis
Here's where it gets really interesting. The chart image alone isn't useful without interpretation. Add a Basic LLM Chain node connected to an OpenAI Chat Model with vision enabled.
The prompt you feed this chain is crucial. It needs to instruct the AI to act as an expert technical analyst focusing specifically on MACD indicators. The prompt should ask it to identify MACD line positions, signal line crossovers, histogram states, centerline crossovers, potential divergences, and provide an overall momentum assessment.
Finally, use an Edit Fields node to combine the analysis text with the chart URL into a single response object that gets returned to the main agent.
Step 4: Connect the Technical Analysis Tool
Back in your main workflow, add a Tool Workflow node. Configure it to execute your technical analysis sub-workflow. Give it a clear description like "Call this tool to conduct technical analysis" so the AI agent knows when to use it.
The agent will automatically pass ticker symbols to this tool when it needs technical chart analysis.
Step 5: Add Sentiment Analysis with Tavily
Add an HTTP Request Tool node and configure it to call the Tavily Search API. Set the method to POST and include your authorization bearer token in the headers.
In the body parameters, set up three key fields: the query (which the AI agent will generate dynamically), search depth set to "advanced", and days set to "7" to get the most recent news. Give this tool a description like "Call this tool to conduct sentiment analysis on the stock".
The AI agent will craft smart search queries combining company names with terms like "stock sentiment", "recent news", and "analyst outlook" to get the most relevant results.
Step 6: Test and Deploy
Use the test data feature in n8n to test your technical analysis workflow independently. The example workflow uses "TSLA" as test data, which is a good starting point.
Once both workflows are tested, activate them and try asking the chat interface about different stocks. The agent will intelligently decide which tools to call and in what order, then synthesize everything into a comprehensive analysis.
image_2.png
Why This Workflow Is a Game Changer
The beauty of this setup goes beyond just automation. You're creating an intelligent system that thinks like an analyst.
First, it saves massive amounts of time. What normally takes 20 minutes of jumping between platforms now happens in seconds. Ask about Apple, Tesla, or any publicly traded company, and get back a report that covers all the bases.
Second, the multi-modal analysis is genuinely powerful. The AI doesn't just read text data; it actually looks at chart images and interprets visual patterns like a human analyst would. It spots MACD crossovers, identifies momentum shifts, and even looks for divergences between price action and indicators.
Third, the integration of different data types creates insights you might miss when looking at each piece separately. The agent actively looks for confirmations and divergences. Does the bullish MACD crossover align with positive news sentiment? Are technical signals warning of a reversal despite rosy headlines? These correlations matter.
The workflow doesn't just gather information. It synthesizes it into something more valuable than the sum of its parts.
Use cases extend beyond personal trading decisions. Financial advisors can use this to quickly prepare client reports. Content creators can generate data-backed analysis for newsletters. Research teams can scale their analysis across multiple stocks without adding headcount.
The conversational memory means you can have follow-up discussions. Ask for more detail on a specific indicator. Request comparison between two stocks. Dig deeper into sentiment drivers. The agent maintains context and builds on previous exchanges.
Ready to Build Your Stock Analysis Agent?
This workflow represents a new way of interacting with financial data. Instead of being a data gatherer, you become a decision maker. The AI handles the research, analysis, and synthesis. You focus on interpretation and action.
The technical implementation is straightforward once you understand the architecture. Two workflows, a handful of API integrations, and thoughtful prompting. But the result is a sophisticated AI agent that combines quantitative data, technical chart analysis, and market sentiment into coherent, actionable insights.
Start with the prerequisites, build the components step by step, and soon you'll have your own AI analyst ready to tackle any stock you throw at it. The market waits for no one, but with this workflow, you'll always be ready with comprehensive analysis at your fingertips.
Share this article
Help others discover this content
Tap and hold the link button above to access your device's native sharing options
More in Data Processing & Analysis
Continue exploring workflows in this category

Data Processing & Analysisintermediate
1 min read
# Build an AI-Powered Conversational Survey Bot with n8n: Turn Static Forms into Dynamic Interviews
Nayma Sultana
Nov 15
Est: 40 minutes

Data Processing & Analysisintermediate
1 min read
Build an AI-Powered YouTube Parser with n8n
Mahedi Hasan Nadvee
Nov 13
Est: 45 minutes

Data Processing & Analysisadvanced
1 min read
Build a Smart AI Chatbot That Actually Knows Your Documents (Using n8n RAG Workflow)
Nayma Sultana
Nov 13
Est: 1 hour