Difference between revisions of "Begin"

From MultiCharts
Jump to navigation Jump to search
(Created page with "Used in combination with <syntaxhighlight>End</syntaxhighlight> to group instructions for conditional execution; a <syntaxhighlight>Begin</syntaxhighlight> must always be foll...")
 
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
Used in combination with <syntaxhighlight>End</syntaxhighlight> to group instructions for conditional execution; a <syntaxhighlight>Begin</syntaxhighlight> must always be followed by an <syntaxhighlight>End.</syntaxhighlight>
+
Used in combination with [[End]] to group instructions for conditional execution; a [[Begin]] must always be followed by an [[End]].  
<syntaxhighlight>Begin</syntaxhighlight> and <syntaxhighlight>End</syntaxhighlight> can be used with <syntaxhighlight>Then, Else, For,</syntaxhighlight> and <syntaxhighlight>While</syntaxhighlight> conditional statements.
+
 +
== Usage ==
 +
<syntaxhighlight>CS Begin
 +
  I1;
 +
  I2;
 +
  I3;
 +
End;</syntaxhighlight>
  
<syntaxhighlight>Begin</syntaxhighlight> should not be followed by a semicolon (;), code lines within an instruction group should end with a semicolon (;), and only the last instance of <syntaxhighlight>End</syntaxhighlight> within the same conditional execution statement should be followed by a semicolon (;).  
+
Where:
+
 
==== Usage ====
+
:'''CS''' - conditional statement.
<syntaxhighlight>CS Begin</syntaxhighlight>
+
:'''I''' - conditional instructions.
I1;
 
I2;
 
I3;
 
<syntaxhighlight>End;</syntaxhighlight>
 
  
Where: <syntaxhighlight>CS</syntaxhighlight> - conditional statement
+
== Notes ==
            I - conditional instructions 
+
* [[Begin]] and [[End]] can be used with [[Then]], [[Else]], [[For]], and [[While]] conditional statements.
 +
* [[Begin]] should not be followed by a semicolon (;), code lines within an instruction group should end with a semicolon (;), and only the last instance of [[End]] within the same conditional execution statement should be followed by a semicolon (;).
  
==== Example ====
+
== Example ==
If UpTrend is true then buy, otherwise sell short:  
+
If ''UpTrend'' is true then buy, otherwise sell short:  
  
<syntaxhighlight>If</syntaxhighlight> UpTrend <syntaxhighlight>Then Begin
+
<syntaxhighlight>If UpTrend = True Then Begin
Buy Next Bar Market;
+
  Buy Next Bar Market;
 
End
 
End
 
Else Begin
 
Else Begin
SellShort Next Bar Market;
+
  SellShort Next Bar Market;
 
End;</syntaxhighlight>
 
End;</syntaxhighlight>
  
 
[[Category:Comparisons and Loops]]
 
[[Category:Comparisons and Loops]]

Latest revision as of 10:57, 19 February 2012

Used in combination with End to group instructions for conditional execution; a Begin must always be followed by an End.

Usage

CS Begin
  I1;
  I2;
  I3;
End;

Where:

CS - conditional statement.
I - conditional instructions.

Notes

  • Begin and End can be used with Then, Else, For, and While conditional statements.
  • Begin should not be followed by a semicolon (;), code lines within an instruction group should end with a semicolon (;), and only the last instance of End within the same conditional execution statement should be followed by a semicolon (;).

Example

If UpTrend is true then buy, otherwise sell short:

If UpTrend = True Then Begin
  Buy Next Bar Market;
End
Else Begin
  SellShort Next Bar Market;
End;