AI Powered Multi-Timeframe Stock Sentiment and Technical Analysis - n8n Workflow

Deploy an advanced n8n workflow to analyze stock technicals and news sentiment using GPT-4, TwelveData, and NewsAPI. Generate actionable trading recommendations automatically with this n8n template.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Quantitative analysts and algorithmic traders.

  • Financial developers seeking advanced automation.

  • Users looking for sophisticated n8n templates for market analysis.

  • Individuals who need automated, data-driven trading signals.

Overview

This comprehensive n8n workflow addresses the complexity of manual financial analysis by integrating real-time stock data (technical indicators from TwelveData) and market news sentiment (from NewsAPI/GPT-4) into a single, highly structured AI decision engine. This powerful n8n automation starts with a simple chat message and orchestrates multiple external APIs and specialized AI models. The core decision logic resides within a Langchain Agent n8n node, which is configured to act as an expert algorithmic trader. It prioritizes risk management and ensures trend alignment across 4-hour, daily, and weekly timeframes before delivering a clear BUY, SELL, or HOLD signal. This is an essential n8n template for sophisticated finance automation, ensuring every recommendation is backed by both technical and fundamental data.

How it Works

The entire process begins with the When chat message received n8n trigger, which initiates the n8n workflow upon a user request.


  1. Symbol Identification: The user's input (e.g., 'Microsoft') is first processed by the Convert to Stock Symbol OpenAI n8n node, which strictly returns the stock ticker (e.g., 'MSFT').

  2. Data Fetching: Three parallel HTTP Request n8n nodes (4h trend, 1day trend, 1week trend) fetch time-series pricing data from the TwelveData API using the extracted symbol.

  3. Data Validation: The results are merged and passed through the Check Twelvedata API Success Switch n8n node. If the API returns an error, the flow terminates, and the Respond with Error n8n node notifies the user.

  4. Technical Processing: If successful, the Code n8n node executes a complex JavaScript function to calculate key technical indicators: Moving Averages (MA5, MA10, MA20), multi-timeframe trend direction, support, resistance, and volume profiles. This creates a clean JSON structure for the AI agent.

  5. Sentiment Processing: Simultaneously, the Get News n8n node fetches recent headlines using NewsAPI. The News Sentiment Analyzer OpenAI n8n node then analyzes this text, returning a structured sentiment score and rationale.

  6. Orchestration and Aggregation: The technical and sentiment data streams are combined using Merge and Aggregate n8n nodes, feeding the complete context into the final AI agent.

  7. AI Decision Making: The Technical Data AI Agent n8n node (powered by the GPT-4o language model) utilizes its predefined persona and trading framework. It can use specialized tools like Get Stock Sentiment (Perplexity) and Get Chart Image for Stock (Chart-Img API) to gather external context and visual aids, adhering to strict trading rules (e.g., minimum 1:2 risk/reward ratio).

  8. Final Recommendation: The agent outputs a highly structured trade recommendation (BUY/SELL/HOLD, Entry Price, Stop-Loss, Target Price), which is delivered to the user via the Respond to Chat n8n node.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided n8n workflow JSON and paste it into your n8n instance via the 'New' menu > 'Import from JSON'.

  2. OpenAI Credentials: Set up your OpenAI API credentials. This n8n template uses OpenAI for both symbol conversion and core sentiment analysis, as well as powering the Agent logic.

  3. TwelveData Setup: Obtain an API key from TwelveData. Set up an HTTP Query Auth credential named 'Twelvedata API Key Auth' in your n8n instance.

  4. NewsAPI Setup: Obtain an API key from NewsAPI. Set up an HTTP Query Auth credential named 'NewsAPI API Key' in your n8n.

  5. Chart-Img Setup (Optional): If you wish to include stock charts in your output, set up an HTTP Header Auth credential for the Chart-Img API.

  6. Perplexity Setup (Optional): The Get Stock Sentiment n8n node requires a Perplexity API key for additional real-time analysis.

  7. Activation: Ensure the n8n workflow is active, and test the When chat message received n8n trigger by sending a sample message to the configured endpoint.

Node Details

When chat message received (n8n trigger): The starting point of this n8n workflow. It monitors for user chat inputs, typically a stock name or ticker, sending the content to the next step.
Convert to Stock Symbol (OpenAI n8n node): Uses a small GPT model (GPT-4.1-mini) to reliably convert natural language stock names into strict trading symbols required for the data APIs.
HTTP Request (n8n node - TwelveData): Used three times to fetch critical time-series data for 4-hour, 1-day, and 1-week intervals, crucial for multi-timeframe analysis within the n8n workflow.
Code (n8n node): Contains extensive custom JavaScript logic. Its function is to transform raw TwelveData JSON into calculated financial metrics (MAs, Support/Resistance, Trend Direction) suitable for complex consumption by the final LLM agent.
News Sentiment Analyzer (OpenAI n8n node): Analyzes fetched news articles to derive a precise, quantified sentiment score and rationale, outputting a strict JSON payload.
Technical Data AI Agent (Langchain Agent n8n node): The core intelligence of the n8n workflow. It combines technical analysis and sentiment data and uses its internal systemMessage (Algorithmic Trader persona) and tools (Perplexity, Chart-Img, GPT-4o) to execute a sophisticated trade analysis and produce the final, actionable recommendation. This specialized n8n node is central to the decision process.


  • Get Chart Image for Stock (HTTP Request Tool n8n node): Acts as a tool for the AI Agent to dynamically request and embed a visual trading chart into its analysis output.

Related n8n Workflows

Free

Nodes: 14 Nodes
Updated: December 26 2025
View all
Created by

AI Automation Specialist - OpenAI, CRM & Automation Expert with a solid understanding of various tools that include Zapier, Make, Zoho CRM, Hubspot, Google Sheets, Airtable, Pipedrive, Google Analytics, and more.

Featured*