Editing Study Scripts

From MultiCharts
Jump to: navigation, search

Studies are PowerLanguage scripts, expressing trading rules in a systematic and logical way that can be executed by a computer. Scripts consist of at least one, but usually more, statements. Each statement is a complete instruction.

To learn more, see PowerLanguage Elements

PowerLanguage scripts can be easily created and edited by using the PowerLanguage Editor. PowerLanguage Editor includes many advanced text editing features, built-in PowerLanguage keyword reference, and a keyword hint feature.

Before a study can be applied to a chart, the study's script must be compiled.

The code is compiled directly in the PowerLanguage editor.

The script of a study can be password protected; script of a protected study can not be viewed without the password.


Text Editing Features

The following text editing features are available:

Undoing and Re-doing Changes

Changes to the script that were made since the editor was open or the study compiled can be undone; "undone" changes can be redone again.


Changes can be undone by one of the following methods:

  • Clicking the Undo PL UNDO.png icon on the toolbar; or:
  • Using the Ctrl+Z keyboard shortcut, or:
  • Selecting Edit in the main menu, and clicking Undo.


Changes can be redone by one of the following methods:

  • Clicking the Redo PL REDO.png icon on the toolbar; or:
  • Using the Ctrl+Y keyboard shortcut, or:
  • Selecting Edit in the main menu, and clicking Redo.


Note: Changes to the script made before the study was compiled cannot be undone.


Copying, Cutting and Pasting Code

Text can be copied, cut, and pasted within the PowerLanguage Editor and between the editor and other programs.


Text can be copied by one of the following methods:

  • Using the Ctrl+C keyboard shortcut; or:
  • Selecting Edit in the main menu, and clicking Copy.


Text can be cut by one of the following methods:

  • Using the Ctrl+X keyboard shortcut; or:
  • Selecting Edit in the main menu, and clicking Cut.


Text can be pasted by one of the following methods:

  • Using the Ctrl+V keyboard shortcut; or:
  • Selecting Edit in the main menu, and clicking Paste.


Finding Text

To find text:

  1. Open the Find window by clicking the Find PL FIND.png icon on the toolbar, by using the Ctrl+F keyboard shortcut, or by selecting Edit on the main menu and clicking Find.
  2. Enter the text to be found into the Find what box.
  3. Select the Match whole word only check box to find whole words only.
  4. Check the Match case check box to make the search case-sensitive.
  5. In the Direction section, choose Up or Down to select the search direction.
  6. Click Find Next to begin the search or to find the next instance of the text.


Replacing Text

To replace text:

  1. Open the Replace window by clicking the Replace PL REPLACE.png icon on the toolbar, by using the Ctrl+H keyboard shortcut, or by selecting Edit on the main menu and clicking Replace.
  2. Enter the text to be found and replaced into the Find what box.
  3. Enter the replacement text into the Replace with box.
  4. Select the Match whole word only check box to find whole words only.
  5. Check the Match case check box to make the search case-sensitive.
  6. In the Direction section, choose Up or Down to select the search direction.
  7. Click Find Next to begin the search or to find the next instance of the text. Once an instance of the text to be replaced is found, the instance is highlighted.
  8. Click Replace to replace the highlighted instance of the text.
  9. Click Replace All to replace all instances of the text in the current study window.


Compiling Scripts

Before a study can be applied to a chart, the study's script must be compiled. In process of compilation, the correctness of code in the script is verified. If any errors are found, the compilation process stops, and the error is highlighted. The results of the compilation, and errors if any, are displayed under the Build tab in the lower panel.

  1. To compile the script in the active window: Click the Compile PL COMPILE.png toolbar icon, press the F3 key, or select Compile in the main menu and click Compile Study Name.
  2. To compile scripts of all opened studies: Select Compile in the main menu and click All Opened, or use the Ctrl+Shift+F2 keyboard shortcut.
  3. To compile any uncompiled scripts of all open studies: Select Compile in the main menu and click All Uncompiled.
  4. To compile all scripts of all studies, stored on the computer: Select Compile in the main menu and click All Studies.
  5. To compile indicators and signals only: Select Compile in the main menu and click All Indicators and Signals Only.


Protecting Studies

The script of a study can be password protected; script of a protected study can not be viewed without the password.

To protect a study:

  1. Select Tools in the main menu, and click Protect Study.
  2. In the Password Selection dialog box that appears, enter a password and click OK.
  3. Reenter the password for confirmation, and click OK to password-protect the study's script.