AI agents & the Ultra API
Connect Claude Code, Codex, Devin or any coding agent to PineTune through the loopback Ultra bridge.
The Developer plan lets a local coding agent operate PineTune: inspect the strategy, edit its Pine source, launch runs, wait for them and apply the best candidate.
Architecture
A Chrome MV3 extension cannot listen on a TCP port. PineTune therefore connects as a WebSocket client to a small, dependency-free Node bridge bound to 127.0.0.1. Your agent calls the bridge over HTTP.
| Endpoint | Purpose |
|---|---|
POST /api |
Send an action ({ "action": "...", ... }) |
GET /health |
Bridge and extension connection status |
GET /connect |
Wake page: nudges the extension to (re)connect |
GET /events |
Live state stream (SSE, or WebSocket upgrade) |
Default port: 5678. All responses are { "ok": true, "data": ... } or { "ok": false, "error": "..." }.
Setup
- Activate a Developer licence in the popup.
- Settings → Ultra Agent API: enable it and set the port (default
5678). - Open a TradingView chart with your strategy and the Strategy Tester.
- Run the CLI client. If nothing is listening on the port it starts the bridge for you and pins the first extension that connects.
curl http://127.0.0.1:5678/health
node tools/ultra-client.js status
node tools/ultra-client.js listTabs
If /health reports connected: false, open http://127.0.0.1:5678/connect in the browser that has PineTune installed.
The research loop
- Inspect:
snapshot --inputs --pinereturns strategy, inputs, editable Pine source, metrics and recent results. - Edit code (optional):
updatePineSourcevalidates, replaces the full source, saves, updates the chart and verifies the result. - Configure:
setConfigwith inputs, ranges, mode, objective and filters (partial updates are merged). - Run:
call --method start, thenwaitDoneblocks until the run reaches a terminal state. - Analyse:
getResults/getHistory. - Apply:
applyBestorapplyResult, which wait for the tester to settle.
“Best” means best among the combinations tested under your objective and filters, not a global optimum.
Agent Skill
PineTune ships a SKILL.md that teaches skill-aware agents the full loop, the API reference and common pitfalls. Point your agent at it, then describe the goal in plain language.
Security
- The bridge only binds to the loopback interface. Never expose it to a LAN or the internet.
- API responses never include your full licence key or third-party API keys.
- Don’t put secrets in request files passed with
--file. - Read-only or protected scripts are never edited around their restrictions.