> ## Documentation Index
> Fetch the complete documentation index at: https://docs.myfundedperpetuals.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Scripts Page

> Save, edit, version, and backtest Pine scripts, show them on your trade charts, share them with a link or code, and add scripts other traders shared.

The Scripts page is where you keep your own Pine scripts. You can write or
import a script, check it for errors, preview it on a chart, backtest
strategies, save versions, and switch scripts on so they run on every trade
chart. You can also share a script and add copies of scripts other traders
shared.

How the engine runs a script, what it can draw, and why values can differ
from TradingView is covered in [Pine Scripts](https://docs.myfundedperpetuals.com/guides/pine-scripts.md).

## Open your scripts

On the trade page, select **Scripts** in the chart toolbar, beside Alerts. The
Scripts window opens over the trade page with three tabs:

| Tab | What it shows |
| - | - |
| **My Scripts** | Your saved scripts and the editor. |
| **Public Library** | Scripts other traders listed. See [Public Library](#public-library). |
| **Top Indicators** | Listed scripts ranked by how many traders added them. See [Top Indicators](#top-indicators). |

The window also has a share code field and **Open Full Page**, which opens
My Scripts and the editor as a full page at
[myfundedperpetuals.com/scripts](https://myfundedperpetuals.com/scripts). The
Public Library, Top Indicators, and the share code field are only in the
window over the trade page.

## My Scripts

My Scripts lists your saved scripts with their **Type** (Indicator or
Strategy), **Status** (**Compiles** or **Has Errors**), and whether they show
**On Trade**. Use **Columns** to show **Latest Version**, **Version On Trade**,
**Last Edited**, and **Created**, and **Filters** to narrow the list by type,
status, or On Trade. The header shows how many On /trade slots are in use.

To add a script:

* **New Script** opens a new indicator or strategy in the editor.
* **Import** takes a pasted script or a \`.pine\` or \`.txt\` file. The script is
  checked before you save it: **Ready**, **Library**, **Needs A Library**, or
  **Won't Compile**. A script that won't compile can still be saved and fixed
  in the editor, but it doesn't run on a chart until it compiles.
* With no scripts yet, choose a template: **Moving Average Cross**, **RSI
  With Levels**, **Session VWAP Bands**, or **Daily Loss Guard**.

A script's name is the title in its \`indicator()\` or \`strategy()\`
declaration, so a script needs a title to be saved. Each script's actions
menu has **Open**, **Share**, and **Duplicate**. Select scripts with their
checkboxes to delete several at once. Deleting a script deletes all its
versions, removes it from your trade charts, and stops its share links and
codes. It can't be undone.

**Libraries** opens your saved Pine libraries. See
[Libraries](https://docs.myfundedperpetuals.com/guides/pine-scripts.md#libraries).

## Edit a script

The editor shows the code beside a preview chart. Choose the preview's
**Market** and **Timeframe** above the chart. The preview runs your unsaved
draft as you type; while the draft has errors, it shows the last draft that
compiled.

The panels under the code are:

| Panel | What it shows |
| - | - |
| **Problems** | Compile errors, warnings, lint hints, runtime errors with the bar they happened on, and the script's \`log.info\`, \`log.warning\`, and \`log.error\` lines (the newest 200). Select one to go to its line. |
| **Inputs** | The script's inputs, with the same fields as the chart's settings. |
| **Inspector** | Every variable's value on a bar you click on the preview chart, plus up to 5 watch expressions. |
| **Trades** | A strategy's simulated trades on the preview, up to 500 rows, with **Export CSV**. |
| **References** | Where a name is declared and used, after **Find All References**. |

The editor also has a **Command Palette**, formatting (with **Format On
Save**), **Quick Fix**, and **Keyboard Shortcuts**, all in the **Script
Actions** menu. You can keep up to 8 scripts and libraries open as tabs.

Unsaved changes are kept as a draft in this browser, not on your account. If
the script was saved somewhere else since your draft started, the editor
offers **Keep Draft** or loading the newer version.

Other actions:

* **Copy Code** copies the editor's code.
* **Rename** changes the title in the script's declaration and saves it as a
  new version. It's available once the script compiles and has no unsaved
  changes.
* **Duplicate** saves a copy of the current saved version as a new script,
  with its saved inputs. Unsaved changes stay in the original's draft.
* **Delete Script** deletes the script and all its versions.

## Save and versions

**Save Version** saves the editor's code as the script's next version. A
script with compile errors can't be saved from the editor: fix the errors
first. Saving code that hasn't changed doesn't add a version.

Each script keeps its newest 20 saved versions. Saving past that deletes the
oldest. **Versions** in the **Script Actions** menu compares a saved version
with the editor, and **Restore Into Editor** loads it as an unsaved draft;
save it to make it current.

While the draft differs from the saved version, the strategy results above
the preview show each figure's change against the saved version, run on the
same bars.

Input values you set in the **Inputs** panel are saved to the script when
the preview runs the saved version, and show **Preview only until you save**
while it runs a draft. They belong to one version: if a new version's inputs
don't match the previous version's, saved input values go back to the
script's defaults and a message says so.

## Show scripts on your trade charts

Turn on **Show On /trade** in the editor, or the **On Trade** switch in My
Scripts, to run a script on every trade chart, in every market. Up to 4
scripts can be on at once, and only a saved script that compiles can be
turned on. The chart runs the script's current saved version: saving a new
version updates your trade charts.

On the trade chart, a script that's on:

* Draws on the price chart or in its own pane, as its \`overlay\` setting
  declares.
* Counts toward the 4 Pine scripts one chart runs, and runs before scripts
  you pasted into the chart's own indicators.
* Keeps input changes you make in its chart settings. They're saved to the
  script and apply on every trade chart and in the editor.
* Can't have its code changed from the chart. Edit it on the Scripts page;
  chart changes to its code are put back.

Right-click the script's name in the chart legend for **Open In Script
Editor**, **Remove From All Trade Charts**, and **Report a Problem**.
Removing the script from the chart also turns it off on all trade charts.

## Backtest a strategy

The preview runs a strategy as a simulated backtest on the preview's market
and timeframe. **Strategy Results** above the preview show **Net P\&L**,
**Win Rate**, **Max Drawdown**, **Profit Factor**, and **Trades**, and **Show
Strategy Report** under the preview opens the full report. Results fill at
bar prices, with fees as the script sets them, and no funding or slippage, so
real fills differ.

**Backtest** in the **Script Actions** menu runs the draft beyond the
preview, one run at a time in your browser:

* **Markets** runs the draft on up to 10 markets, including the preview's,
  on the preview's timeframe with the current inputs, and lists each
  market's results. A script that reads other symbols with
  \`request.security()\` runs without that data in a backtest, and those
  markets are marked because their results may be off.
* **Sweep** varies up to 2 number inputs (\`input.int\` or \`input.float\`) over
  a **From**, **To**, and **Step** you choose, up to 100 combinations, on the
  preview market's bars. Two inputs show a **Net P\&L Heatmap**. **Apply**
  sets a combination on the draft's preview only; saved inputs and your
  trade charts don't change.

> [!WARNING]
>
> Backtests and sweeps are simulations on past data. They never place orders,
> don't use your account balance, and don't affect your challenge, rules, or
> statistics. A combination tuned on past data can fit noise, so check other
> markets and periods before relying on it.

## Share a script

Select **Share** in the editor or in a script's actions menu, then **Create
Share Code**. Sharing creates a share code, such as \`MFP-7K2Q-9XWD\`, and a
share link for the script's current saved version. Unsaved changes aren't
included.

| How it's shared | Who can use it |
| - | - |
| Share link | Anyone with the link can view the source, even without signing in. Signed-in traders can select **Copy To My Scripts**. |
| Share code | Signed-in traders paste it into the share code field in the Scripts window and select **Add**. |
| Public Library listing | Turn on **Also List It in the Public Library** in the share dialog. Every trader with Scripts can find it and add a copy. |

Each share shows one version. Saving new versions doesn't change what it
shows or what traders who added it run; publish an update when you want to
offer them a newer version. Traders who add it get their own copy in My
Scripts, starting from the script's default inputs and switched off for
trade charts, and they can't change your original.

**Turn Code Off** stops the link and code and removes the listing. Copies
traders already added stay theirs. **Other Shared Versions** lists older
versions you still share, each with **Stop Sharing**. You can keep up to 50
share links at once.

### Publish an update

To offer a newer version to everyone who added an earlier one, save the new
version, open **Share**, and select **Publish Version** under the older
version in **Other Shared Versions**. The share keeps its code, link, Public
Library listing, and trader counts, and from then on shows the new version.
Traders who already added it see **Update Available** and choose whether to
accept it; their scripts don't change until they do.

You can publish only your script's current saved version, only when it
compiles, and only when that version doesn't already have its own share code.
A listing that staff removed from the Public Library can't be updated.

> [!NOTE]
>
> A share shows the script's name, version, source code, and when it was shared,
> credited to your public username and generated avatar. Your uploaded profile
> photo and a link to your public profile appear only while your [public
> profile](https://docs.myfundedperpetuals.com/settings/public-profile.md) is on. Your email, account, and trading are
> never shown. Shared pages are hidden from search engines, but anyone you give
> the link to can open it.

## Public Library

The **Public Library** tab lists scripts other traders chose to list. Search
by name, filter to **Indicators** or **Strategies**, and sort by **Most
Used** or **Newest**. Each card shows the script's author and how many
traders added it; counts update every hour.

**Add** saves a copy to My Scripts. **View Source** opens the script's shared
page. When the author publishes an update, traders who already added it can
review and accept it; see [Update an added script](#update-an-added-script). **Report Listing** tells staff what's wrong with a listing, such as
copied work or a misleading name; staff can remove it from the Public
Library, and a removed version can't be listed again. Your own listings show
**Your Listing**.

## Update an added script

When the author of a script you added publishes a newer version, the script
shows **Update Available** in My Scripts and in the editor. Your copy never
changes on its own. Select **Update Available** to review the update:

* The version you have and the new version, and who published it.
* What the new version reads with `request.data()` and any links in its
  text, so you can check them before it runs on your charts.
* A side-by-side comparison of your current version and the new one.
* A warning when you've saved your own changes since adding or last updating
  the script, because accepting replaces them.

**Accept & Update** checks the new version in your browser and saves it as
your script's next version. Your previous version stays in your version
history, so you can restore it from **Versions**. Saved input values carry
over when the new version's inputs match; otherwise they reset to the new
version's defaults. If the script shows on your trade charts, they switch to
the new version. An update that doesn't compile for you, or that imports a
library you don't have, isn't applied.

**Dismiss** hides the update until the author publishes a newer one. Updates
stop being offered when the author stops sharing the script, deletes it, or
staff remove its Public Library listing; your copy stays yours.

## Top Indicators

The **Top Indicators** tab ranks Public Library scripts by how many different
traders added each one in the last **7 Days**, **30 Days**, or **All Time**,
up to the top 50. Adds through a share link or code count too; adding your
own script doesn't. Each row shows how its place changed against the window
before. Rankings update every hour.

## Script Data

**Script Data**, in the **More Actions** menu on My Scripts, holds the text
values your scripts read with `request.data("key")` (see
[Your own data in a script](https://docs.myfundedperpetuals.com/guides/pine-scripts.md#your-own-data-in-a-script)).

1. Open **More Actions** and choose **Script Data**.
2. Choose **Add Key**, enter a key and a value, and choose **Save**. To change
   a value, choose **Edit** next to its key.
3. Choose **Copy API Example** to copy a `curl` command that sets the same
   key from your own program with an API key that has trade scope.

Charts and editor previews running a script that reads a key update as soon
as you save it. **Delete** removes a key; scripts that read it show `na`
until you add it again.

Script data belongs to your account, not to a script. Other traders never
see it, and a script someone shares with you reads your values, not theirs.
A shared script's page and **Import** show the keys a script reads, and any
links in its text, before you add it.

## Report a Problem

Use **Report a Problem** when something on the Scripts pages or the chart
doesn't work, a script compiles on TradingView but not here, or a script
plots or behaves differently from TradingView. It's in the **Script
Actions** menu in the editor, the **More Actions** menu on My Scripts, and a
saved script's legend menu on the trade chart.

Describe what you expected and what happened instead, in up to 4,000
characters. **What's Attached** lists what's sent with the report: the
script's name and version, the source of your draft or saved version, the
problems the editor showed, the chart's market and timeframe, and your
browser, window size, and language. You can send up to 10 reports an hour
and 30 a day.

## Limits

| Limit | Value |
| - | - |
| Saved scripts | 100 |
| Saved versions per script | 20 (the oldest are deleted) |
| Scripts on your trade charts at once | 4 |
| Open editor tabs | 8 |
| Share links you keep at once | 50 |
| Added scripts checked for updates | 50 most recently edited |
| Markets in one backtest | 10 |
| Inputs in one sweep | 2 |
| Combinations in one sweep | 100 |
| Watch expressions per script | 5 |
| Report description | 4,000 characters |
| Script Data keys | 20 |
| Script Data value length | 65,536 characters |
| Script Data changes | 30 a minute, 1,440 a day |

At 100 saved scripts, delete one to add another. Script length, run time,
and drawing limits are in [Pine Scripts](https://docs.myfundedperpetuals.com/guides/pine-scripts.md#limits).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.