save_pine_script
Save Pine Script source to a TradingView library as a new script or new version, using a two-step confirm flow to preview changes before writing. Compile errors are reported with line numbers for quick fixes.
Instructions
Save Pine source to the user's script library — the ONLY write tool, with a confirm flow: without confirm=true nothing is written and a dry-run preview is returned; show it to the user and get their approval before calling again with confirm=true. Non-destructive by design: creates a new script (name, no pine_id) or a new version of an existing one (pine_id), and every older version stays retrievable via get_pine_source(pine_id, version). Compile errors are returned with line numbers; note the version is stored even if compilation fails (see revertHint). Typical PDCA loop: get_pine_source -> edit -> save_pine_script -> run_backtest.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | Script name — required when creating a new script, optional rename otherwise | |
| source | Yes | Full Pine source, e.g. starting with //@version=5 | |
| confirm | No | Must be true to actually write. Default: false = dry run only | |
| pine_id | No | Existing script to save a NEW VERSION of. Omit to create a new script |