Skip to content

Agent Workflows

tradesdontlie edited this page Jul 21, 2026 · 1 revision

Agent Workflows

This is the "which tool when" decision tree — the fastest way for an agent (or a human) to pick the right tool for an intent. It mirrors the guidance baked into the project's CLAUDE.md so agents behave consistently. For the full alphabetical list, see Tool Reference.

The core loop is always the same: read state → act → verify.


"What's on my chart right now?"

  1. chart_get_state → symbol, timeframe, chart type, and every indicator with its entity ID.
  2. data_get_study_values → current numeric values from all visible indicators (RSI, MACD, Bollinger Bands, EMAs, custom plot()s).
  3. quote_get → real-time price, OHLC, volume for the current symbol.

"What levels / lines / labels are showing?"

Custom Pine indicators draw with line.new(), label.new(), table.new(), box.new(). These are invisible to normal data tools. Use the Pine graphics family (full guide: Reading Custom Pine Output):

  1. data_get_pine_lines → horizontal price levels (deduplicated, sorted high→low).
  2. data_get_pine_labels → text annotations with prices (e.g., "PDH 24550", "Bias Long ✓").
  3. data_get_pine_tables → table data as formatted rows (session stats, dashboards).
  4. data_get_pine_boxes → price zones as {high, low} pairs.

Pass study_filter to target a specific indicator by name substring (e.g., study_filter: "Profiler").

"Give me price data"

  • data_get_ohlcv with summary: true → compact stats (high, low, range, change%, avg volume, last 5 bars).
  • data_get_ohlcv without summary → individual bars (count to limit, default 100).
  • quote_get → single latest price snapshot.

"Analyze my chart" (full report)

  1. quote_get → current price.
  2. data_get_study_values → all indicator readings.
  3. data_get_pine_lines → key price levels from custom indicators.
  4. data_get_pine_labels → labeled levels with context.
  5. data_get_pine_tables → session stats / analytics tables.
  6. data_get_ohlcv with summary: true → price-action summary.
  7. capture_screenshot → visual confirmation.

"Change the chart"

  • chart_set_symbol → switch ticker (AAPL, ES1!, NYMEX:CL1!).
  • chart_set_timeframe → switch resolution (1, 5, 15, 60, D, W).
  • chart_set_type → switch style (Candles, Heikin Ashi, Line, Area, Renko).
  • chart_manage_indicator → add/remove studies (full name: "Relative Strength Index", not "RSI").
  • chart_scroll_to_date → jump to a date (ISO: 2025-01-15).
  • chart_set_visible_range → zoom to an exact date range (unix timestamps).

"Work on Pine Script" (the dev loop)

  1. pine_set_source → inject code into the editor.
  2. pine_smart_compile → compile with auto-detection + error check.
  3. pine_get_errors → read compilation errors.
  4. pine_get_console → read log.info() output.
  5. data_get_strategy_results → review performance.
  6. capture_screenshot → capture the result.

Validate before injecting:

  • pine_analyze → static analysis offline (out-of-bounds, bad loop bounds, implicit casts) — no TradingView needed.
  • pine_check → server-side compile without opening the chart.

⚠️ Avoid pine_get_source on complex scripts (200KB+). Only read it back if you need to edit.

"Practice trading with replay"

  1. replay_start with date: "2025-03-01" → enter replay mode.
  2. replay_step → advance one bar (or replay_autoplay with a speed in ms).
  3. replay_trade with action: "buy"/"sell"/"close" → execute trades.
  4. replay_status → check position, P&L, current date.
  5. replay_stop → return to realtime.

"Screen multiple symbols"

  • batch_run with symbols: ["ES1!", "NQ1!", "YM1!"] and action: "screenshot", "get_ohlcv", or "get_strategy_results". Compare metrics across the set in one call.

"Draw on the chart"

  • draw_shapehorizontal_line, trend_line, rectangle, text (pass a point + optional point2).
  • draw_list → see what's drawn.
  • draw_remove_one → remove by ID · draw_clear → remove all.

"Manage alerts"

  • alert_create → set a price alert (condition: crossing / greater_than / less_than).
  • alert_list → view active alerts · alert_delete → remove.

"Compare several symbols side by side"

  • pane_set_layout → set a grid (e.g., 2x2) · pane_set_symbol → put a symbol in each pane · pane_list / pane_focus to inspect and target.
  • Or tab_new / tab_switch to keep separate chart tabs.

"Navigate the UI"

  • ui_open_panel → open/close pine-editor, strategy-tester, watchlist, alerts, trading.
  • ui_click → click buttons by aria-label, text, or data-name.
  • layout_switch → load a saved layout · ui_fullscreen → toggle fullscreen.
  • Escape hatches when nothing else fits: ui_find_element, ui_mouse_click, ui_keyboard, ui_type_text, ui_evaluate.

"TradingView isn't running"

  • tv_launch → auto-detect and launch with CDP on Mac/Win/Linux.
  • tv_health_check → verify the connection.

Rules of thumb

  • chart_get_state once, then reference the entity IDs it returns — don't re-poll.
  • Entity IDs are session-specific — don't cache them across sessions.
  • Pine indicators must be visible for the data_get_pine_* tools to read them.
  • Prefer a screenshot over a giant data dump for visual context — it's ~300 bytes (a file path) and gives the whole picture. See Context Management.