[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [amibroker] AFL brackets and parentheses



PureBytes Links

Trading Reference Links




Hello,
 
Excerpts from AFL Language Reference part 
of User's Guide:
 
 
Parentheses (open ( and 
close ) ) group expressions, isolate conditional expressions and indicate 
function calls and function parameters:d = c * ( a + b ) /* override normal 
precedence */a= (b AND c) OR (d AND e) /* conditional expression 
*/func() /* function call no arguments */
(...)
Accessing array elements: [ ] - subscript operator
An array identifier followed by an expression in square brackets ([ ]) is a 
subscripted representation of an element of an array object.
arrayidentifier [ expression ]
It represents the value of expression-th element of array. 
BarCount constant gives the number of bars in array (such as 
Close, High, Low, Open, Volume, etc). Array elements are numbered from 0 (zero) 
to BarCount-1. 
To get the first bar you can use array[ 0 ], to get the last bar of array you 
can use array[ BarCount - 1 ];
For example:
Close[ 5 ];Represents the sixth element (bar) of the close 
array.
Close[ 0 ];Represents the very first available bar of the 
close array.
High[ BarCount - 1 ];Represents the last bar of High array. 


Compound statements (Blocks)
A compound statement consists of zero or more statements enclosed in curly 
braces ({ }). A compound statement can be used anywhere a statement is expected. 
Compound statements are commonly called “blocks.”
{

  statement1;
  ....
  statementN;
}
(this is 'borrowed' from C language, users of other programming languages are 
used to use BEGIN for { and END for } )

if( Amount > 100 ){

  _TRACE("Amount above 100");Balance += 
Amount;
}else Balance -= Amount;
 
(..)
++  Post-increment/pre-increment(i++ works like i = i + 1)

-- Post-decrement/pre-decrement(i-- works like i = i - 1 )
A few words about increment/decrement operators. There are two kinds of 
them: postfix and prefix. 

The unary operators (++ and --) are called “prefix” increment or decrement 
operators when the increment or decrement operators appear before the operand. 
Postfix increment and decrement has higher precedence than prefix increment and 
decrement operators. When the operator appears before its operand, the operand 
is incremented or decremented and its new value is the result of the 
expression.
i = 5;
j = ++i; // i will be incremented first and result (number 6) will be 
assigned to j.
The result of the postfix increment or decrement operation is the value of 
the postfix-expression before the increment or decrement operator is applied. 
The type of the result is the same as that of the postfix-expression but is no 
longer an l-value. After the result is obtained, the value of the operand is 
incremented (or decremented).
i = 5;
j = i++; // j will be assigned the value of 5 (before incrementation) and 
then i will be incremented to 6.
 
Best regards,Tomasz Janeczkoamibroker.com
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  Lionel 
  Issen 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Saturday, August 30, 2003 2:17 
  AM
  Subject: RE: [amibroker] AFL brackets and 
  parentheses
  
  Please send me the page 
  numbers.  I did look in this section and found some examples, I also need 
  the definitions of when to use them.  I find an example without the  
  explanation is a bit inadequate.
   
  Lionel
   
   
  
  
  <FONT 
  face=Tahoma size=2>-----Original Message-----From: wavemechanic 
  [mailto:wd78@xxxxxxxxxxxx] Sent: Friday, August 29, 2003 5:21 
  PMTo: <A 
  href="">amibroker@xxxxxxxxxxxxxxxSubject: 
  Re: [amibroker] AFL brackets and parentheses
  Lionel:
   
  Most if not all of your questions are handled in the 
  AFL Reference Manual under Help|Contents|AmiBroker Formula Language|AFL 
  Reference Manual.
   
  Bill
  <BLOCKQUOTE 
  >
    ----- Original Message ----- 
    <DIV 
    >From: 
    Lionel 
    Issen 
    To: <A title=amibroker@xxxxxxxxxxxxxxx 
    href="">amibroker@xxxxxxxxxxxxxxx 
    Sent: Friday, August 29, 2003 5:44 
    PM
    Subject: [amibroker] AFL brackets and 
    parentheses
    
    Please explain to me when 
    to use the different brackets that are shown in the user manual/online 
    help:
     
    [ ], ( ), and { } or are 
    they interchangeable.
     
    When is == used instead of 
     = ?
     
    When should ++n be used 
    instead of n?
     
    Thanks
     
    Lionel
     
    
     Send BUG REPORTS to <A 
    href="">bugs@xxxxxxxxxxxxxSend SUGGESTIONS 
    to 
    suggest@xxxxxxxxxxxxx-----------------------------------------Post 
    AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: 
    <A 
    href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
    group FAQ at: <A 
    href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
    Send BUG REPORTS to bugs@xxxxxxxxxxxxxSend 
  SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 
  Send 
  BUG REPORTS to bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  Your use of Yahoo! Groups is subject to the <A 
  href="">Yahoo! Terms of Service. 







Yahoo! Groups Sponsor


  ADVERTISEMENT 









Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html



Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.