NORGATE DATA

 

AmiBroker FAQ

General

My charts only show a limited amount of data - how do I fix this?
My charts show non-trading days such as weekends and holidays - how do I remove them?
I see gaps in Markets/Groups - how do I remove them?
I see some strange Time Series indicator values on my weekly/monthly charts or in my analyses - how do I fix this?
What names should I use for dynamic/static variables in the VarSet and StaticVarSet functions?

Database

How do I find the location of my AmiBroker/NorgateData database folder?
My AmiBroker/NorgateData database is no longer updating. What's the first thing I should check?
Why does AmiBroker frequently show that "MAINT" is required?
Why won't Database Maintenance start when I right-click on "MAINT"?
How do I incorporate data from elsewhere into the AmiBroker/NorgateData database?
How do I create a fresh Symbols list in the AmiBroker/Norgate database?
How can I create a fresh NorgateData database in AmiBroker?
With "Configure NorgateData plug-in" and the options for "Price & Volume Adjustment", what events count as "Capital reconstructions" and "Special Distributions"?

Watch Lists

How do I re-order the Watch Lists? (I would like to move my favourite Watch Lists to the top).
What is the best way to reference Watch Lists in AFL?
How do I bring in my personal Watch Lists from another AmiBroker database?
What's the difference between a "static" Watch List created by AmiBroker and one created by NDU for use in AmiBroker?
I've created a Watchlist using NDU and it doesn't appear in AmiBroker. What do I need to do?

System Testing

How can I increase the speed of AmiBroker Scans/Explorations/Backtests?
How do I exit a position in a backtest prior to a stock being delisted?
Why does my trading system backtest only give signals from a particular date onwards rather than from the start of the backtest?
Why do I get "Error 47" on a backtest? (I am using SetForeign/RestorePriceArrays)
When backtesting Futures, I receive the error message "not entered because requested size is less than minshares/minposvalue" or "not entered because of insufficient funds or wrong position size/value". How do I fix this?
My trading system backtest shows a different sequence of trades than previously recorded. How could that be possible?
My trading system backtest results are different from one PC to another. What are possible reasons for this?
My trading system shows trades with anomalous position values and profit levels. How do I fix this?

Help

Where can I get help on using AmiBroker?



My charts only show a limited amount of data - how do I fix this?

There is a setting in AmiBroker for "Number of bars". Click File > Database settings to increase the number of bars.

My charts show non-trading days such as weekends and holidays - how do I remove them?

There is a setting in Amibroker to "Pad non-trading days". Select the View menu and make sure that this setting is unticked.
There is also a setting in the Norgate Data plugin to control Date Padding. To check the current setting, click File > Database settings > Configure.

I see gaps in Markets/Groups - how do I remove them?

Click on the icon to the right of the Symbols Search arrow in AmiBroker and a drop-down box will appear. Make sure that "Hide empty markets" and "Hide empty groups" are ticked.

I see some strange Time Series indicator values on my weekly/monthly charts or in my analyses - how do I fix this?

This problem can occur when certain settings for weekly or monthly bar dates generated by AmiBroker are used.
To fix this, in AmiBroker go Tools > Preferences > Intraday and:

What names should I use for dynamic/static variables in the VarSet and StaticVarSet functions?

AmiBroker has a strict requirement that variable names only contain the following characters: A-Z, 0-9 and _. If you try to include portions of the current symbol in the variable name you will receive errors on some symbols such as BRK.B, ARNC-, $SPX etc.

You can use a simple string substitution to ensure that your variable names follow the AmiBroker requirements, eg:

        varname = "myvar_" + Name();
        varname = StrReplace(varname,".","_");
        varname = StrReplace(varname,"-","_");
        varname = StrReplace(varname,"#","_");
        varname = StrReplace(varname,"$","_");
        varname = StrReplace(varname,"@","_");
        varname = StrReplace(varname,"%","_");
        

How do I find the location of my AmiBroker/NorgateData database folder?

The location is recorded by NDU. Open NDU and click on Integration > AmiBroker. (You should exclude this folder from real-time Anti-virus/malware checking for best performance).

My AmiBroker/NorgateData database is no longer updating. What's the first thing I should check?

Check to see that the database still has the Norgate Data plug-in assigned as its data source (File > Database settings).

Why does AmiBroker frequently show that "MAINT" is required?

Maintenance is flagged as being required even if just a single bit of "background" information changes. NDU supplies fundamentals, metadata and dynamic Watch Lists for stocks (in addition to price and volume data), so there are many bits of information that can change.

Why won't Database Maintenance start when I right-click on "MAINT"?

The currently-selected (active) symbol may be an imported symbol where "Use only local database" is set to "Yes". Navigate to a non-imported symbol (one supplied by Norgate Data) and try again.

How do I incorporate data from elsewhere into the AmiBroker/NorgateData database?

AmiBroker allows you to import data into a database (for instructions, refer to the AmiBroker Knowledge Base). However, imported symbols will be removed from the NorgateData database each time you run "Database Maintenance" unless at least one of the following conditions is met:

If you are creating your own Composite securities within AmiBroker, you must use the CategoryAddSymbol() function to put your new composite security into one or more of the above categories. e.g.:

        CategoryAddSymbol(Name(),CategoryMarket,201);
        CategoryAddSymbol(Name(),CategoryGroup,201);
If you are using the ASCII Import Wizard, you can use the following lines to assign a stock to a particular market/group:
        $MARKET 201
        $GROUP 201
        $USEONLYLOCALDB 1
The "Use only local database" setting is required, otherwise the data will not be saved into the database correctly.

If you have manually created a new symbol in AmiBroker, you will need to view the Information for that symbol (Window > Symbol Information) and set "Use only local database" to "Yes". The Market and Group should also be set to 201 or higher.

How do I create a fresh Symbols list in the AmiBroker/Norgate database?

You may want to create a fresh Symbols list if some empty symbols have found their way into the database and can't be removed. Firstly, close AmiBroker. Then navigate to the database folder using Windows (File) Explorer and delete the file "broker.master". This file will be re-built when AmiBroker is next opened.

How can I create a fresh NorgateData database in AmiBroker?

Step 1: Ensure that the AmiBroker NorgateData database is not the default AmiBroker database.
If required, change the default database path and then close AmiBroker.

Click here for more information

Step 2: Confirm the location of the AmiBroker NorgateData database folder.
This information is shown in NDU under Integration > AmiBroker.

Step 3: Use Windows Explorer to rename the existing folder.
For instance, rename "c:\Program Files\AmiBroker\NorgateData" to "c:\Program Files\AmiBroker\NorgateData (old)".
It is advisable to rename the existing folder rather than just delete it, in case there are Watch Lists and/or other information that you wish to preserve and transfer to the new database folder.

Step 4: Create a new NorgateData database in AmiBroker.
Follow the database creation instructions on this page.

With "Configure NorgateData plug-in" and the options for "Price & Volume Adjustment", what events count as "Capital reconstructions" and "Special Distributions"?

Capital reconstructions include splits & consolidations (reverse splits), capital returns, bonus issues (stock dividends) and right issues.
Special distributions include special dividends and distributions associated with spin-offs.

How do I re-order the Watch Lists? (I would like to move my favourite Watch Lists to the top).

There is a file called "index.txt" associated with every AmiBroker database. This file is found in the "WatchLists" sub-folder (e.g. "c:\Program Files\AmiBroker\NorgateData\WatchLists"). To re-order your Watch Lists, first of all make sure that AmiBroker is closed. Then open the index.txt file and change the order of the entries (make sure to move the entries rather than copy them, as the system cannot tolerate duplicates).

What is the best way to reference Watch Lists in AFL?

We recommend the use of the InWatchListName function to reference Watchlists in AFL code as opposed to using Watchlist numbers. This is because Watchlist numbers are problematic in the face of changes to the Watchlist order or removal of Watchlists.

InWatchListName("watchlist name here")
An alternative to using the InWatchListName function is to use the Watchlist Name to look up the Watchlist number as follows:
wlnumber = CategoryFind("watchlist name",categoryWatchList)

How do I bring in my personal Watch Lists from another AmiBroker database?

Each AmiBroker database folder has its own "WatchLists" sub-folder. This sub-folder contains *.tls files. Copy the relevant *.tls files from one "WatchLists" sub-folder to the other.

What's the difference between a "static" Watch List created by AmiBroker and one created by NDU for use in AmiBroker?

The list created by AmiBroker will not reflect a symbol change should it occur.

I've created a Watchlist using NDU and it doesn't appear in AmiBroker. What do I need to do?

Run database maintenance in AmiBroker

How can I increase the speed of AmiBroker Scans/Explorations/Backtests?

  1. Put your data onto a secondary SSD drive (or purchase an SSD drive to replace your main system drive). Solid State Drives increase performance significantly.
  2. Upgrade to the Professional Edition of AmiBroker, which can utilize all of the processing cores on your CPU (backtesting with the Standard edition of AmiBroker is limited to two simultaneous threads).
  3. Install a 64-bit version of Windows so that you can use the 64-bit version of AmiBroker Professional Edition. 64-bit CPU operations are significantly quicker than 32-bit. The 64-bit Professional Edition of AmiBroker can also better utilize all available RAM.
  4. Prevent your antivirus scanner from doing real-time scanning on your data folders (i.e. exclude both the NDU database and your AmiBroker database from real-time scanning). Since the data folders do not contain any executable files that need constant monitoring, this significantly decreases the CPU load by bypassing the virus checking on these large folders. You can determine your NDU database location by starting NDU and clicking the Database tab. You can determine your AmiBroker database by starting NDU and clicking Integration->AmiBroker
  5. Change the AmiBroker settings for "In-memory cache size". These settings are established under Tools > Preferences > Data. If you have at least 2GB of RAM, you could increase "Max. MegaBytes" to 1000. The 64-bit version of AmiBroker allows even higher settings. For instance, you could use a setting like 6000 MB given something like 16 GBs of RAM. As long as all of the data can fit into RAM, the second run (and all subsequent runs) will go very fast. You can monitor AmiBroker's cache usage by clicking Tools > Performance Monitor. The setting for "Max. Symbols" may also be increased to the limit of 20,000. However, a run should never be performed on more symbols than is necessary (see below).
  6. Where applicable, use "Filter" to restrict your runs to a pre-defined universe of symbols. For instance, when using the NorgateIndexConstituentTimeSeries function to run a back-test against the constituents of a particular index, use "Filter" to select the relevant Watch List for that index. This will provide a faster result than running the test against all symbols.
  7. Where applicable, when creating a database, set the "numbers of bars" to the lowest possible value. For instance, if a scan or exploration only requires 12 months of data, change the "number of bars" accordingly (File > Database settings). 12 months is approximately 250 bars. For backtesting you will probably want a higher number of bars to test against. Note: Once initially set, AmiBroker will not reduce the number of bars in its cache, so lowering the number will not subsequently help. It may be easier to have one database for scans, and one for backtesting.

How do I exit a position in a backtest prior to a stock being delisted?

Assuming a trade delay of 1 bar, you need to have an "exit" signal on the second last bar to simulate exiting a delisted stock. This will cause AmiBroker to exit the position on the final day of trading. You also want to avoid entering any new positions during the final 2 days.

OnSecondLastBarOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() == (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") ) ;
OnLastTwoBarsOfDelistedSecurity = !IsNull(GetFnData("DelistingDate")) AND (BarIndex() >= (LastValue(BarIndex()) -1) OR DateTime() >= GetFnData("DelistingDate") );

Buy = Buy AND NOT OnLastTwoBarsOfDelistedSecurity;
Sell = Sell OR OnSecondLastBarOfDelistedSecurity;

// If you have a short selling system you will also need to include the following:

Short = Short AND NOT OnLastTwoBarsOfDelistedSecurity;
Cover = Cover OR OnSecondLastBarOfDelistedSecurity;
        

Why does my trading system backtest only give signals from a particular date onwards rather than from the start of the backtest?

If you are using any sort of rotational backtest or ranking backtest (where you iterate through each stock and generate rankings at the start of the test), AmiBroker will use the start date of the first security in the exploration or backtest. When you are testing against listed and delisted stocks that have different IPO dates and delisting dates, it may be very difficult to find a security that traded for every day of the backtest period.

Click here for more information

Why do I get "Error 47" on a backtest? (I am using SetForeign/RestorePriceArrays)

In AmiBroker versions prior to v6.13, when SetForeign is used, AmiBroker needs to keep the contents of the foreign symbols in its in-memory cache. If the number of foreign symbols accessed exceeds the cache size then error 47 will be given. You should increase the In-memory cache size in Tools > Preferences > Data. Ensure that "max. symbols" and "max. MegaBytes" have enough size to cache all symbols. Alternatively, upgrade to AmiBroker v6.20.1 or above.

When backtesting Futures, I receive the error message "not entered because requested size is less than minshares/minposvalue" or "not entered because of insufficient funds or wrong position size/value". How do I fix this?

Futures can only be traded in whole contracts (i.e. "round lots"), so the RoundLotSize in AmiBroker is set to 1 (unlike stocks where RoundLotSize=0). Backtests on Futures can be quite sensitive to this setting.

Here are some things that you can check:

My trading system backtest shows a different sequence of trades than previously recorded. How could that be possible?

You may be testing on a particular class of stocks where membership of the class is not fixed and no information exists as to historical membership. For instance, you may be testing on "Nasdaq" stocks. If a stock that was previously listed on Nasdaq changes to NYSE, then any trades previously recorded for the stock will disappear from the backtest. Similarly, if you are backtesting on stocks in a particular sector or industry.

Further information can be found in the AmiBroker Knowledge Base article Why do backtest results change?

My trading system backtest results are different from one PC to another. What are possible reasons for this?

Before comparing results -

  1. Make sure that the two machines have been brought up-to-date to the exact same point, with respect to both NDU data updates and AmiBroker database maintenance.
  2. Check that the Norgate Data plugin settings are the same. To check the settings, open the NorgateData database in AmiBroker and click File > Database settings. Take a note of the "Number of Bars". Then click "Configure" and note the settings for "Data Padding" and "Price & Volume Adjustment".
  3. Check that the AmiBroker Preferences settings are identical (Tools > Preferences). In particular, check the settings for -
    Currencies > Base currency
    Intraday > START time of interval (recommended)
    Intraday > Override:Weekly/monthly bars use day of last trade.
  4. Check that the AmiBroker Analysis/Backtester settings are identical. You can save these settings to a .APX file and then compare the APX files from both machines. Further information can be found in the AmiBroker Knowledge Base article How to synchronize backtesting setup on different computers.

My trading system shows trades with anomalous position values and profit levels. How do I fix this?

AmiBroker returns the results from backtesting in the selected "base currency". It converts the currency from the security's trading currency to the base currency at each point of the trade to determine the Position Value and Profit/Loss amounts. In AmiBroker go Tools > Preferences > Currency and set the base currency as required (eg: Australian traders may want to select AUD).

Where can I get help on using AmiBroker?

For help with using AmiBroker see the AmiBroker website. The AmiBroker staff are also quick to respond to support emails.
Some good books have been written on AmiBroker by Howard Bandy: Introduction to AmiBroker, Quantitative Trading Systems and Advanced AmiBroker.

There are also some AmiBroker user forums available on the Internet - AmiBroker Yahoo Group, and the Unofficial AmiBroker Users Forum.

Should you require it, paid assistance is also available from AmiBrokerCoding.Com, TheChartist and Alvarez Quant Trading.