April 13, 2015 15:54
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.90 first.
Just run the installer and follow the instructions.
Then run AmiBroker. You should see "AmiBroker 5.95.0 BETA" written in the About box.
See CHANGE LOG below for detailed list of changes. Note that only changes
that affect end-user directly are listed here. Internal code changes/refactoring
is usually not mentioned.
CHANGE LOG
CHANGES FOR VERSION 5.95.0 (as compared to 5.94.0)
Keep in mind that if you are changing ApplyStop order/precedence you
1. MUST DEFINE ALL APPLYSTOP even if you don't use all stop types. It you
don't use given stop type use stopModeDisable in mode parameter
2. There must be NO DUPLICATE in precedence numbers. Otherwise unpredictable
behavior may occur.
3. The order of events inside bar is unknown so specifying given order of
execution of stops
is based on assumptions that may or may not be correct for given trading scenario.
It is advised to keep max. loss stop as first one.
Whenever N-bar stop is executed first or not depends on your trading setup.
If you trade on open, then Nbar stop may be executed first (even before max
loss).
Trailing stop can be excuted before or after profit target depending on your
setup. Contrary to "gut feeling" executing trailing stop before profit
target is not necesarily more pessimistic, because
in several cases leads to increasing CAR instead of decreasing it. Now you
can test both. Choose whatever fits your trading style. Choo
Example:
// Applystops will be excuted in the following order: loss, trailing, profit,
n-bar:
ApplyStop( stopTypeLoss, stopModePercent, 5, True, False, 0, 0 /*precedence*/
);
ApplyStop( stopTypeTrailing, stopModePercent, 5, True, False, 0, 1 /*precedence*/
);
ApplyStop( stopTypeProfit, stopModePercent, 5, True, False, 0, 2 /*precedence*/
);
ApplyStop( stopTypeNBar, stopModeBars, 40, False, False, 0, 3 /*precedence*/
);
Note:
for backward compatibility:
With stopTypeNBar, when Precedence parameter is provided then ExitAtStop
setting is ignored.
When Precedence parameter is not provided for stopTypeNBar
there are two possible sequences applied by default
if NBarHasPriority setting is true or you call ApplyStop with ExitAtStop
set to true then sequence is N-bar, loss, profit, trailing
otherwise default sequence is loss, profit, trailing, N-bar
These defaults will be re-applied whenever you call ApplyStop( stopTypeNBar
... ) without providing precedence parameter.
Note 2:
Fixed ruin stop (99.6% loss) is always executed as last one.
per = Optimize( "period", 20, 2, 100, 1 );
Buy = Cross( C, MA( C, per ) );
Sell = Cross( MA( C, per ) , C );
SetOption("MCEnable", True );
SetOption("MCRuns", 1000 );
SetPositionSize( 1, spsShares );
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest(); // run default backtest procedure
// get access to Monte Carlo results
// note 1: it may be NULL if MC is NOT enabled
// note 2: MC results are available after Backtest() or PostProcess as MC simulation
is done in final phase of post processing
mc = bo.GetMonteCarloSim();
if( mc )
{
// get 25-th percentile of final equity distribution
bo.AddCustomMetric("FinalEq25", mc.GetValue( "FinalEquity",
25 ) );
}
}
It implements fast 4th-order infinite impulse response filter.
Analytically it is:
y[ n ] = b0 * x[ n ] + b1 * x[ n - 1 ] + b2 * x[ n - 2 ] + b3 * x[ n - 3
] + b4 * x[ n - 4 ]
+ a1 * y[ n - 1 ] + a2 * y[ n - 2 ] + a3 * y[ n - 4 ] + a4 * y[ n -4 ];
AFL equivalent:
y = x; // init so no glitches at the beginning appear
for( n = 4; n < BarCount; n++ )
{
y[ n ] = b0 * x[ n ] + b1 * x[ n - 1 ] + b2 * x[ n - 2 ] + b3 * x[ n - 3 ]
+ b4 * x[ n - 4 ]
+ a1 * y[ n - 1 ] + a2 * y[ n - 2 ] + a3 * y[ n - 4 ] + a4 * y[ n - 4 ];
}
Filters of orders 3 and 2 can be implemented by leaving unneeded arguments at default value of zero.
Coefficients b0, b1, b2, b3, b4 multiply the input signal x[n] and are referred to as the feedforward coefficients. Coefficients a1, a2, a3, a4 multiply the output signal y[n] and are referred to as the feedback coefficients. Pay careful attention to the sign of the feedback coefficients. Some design tools flip the sign of the feedback coefficients. In this case the feedback coefficients must be negated.
This convention is used so feedback coefficients work the same as in AMA2 in case of first order filter, so
IIR( array, factor, 1-factor )
is the same as
AMA2( array, factor, 1-factor )
(with very minor difference is that IIR uses internally double precision arithmetic while AMA2 uses single precision)
simple ema:
factor = 2/(period+1);
IIR( input, factor, 1- factor );
wilders:
factor = 1/period
IIR( input, factor, 1-factor );
Ehlers Supersmoother
Periods = 10;
c1 = 1.41421 * 3.14159 /
Periods;
c2 = 2.71828^-c1;
a1 = 2 * c2 * cos(
c1 );
a2 = -c2^2;
b0 = (1 - a1 - a2)/2;
b1 = b0;
x = IIR( Close, b0, a1, b1, a2 );
Plot( x, "Super Smoother", colorRed );
CHANGES FOR VERSION 5.94.0 (as compared to 5.93.0)
AmiBroker's built-in Monte Carlo simulator is high speed (30+ million trades
per second) simulator that runs series of random trade sequences based on
backtest output.
It uses high-quality Mersene Twister random number generator.
It is run automatically after backtest and produces a series of CDF charts
(see extra tabs in the New Analysis window). These charts are probably going
to be moved
to the report at later stage.
Monte Carlo simulator is by default available only during portfolio backtest
runs. It is NOT available/running during optimization or individual optimization.
(I may enable it in the future).
You can control process of Monte Carlo simulation using new Settings page:
"Enable Monte Carlo Simulation" - turns on/off MC simulator
"Number of runs" - defines how many MC simulation runs is done (default 1000)
"Position sizing" - defines position sizing used by Monte Carlo
simulator.
Position sizing algorithm used by MC process is independent from that used
by backtest. To do so MC may apply special processing to trade list obtained
from backtester depending on this option setting.
- "Don't change" - uses trades as they are coming from the backtester
without changing position size and profit as it is reported from the backtester
- "Fixed size: N shares/contracts" - trade fixed number of shares/contracts.
It takes per-share profit as reported by backtester and muliplies it by N
contracts as entered in the settings. Per-share profit is calculated by dividing
profit reported by the backtester by number of shares/contracts reported
by the backtester
- "Constant value: X" - trades fixed amount per trade. Takes percent
profit reported by backtester and multiplies it by constant value entered
to get the profit.
returns TRUE or FALSE whenever string matches searchstring or not.
Searchstring is can contain wild-card characters such as:
* - matches any string, including empty strings
? - matches any single character
This function is case sensitive (of course except wildcard characters).
If you want case insensitive matching - convert both string and searchstring
to lowercase or uppercase
prior to matching (StrLower/StrUpper)
Example:
x = StrMatch("Every breath you take", "Every * you *");
// x will be TRUE
x = StrMatch("Every step you make", "Every * you *");
// x will be TRUE
Tables of all UCN/Unicode characters
http://www.unicode.org
http://unicode-table.com/
http://www.unicodemap.org
http://en.wikipedia.org/wiki/List_of_Unicode_characters
Various arrows:
http://www.unicode.org/charts/PDF/U2190.pdf
Enclosed alphanumerics:
http://www.unicode.org/charts/PDF/U2460.pdf
(note: NOT all glyphs (graphical representations of characters) are actually
present in current font. This depends on your operating system. For example
Segoe UI in Windows 7 has lots of characters, but Windows 8 has more,
if a glyph is missing usually an empty rectangle is drawn). DejaVu free font
has lots of glyphs, Symbola free font has lots of weird shapes.
Plot( C, "", colorDefault );
PlotTextSetFont( "♥Ω↑⇑⓮☝", "Segoe
UI", 30, 20, HighestVisibleValue( C )/2 + LowestVisibleValue( C )/2
, colorRed );
Title = "A demo of UCN: "+EncodeColor(colorRed)+"♥Ω↑€Σβ☂☎";
CHANGES FOR VERSION 5.93.0 (as compared to 5.92.0)
WHITE_BRUSH 0
LTGRAY_BRUSH 1
GRAY_BRUSH 2
DKGRAY_BRUSH 3
BLACK_BRUSH 4
NULL_BRUSH 5 (the same as hollow brush)
HOLLOW_BRUSH 5
WHITE_PEN 6
BLACK_PEN 7
NULL_PEN 8
OEM_FIXED_FONT 10
ANSI_FIXED_FONT 11
ANSI_VAR_FONT 12
SYSTEM_FONT 13
DEVICE_DEFAULT_FONT 14
SYSTEM_FIXED_FONT 16
DEFAULT_GUI_FONT 17
Example circle with hollow interior:
GfxSelectPen( colorOrange, 4 );
GfxSelectStockObject( 5 ); // hollow brush
GfxCircle(100, 100, 20 );
HS_HORIZONTAL 0 /* ----- */
HS_VERTICAL 1 /* ||||| */
HS_FDIAGONAL 2 /* \\\\\ */
HS_BDIAGONAL 3 /* ///// */
HS_CROSS 4 /* +++++ */
HS_DIAGCROSS 5 /* xxxxx */
Hatch color is specified by color parameter, hatch background is specified
by current background color
see: GfxSetBkColor()
GfxSelectPen( colorOrange, 4 );
GfxSetBkColor( colorLightGrey );
GfxSelectHatchBrush( colorBlue, Param("Hatch pattern", 5, 0,
5 ) );
GfxCircle(100, 100, 20 );
bi = BarIndex();
x = Percentile( Close, bi, 50 );
Plot( x, "Cumulative 50% Percentile", colorRed );
Plot( Close, "Price", colorDefault, styleCandle );
XYChartSetAxis(chartname, "[x]", "[sinx/x]", styleLine
| styleDots ); // bar style
for( x = -10; x < 10; x += 0.2 )
{
y = sin(x ) / x;
XYChartAddPoint( chartname, "", x, y, colorGreen, colorRed );
}
XYChartAddPoint( chartname, "", Null, Null ); // add a NULL point
to begin new line
for( x = -10; x < 10; x += 0.2 )
{
y = sin( 2 * x ) / x;
XYChartAddPoint( chartname, "", x, y, colorOrange, colorBlue );
}
You can turn it off from Settings, Reporting
Buy-and-hold simulation uses current symbol when doing single-symbol backtests/optimization.
When doing portfolio backtest for more than one symbol, it uses "Portfolio
B&H symbol" as a benchmark for buy and hold.
Current rates used are listed in the Detailed Log
1. Add a symbol that will hold interest rates. It does not need to have
quotes every day,
you can have only quotes on days when interest rate changes.
Interest rates should be expressed in PERCENTS. So if interest is 5% you
should enter 5 in "close" price field for particular date
2. Enter the rate symbol into "Dynamic interest symbol" in the Settings.
3. Enter "Fixed interest rate" in the Settings. It will be used for days PRIOR to very first date available in intrest rate symbol.
CHANGES FOR VERSION 5.92.0 (as compared to 5.91.1)
Example of bar style usage (this is EXPLORATION code):
chartname = "example";
XYChartSetAxis( chartname, "[x]", "[sinx/x]", 1 ); //
bar style
for ( x = -10;
x < 10; x += 0.2 )
{
y = sin( x ) / x;
XYChartAddPoint( chartname, "",
x, y, colorGreen );
}
Second example:
chartname = "gaussian";
XYChartSetAxis( chartname, "[x]", "[gaussian]", 1 );
for ( x = -3;
x < 3; x += 0.125 )
{
y = exp( - x ^ 2 );
XYChartAddPoint( chartname, "",
x, y, IIf( abs(
x ) <= 1, colorGreen, colorRed )
);
}
CHANGES FOR VERSION 5.91.0 (as compared to 5.90.1)
SetOption("NoDefaultColumns", True );
Filter = 1;
AddColumn( Close, "Column1" );
AddColumn( Null, "Column2" );
for( i = 0;
i < 10; i++ )
{
AddRow( StrFormat( "row
%g\tsecond column", i ) );
}
only_when = ( Month() % 2 )
== 0; // even months only
x = SparseCompress( only_when, Close ); // compact
sparse data
y = MA( x, 10 ); //
regular calculation
y = SparseExpand( only_when, y ); //
expand sparse data
Plot( C, "Price", colorDefault, styleBar );
Plot( y, "Sparse MA from
even months", colorRed );
function SparseCompressEquiv( sparse_array,
data_array )
{
result = Null;
j = BarCount - 1;
for( i = BarCount - 1;
i >= 0; i-- )
{
if( sparse_array[ i ] ) result[ j-- ] =
data_array[ i ];
}
return result;
}
function SparseExpandEquiv( sparse_array,
data_array )
{
result = Null;
j = BarCount - 1;
for( i = BarCount - 1;
i >= 0; i-- )
{
if( sparse_array[ i ] ) result[ i ] = data_array[
j-- ];
}
return result;
}
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