Skip to main content
Glama
CenblueOne

J-SQUAD TradingView MCP Combined

by CenblueOne
README.md
# J-SQUAD TradingView MCP Combined

> **58 tools · 8 modules** — MCP server for Claude Desktop that integrates TradingView Desktop (CDP), TradingView Screener API, Yahoo Finance, IDX/BEI Indonesia tools, backtesting engine, news sentiment, trade math, and market sessions.

Built by [CenblueOne](https://github.com/CenblueOne) as part of the **J-SQUAD** IDX trading bot system.

---

## Sources (merged)

| Repo | Contribution |
|------|-------------|
| [tradesdontlie/tradingview-mcp](https://github.com/tradesdontlie/tradingview-mcp) | CDP core — TradingView Desktop automation |
| [CenblueOne/tradingview-mcp-two](https://github.com/CenblueOne/tradingview-mcp-two) | TA screener, IDX tools, backtesting, news |
| [CenblueOne/tradingview-mcp-three](https://github.com/CenblueOne/tradingview-mcp-three) | Trade math, sessions, Pine data, pane/tab, replay |

---

## Tool List

### MODULE 1 — CDP (TradingView Desktop) · 23 tools
> Requires `TradingView.exe --remote-debugging-port=9222`

| Tool | Description |
|------|-------------|
| `tv_connect` | Test CDP connection to TV Desktop |
| `tv_chart_state` | Get current symbol, timeframe, exchange |
| `tv_get_quote` | Live price, change, volume from open chart |
| `tv_set_symbol` | Switch symbol on active chart |
| `tv_set_timeframe` | Change timeframe (1m/5m/1h/1d…) |
| `tv_get_indicators` | List active indicators on chart |
| `tv_screenshot` | Take screenshot of TV Desktop (base64) |
| `tv_pine_inject` | Run Pine Script code on active chart |
| `tv_create_alert` | Create price alert |
| `tv_pine_get_data` | Read Pine Script output values from chart |
| `tv_snapshot` | All-in-one: state + quote + indicators |
| `tv_pine_data` | Extract lines/labels/tables/boxes from Pine |
| `tv_chart_type` | Switch chart type (Candles/HA/Line/Renko…) |
| `tv_manage_indicator` | List / add / remove indicators |
| `tv_chart_navigate` | Jump to date, scroll back N bars, reset |
| `tv_draw_shape` | Draw horizontal line, rectangle, long/short position |
| `tv_alert_manage` | List / delete alerts |
| `tv_data_ohlcv` | Get OHLCV bars from Desktop chart |
| `tv_pane` | List panes / set layout / focus pane / set symbol |
| `tv_tab` | List / new / close / switch chart tabs |
| `tv_replay` | Control bar replay (start/step/autoplay/stop) |
| `tv_watchlist` | Get watchlist / add symbol |
| `tv_symbol_search` | Search symbol by keyword |

### MODULE 2 — Technical Analysis · 6 tools
> VPS-compatible, uses TradingView Screener API (no Desktop needed)

| Tool | Description |
|------|-------------|
| `get_ta` | Full TA: RSI, MACD, BB, EMA, ADX, Stoch, CCI |
| `get_multi_tf` | Multi-timeframe TA (1h + 4h + 1d) |
| `get_screener` | Scan multiple symbols, rank by signal strength |
| `get_ta_simple` | Quick BUY/SELL/HOLD recommendation |
| `bulk_screener` | Scan up to 50 symbols in one call |
| `get_ta_batch` | Batch TA for a list of symbols |

### MODULE 3 — Yahoo Finance · 3 tools

| Tool | Description |
|------|-------------|
| `yf_price` | Real-time price, change%, volume, market cap |
| `yf_ohlcv` | Historical OHLCV data (any period/interval) |
| `market_snapshot` | Multi-symbol price snapshot |

### MODULE 4 — IDX / BEI Indonesia · 7 tools

| Tool | Description |
|------|-------------|
| `idx_price` | IDX stock price via Yahoo Finance (.JK) |
| `idx_ta` | TA for IDX stock (exchange=IDX, screener=indonesia) |
| `idx_mtf` | Multi-timeframe TA for IDX stock |
| `idx_market` | IDX market overview: IHSG, top gainers/losers |
| `idx_screener` | Scan LQ45/IDX_MAJOR by change%, volume |
| `idx_signals` | Batch TA signals for IDX watchlist |
| `idx_backtest` | Quick backtest an IDX stock (9 strategies) |

### MODULE 5 — Backtesting Engine · 3 tools
> 9 built-in strategies · Walk-forward validation · ROBUST/MODERATE/WEAK verdict

**Strategies:** `rsi` · `ema_cross` · `bollinger` · `macd` · `supertrend` · `donchian` · `rsi_pullback` · `triple_ema` · `keltner_breakout`

| Tool | Description |
|------|-------------|
| `idx_backtest` | Quick backtest for IDX stock |
| `backtest_strategy` | Full backtest: any symbol, any strategy, custom params |
| `backtest_compare` | Compare all 9 strategies on one symbol |

### MODULE 6 — Sentiment & News · 3 tools

| Tool | Description |
|------|-------------|
| `financial_news` | Live headlines: Yahoo Finance, CNBC, MarketWatch |
| `market_sentiment` | Sentiment score from recent news (BULLISH/BEARISH/NEUTRAL) |
| `combined_analysis` | Power tool: TA + Price + Sentiment → STRONG BUY/SELL/HOLD |

### MODULE 7 — Trade & Risk Math · 4 tools

| Tool | Description |
|------|-------------|
| `position_size` | Lot size from balance, risk%, SL pips (forex/gold/index/crypto) |
| `rr_calc` | Risk:Reward ratio, meets 1:2 minimum check |
| `journal_add` | Add trade to local journal (JSONL) |
| `journal_list` | View trade journal (filter by symbol) |

### MODULE 8 — Market Sessions · 2 tools

| Tool | Description |
|------|-------------|
| `market_sessions` | Active sessions in WIB + overlaps + IDX status + BEI holidays |
| `morning_brief_idx` | IDX morning brief: top bullish/bearish from LQ45 scan |

---

## Requirements

```
Python >= 3.9
mcp >= 1.0.0
tradingview-ta >= 3.3.0
yfinance >= 0.2.40
pandas >= 2.0.0
numpy >= 1.24.0
websocket-client >= 1.7.0    # CDP tools only
feedparser >= 6.0.0
requests >= 2.31.0
```

---

## Installation

### 1. Install dependencies

```bash
pip install -r requirements.txt
```

### 2. Configure Claude Desktop

Edit `claude_desktop_config.json` (Windows: `%APPDATA%\Claude\claude_desktop_config.json`):

```json
{
  "mcpServers": {
    "tradingview-combined": {
      "command": "python",
      "args": ["C:/path/to/server.py"],
      "env": {
        "TV_CDP_PORT": "9222"
      }
    }
  }
}
```

See `claude_desktop_config.json` in this repo for a ready-to-use example.

### 3. CDP Setup (for TradingView Desktop tools only)

Launch TradingView Desktop with remote debugging enabled:

**Windows:**
```
"C:\Users\<user>\AppData\Local\Programs\TradingView\TradingView.exe" --remote-debugging-port=9222
```

Or create a shortcut with `--remote-debugging-port=9222` as argument.

Verify CDP is active: open `http://localhost:9222/json` in browser. You should see a JSON list of pages.

---

## Environment Variables

| Variable | Default | Description |
|----------|---------|-------------|
| `TV_CDP_PORT` | `9222` | CDP port for TradingView Desktop |

---

## Usage Examples

**Market analysis:**
```
Analyze BBRI on IDX — give me TA + sentiment + price
```
→ Calls `combined_analysis(symbol="BBRI", exchange="IDX", screener="indonesia")`

**Morning scan:**
```
Run morning brief for IDX
```
→ Calls `morning_brief_idx()` — scans LQ45, returns top 5 bullish + bearish

**Backtest:**
```
Backtest TLKM with supertrend strategy for 1 year
```
→ Calls `backtest_strategy(symbol="TLKM.JK", strategy="supertrend", period="1y")`

**Position sizing:**
```
I have $10,000 balance, risk 1%, SL is 50 pips, instrument is gold
```
→ Calls `position_size(balance=10000, risk_pct=1, sl_pips=50, instrument="gold")`

**TradingView Desktop:**
```
What's currently on my TradingView chart?
```
→ Calls `tv_snapshot()` — returns symbol, timeframe, price, active indicators

---

## Module Dependency Map

```
CDP tools (Module 1)     → requires: TradingView Desktop + websocket-client
TA tools (Module 2)      → requires: tradingview-ta
Yahoo Finance (Module 3) → requires: yfinance
IDX tools (Module 4)     → requires: tradingview-ta + yfinance
Backtesting (Module 5)   → requires: yfinance + pandas + numpy
News (Module 6)          → requires: yfinance + feedparser
Trade Math (Module 7)    → no external deps
Sessions (Module 8)      → requires: tradingview-ta (for morning_brief_idx)
```

All modules degrade gracefully — missing a library disables only that module's tools.

---

## Part of J-SQUAD

This MCP server is designed to work alongside the J-SQUAD IDX trading bot system:

- **ARA Hunter** — detects approaching ARA stocks
- **Bandar Hunter** — detects institutional accumulation
- **Signal Aggregator** — aggregates signals across brokers
- **KINARA ENGINE** — TradingView webhook → Telegram alerts

---

## License

MIT — feel free to use, fork, and extend.