Skip to content

Chart Screenshots

The dashboard displays a live chart screenshot captured from TradingView in the center panel. Screenshots are taken programmatically and served as base64-encoded PNG images.

Capture Method

Screenshots are captured using the TradingView automation layer:

capture.captureScreenshot({ region: 'chart', method: 'cdp' })
  • region: 'chart' -- captures only the chart area, excluding TradingView chrome
  • method: 'cdp' -- uses Chrome DevTools Protocol for reliable, headless capture

Caching

Screenshots are cached server-side for 10 seconds to avoid excessive capture calls. If a request arrives within the cache window, the cached image is returned immediately.

Refresh Cycle

The frontend requests a new screenshot every 15 seconds via the API. Combined with the 10-second cache, this means:

  • At most one fresh capture every 10 seconds
  • The displayed image is never more than ~15 seconds old

Display

The screenshot is rendered as a base64 PNG directly in the <img> tag in the center area of the dashboard. No temporary files are written to disk.

API

Endpoint Method Response
/api/screenshot GET { "data": "<base64 PNG string>" }

The response is a JSON object with a single data field containing the full base64-encoded PNG. The frontend sets this as the image source:

img.src = 'data:image/png;base64,' + response.data;