PureBytes Links
Trading Reference Links
|
Hello,
A new beta version (4.35.0) of AmiBroker has just been
released.
It is available for registered users only from the members
area at:
<FONT
size=2>http://www.amibroker.com/members/bin/ab4350beta.exe
If you forgot your user name / password to the members
area
you can use automatic reminder service at: <A
href=""><FONT
size=2>http://www.amibroker.com/login.html
Short list of changes in
this beta (read change log in the "read me" below for the
details):
do-while loop implemeted
it is now allowed to 'add' (or rather concatenate) string to a number /
array. This saves quite a bit of typing.
additional tweaks in AFL engine & garbage collection, futher speed up
of execution of very long loops
more error checking in AFL engine - will report using uninitialized
variables that were accepted silently in 4.31.x - 4.34.x
standard include paths for #includes
IIf/Min/Max are now overloaded functions (have two variants each)
added 'endless loop detection threshold' setting to Preferences "AFL" tab.
Recommended value 100000 or higher.
fixed parameter counting in CallFunction plugin callback in case of
overloaded functions
fixed problem with premature freeing of arrays passed in default
parameters fields (causing for example problem with color exploration output -
introduced in 4.32)
Best regards,Tomasz Janeczkoamibroker.com
AmiBroker 4.35.0 Beta Read Me
May 8, 2003 17:01
THIS IS AN EARLY BETA VERSION OF THE SOFTWARE. EXPECT BUGS
!!!
AGAIN: THIS IS AN EARLY BETA VERSION OF THE SOFTWARE. EXPECT BUGS
!!!
Backup your data files and entire AmiBroker folder
first!
INSTALLATION INSTRUCTIONS
IMPORTANT: This archive is update-only. You have to install full
version 4.30 first.
Just run the installer and follow the instructions.
Then run AmiBroker. You should see "AmiBroker 4.35.0 beta" written in the
About box.
See CHANGE LOG below for detailed list of changes.
HELP ON NEW FEATURES
USER-DEFINABLE FUNCTIONS, PROCEDURES, LOCAL/GLOBAL VARIABLES (4.34 or
higher)
Here is a sample code showing user-defined function:
// the following function is 2nd order smoother
function IIR2( input, f0, f1, f2 ){ result[ 0 ] =
input[ 0 ]; result[ 1 ] = input[ 1 ];
for( i = 2; i < BarCount; i++
) { result[ i ] = f0 * input[ i ] +
f1 * result[ i - 1 ] +
f2 * result[ i - 2 ]; }
return result;}
Plot( Close, "Price", colorBlack, styleCandle );Plot( IIR2( Close,
0.2, 1.4, -0.6 ), "function example", colorRed );
In this code IIR2 is a user-defined function. input, f0, f1,
f2 are formal parameters of the functions.At the time of function call
the values of arguments are passed in these variables. Formal parameters behave
like local variables.Later we have result and i which are
local variables. Local variables are visible inside function only. If any other
function uses the same variable name they won't interfere between each
other.
Due to the fact that AFL does not require to declare variables the decision
whenever given variable is treated as local or global is taken depending on
where it is FIRST USED.
If given identifier appears first INSIDE function definition - then it is
treated as LOCAL variable.If given identifier appears first OUTSIDE function
definition - then it is treated as GLOBAL variable.
Example (commentary):
k = 4; // this is GLOBAL variable
function f( x ){ z = 3; // this is LOCAL
variable return z * x * k; // 'k' here references
global variable k (first used above outside
function)}
z = 5; // this is GLOBAL variable with the same name as local variable
in function f
"The value of z before function call :" + WriteVal( z );
// Now even if we call function // the value of our global variable
z // is not affected by function call because// global variable z and
local variable z are separate and // arguments are passed by value (not by
reference)
"The result of f( z ) = " + WriteVal( f( z ) );
"The value of z after function call is unchanged : " + WriteVal( z
);
At the end of the function we can see 'return' statement that is used to
return the result to the caller. Note that currently return statement must be
placed at the very end of the function.
It is also possible to write a procedure (a function that returns nothing
(void))
procedure SinePlotter( Freq, ColorIndex ){ pname =
"Line"+WriteVal(ColorIndex,1.0); array = sin( Cum( Freq * 0.01 )
); Plot( array, pname , colorRed + ColorIndex, styleThick
);}
for( n = 1; n < 10; n++ ){ SinePlotter(
n/2+Cum(0.01), n );}
Note that although there are two separate keywords 'function' and 'procedure'
AmiBroker currently treats them the same (they both accept return values but not
require them), but in the future the rules maight get enforced to usereturn
statement ONLY in conjunction with function keyword. So it is advised to use
function keyword in case when your function returns any value and procedure
keyword otherwise.
Note also that recursion (having a function call itself from within itself)
is NOT supported as for now.
FLOW CONTROL AND LOOPING
(4.31 or higher)
do-while Statement
The do-while statement lets you repeat a statement or compound
statement until a specified expression becomes false.
Syntax
do statement while ( expression )
;
The expression in a do-while statement is evaluated after the
body of the loop is executed. Therefore, the body of the loop is always executed
at least once.
The expression must have numeric or boolean type. Execution proceeds
as follows:
The statement body is executed.
Next, expression is evaluated. If expression is false, the
do-while statement terminates and control passes to the next statement
in the program. If expression is true (nonzero), the process is
repeated, beginning with step 1.
This is an example of the do-while statement:x=100;
do
{
y = sin( x );
x--;
} while ( x > 0 );
In this do-while statement, the two statements y = sin( x
); and x--; are executed, regardless of the initial value of
x. Then x > 0 is evaluated. If x is
greater than 0, the statement body is executed again and x > 0
is reevaluated. The statement body is executed repeatedly as long as
x remains greater than 0. Execution of the do-while
statement terminates when x becomes 0 or negative. The body of the
loop is executed at least once.
while Statement
The while statement lets you repeat a statement until a specified expression
becomes false.
Syntax
while ( expression ) statement
The expression must have arithmetic (numeric/boolean) type.
Execution proceeds as follows:
The expression is evaluated.
If expression is initially false, the body of the while
statement is never executed, and control passes from the while
statement to the next statement in the program.
If expression is true (nonzero), the body of the statement
is executed and the process is repeated beginning at step 1.
This is an example of the while statement: i = 10;while( i < 20 ){ Plot( MA( Close, i ), "MA" + WriteVal( i, 0 ), colorBlack + i ); i = i + 1;}
The example plots 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 -
bar moving averages.
for Statement
The for statement lets you repeat a statement or compound statement a
specified number of times. The body of a for statement is executed zero
or more times until an optional condition becomes false.
Syntax
for ( init-expression ; cond-expression
; loop-expression ) statement
Execution of a for statement proceeds as follows:
The init-expression, is evaluated. This specifies the
initialization for the loop. There is no restriction on the type of
init-expression.
The cond-expression, is evaluated. This expression must have
arithmetic type. It is evaluated before each iteration. Three results are
possible:
If cond-expression is true (nonzero), statement is
executed; then loop-expression, if any, is evaluated. The
loop-expression is evaluated after each iteration. There is no
restriction on its type. Side effects will execute in order. The process
then begins again with the evaluation of cond-expression.
If cond-expression is false (0), execution of the for
statement terminates and control passes to the next statement in the
program.
This example illustrates the for statement: myema[ 0 ] = Close[ 0 ];for( i = 1; i < BarCount; i++ ){ myema[ i ] = 0.1 * Close[ i ] + 0.9 * myema[ i - 1 ];}This example iterates all bars of close array to calculate exponential moving average
if, else Statements
if( expression )statement1 [else
statement2]
The if keyword executes statement1 if expression is true
(nonzero); if else is present and expression is false (zero), it
executes statement2. After executing statement1 or
statement2, control passes to the next statement.
Example 1if ( i > 0 )
y = x / i;
else
{
x = i;
y = abs( x );
}
In this example, the statement y = x/i; is executed if
i is greater than 0. If i is less than or equal to 0,
i is assigned to x and <FONT
face="Courier New">abs( x ) is assigned to y.
Note that the statement forming the if clause ends with a semicolon.
When nesting if statements and else clauses, use braces to
group the statements and clauses into compound statements that clarify your
intent. If no braces are present, the compiler resolves ambiguities by
associating each else with the closest if that lacks an
else.
Example 2if ( i > 0 ) /* Without braces */
if ( j > i )
x = j;
else
x = i;
The else clause is associated with the inner if statement in
this example. If i is less than or equal to 0, no value is assigned
to x.
Example 3if ( i > 0 )
{ /* With braces */
if ( j > i )
x = j;
}
else
x = i;
The braces surrounding the inner if statement in this example make the
else clause part of the outer if statement. If i is
less than or equal to 0, i is assigned to x.
CHANGE LOG
CHANGES FOR VERSION
4.34.2 (as compared to 4.34.0)
do-while loop implemented:Syntax:do statement
while ( expression ) ;The expression in a do-while
statement is evaluated after the body of the loop is executed. Therefore,
the body of the loop is always executed at least once.
Example:i=0;do{ i++;}while(
i < 100 );WriteVal( i );
it is now allowed to 'add' (or rather concatenate) string to a number /
array. This saves quite a bit of typing. This works as in JScript. The
left-hand operand of '+' has to be a string. The right-hand operand may be
string, number or array. Numbers are coerced to strings using %g sprintf
formatting (prints out decimal point only when necessary) and then
concatenated. In case of arrays SELECTED VALUE is coerced to string and then
concatenated.So now instead of i = 100;"Value is " +
WriteVal( i );"Close : " + WriteVal( Close ) + ", Open : " + WriteVal(
Open ) + ", High : " + WriteVal( High );you can
write:i = 100;"Value is " + i;"Close : " + Close + ",
Open : " + Open + ", High : " + High;Note
that"Test " + 100 + 1;will give you "Test 1001"
because statements are parsed from left to right."Test " is added first to
"100" giving "Test 100" and then to "1" giving"Test 1001". If you want to
perform numeric adding first please use braces:"Test " + ( 100 +
1 );- this will give you "Test 101"
additional tweaks in AFL engine & garbage collection, futher speed up
of execution of very long loops
more error checking in AFL engine - will report using uninitialized
variables that were accepted silently in 4.31.x - 4.34.x
#include now accepts new way of specifying file names to
include:#include <filename.afl>(note <
> braces instead of " " ) if you specify the file name this way AmiBroker
will look forthe file in "standard include path" that is definable using
new prefs setting in Tools->Preferences->AFLIt makes much shorter to
write includes and you can move include folder now without changing all AFL
codes using #includes.For example if you have set standard include
path to "C:\AFL\MyIncludes" and write in your formula:#include
<common.afl>AmiBroker will look for
C:\AFL\MyIncludes\common.afl fileAlso now #include
reports file(s) not found in regular error message box.
IIf/Min/Max are now overloaded functions (have two variants each)IIF(
Condition_ARRAY, True_Array, False_Array ) (old one)IIF( BoolValue,
TrueValue, FalseValue )Min( array1, array2 ) (old one)Min(
number1, number2 ) Max( array1, array2 ) (old one)Max( number1,
number2 ) The second one is choosen when all arguments are numbers and
it is much much faster and returns number so LastValue() call is not
neccessary anymore.Example:// much faster
and does not require LastValue()period = IIF( name() ==
"MSFT", 5, 10 );result = Min( 7, 3 ); // (result is still
a number not array as in previous versions)
added 'endless loop detection threshold' setting to Preferences "AFL" tab.
Recommended value 100000 or higher.
fixed parameter counting in CallFunction plugin callback in case of
overloaded functions
fixed problem with premature freeing of arrays passed in default
parameters fields (causing for example problem with color exploration output -
introduced in 4.32)
CHANGES FOR VERSION
4.34.2 (as compared to 4.34.0)
improved crash recovery dialog to include AFL engine state information and
(in some cases) the source line of the formula that causes an exception
added ability to catch all exceptions in indicators and commentaries
(switchabel via Tools->Preferences->AFL, "catch system exceptions...",
ON by default) - allows you to continue to work even in case of serious
problem
loop break by Shift+BREAK is now more sensitive
now you can control how often Shift+BREAK key is checked during formula
execution (Tools->Preferences->AFL, "check SHIFT+Break every" (1..100,
default = 50) (note that specifying low values may degrade performance
slightly)
tweaked AFL memory allocator hash tables to get more speed for large
looping formulas
although I never reproduced this problem I made some changes so 'TAB' key
should not wipe the contents of AFL editor anymore
CHANGES FOR VERSION
4.34.0 (as compared to 4.33.0)
user-definable functions
and procedures with parameters and local variables
'A' is NO LONGER
predefined symbol. I decided to remove it because people tend to use A as
user-variable forgetting the fact that it was build-in array holding typical
price (H+L+C)/3. Use 'Avg' instead.
indicator list column width increased in Indicator Builder
DayOfYear - returns the calendar day number counting from beginning of the
year January 1st is 1. Maximum number returned is 366
CHANGES FOR VERSION
4.33.0 (as compared to 4.32.2)
Database purify tool implemented (available via Tools->Database
Purify)allows to detect missing/extra quotes, possible splits, invalid
OHLC relationshipApply to/range settings similar to AA window. You can
also right click over result list to add symbols to watch list and copy the
list to the clipboard (and paste it later to any other program for futher
use)
further improvements to AFL garbage collector, now looping regardless of
loop count requires the same amount of memory as just single pass of the code
(no growing allocated memory during loops).This enormously lowered memory
consumption for some formulas and increased the speed of some loops 3..4
times.
added variable period support to the following
functions:LinRegSlope,LinearReg,LinRegIntercept,StdErr,TSF
Sample code:
Plot( Close, "Test", colorBlack );
range = 15 * MA( ATR( 15 ), 50 ) / ATR( 15 );
//Plot( range, "range", colorBlue, styleOwnScale );Plot( LinearReg(
Close, range ), "Test", colorRed );
fixed sometimes incorrect output of variable-period version of LLV/HHV
fixed crash occuring when bad arguments were passed to the function (bug
introduced in 4.32.x).
CHANGES FOR VERSION
4.32.2 (as compared to 4.32.1)
second bug in experimental garbage collector fixed.
CHANGES FOR VERSION
4.32.1 (as compared to 4.32.0)
garbage collector was releasing memory too soon in some cases, now fixed.
CHANGES FOR VERSION
4.32.0 (as compared to 4.31.1)
added type check in IF/ELSE statements
added type check in array element assignment
error messages now numbered and display changed slightly
you can break running loop by pressing Shift+BREAK (Pause) key combination
calling COM objects works again (was broken in 4.31.x)
changed slightly the way TAB works in editor, if TAB is pressed any
selection is deselected to avoid accidential deletion of text
experimental: added 'agressive garbage collector' that extremely
decreases the amountof memory required to run AFL formula by releasing the
memoryused for temporary variables as soon as possible
(previouslytemporary memory was released at the end of formula
execution).A side-effect of new garbage collector is some speed up in
formula execution.
new tab in preferences for AFL engine settings
experimental feature, NOT for beginners, may be removed/modified in
future releases: new _TRACE( "string" ) AFL function addedthat
allows to write debug messages from AFL code to system debug viewer.(it
calls internally OutputDebugString Win API function).To view debug
messages you have to run DebugView freeware program from
http://www.sysinternals.com/
CHANGES FOR VERSION
4.31.1 (as compared to 4.31.0)
fixed bug introduced in 4.31.0 causing no text output in
commentary/interpretation
CHANGES FOR VERSION
4.31.0 (as compared to 4.30.0)
Workspace window uses "icon font" set in the Windows settings instead of
hard coded Tahoma 8
for better readability and ClearType(tm) compatibility on WinXP, all
dialog windows use now 'MS Shell Dlg' face name that maps to standard MS Sans
Serif on Win 9x/Me/NT and Tahoma on Win 2K and XP.
rewritten AFL parser, now formula is parsed and coverted to syntax tree
and then interpreted. This would allow further improvements including
compilation. This allowed also to add loops/if-else statements.
implemented IF/ELSE statement, WHILE and FOR loops:The same basic
'for' loop in AFL is 2..3 times faster than in JScriptSyntax follows
C++/JScript style:
while( conditional_expression ) statement;
for( initializer_part; conditional_expression; iterator_part )
statement;
if( conditional_expression ) statement;
if( conditional_expression )
statement;elsestatement;
implemented compound statements: these are blocks of statements
enclosedin opening and closing curly brace
{statement1;statement2;...statementN;}
compound statement can appear anywhere when simple statement can.
For example:
i = 10;while( i < 20 ){Plot( MA( Close, i ), "MA" +
WriteVal( i, 0 ), colorBlack + i );i = i + 1;}
implemented C-style postfix and prefix increment/decrement operators
i = 10;WriteIf( i++ );WriteIf( ++i );WriteIf( i
);
implemented array element access (subscript) operator []:
WriteVal( Close[ 0 ] ); // prints the first bar of close
array
/* a sample low-level implementation of exponential moving average in
AFL */
myema[ 0 ] = Close[ 0 ];
for( i = 1; i < BarCount; i++ ){myema[ i ] = 0.1 * Close[
i ] + 0.9 * myema[ i - 1 ];}
added built-in constant 'BarCount' that returns number of bars available in
arrays (the number of elements of array)When QuickAFL is turned on it may
be less than true number of bars because QuickAFL feature attempts to use only
visible bars (and few before). You can control how many bars the formula
requires using SetBarsRequired() function
implemented infinite-loop protection. Nice if you forgot to increment
counter variable in 'for' loop :-)
tab key now works without need to press ALT/CTRL in AFL editors
added C-like synonyms for logical ADD/OR/NOT: &&, ||, !
/* a sample low-level implementation of Profit-target stop in
AFL: */
Buy = Cross( MACD(), Signal() );
priceatbuy=0;
for( i = 0; i < BarCount; i++
){ if( priceatbuy == 0 && Buy[ i
] ) priceatbuy = BuyPrice[ i ];
if( priceatbuy > 0 &&
SellPrice[ i ] > 1.1 * priceatbuy
) { Sell[
i ] = 1; SellPrice[ i ] = 1.1 *
priceatbuy; priceatbuy =
0; } else Sell[
i ] = 0;}
/* sample EMA rainbow */
Plot( Close, "Price", colorBlack, styleCandle );for( Range = 15;
Range < 100; Range++ ) Plot( EMA( Close, Range ),
"MA"+WriteVal(Range,0), colorRose + Range % 8, styleNoLabel );
HOW TO REPORT BUGS
If you experience any problem with this beta version please send detailed
description of the problem (especially the steps needed to reproduce it) to <A
href="">bugs@xxxxxxxxxxxxx
Yahoo! Groups Sponsor
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.
|