amibroker

HomeKnowledge Base

How to display Bond and Bill prices in fractions

Treasury Bond and Bill futures are traded in fractions, not decimals. A typical bond quote may be 124’21 which means 124 and 21/32nds, so one needs special method to display prices in non-decimal format.

To achieve desired result we need to do two things.

1. Switch Y axis grid to desired fraction format. To make a change, right click on the chart and select Parameters, then switch to Axes & Grid tab and change Grid Format as shown below:

Parameter Window

2. Create a price chart with custom title showing fractions instead of decimals. Go to Analysis->Formula Editor, enter the following formula and press Apply Indicator toolbar button.

function NumToFracnum )
{
  return 
StrFormat("%.0f'%0.f"floornum ), fracnum ) * 320 );
}
PlotClose"Close"colorDefaultstyleCandle);
Title "{{NAME}} - {{INTERVAL}} {{DATE}} Close: " NumToFracClose )

The NumToFrac function formats decimal value into full points and 1/320nds fraction of the full point.

Too small / unreadable Profit Table in the backtest report

Some of users may observe that their Profit table is too small, so the numbers get truncated or the text is too small.

First let me tell you that profit table in the backtest report is not really a table, but a bitmap image with fixed dimensions. Profit table, like any other user-definable report chart, is created by running an AFL formula present in the “Report charts” subfolder. The chart is rendered into bitmap image that gets later embedded in the backtest report.

The size of backtest report images depends on Analysis window settings. In order to increase the size of generated images, it is necessary to go to Analysis -> Settings, Report tab and increase the picture dimensions:

reportchartdim

Once you change it, newly generated reports will use enlarged image dimensions. Adjusted settings will affect new backtests only, but not the old reports that have already been generated.

Tip: You can create your own report charts by placing your own AFL formula in the “Report charts” subfolder.

Webroot antivirus prevents clipboard Paste function

If you are using Webroot Secure Anywhere (antivirus) please be aware that it causes problems with Windows Clipboard, preventing Edit->Paste from operating in many applications including the new AFL editor.

The solution is to go to Webroot Identity Protection settings and turn OFF Identity Shield.

The issue affects many applications and is described in detail on their forum:
https://community.webroot.com/t5/Webroot-SecureAnywhere-Complete/Copy-Paste-Stops-Working-in-some-applications/td-p/21588/page/4

Why do backtest results change?

From time to time we receive questions about why you can get different results back-testing the same code.

There are many reasons for differences in backtest results:

  1. Different data

    For example if past history is updated/changed due to splits for example or backfill or external data update.

  2. Different settings / parameters

    May happen if your formula uses Param() functions that output values that may be changed from the Parameter window.

    Note that Parameters in Analysis window use shared ChartID=0, which means that if two formulas use same parameter names they would share parameter values as well.

  3. Different formula

    Sometimes even slight change to the formula causes big change in the results, for example if your formula uses #include and included code has changed

  4. The formula that self-references its previously generated results.

    Such code produces some data that is later used to produce next run output (for example your code produces composites that are later used – if those composites change – the input data change so the results change, or if your formula uses previous backtest equity or if your formula uses STATIC variables without deleting/clearing them at the beginning)

  5. The formula uses random number generator

    This occurs when your formula directly or indirectly calls any function that produces random numbers such as Random or mtRandom

  6. The formula reads external files/data that might have changed

    This occurs when your formula directly or indirectly calls any functions that read external files or data that have changed between backtests. It can be as trivial as using current time in your formula.

  7. The formula sets global (per-backtest) settings to non-constant value – for example sets global option differently for each symbol.

    This one is subtle and can be easily overlooked by non-experienced users. One has to understand that global (per-backtest) settings are applied to entire portfolio. If one changes those settings on per-symbol basis, then “last write” counts, and it means that result of your backtest will depend on which execution thread ended last. In Windows OS, it is generally unpredicatable which thread ends first because of so many factors that affect execution time. So your backtest may use different settings in different runs as a result of this. Bottom line: never change global settings in your formula to non-constant value.

AmiBroker on tablets and smartphones

AmiBroker is a Windows-only application, so you can not run it natively on iPad, iPhone, Android tablets or smartphones or other devices operating an ARM processor.

To run AmiBroker natively on tablet, you need a tablet with full Windows version and Intel processor. There are plenty of such tablets available, some of them very competitively priced: MS Surface Pro (pricey) and Asus Transformer T100, Dell Venue 8 Pro, Acer Iconia W4-821 which are very nicely done and extremely well priced.

You can also consider using remote access tools like TeamViewer or LogMeIn and just accessing your PC over the web from your tablet and/or smartphone.

AmiBroker on an Apple Mac (OSX)

AmiBroker is a Windows application and does not have native Mac version, however we do have many Apple Mac users, who use Parallels (www.parallels.com) virtualization software in order to run AmiBroker on Mac and AmiBroker works perfectly fine in such configuration.

Lost activation key

In case you lost your AmiBroker activation key please fill the form at:
http://www.amibroker.com/lostkey.html
Once you fill the form, you will have the registration e-mail resent automatically.

Then check your e-mail inbox, there will be an e-mail with the download link to your personal activation key. Download the file, run the activation wizard and AmiBroker will become fully activated.

Please note that the activation keys for 32-bit and 64-bit are separate so you should make sure you are using one that matches your installed AmiBroker version. To check AmiBroker version, go to Help->About menu. Note also that 64-bit version is available only to owners of Professional Edition license (or Ultimate Pack Pro).

Using Zig-Zag in trading systems

Zig-zag indicator, as well as other functions using it (Peak/Trough, PeakBars, Troughbars), inherently look into the future. As such they should not be used in trading system formulas without taking precautions. The only way to fix the ‘problem’ is to delay the signal as long as it takes for zig/zag to stabilise last ‘leg’. The delay is variable and depends how much time it takes for defined percentage change to occur in the price series since last peak/trough.

Ready-to-use solution is presented in the Traders’ Tips section of the AmiBroker members area:
http://www.amibroker.com/members/traders/11-2003.html

(NOTE: access to members’ area is limited to licensed users only, if you forgot your password use reminder at http://www.amibroker.com/login.html)

Points-only backtest

Some users coming from Metastock ask for “points-only” test.

One needs to know that AmiBroker features way more sophisticated futures mode than MS ever had: http://www.amibroker.com/guide/h_futbacktest.html
It provides full support for futures trading, handling margin deposit, point value, etc.

“Points-only” test is kind of the simplest possible case, but if you want to do just that, it can be implemented using these two lines:

SetOption("FuturesMode"True );
SetPostionSize1spsShares ); // trade just 1 contrac

That is all what you need to add to your formula to get point-only test.

Third-party plugins must ship with proper runtime

From time to time we receive questions from people having problems loading some unknown third party plug-ins. These plug-ins are most commonly written by some hobby programmers who don’t know how to compile and ship the plug-ins so they work on client machines.

When plug-in DLL is written with AmiBroker Development Kit (ADK) it is usually compiled with Microsoft C runtime library. The “problem” is that depending on compiler used, different versions of C runtime are required for the DLL to be loaded by the operating system.

For example Visual C++ 6.0 links against MSVCRT.DLL that is commonly found in all Windows starting from Windows XP so you can “forget” about installing the runtime. But when plugin is compiled with more recent Visual C++ 2005, 2008 or 2010 then required C runtime library is almost never present on client computer.

In order to load the plugin compiled with VC2005 or higher, one must install proper run-time library on the client computer. The runtime must exactly match the compiler version and eventual compiler service pack used to compile the DLL, otherwise operating system will not load the DLL. The developer of 3rd party DLL can find appropriate runtimes (vcredist.exe) in

VCInstallDir\SDK\v2.0\Bootstrapper\Packgages\vcredist_x86
or
VCInstallDir\SDK\v2.0\Bootstrapper\Packgages\vcredist_x64

or similar directory (depending on VC version he/she is using). Then such vcredist.exe must be shipped by the plugin vendor to the client for the installation.

Alternatively the plugin vendor can compile their DLL with static runtime library.

There is a freeware tool called Dependency Walker (http://www.dependencywalker.com/) that allows to check what given DLL needs to be loaded by the operating system. Tell your plugin vendor to use that tool so they don’t miss the essential dependencies.

« Previous PageNext Page »