Difference between revisions of "Editing Study Scripts"

From MultiCharts
Jump to navigation Jump to search
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
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.  
 
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 [[<span style="color: red;">'''LINK'''</span>/04_PL/41-0006_Elements.html name="";  |PowerLanguage Elements]]
+
To learn more, see [[Language_Elements|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.
 
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 [[<span style="color: red;">'''LINK'''</span>/03_PLE/31-0103_WorkingStudies.html name="4";  |compiled]].  
+
Before a study can be applied to a chart, the study's script must be [[Editing_Study_Scripts#Compiling Scripts|compiled]].  
  
 
The code is compiled directly in the PowerLanguage editor.
 
The code is compiled directly in the PowerLanguage editor.
  
The script of a study can be [[<span style="color: red;">'''LINK'''</span>/03_PLE/31-0103_WorkingStudies.html name="5";  |password protected]]; script of a protected study can not be viewed without the password.
+
The script of a study can be [[Editing_Study_Scripts#Protecting Studies|password protected]]; script of a protected study can not be viewed without the password.
  
 
<br>
 
<br>
Line 22: Line 22:
 
<br>Changes can be undone by one of the following methods:
 
<br>Changes can be undone by one of the following methods:
  
* Clicking the '''Undo''' http://www.multicharts.com/img/wiki/toolbar/PLE/05_Undo.gif icon on the toolbar; or:  
+
* Clicking the '''Undo''' [[File:PL_UNDO.png]] icon on the toolbar; or:  
 
* Using the Ctrl+Z keyboard shortcut, or:  
 
* Using the Ctrl+Z keyboard shortcut, or:  
 
* Selecting '''Edit''' in the main menu, and clicking '''Undo'''.  
 
* Selecting '''Edit''' in the main menu, and clicking '''Undo'''.  
Line 28: Line 28:
 
<br>Changes can be redone by one of the following methods:
 
<br>Changes can be redone by one of the following methods:
  
* Clicking the '''Redo''' http://www.multicharts.com/img/wiki/toolbar/PLE/06_Redo.gif icon on the toolbar; or:  
+
* Clicking the '''Redo''' [[File:PL_REDO.png]] icon on the toolbar; or:  
 
* Using the Ctrl+Y keyboard shortcut, or:  
 
* Using the Ctrl+Y keyboard shortcut, or:  
 
* Selecting '''Edit''' in the main menu, and clicking '''Redo'''.  
 
* Selecting '''Edit''' in the main menu, and clicking '''Redo'''.  
Line 60: Line 60:
 
To find text:  
 
To find text:  
  
# Open the '''Find''' window by clicking the '''Find''' http://www.multicharts.com/img/wiki/toolbar/PLE/07_Find.gif icon on the toolbar, by using the Ctrl+F keyboard shortcut, or by selecting '''Edit''' on the main menu and clicking '''Find'''.
+
# Open the '''Find''' window by clicking the '''Find''' [[File: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'''.
 
# Enter the text to be found into the '''Find what''' box.  
 
# Enter the text to be found into the '''Find what''' box.  
 
# Select the '''Match whole word only''' check box to find whole words only.  
 
# Select the '''Match whole word only''' check box to find whole words only.  
Line 72: Line 72:
 
To replace text:  
 
To replace text:  
  
# Open the '''Replace''' window by clicking the '''Replace''' http://www.multicharts.com/img/wiki/toolbar/PLE/08_Replace.gif icon on the toolbar, by using the Ctrl+H keyboard shortcut, or by selecting '''Edit''' on the main menu and clicking '''Replace'''.  
+
# Open the '''Replace''' window by clicking the '''Replace''' [[File: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'''.  
 
# Enter the text to be found and replaced into the '''Find what''' box.  
 
# Enter the text to be found and replaced into the '''Find what''' box.  
 
# Enter the replacement text into the '''Replace with''' box.  
 
# Enter the replacement text into the '''Replace with''' box.  
Line 87: Line 87:
 
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.  
 
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.  
  
# To compile the script in the active window: Click the '''Compile''' http://www.multicharts.com/img/wiki/toolbar/PLE/12_Compile.gif toolbar icon, press the F3 key, or select '''Compile''' in the main menu and click '''Compile Study Name'''.
+
# To compile the script in the active window: Click the '''Compile''' [[File:PL_COMPILE.png]] toolbar icon, press the F3 key, or select '''Compile''' in the main menu and click '''Compile Study Name'''.
 
# 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.
 
# 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.
 
# To compile any uncompiled scripts of all open studies: Select '''Compile''' in the main menu and click '''All Uncompiled'''.
 
# To compile any uncompiled scripts of all open studies: Select '''Compile''' in the main menu and click '''All Uncompiled'''.
Line 93: Line 93:
 
# To compile indicators and signals only: Select '''Compile''' in the main menu and click '''All Indicators and Signals Only'''.
 
# To compile indicators and signals only: Select '''Compile''' in the main menu and click '''All Indicators and Signals Only'''.
  
 +
There are two compilation modes available to select from the dropdown box: '''Fast Execution''' and '''Fast Compilation'''.<br>
 +
 +
[[File:CompilationMode.png]]
 
<br>
 
<br>
 +
In '''Fast Execution''' mode the app attempts to optimize the study’s script.<br>
 +
In '''Fast Compilation''' mode this procedure is skipped. It should not influence the script calculation and robustness of the code.
 +
 +
 +
<br>
 +
 
== Protecting Studies ==  
 
== Protecting Studies ==  
  

Revision as of 14:19, 23 March 2022

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.

There are two compilation modes available to select from the dropdown box: Fast Execution and Fast Compilation.

CompilationMode.png
In Fast Execution mode the app attempts to optimize the study’s script.
In Fast Compilation mode this procedure is skipped. It should not influence the script calculation and robustness of the code.



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.