April 8, 2011 19:26

THIS IS A 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 5.30 first.

Just run the installer and follow the instructions.

Then run AmiBroker. You should see "AmiBroker 5.38.0 BETA" written in the About box.

See CHANGE LOG below for detailed list of changes.

CHANGE LOG

CHANGES FOR VERSION 5.38.0 (as compared to 5.37.1)

• Fixed structure packing in x64 version causing problems with display of parameter tooltips for 3rd party DLLs
• WMA had trouble with null handling at the beginning. Fixed.
• Improved CCI accuracy in x64 version (as compared to x86 version)
Tools->Preferences, "Charting"

- by turning this ON, zoom level gets reset to default number of bars as defined in preferences for
any loaded layout, bringing old (pre-5.37) behaviour

• AFL: FIR( array, coefficients, size ) implemented
This function implements general-purpose Finite Impulse Response filter (FIR)
http://en.wikipedia.org/wiki/Finite_impulse_response

The output is convolution of input aray with coefficents table (impulse response table).

The function performs automatic normalization of coefficient table if necessary (if its sum is not 1)

INPUTS:
array - input array to be smoothed
coefficients - array of FIR coefficients
size - number of coefficients ( filter_order + 1 )

It is functional (but 2+ times faster) equivalent of following AFL:

function FIR_AFL( input, coeff, size )
{
result = 0;
sumcoeff = 0;
for( i = 0; i < Min( size, BarCount ); i++ )
{
sumcoeff += coeff[ i ];
result += coeff[ i ] * Ref( input, - size + i + 1 );
}

return result/sumcoeff;
}

For example 5 bar weighted moving average can be written:
coeff[ 0 ] = 1;
coeff[ 1 ] = 2;
coeff[ 2 ] = 3;
coeff[ 3 ] = 4;
coeff[ 4 ] = 5;

FIR( Close, coeff, 5 );

Another example: ALMA which is FIR filter with shifted Gaussian coefficents can be implemented as follows:

function ALMA_AFL( input, range, Offset, sigma )
{
local m, im, s, Coeff;

m = floor( Offset * (range - 1) );
s = range / sigma;

for( i = 0; i < Min( range, BarCount ); i++ )
{
im = i - m;
Coeff[ i ] = exp( - ( im * im )/ ( 2 * s * s ) );
}

return FIR( input, Coeff, range );
}

• AFL: HMA (Hull Moving Average)
HMA - Hull Moving average it is equivalent to this AFL:

function HMA_AFL( input, Range )
{
return WMA( 2 * WMA( input, int( Range / 2 ) ) - WMA( input, Range ), int( sqrt( Range ) ) );
}

• AFL: new function: DateTimeAdd( datetime, amount, interval = inDaily )
The function adds specified amount of 'intervals' to input datetime array.
Allows for example to calculate datetime 5 days back or 13 months into the future
INPUT:
datetime - scalar or array - the datetime value to add to (for example returned by Now(), DateTime() or StrToDateTime/_DT or ConvertDateTime functions)
amount - number of 'intervals' to add (seconds/minutes/hours/days/etc - depending on interval parameter)
interval - specifies unit you want to add, supported units are in1Second, in1Minute, inHourly, inDaily, inWeekly, inMonthly, inQuarterly, inYearly

RETURNS:
datetime (scalar or array) - returned type depends on input

Example 1:

x = Now( 5 ) ;
printf("11 days from now " + DateTimeToStr( DateTimeAdd( x, 11, inDaily ) ) ;

Example 2 (commentary):

x = Now(5);
" now is " + DateTimeToStr( x );

for( shift = -12; shift <= 12; shift++ )
{
printf("%g seconds from now is " + DateTimeToStr( DateTimeAdd( x, shift, 1 ) ) + "\n", shift );
printf("%g minutes from now is " + DateTimeToStr( DateTimeAdd( x, shift, in1Minute ) ) + "\n", shift );
printf("%g hours from now is " + DateTimeToStr( DateTimeAdd( x, shift, inHourly ) ) + "\n", shift );
printf("%g days from now is " + DateTimeToStr( DateTimeAdd( x, shift, inDaily ) ) + "\n", shift );
printf("%g weeks from now is " + DateTimeToStr( DateTimeAdd( x, shift, inWeekly ) ) + "\n", shift );
printf("%g months from now is " + DateTimeToStr( DateTimeAdd( x, shift, inMonthly ) ) + "\n", shift );
printf("%g quarters from now is " + DateTimeToStr( DateTimeAdd( x, shift, inQuarterly ) ) + "\n", shift );
printf("%g years from now is " + DateTimeToStr( DateTimeAdd( x, shift, inYearly ) ) + "\n\n", shift );
}

• AFL: new function: Lookup( array, datetime, mode = 0 )
The function searches for the bar with specified datetime and returns the value from the same position of the input array.
If exact match can not be found it returns:
Null - when mode is 0 (zero) - the default behaviour,
closest predecesor bar value - when mode is -1
closest successor bar value - when mode is 1

Example:
InputDate = "2011-04-05";
Title = "Close value at (or before) " + InputDate + " is " + Lookup( Close, _DT( InputDate ), -1 );

This function uses very fast binary search and it is many times faster than previous AFL-based methods
such as FindValueAtDateTime() presented in the past.
Any call to FindValueAtDateTime ( input, dt, value ) can be now replaced with Lookup( input, value )
(there is no need to pass dt- datetime).

NOTE: This function does not affect QuickAFL required bars, therefore it will only search bars that are actually
loaded in arrays. For indicators it may mean that it won't be able to find value if it is invisible, unless you
use SetBarsRequired() function to ensure that more bars are loaded.

• AFL: function _DT( "string" ) added - this is short alias for StrToDateTime() function
// in charts / indicators /interpretation they return the values of array at first and last visible bars
// in other (non-indicator) modes they return array elements with subscripts of 0 and BarCount -1 respectively
// Note that these functions do not affect QuickAFL, so LastVisibleValue may be used instead of LastValue
// These functions are intended to complement functionality already available via HighestVisibleValue and LowestVisibleValue

x = C;
Plot( x, "x", colorRed );
Plot( FirstVisibleValue( x ), "fvv", colorGreen );
Plot( LastVisibleValue( x ), "lvv", colorBlue );

• Cum( Null) was causing exception in AFL engine. Fixed
• Print preview flickered when moving the mouse due to frequent refreshes when crosshair was enabled. Fixed.
• Structured exception handler is set for every thread for better exception reporting

CHANGES FOR VERSION 5.37.1 (as compared to 5.36.0)

• EncodeColor did not accept colorDefault (-1) in 5.37.0. Fixed 5.37.1.
• AFL Code Wizard 1.01: fixed incompatibility with Internet Explorer 9
• AFL: PlotText() internally detects if given x-coordinate is outside visible area, skips entire processing and returns zero (without plotting anything) for invisible bars. This saves execution time for inefficiently written formulas that did not check for visible bars by themselves.
• Report charts now use Formula path as defined in preferences not hard-coded one so they work if user has moved his/her formula folder elsewhere
• Fixed crash occuring sometimes on completly blank chart when user set number of blank (future) bars to zero (#75570)
• Fixed crash when trying to use Overlay onto blank chart
• AmiBroker is now marked as DPI-aware (this ensures crisp display by turning off Win7 DPI virtualization that scales and blurs image on high DPI (>=150dpi) displays)
• AFL: added new message: 'Error 52. Invalid argument value. Argument must be positive (and not Null))'. The message is displayed when you pass incorrect value to a function (like Null as a range to Sum() )
• Layout files now include zoom factor so charts are loaded with most recently used zoom level
• Updated version of UI library featuring new appearance themes and alpha-channel resize tracker

CHANGES FOR VERSION 5.36.0 (as compared to 5.35.0)

• AFL Editor more detailed code checks implemented - now displays *warnings* (for code parts that are syntactically correct but likely errorneous in practice)

Example: Warning 501. Assigment within conditional. Did you mean == instead of = ?
The warning will display if you use = (assignment operator) as a condition in
if(), while(), do-while(), and for() statements and IIf() function

The result of an = assignment statement is the value of the right-hand side of the = statement. You can use an assignment statement as a conditional test, but it is not recommended. It usually is the result of a typo where a == equality test was intended, as the following example shows:

Example:
if( x = 3 ) // x will be assigned with 3 then it is used as "true" value so condition is always met - AmiBroker will display warning 501. Assignment within conditional
{
// this if will ALWAYS be executed
}

Probably the user meant:
if( x == 3 ) // x will be compared to 3
{
// this is true conditional part
}

If you want to overcome warning 501 while still doing assigment within conditional perform a check like this:
if( ( x = 3 ) == True ) // this NOT cause warning 501
{
printf("test");
}

• Temporary workaround for docking window crash when Internet Explorer 9 is installed and web research window resized
• AFL: GicsID and InGICS added

GicsID( mode )
returns STRING
- gives information about current symbol GICS category
mode = 0 - returns string containing GICS code alone (such as " 15103020")
mode = 1 - returns string containing GICS category name (such as "Paper Packaging")
mode = 2 - returns string containing both code and name (such as "15103020 Paper Packaging")

InGics( "gics_code" )
- performs yes/no test if current symbol belongs to given GICS category for example
if GICS set for the symbol is 15103020
InGics("15"), InGICS("1510"), InGics("151030") and InGics("15103020") will ALL return true
but all others (like InGics("20")) will return false.

Example usage:

"GICS(0) = " + GicsID( 0 );
" GICS(1) = " + GicsID( 1 );
" GICS(2) = " + GicsID( 2 );

for( i = 10; i < 90; i+= 1 )
{
gics_code = StrFormat("%02.0f", i );
printf("In Gics '"+ gics_code + "' = %g\n", InGics( gics_code ) );
}

• In minimised windows RequestTimedRefresh with onlyvisible parameter set to False worked unreliably when multithreading was ON. Fixed.
• AFL engine gives more detailed information about exceptions (including line numbers and file path)
• Formula editor, indicators and commentary catch all exceptions, not only system exceptions
• Fixed potential crash when param dialog is referring to non-existing view (NO_CHART_ID)
• AFL: "Unknown exception" should now be reported with line numbers for easier identification of ofending function
• AFL: for/while/do-while loops were not executed if syntax or runtime error occured before them and "stop parsing on first error" was turned off. Fixed

CHANGES FOR VERSION 5.35.0 (as compared to 5.34.5)

• AFL Editor: "firstvisiblebarindex" and "lastvisiblebarindex" are initialized with first and last data bar when using "Verify syntax" to avoid problems. Although these Status fields should only be used in indicators, it is quite common mistake among users to use them unconditionally
• AFL: Sum() function displays Error 52. Invalid argument value when range argument is negative (instead of random crash)
• Account manager: fixed OLE exception in date conversion occuring randomly due to uninitialized exit date when trade has been opened.
• Indicator Maintenance Wizard now creates log (indmaint.log in AmiBroker directory) that reports all layout files read and eventual errors found. It also attempts to read corrupted layouts in a "safe" way so it does not crash
• Parameter window: fixed handling of mixed section and section-less parameters
• Quote Editor: fixed editing when timeshift was not zero plus added ability to turn on/off timeshift (so quotes can be edited in original exchange zone)
• Fix: Click on items in param() window did not set focus ( fix @ line 1505 HotPropCtrl.cpp )
• AFL: Error 10. Subcript out of range message now gives information about exactly which array element was accessed
• AFL: Added new error message "Error 51. Array subscript has Null value"
• /STACK:2097152,16384 (2M/16K) option for x64 compilation - to allow deep nesting in AFL, also reduced stack usage by Execute() function
• OLE: AB.RefreshAll( [optional] Flags = 1 ) - takes now new optional parameter Flags. Flags = 1 means refresh only charts (fast), Flags = 3 means refresh charts, dialogs, symbol list, chart list, etc (SLOW!)
• OLE: AB.RefreshAll() changed for improved consistency (marks for refresh and it is refreshed every 1 second regardless of number of requests within one second)
• //--Indicator-End-- special marker is now obsolete and does nothing (entire formula is executed). For conditional execution of interpretation code use conditional statement if with Status() function
• Fix: switch( str_function_call_here ) did not work properly when expression was a function call returning string such as StrLeft(). Fixed
• AFL: Equity() now uses thread local storage for keeping stop state variables to prevent interference when multiple threads call Equity()
• AFL: mtRandom(A) now uses thread local storage, so using non-null seed yields reproducible sequence even if multiple threads are calling mtRandom in parallel
• Implemented cross-thread bidirectional communication mechanism that allows to call functions across threads in safe way. This allows among other things to make non-threading safe APIs (like Quotes Plus) to operate properly with multi-threading enabled. (Fixes GetExtraData crash with QP2 - FC#2072)
• Prefs/Misc/"Show interpretation in tooltips" checkbox removed as this functionality has been removed in 5.32.0. Use Interpretation window instead (View->Interpretation)
• OLE: AB.Import() - UI is automatically refreshed after import so there is no need to call RefreshAll() anymore. Also the refresh is "smart" it only updates symbol lists if any symbols were added

CHANGES FOR VERSION 5.34.5 (as compared to 5.34.0)

• Worked around Microsoft OS bug #248760 and #209467 - writing to metafiles from multiple threads causes lost object selections. This has caused display unstability for Gfx function-generated output. The only way to fix that was NOT to use metafiles at all. Gfx code was rewritten not to use Microsoft metafiles. As a result of custom implementation Gfx functions work now 3 times faster and are multi-threading safe.
• GfxDrawText automatically falls back to much (4x) faster ExtTextOut when format is 0 or DT_NOCLIP and string does not contain any new line characters

CHANGES FOR VERSION 5.34.0 (as compared to 5.33.0)

• Fix: Gfx functions when run in multithreaded mode slowed down over time due to Micosoft MFC library GDI wrappers not being thread-safe. Fixed by replacing MFC calls with straight WINAPI calls.
• Multi-threading charts are now ON by default and will be reset to ON on each restart. This change is temporary but added because some people forget to turn this on.
• Fix: When Symbol Lock was ON, currently focused chart did not update its quote cache. Fixed
• Fix: Status("redrawaction") was giving 0 result for timed refreshes in 5.31-5.33 while it should give 1. Fixed.
• Fix: GDI leak found when using Gfx* functions in Automatic Analysis that resulted in resource exception after long use. Fixed
• Fix: GDI leak found after Parameter windows "Reset all". Fixed
• Fix: Black screen in Edit->Image->Copy as bitmap/Metafile/Export/Send e-mail. Fixed. Now uses separate instance of AFL engine not to interfere with execution running in the background.
• Fix: AFL engine did not release memory buffer for pre-processed parts (#include). Fixed
• AmiBroker now has requestedExecutionLevel set to "asInvoker" in its manifest file and that prevents Vista/Windows 7 folder virtualization. It also displays a warning message when it does not have write access to its working directory.

CHANGES FOR VERSION 5.33.0 (as compared to 5.32.1)

• OLE: Analysis object - added IsBusy property that allows OLE programs to check whenever AA is currently running asynchronous AA operation
• In 5.32.1 only active window was refreshed automatically by streaming data - others required mouse click. Fixed.
• In 5.32 formulas using Status("actionex") == actionIndicator caused blank pane when focused because actionex was NOT indicator. Compatibility shim implemented.
• Fix: Interval linked charts did not update immediatelly and multi-window layouts required click to update after loading. Fixed.
• Fix: Crash @501C30 when doing double right click on Data window
• Dangling pointer to view (after its deletion) removed from timedrefresh map and parameter window. This prevents some crashes
• Compat: In 5.32 when SetOption() was placed AFTER custom backtester procedure code in user formula - such options did not affect CBT results. Technically 5.32 was correct one and 5.30 incorrect (such options affected CBT results), but because probably too many user formulas are poorly written without taking attention on placement of SetOption() calls and that created false bug reports, an old compatible behaviour was restored till the time when error messages about wrong placement of SetOption() calls are implemented, so users become aware about their coding errors.
• Bug recovery/report dialog now allows the user to type steps required to reproduce the crash and select how often given problem occurs
• Attempts to run AA asynchronous operation (Backtest/Optimize/Scan/Explore) via OLE while another one is still running are detected and prevented (with error message "Automatic Analysis is Busy processing")
• AFL thread termination routine checks for possible same-process COM call deadlock and pumps COM messages if necessary to complete thread gracefully

CHANGES FOR VERSION 5.32.1 (as compared to 5.32.0)

• Fix: when "stop parsing at first error" option was turned on "Reset all" button in parameters window caused params to disappear. Fixed
• Fix: random crash @7792E25B (small alloc heap corruption) fixed
• Fix: random crash @4BFFF7 (when accessing static variables from multiple threads at once). Fixed.
• Fix: Eliminated multi-threaded race condition that randomly caused blank charts.

CHANGES FOR VERSION 5.32.0 (as compared to 5.31.2)

• Parameters work also without _SECTION_BEGIN/_SECTION_END, Parameters 'Reset All' operation improved
• Interpretation does not use extra execution cycle anymore (text evaluation is done within normal indicator execution)
• Formula Editor: Syntax check, Apply indicator, Insert work faster because it only uses 100 bars to perform syntax check instead of all bars
• Formula Editor: Code check & profile uses not more than 100K bars
• Fix: Timing display in the chart shows correctly AFL execution and redraw time when multi-threading is ON and does not flicker
• Fix: Say() function works properly when multithreading is ON
• Fix: Errors occuring in JScript/VBScript parts do not result in crash anymore
• Data Window now allows to choose which of default data elements (OHLCV, OI, Aux1/2) to display - use Right click context menu
• Data window display is immediate and does not require extra AFL execution
• Data tooltip readout is immediate - does not use extra execution cycle anymore (implemented internal cache)
• When there are no parameters for given indicator - empty brackets are not added anymore for display in tooltip/data window and as a return value of _DEFAULT_NAME().

CHANGES FOR VERSION 5.31.2 (as compared to 5.31.1)

• Fixed: Problems with Gfx functions in 5.31.1
• Fixed: Parameters window was not refreshed properly after ResetAll in 5.31.1
• Fixed: Crash when switching layouts in 5.31.1
• Fixed: Crash @004C297D - Foreign returned wrong interval in 5.31.1
• Fixed: Crash @0040F91C / @0040FA2B (all references to ChartInfo removed from AFL engine) in 5.31.1
• Fixed: Automatic Analysis ignored changes done via SetOption and other runtime settings-related changes in 5.31.1
• Fixed: Changing chart display interval did not work immediatelly in 5.31.1

CHANGES FOR VERSION 5.31.1 (as compared to 5.31.0)

• fixed crash @0040BACD (using Gfx... functions) when multi-threading was enabled
• fixed crash @0041E27C (JScript/VBScript embedded code) when multi-threading was enabled
• fixed crash @7686F05D and @004B83EC (load/create new database) when multi-threading was enabled

CHANGES FOR VERSION 5.31.0 (as compared to 5.30.4)

• Major change: AFL Engine rewritten completely to allow multi-threaded execution

CAVEAT: this is very new code and may not be stable

This change will lead to several improvements that will be added in future versions. First public release of multi-threaded AFL engine (5.31.0 BETA) features support for multi-threading in commentary and charts.

By default multi-threaded execution in charts is disabled. To enable multi-threaded execution of charts, go to Tools->Preferences, "AFL" tab and check "Multi-threaded charts".
Note that once you turn this option on, each chart PANE will execute in separate thread, so refreshes of each pane will become completely asynchronous, non-blocking. This has quite dramatic (positive) effect on perceived snappiness of user interface.

However, there are also things you need to keep in mind. If your formulas rely on certain order of execution of panes, they may work incorrectly because generally all panes will be executing in parallel, and it depends on complexity of formula which one will finish earlier. Also a formula that is quick to execute may run several times while the other lenghty one is only finishing one run.
This has also another side effect that Foreign and AddToComposite functions when they are used in chart formulas, will operate in asynchronous way (what you write with AddToComposite may not necesarily appear instantly if you read it back right after using Foreign()), therefore it is recommended to use static variables when you need synchronized access between threads.

Since each thread uses approximatelly 1 MB of RAM for thread stack, the memory consumption when using multi-threading may be slightly larger.

There are some things that do not work properly yet when "multi-threading charts" are turned on:
• Performance meter / chart timing display do not show AFL execution times (the values reported are minimal).
• Data tooltips / Data window are still executed in main GUI thread and this in theory can lead to problems (to improve stability it is recommended to turn off price data tooltips in Tools->Preferences->Miscellaneous)
• \$HYBRID now allows importing OpenInterest, Aux1, Aux2 onto existing data without need to specify price
• New AFL function: PlaySound( "filename" )

The function plays back specified .WAV file

returns 1 on success, 0 on failure

Example:
PlaySound("c:\\windows\\media\\ding.wav");

• New AFL function: ShellExecute( "filename", "arguments", "workingdir", showcmd = 1 )

The function opens a file or runs executable.

It is equivalent of Windows API ShellExecute, with one difference, it always uses "open" verb.
This allows running executables, scripts, opening document files using their associated editors, etc.

If the function succeeds, it returns a value greater than 32. If the function fails, it returns an error value that indicates the cause of the failure.
For possible error codes, consult Microsoft documentation:
http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

Example:

• Multiple file open dialogs now use 1MB buffer (instead of 256K)
• OptimizerSetOption and OptimizerSetEngine are now no-ops for anything but backtest/optimization action

This prevents random problems when one used OptimizerSetOption or OptimizerSetEngine within indicator code.
• Value labels are drawn with a little offset from the Y axis. First Plot() label is drawn with an arrow pointing out exactly price level
• When main application window is in modal state (displaying File open dialog for example), RequestTimedRefresh is held
This fixes problem with file dialog changing current working directory while browsing for directory (FC #1670)
• When multiple MDI windows are open and one is maximized, the windows in back that are completely obscured by others and minimized windows are not redrawn during normal RT refresh

It is worth noting that if you use RequestTimedRefresh the chart will continue to be refreshed periodically even if obscured by other windows.
If you use RequestTimedRefresh with "onlyvisible" parameter set to False, the chart will be also refreshed if it is minimized

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 support at amibroker.com