n8n AI Agents Finance
9 min read Automation

Build Your Own AI Stock Market Analyst Using n8n - Automate Buy/Sell Recommendations

Most investors struggle to analyze complex market data in real-time. This n8n workflow automates stock analysis by connecting TradingView's API with Telegram, delivering instant buy/sell recommendations with technical indicators for Indian and Sri Lankan markets - no finance degree required.

The Investor Dilemma: Too Much Data, Not Enough Time

Every investor knows the frustration: you find a promising stock, but by the time you've analyzed all the indicators - current price, moving averages, RSI, liquidity ratios - the optimal entry point has passed. Retail investors particularly struggle with this analysis paralysis, often making emotional decisions rather than data-driven ones.

The solution? Automating the technical analysis process using n8n to create your personal AI stock analyst. This workflow connects directly to TradingView's market data API, processes the numbers through a structured analysis framework, and delivers clear buy/sell recommendations directly to your Telegram app.

72% of retail investors lose money due to emotional trading and lack of systematic analysis. This n8n workflow removes human bias by providing consistent, data-driven recommendations based solely on technical indicators.

TradingView API: The Foundation of Your AI Analyst

TradingView's API provides real-time market data for stocks across global exchanges, including comprehensive technical indicators. While their web interface is popular among traders, the API allows programmatic access to this data - perfect for automation through n8n.

The workflow uses TradingView's "market data" endpoint, which returns:

  • Current price and previous close
  • Percentage change
  • Volume and liquidity metrics
  • Technical indicators (RSI, moving averages)
  • Performance across different timeframes

Testing the API through Postman (as shown at 3:12 in the video) confirms it works for both Sri Lankan (CSE) and Indian (NSE) markets before building the n8n workflow.

n8n Workflow Breakdown: 6 Nodes That Automate Analysis

The complete workflow consists of six interconnected n8n nodes that transform a simple Telegram message into a comprehensive stock analysis:

Step 1: Telegram Trigger Node

Listens for stock ticker requests (like "TATASTEEL" or "JOHNKELLS") from your Telegram bot. This acts as the workflow's entry point.

Step 2: Get Symbol Node

Validates the stock symbol and prepares the API request format for TradingView.

Step 3: JSON Transform Node

Structures the market data request with the proper parameters for either Indian (NSE) or Sri Lankan (CSE) markets.

Step 4: Get Live Data Node

Makes the actual API call to TradingView and retrieves all market data for the requested stock.

Step 5: Format Reply Node

Processes the raw data into a human-readable analysis with clear buy/sell recommendations.

Step 6: Telegram Reply Node

Sends the formatted analysis back to the user through Telegram, including a direct link to the TradingView chart.

No coding required: The entire workflow uses n8n's visual interface - you just need to configure the API endpoints and Telegram bot credentials.

Telegram Integration: Your Mobile Stock Research Assistant

Telegram serves as the perfect interface for your AI stock analyst because:

  • Available on all devices (mobile/desktop)
  • Supports rich formatting in messages
  • Allows clickable links to TradingView charts
  • Maintains conversation history for reference

Setting up the Telegram bot takes just minutes through BotFather (shown at 6:45 in the video). Once configured, you simply:

  1. Message your stock ticker to the bot
  2. Receive within seconds:
    • Current price and change
    • Technical rating (Strong Buy/Buy/Hold/Sell)
    • Key indicators summary
    • Direct TradingView chart link

This puts professional-grade analysis in your pocket, available whenever market opportunities arise.

Adapting for Indian Market: NSE vs. CSE Configuration

The workflow defaults to Sri Lankan markets (CSE) but can be easily adapted for Indian stocks (NSE) by modifying three nodes:

1. Get Live Data Node

Change the API endpoint URL from .../symbols=CSE:... to .../symbols=NSE:...

2. Search Symbol Node

Update the exchange value from SLK (Sri Lanka) to NSC (National Stock Exchange)

3. Format Reply Node

Modify the currency display from LKR to INR in the JavaScript code

These changes (demonstrated at 9:30 in the video) allow the same workflow to analyze Tata Steel, Tata Motors, or any NSE-listed stock with equal precision.

Sample Recommendations: How the AI Analyst Thinks

The formatted Telegram response provides a comprehensive analysis:

TATASTEEL Analysis (NSE)
Current Price: ₹184.00 (+0.55%)
Previous Close: ₹183.00
Recommendation: Buy
Technical Rating: 8/10
Liquidity: High
RSI: 62 (Neutral)
50-Day MA: ₹178.50 (Support)
View Live Chart: [Clickable Link]

For John Keells Holdings (CSE), the analysis includes similar metrics tailored to Sri Lankan market conventions. The consistent format allows for quick comparison across your watchlist.

Extending the Workflow: Adding AI Interpretation

While the current workflow provides raw technical analysis, you can enhance it by integrating AI interpretation:

Option 1: ChatGPT/Gemini Analysis

Add nodes to send the technical data to an LLM for more nuanced interpretation of what the indicators mean in current market conditions.

Option 2: Sentiment Analysis

Incorporate news API data to assess whether media sentiment aligns with the technical indicators.

Option 3: Portfolio Tracking

Connect to Google Sheets to log recommendations and track actual performance versus the AI's predictions.

The GitHub repository mentioned in the video (at 11:20) includes starter code for these advanced integrations.

Watch the Full Tutorial

See the complete workflow in action, from Telegram request to detailed stock analysis, in the video tutorial below. Pay special attention to the 6:45 mark where we configure the Telegram bot connection - this is the most common setup hurdle.

Video tutorial showing how to build AI stock analyst with n8n

Key Takeaways

This n8n workflow demonstrates how automation can level the playing field for retail investors. By systematically analyzing technical indicators rather than relying on gut feelings, you make more disciplined, profitable decisions.

In summary: The AI stock analyst workflow connects TradingView's market data API with Telegram through n8n, providing instant technical analysis for Indian and Sri Lankan stocks. With minor configuration changes, it can adapt to other global markets or integrate additional AI interpretation layers.

Frequently Asked Questions

Common questions about this topic

The workflow currently supports both Indian (NSE) and Sri Lankan (CSE) stock markets. The system can be adapted for other markets by modifying the TradingView API endpoints and exchange codes in the n8n workflow.

We've specifically tested it with these two markets, but the same principles apply to any market that TradingView covers through their API.

  • Indian Market: Uses NSE exchange codes
  • Sri Lankan Market: Uses CSE exchange codes
  • Other markets require endpoint adjustments

The system analyzes current price, previous close, percentage change, liquidity ratios, performance metrics, technical indicators (like RSI and moving averages), and provides an overall buy/sell recommendation based on this comprehensive data analysis.

It looks at both short-term indicators (like daily price movements) and longer-term trends (50-day moving averages) to give a balanced view.

  • Price data: Current, previous close, change
  • Volume indicators: Liquidity assessment
  • Technical indicators: RSI, moving averages

No coding is required. The workflow uses n8n's visual interface to connect the TradingView API with Telegram. Basic technical skills are needed for initial setup, but the template provides all necessary configuration.

You'll need to be comfortable with:

  • Creating a Telegram bot via BotFather
  • Copying/pasting API endpoints
  • Following step-by-step node configuration

The recommendations are based on TradingView's comprehensive market data and technical indicators. While no system is 100% accurate, this provides data-driven insights that outperform manual analysis for most retail investors.

In backtesting, the technical indicators alone have shown about 65-70% accuracy in predicting short-term price movements when used systematically.

  • Better than emotional trading decisions
  • Consistent application of technical rules
  • Improves with additional AI interpretation

Yes, the workflow can be extended to include AI analysis from ChatGPT or Gemini by adding additional n8n nodes. This would provide more nuanced interpretation of the technical indicators and market conditions.

The GitHub repository includes starter code for adding:

  • ChatGPT interpretation of technical signals
  • Gemini analysis of market context
  • Combined technical/fundamental perspectives

The data updates in real-time whenever a new query is made through Telegram. The system pulls live market data from TradingView's API at the moment of request, ensuring you always get current information.

You can:

  • Query individual stocks as needed
  • Set up automatic daily scans
  • Trigger alerts on significant movements

The basic market data endpoints used in this workflow are currently free. TradingView does offer premium API tiers with more features, but they're not required for this basic analysis functionality.

Current API limits:

  • Free tier: 5 requests per minute
  • More than adequate for personal use
  • Premium tiers available for higher volume

GrowwStacks specializes in building custom automation solutions for financial analysis. We can implement this stock analyst workflow for your firm, customize it for specific markets or indicators, integrate it with your existing systems, and provide ongoing support.

Our services include:

  • Full implementation of this workflow
  • Customization for your preferred markets
  • Integration with your existing tools
  • Ongoing maintenance and updates

Get Your Personal AI Stock Analyst Working for You

Stop second-guessing your investment decisions and start acting on data-driven recommendations. Our automation experts can have this AI stock analyst workflow customized for your portfolio in under 48 hours.