convez.ai
MCP Server
nessos666

chart-vision-mcp

nessos666/chart-vision-mcp

Ver no GitHub
InicialPluginScore · de 0 a 100

Local TradingView chart analysis via OpenCV + Tesseract OCR. No API keys, no GPU, runs fully offline — MCP server with color/level/zone detection.

Instalação

$npx convez-ai nessos666/chart-vision-mcp

1 comando no terminal: detecta o formato do repositório (marketplace ou plugin avulso) e instala via Claude Code. Requer Node 18+ e o Claude Code instalado.

Métricas

Estrelas
3
Forks
1
Acompanhando
0
Saúde
42%
Último commit
há 5 meses
Versão
—
Issues abertas
0
Contribuidores
2

README

A tradução para o português deste README ainda está na fila.


Why?

AI agents that analyze TradingView charts typically rely on one of three approaches — each with serious tradeoffs:

ApproachCostSpeedPrivacyQuality
GPT-4 Vision / Gemini$$$ per API call~3-10sYour chart data leaves your machineHigh — understands context
Local VLM (LLaVA, Qwen-VL)Free (GPU required)~5-30sFully localMedium — small models hallucinate
OpenCV + OCR (this project)Free< 1sFully localMedium — structural, not semantic

Chart Vision MCP occupies a unique niche: it's the only option that is simultaneously free, instant, and fully offline. It doesn't "understand" charts the way an LLM does — but for structural analysis (candle colors, level lines, zone boundaries, volume) it's often more reliable than a vision LLM that might hallucinate price levels.


How It Works

┌─────────────────┐     screenshot     ┌──────────────────────┐
│   Screen / TV   │  ───────────────►  │  OpenCV Analysis     │
│                 │                    │                      │
└─────────────────┘                    │  Step 1: Grab screen │
                                       │  Step 2: Color mask  │
┌─────────────────┐                    │  Step 3: Hough lines │
│   Tesseract OCR │  ◄───────────────  │  Step 4: Contours    │
│                 │    image regions   │  Step 5: OCR crop    │
└─────────────────┘                    │                      │
                                       └──────────┬───────────┘
                                                  │ JSON result
                                                  ▼
                                       ┌──────────────────────┐
                                       │  MCP Response        │
                                       │  {                   │
                                       │    candle_bias,      │
                                       │    levels: [...]     │
                                       │    zones: [...],     │
                                       │    labels: [...],    │
                                       │    volume_rel,       │
                                       │    trend             │
                                       │  }                   │
                                       └──────────────────────┘

What it detects — step by step

StepMethodWhat it findsWhy it matters
1. Candle colorsHSV color maskingGreen/red pixel ratio per regionBullish vs bearish bias for the visible period
2. Level linesProbabilistic Hough TransformHorizontal lines matching known colorsSupport/resistance levels drawn on the chart
3. ZonesContour analysis on color masksFilled rectangles (FVG zones, order blocks)Key areas where price might react
4. VolumeBar height measurementRelative volume comparison across visible barsConfirms whether moves have conviction
5. OCRTesseract + preprocessingPrice labels, indicator values, annotationsExtracts actual numbers from the image
6. TrendPrice position algorithmUp / Down / Sideways classificationOverall market direction from the visible range

Example output

{
  "candle_bias": "bullish",
  "green_pct": 58.3,
  "red_pct": 41.7,
  "levels": [
    {"price": 19250, "color": "red", "type": "horizontal"},
    {"price": 19300, "color": "blue", "type": "horizontal"}
  ],
  "zones": [
    {"color": "yellow", "bounds": {"x1": 100, "y1": 200, "x2": 300, "y2": 250}}
  ],
  "labels": ["19250.00", "19300.00", "RSI: 62.4"],
  "volume_rel": "increasing",
  "trend": "up"
}

Comparison: OpenCV vs Vision LLMs

Vision LLMs are getting better at reading charts, but they have fundamental weaknesses that OpenCV doesn't:

Where OpenCV wins

ScenarioOpenCVVision LLM
Color accuracyExact HSV matchingMay confuse similar colors
Line positionPixel-exact coordinatesApproximate spatial reasoning
ConsistencyDeterministic — same input, same outputStochastic — different analysis each time
Speed< 1 second3-30 seconds
Cost$0$0.01-$0.10 per call
OfflineYesNo (cloud models)

Where Vision LLMs win

ScenarioOpenCVVision LLM
Chart patternsCan't detect head-and-shouldersCan reason about patterns
Context understanding"Many green candles = bullish""This looks like a breakout from consolidation"
Complex indicatorsCan only see colored linesCan read indicator values and interpret
AmbiguityFails on unclear visualsMakes educated guesses

The best of both worlds

Use Chart Vision MCP for the structural analysis (what colors, lines, and zones are on screen), and feed those results into an LLM for semantic interpretation. This gives you both speed (structural data is instant) and understanding (LLM reasons about the structured data).


MCP Integration

This project is a Model Context Protocol (MCP) server, which means it integrates natively with AI agents like Hermes, Claude Code, or any MCP-compatible host.

Register in your MCP config

{
  "mcpServers": {
    "chart-vision": {
      "command": "python3",
      "args": ["/path/to/chart_vision_mcp_server.py"],
      "env": {}
    }
  }
}

Available tools

ToolDescriptionParameters
chart_vision_analyzeScreenshot + full analysis (OpenCV + OCR)region: "full" or "chart"
chart_vision_screenshotScreenshot only, no analysis(none)

Both tools work without any API key or internet connection.


Hybrid Approach (Recommended)

Chart Vision MCP is most powerful when combined with real TradingView data. The vision layer gives you visual structure; the TV data layer gives you exact numeric values:

1. mcp_tv_chart_get_state          → what symbol, timeframe, indicators
2. mcp_tv_data_get_ohlcv           → last 20 bars (exact prices)
3. mcp_tv_data_get_pine_lines      → exact horizontal level prices
4. mcp_tv_data_get_pine_labels     → FVG / Order Block zones (exact boundaries)
5. mcp_tv_data_get_study_values    → RSI, MACD, Bollinger Bands (exact values)
6. mcp_chart_vision_analyze        → visual structure (colors, candle bias)

The TV MCP tools give you ground truth (exact prices, indicator values). Chart Vision gives you the visual gestalt (is it bullish or bearish-looking?). Together they're stronger than either alone.


Quick Start

git clone https://github.com/nessos666/chart-vision-mcp.git
cd chart-vision-mcp
pip install opencv-python pillow numpy pytesseract
sudo apt install tesseract-ocr   # Linux

# Run standalone analysis
python chart_vision.py --debug

# Or use the MCP server
python chart_vision_mcp_server.py

Files

FilePurposeLines
chart_vision.pyStandalone OpenCV analysis458
chart_vision_mcp_server.pyMCP server (v2.0, stdio JSON-RPC)258
chart_vision_gemini.pyGemini Vision integration (optional, requires API key)~150

Limitations

This is not an ML model. It doesn't "understand" charts the way a human or LLM does. It provides a deterministic, color-based structural analysis of what's visible on screen. It will not:

  • Detect complex patterns (head-and-shoulders, wedges, triangles)
  • Interpret candlestick patterns (doji, engulfing, harami)
  • Read every indicator value reliably (OCR accuracy depends on font size and contrast)
  • Understand market context or news

Use it for what it's good at: fast, reliable, zero-cost structural chart analysis that never hallucinates a price level.


Requirements

opencv-python>=4.8
pillow>=10.0
numpy>=1.26
pytesseract>=0.3

Plus system package: tesseract-ocr


Testing

# Syntax check
python3 -m py_compile chart_vision.py
python3 -m py_compile chart_vision_mcp_server.py

# Run with debug (shows intermediate steps)
python chart_vision.py --debug

Related


License

MIT — free to use, modify, and integrate.

Ver o original no GitHub

Bom para

Relacionados