tv_copy_layout
Clone any TradingView chart layout into a new saved layout, optionally from a source URL, with duplicate-name protection and confirmation of the copy.
Instructions
TradingView "Make a copy": clone the layout shown in the bound tab (optionally opening source_url first, e.g. someone else's View Only chart) into a new saved layout with the given name. Settles when the copy appears in the saved-layout list (45-60 s: server clone + page reload); reports which tab shows it (TV Desktop opens a copy of another user's chart in a NEW tab). Refuses an empty name or a name that already exists among the saved layouts unless allow_duplicate_name=true.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | name of the new layout | |
| layout | No | chart layout id, target id, or 0-based index; default = the chart tab that is actually painting | |
| timeout_s | No | deadline for the clone (and for the open, each), default 120 - the clone is a server round trip plus a full page reload | |
| source_url | No | chart URL or layout id to open first (same rules as tv_open_chart_url); default = whatever the tab shows | |
| expect_layout | No | layout id the tab is expected to show right now; the call refuses if it differs (a tab keeps its target id when the user opens another layout in it) | |
| discard_changes | No | with source_url: navigate away from unsaved changes | |
| allow_duplicate_name | No | allow a name that already exists (default false) |