×

Sign up and get MultiCharts free

Use its powerful simulation mode with data included out of the box. Just fill out the form and start honing your trading skills with a few clicks.

Changes - MultiCharts

Changes

Jump to navigation Jump to search

For

82 bytes added, 11:08, 19 February 2012
no edit summary
Used in combination with [[To]] or [[DownTo]] to form a loop statement that will execute a set of instructions repeatedly until the loop count reaches the specified final value.
The loop statement specifies a numerical variable that holds the loop count, as well as initial and final counter values. [[To]] specifies that the value of the counter variable is to be increased by one on the completion of each loop, while [[DownTo]] specifies that the value of the counter variable is to be decreased by one on the completion of each loop.
The use of [[Begin]] loop statement specifies a numerical variable that holds the loop count, as well as initial and final counter values. * [[EndTo]] statements specifies that the value of the counter variable is required to group the instructions for execution within be '''increased''' by one on the completion of each loop; a * [[BeginDownTo]] must always specifies that the value of the counter variable is to be followed '''decreased''' by an [[Endone on the completion of each loop.]]
The use of [[Begin]] should not and [[End]] statements is required to group the instructions for execution within the loop; a [[Begin]] must always be followed by a semicolon (;), code lines within an instruction group should end with a semicolon (;), and [[End]] should be followed by a semicolon (;). ==== Usage ====
<syntaxhighlight>For Counter=IValue To FValue Begin
I1; I2;
End;</syntaxhighlight>
or:
 
<syntaxhighlight>For Counter=IValue DownTo FValue Begin
I1; I2;
End;</syntaxhighlight>
Where: [[ :'''Counter]] ''' - a numerical variable used store the loop count.:'''IValue''' - a numerical expression specifying the initial counter value.:'''FValue''' - a numerical expression specifying the final counter value.
== Notes ==* [[IValueBegin]] - should not be followed by a numerical expression specifying the initial counter valuesemicolon (;), code lines within an instruction group should end with a semicolon (;), and [[End]] should be followed by a semicolon (;).
[[FValue]] - a numerical expression specifying == Examples ==Add the final counter value high prices of the last 10 bars with ''To'' to the ''HighPriceSum'' variable:
<syntaxhighlight>For BarBackNo =0 To 9 Begin  HighPriceSum === Example ====Add the high prices of the last 10 bars to the HighPriceSum + High[[HighPriceSum]BarBackNo] variable:;
<syntaxhighlight>For BarBackNo=0 To 9 Begin
HighPriceSum=HighPriceSum+High[BarBackNo];
End;</syntaxhighlight>
Add the high prices of the last 10 bars with ''DownTo'' to the [[''HighPriceSum]] '' variable: <syntaxhighlight>For BarBackNo = 9 DownTo 0 Begin  HighPriceSum = HighPriceSum + High[BarBackNo];
<syntaxhighlight>For BarBackNo=9 DownTo 0 Begin
HighPriceSum=HighPriceSum+High[BarBackNo];
End;</syntaxhighlight>
 
[[Category:Comparisons and Loops]]

Navigation menu