Besides importing scripts we can also export them from the PowerLanguage .NET Editor. So how do we export our scripts?

Exporting scripts from the PowerLanguage .NET Editor

The PowerLanguage .NET Editor [intro] is the primary tool for creating and editing indicators, trading strategies, and functions in MultiCharts .NET (MultiCharts, 2014). Although we can also edit such scripts in other programs (like Visual Studio), things like removing and importing scripts is only possible in the PowerLanguage .NET Editor, as is exporting scripts.

We export scripts from the PowerLanguage .NET Editor with a window called ‘Export Studies’. Studies is the collective term that MultiCharts .NET uses for indicators, signals (which are trading strategies), and functions (MultiCharts Wiki, 2013). We’ll call these scripts since that’s their more common name.

Scripts that are exported from the PowerLanguage .NET Editor are put in a PowerLanguage .NET Archive file that has the .pln file extension. A single archive file can contain one or several scripts, and this archive file is only used when importing scripts. There are no other programs that can open .pln files (MultiCharts Support, personal communication, March 31, 2015).

By the way, scripts exported from the PowerLanguage .NET Editor (.pln files) are different from files exported from the MultiCharts PowerLanguage edition, which are .pla files. There’s no compatibility between these different archive files, and so scripts from one platform cannot be imported into another platform (Henry MultiCharts, 2013a).

Exporting a script from the PowerLanguage .NET Editor

To export a script from the PowerLanguage .NET Editor, we first start the code editor and then click on the ‘File’ menu item and select ‘Export…’ (or we use the Ctrl + E keyboard shortcut):

File menu in the PowerLanguage .NET Editor

That brings up the ‘Export Studies’ window in which we can select the script(s) to export:

Export Studies window

Let’s export the ADX and ADXR indicators in this example. Since all scripts are unselected by default (visible with the icon before the script’s name), we first need to click the checkbox to mark the script for export ( ). Then we press ‘OK’ to export the scripts:

Exporting a MultiCharts .NET indicator

That brings up a file browser window in which we navigate to the folder where we want to store the exported scripts. In this window we also need to provide a file name for the PowerLanguage .NET Archive. We then press ‘Save’:

Export Studies file browser window

In this window we can also see that we’re only able to export scripts as a PowerLanguage .NET Archive (.pln):

File type of exported MultiCharts .NET scripts

Once we’ve clicked the ‘Save’ button, a window pop-ups saying that the scripts are exported:

Script export successful

By the way, we cannot password-protect exported scripts (Henry MultiCharts, 2013b). Things that we can do include removing or changing the scripts’ settings we’ve just exported or import them in another PowerLanguage .NET Editor.

Features of the ‘Export Studies’ window in MultiCharts .NET

The ‘Export Studies’ window has several features that make exporting scripts easier. First, icons allow us to quickly see the script type. Functions are preceded with a green icon ( ), indicators have a blue one ( ), and an orange icon ( ) is placed before signals (that is, trading strategies).

Then there are three checkboxes below the ‘Study Type’ heading:

Filtering MultiCharts .NET scripts for export

By checking these boxes we filter the scripts that are displayed in the ‘Export Studies’ window. For example, with just the ‘Signal’ box ticked the ‘Export Studies’ window only lists the trading strategies:

Only show MultiCharts .NET trading strategies

Another feature of the ‘Study Type’ heading are the two numbers behind each script type. The first is the total number of scripts of that type, while the second (between parentheses) is the amount of scripts selected for export. For example, here we’ve selected 4 indicators (out of 326) and 5 trading strategies (from a total of 189):

MultiCharts .NET script count
Tip: Filtering scripts with those checkboxes does not affect which scripts are actually selected. If we, for example, only display user-made functions, the selected count is still 9 even though there are no selected scripts in the current view:
Exporting selecting MultiCharts .NET scripts

Another feature of the ‘Export Studies’ window is sorting scripts ascending or descending by clicking on the ‘Name’, ‘Type’, ‘Status’, or ‘Modified’ columns. For example, sorting scripts alphabetically is done with the ‘Name’ column:

Sorting MultiCharts .NET scripts by name

We can also sort on the modified date, although that’s less useful since several scripts often have the same modified date:

Sorting MultiCharts .NET scripts by modified date

Another feature of ‘Export Studies’ is selecting a specific script by typing the first letter(s) of its name. For example, when we press ‘v’ the first script that begins with this letter is selected:

Selecting a MultiCharts .NET script by typing its letter

Likewise, typing ‘vol’ causes the row selector to jump to the first script that starts with those letters:

Typing the first part of a script's name

Selecting more than one script is done with the Control and Shift keys. Holding down Control and then clicking on each script allows us to manually select individual scripts. And pressing Shift while clicking on two scripts selects all the scripts in between.

With Space we can then mark the selected scripts for export ( ) or not ( ).

Exporting uncompiled scripts from the PowerLanguage .NET Editor

The ‘Export Studies’ window’s ‘Status’ column shows us if a script is compiled or not. For instance:

Exporting uncompiled MultiCharts .NET scripts

Even though we can export uncompiled scripts, it’s better to compile the script first. That’s because an uncompiled status can also indicate unsaved edits.

Tip: export a script with all of its user-made functions

An important thing to keep in mind when exporting scripts from the PowerLanguage .NET Editor is that functions used in a script’s code are not automatically selected when exporting. And so we manually need to check the script’s code for any user-made functions, and then export those functions alongside the indicator or strategy that we want to export.

To see why that’s important, let’s consider an example. Here we have an indicator that references the user-made ‘Custom_Function’ (see arrow):

Referencing a function in a MultiCharts .NET script

Now when we select this indicator for export in the ‘Export Studies’ window, the ‘Custom_Function’ script is not automatically selected with it:

Exporting an example indicator from the PowerLanguage .NET Editor

But let’s proceed anyway and export the ‘Example_Indicator’ without the function it uses. So we press ‘OK’ in the ‘Export Studies’ window and then save the archive file somewhere:

Saving the PowerLanguage .NET Archive file

Pressing ‘Save’ brings up a message saying that the export was successful:

MultiCharts .NET script successfully exported

But while the export succeeded, other people cannot use our exported ‘Example_Indicator’ script. To see why, we import the script archive in another PowerLanguage .NET Editor. For that we click on ‘File’ and then select ‘Import…’ or press the Ctrl + I keyboard shortcut. After that we open the archive file:

Importing a MultiCharts .NET script

Then we import all scripts in the .pln file:

Import Studies window

After that we get the message that the import succeeded:

Script successfully imported

What did not work out, however, is compiling the script: the indicator is shown with the error icon ( ) in the ‘Studies’ window panel and the ‘type or namespace ‘Custom_Function’ could not be found’ error is given:

Compiling with a missing function
Tip: Export your script with all of the custom functions it uses so that the person who receives the .pln file can compile it successfully. This applies to user-made functions only; standard functions cannot be exported (see below).

Scripts that cannot be exported: standard functions

The standard, read-only functions are pre-built into the PowerLanguage .NET Editor and cannot be exported (Henry MultiCharts, 2013c). Custom, user-made functions can be exported, however.

The difference between these two type of functions can be seen in the ‘Studies’ window panel: custom functions have a white check ( ) and standard functions a red sign ( ). For example:

Custom vs. standard MultiCharts .NET functions

Since the standard functions cannot be exported, the ‘Export Studies’ window only lists custom functions:

Exporting a custom MultiCharts .NET function

Exported scripts can be used as a backup, but we can also backup all MultiCharts .NET scripts. Other things we can do with the PowerLanguage .NET Editor are importing scripts, deleting scripts, and changing script settings.

Summary

The ‘Export Studies’ window in the PowerLanguage .NET Editor exports scripts to an archive file. That window allows filtering on type of script (user-made functions, indicators, or strategies) and sorting with the columns. Even though we can export uncompiled scripts, it’s better not to do so in case of unsaved edits. When we export a script that references custom functions, we need to make sure that all of those functions are also exported.


References

Henry MultiCharts (2013a, December 30). MultiCharts .NET FAQ. Retrieved on July 24, 2015, from http://www.multicharts.com/discussion/viewtopic.php?f=19&t=45848#p101142

Henry MultiCharts (2013b, December 13). MultiCharts .NET FAQ. Retrieved on July 24, 2015, from http://www.multicharts.com/discussion/viewtopic.php?f=19&t=45848#p100791

Henry MultiCharts (2013c, December 13). MultiCharts .NET FAQ. Retrieved on July 24, 2015, from http://www.multicharts.com/discussion/viewtopic.php?f=19&t=45848#p100797

MultiCharts (2014). MultiCharts .NET Programming Guide (version 1.1). Retrieved from http://www.multicharts.com/downloads/MultiCharts.NET-ProgrammingGuide-v1.1.pdf

MultiCharts Wiki (2013, May 6). Using Studies (PowerLanguage Editor). Retrieved on July 16, 2015, from https://www.multicharts.com/trading-software/index.php/Using_Studies_%28PowerLanguage_Editor%29