Language Elements: Difference between revisions
From MultiCharts
→PowerLanguage
No edit summary |
|||
(4 intermediate revisions by 3 users not shown) | |||
Line 5: | Line 5: | ||
Implementing trading strategies in PowerLanguage requires familiarity with the basic rules and structure of the language, outlined below, as well as with the keywords described in the keyword section of this reference guide. | Implementing trading strategies in PowerLanguage requires familiarity with the basic rules and structure of the language, outlined below, as well as with the keywords described in the keyword section of this reference guide. | ||
==PowerLanguage Studies and Statements== | |||
A complete PowerLanguage "program" is called a '''Script'''. An example of a script would be a Strategy, a study that issues trading orders, an Indicator, a study that draws plots on a chart to assist in making trading decisions, or a Function, an independent procedure (subroutine) that can be called from another script to carry out a specific task. | A complete PowerLanguage "program" is called a '''Script'''. An example of a script would be a Strategy, a study that issues trading orders, an Indicator, a study that draws plots on a chart to assist in making trading decisions, or a Function, an independent procedure (subroutine) that can be called from another script to carry out a specific task. | ||
Line 17: | Line 17: | ||
Statements are evaluated from left to right, and scripts are evaluated from top to bottom. | Statements are evaluated from left to right, and scripts are evaluated from top to bottom. | ||
==Price Charts== | |||
A data series consists of groups of price data points, based on a defined interval and arranged in a chronological order. | A data series consists of groups of price data points, based on a defined interval and arranged in a chronological order. | ||
Line 29: | Line 29: | ||
Both time and price in the above statement are referenced in terms of bars. | Both time and price in the above statement are referenced in terms of bars. | ||
==Price Chart Evaluation by PowerLanguage Studies== | |||
A PowerLanguage script evaluates a chart on bar-by-bar basis, starting with the very first (oldest) bar on the chart. The exact same script is executed for every bar. | A PowerLanguage script evaluates a chart on bar-by-bar basis, starting with the very first (oldest) bar on the chart. The exact same script is executed for every bar. | ||
Line 39: | Line 39: | ||
[[File:bars.gif]] | [[File:bars.gif]] | ||
This | This basic overview is intended to give the initial understanding of how PowerLanguage studies function. | ||
A more detailed description of how a chart is evaluated is presented in the [[How_Scripts_Work|How Scripts Work]] section. | A more detailed description of how a chart is evaluated is presented in the [[How_Scripts_Work|How Scripts Work]] section. | ||
==PowerLanguage== | |||
PowerLanguage allows a combination of keywords, constants, variables, mathematical and logical operators, and punctuation to be used to express trading rules and bring about both conditional as well as unconditional actions and output. | |||
<br>There are tools to accomplish a variety of tasks, from the very basic, such as: | <br>There are tools to accomplish a variety of tasks, from the very basic, such as: | ||
Line 53: | Line 53: | ||
all the way to array functions available in the advanced programming languages. | all the way to array functions available in the advanced programming languages. | ||
Each category of | Each category of PowerLanguage components is discussed below: | ||
==Keywords== | |||
Most of the keywords are the instructions, "action words", of PowerLanguage. | Most of the keywords are the instructions, "action words", of PowerLanguage. | ||
Line 65: | Line 65: | ||
A list of keywords with detailed descriptions and examples is available in the [[:Category:PowerLanguageKeywords|Keyword Reference]] | A list of keywords with detailed descriptions and examples is available in the [[:Category:PowerLanguageKeywords|Keyword Reference]] | ||
==Skip Words== | |||
Skip words are the interjections of PowerLanguage. They actually do nothing, and are skipped during code execution, but they make PowerLanguage easier to read. | Skip words are the interjections of PowerLanguage. They actually do nothing, and are skipped during code execution, but they make PowerLanguage easier to read. | ||
Line 71: | Line 71: | ||
In PowerLanguage Editor, skip words appear in red. A list of these words is available in the [[:Category:Skip_Words|Skip Words]] section of this guide. | In PowerLanguage Editor, skip words appear in red. A list of these words is available in the [[:Category:Skip_Words|Skip Words]] section of this guide. | ||
==Operators== | |||
There are four types of operators: Mathematical, Relational, Logical, and String. | There are four types of operators: Mathematical, Relational, Logical, and String. | ||
Line 115: | Line 115: | ||
"String expression one and string expression two" | "String expression one and string expression two" | ||
==Referencing previous bars== | |||
Previous bars' values can be referenced by using the statement <code>N Bars Ago</code>, or by using the bar offset notation that consists of a numerical expression enclosed in square brackets: | Previous bars' values can be referenced by using the statement <code>N Bars Ago</code>, or by using the bar offset notation that consists of a numerical expression enclosed in square brackets: | ||
Line 125: | Line 125: | ||
<code>High [2]</code> | <code>High [2]</code> | ||
==Time and Date== | |||
Time values in PowerLanguage are specified in the 24-hour HHmm or HHmmss formats, where 1300 = 1:00 PM and 130000 = 1:00:00 PM, respectively. | Time values in PowerLanguage are specified in the 24-hour HHmm or HHmmss formats, where 1300 = 1:00 PM and 130000 = 1:00:00 PM, respectively. | ||
Line 133: | Line 133: | ||
This format is also known as the "EL Date" format. | This format is also known as the "EL Date" format. | ||
==Variables== | |||
Variables are used to store numerical, string, or logical (true/false) values. The value stored in a variable can be referenced throughout a script by the variable’s name, and can be modified by the script at any time. Variables must be declared before use. | Variables are used to store numerical, string, or logical (true/false) values. The value stored in a variable can be referenced throughout a script by the variable’s name, and can be modified by the script at any time. Variables must be declared before use. | ||
Line 139: | Line 139: | ||
For more information see [[Variable]] | For more information see [[Variable]] | ||
==Arrays== | |||
Arrays are multiple-element variables. | Arrays are multiple-element variables. |