<!-- Public documentation export; not library implementation source. -->
# Optional Pine integration

Pine is optional. To use it, you need both the configuration and the matching worker and editor files. Shipping the files alone won't let scripts run.

Pine executes scripts over chart data. Separately, [AI integration](https://docs.lumencharts.com/charting-library/automation/) orchestrates chart operations and exposes data/capture ports. Pine does not require an AI provider or the automation runtime.

> Pine Script® is a trademark of TradingView, Inc. Lumen Charts is not affiliated with, sponsored by or endorsed by TradingView. References to Pine Script describe language compatibility only.

## Turn on Pine

```js
const widget = new LumenChartingLibrary.widget({
  container: 'chart', library_path: '/lumen_charting_library/',
  datafeed, symbol: 'AAPL', interval: '1D', locale: 'en',
  pine_script: { enabled: true },
});
widget.onChartReady(async () => {
  const id = await widget.activeChart().createPineStudy(
    '//@version=5\nindicator("Average", overlay=true)\nplot(ta.sma(close, 20))',
  );
  console.log(id);
});
```

## Matching files and errors

Your code, the worker and the optional editor must all come from the same manifest. Catch compile and run errors, and let users fix or remove the script. Having an editor doesn't mean every part of the Pine language is supported. Anything unsupported should fail with a clear error.

## Local versus hosted features

Running scripts locally doesn't set up cloud workspaces, publishing, external libraries or alert delivery. Those need their own providers and identity setup. An alert event on the chart doesn't prove that a notification actually reached anyone.

## Lifecycle

Remove scripts you no longer need, unsubscribe from progress and log listeners, and remove the chart before you throw away its host. If the inputs, source or data change, don't reuse the old results.

[Interactive chart example](https://docs.lumencharts.com/charting-library/studies/pine) — runs in a browser with synthetic data.

---
Documentation page: https://docs.lumencharts.com/charting-library/studies/pine
