Morning Prep Workflow
You are running the user's daily pre-market routine on TradingView.
Step 1: Pull the Watchlist
watchlist_get— read the active watchlist symbols. Membership comes from the symbols API, so it is complete even with the watchlist panel closed; prices are best effort and only attached when the panel is open, so checkquotes_availablebefore reading any price off it.- If empty, ask the user to import one via
watchlist_import(they may have a JSON backup saved from a priorwatchlist_export)
Example watchlist: ["ES1!", "NQ1!", "CL1!", "GC1!", "DXY", "BTCUSD"].
Step 2: Restore Morning Layout (if saved)
state_list— check for a snapshot named "morning" or similar- If found:
state_restorewithnameset to that snapshot name — this brings back the user's preferred indicators, drawings, timeframe, and chart type. It is DESTRUCTIVE: it makes the chart match the snapshot, so anything not in the snapshot is removed. Take astate_snapshotof the current chart first if it might be wanted back. - If not found: proceed with current chart state and offer to
state_snapshotwithname"morning" at the end
If state_restore fails with CHART_LOADING, wait ~2s and retry once.
Step 3: Batch Screenshot the Watchlist
Use batch_run with action: "screenshot" and the full symbol list. This captures each symbol without manual chart_set_symbol loops.
batch_run({ symbols: <watchlist>, action: "screenshot" })
Screenshots save to screenshots/ with timestamps — reference them in the summary.
Step 4: Deep-Dive Top 5
Pick the 5 most-relevant symbols (user's main instruments, e.g., ES1!, NQ1!, CL1!, GC1!, BTCUSD). For each:
chart_set_symbol— switch the chartdata_get_ohlcvwithsummary: true— compact stats (overnight high/low, range, change%)quote_get— the price held by the chart you just switched to. It is only as fresh as the chart's data connection and reportssuccess: trueon a stale bar, so checktv_health_checkonce before the loop and say so plainly ifdatafeed.stateisdisconnectedrather than reading out prices that look current.quote_batchtakes all five symbols in one call, does not touch the chart, and does not depend on that connection.
Keep OHLCV summary-only to avoid context bloat.
Step 5: Indicator Pulse
For the top-5 only:
data_get_study_values— RSI, MACD, EMAs currently on chartdata_get_pine_labelswithstudy_filterif the user runs a custom profiler (e.g., "Profiler", "Session Stats")
If data_get_indicator is needed and returns source: "dom_fallback", note that inputs were read from DOM (less reliable than API) — flag any suspicious readings.
Step 6: Summarize to Chat
Produce a compact briefing:
- Overnight leaders/laggards — from batch screenshots + OHLCV change%
- Key levels in range — pulled from
data_get_pine_linesif a levels indicator is loaded - Bias per instrument — one line each (e.g., "ES1! — holding above PDH 5812, bullish above 5800")
- Watch items — alerts firing near current price (use
alert_listto cross-reference)
Cleanup
Offer to state_snapshot with name morning-<date> so today's layout is reproducible tomorrow. If the user added throwaway drawings while prepping, draw_clear them before snapshotting.