GeneralMy 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?
PluginI have clicked "Install Plugin" under Integration > AmiBroker but continue to see that the plugin hasn't been installed. What could be wrong?
DatabaseHow 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?
Watch ListsHow 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 TestingHow 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?
My trading system gives anomalous results when using AmiBroker's Pad & Align setting. How do I fix this?
Why does the current bar show in a chart, but an exploration can only see the previous day?
HelpWhere can I get help on using AmiBroker?
There is a setting in AmiBroker for "Number of bars". Click File > Database settings to increase the number of bars.
There is a setting in Amibroker to "Pad non-trading days". Select the View menu and make sure that this setting is
There is also a setting in the Norgate Data plugin to control Date Padding. To check the current setting, click File > Database settings > Configure.
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.
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:
- set "Time stamp of compressed intraday bars shows:" to "START time of interval (recommended)", and
- check "Override: Weekly/monthly bars use day of last trade."
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,"%","_");
You may have copied the AmiBroker folder over from another machine without actually installing AmiBroker. If so, you will need to run AmiBroker setup. See How to migrate AmiBroker to a new computer for more information.
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).
Check to see that the database still has the Norgate Data plug-in assigned as its data source (File > Database settings).
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.
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.
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:
- Market ID > 200
- Group ID > 200
- Symbol starts with a tilde "~"
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 1The "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.
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.
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.
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.
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).
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)
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.
The list created by AmiBroker will not reflect a symbol change should it occur.
Run database maintenance in AmiBroker
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;
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. There are at least two ways of solving this issue.
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:
- Do you have enough equity to cover the margin required for a round lot?
- What is your base currency set to (Tools > Preferences > Currencies)? If your base currency is different to the currency of the Futures contract then your available equity may have been reduced due to the currency conversion.
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?
Before comparing results -
- 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.
- 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".
- 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.
- 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.
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).
When there is no trading on a particular day, the "Pad and align data to reference symbol" setting in AmiBroker copies the entire OHLC from the previous bar to the current day. The AmiBroker backtester also allows trades to be taken on padded dates.
The Norgate Data plugin takes a different approach to date padding. When used, if there are no trades on a given date the previous Close (only) is copied to the OHLC fields of the padded day and the Volume is set to zero.
To determine whether a given date is padded in the data set, you can use the NorgatePaddingStatusTimeSeries() indicator. This can be used in your Buy, Sell, Short and Cover rules to prevent a trade signal from being generated on a padded date. To make of use it, simply add the following to your trade condition:
This can occur when you use Pad & Align with multiple markets - referencing a symbol from one market that has a different set of dates than the current chart. For example, you are looking at an Australian stock, but your Pad & Align field is set to use a US stock index like $DJI which hasn't yet traded for that date. For any exploration, you should set the Pad & Align field appropriately and save your analysis settings into its own .apx file.
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.