Australian (ASX) Stock Market Forum

Amibroker FAQ

morning folks, wondering if anyone can help me!

I'm wanting to look at the performance of the market for certain dates(I'm looking at past econ data release dates). I know how to code one particular date into AFL using the datenum() function and have it print an arrow on the chart for that particular day, but how would I go about that for multiple instances( well over 150 ).

Any help greatly appreciated:)

Hi Professor --

The date you want to flag needs to be coded in or read in -- I'll leave that for another posting if it is necessary. For now, assume that the date you want to use is: July 21, 2010
The AmiBroker equivalent is: 1100721

You can see the relationship: concatenate together: (Year-1900) in three digits, month in two digits, day in two digits.

One way is to assign the date to a variable
DateOfInterest = 1100721;

For ease of programming, store the date associated with each bar in a variable:
dn = datenum(); // do this once

The code to put a signal on that date is:
SignalDate = dn == DateOfInterest;

If you want to Buy on that date:
Buy = SignalDate;

If you want to plot showing that date:
shapes = ShapeUpArrow * SignalDate;
shapecolor = colorRed;
plotshapes(shapes,shapecolor);

Or have I misunderstood?

Thanks,
Howard
 
Hi Professor --

The date you want to flag needs to be coded in or read in -- I'll leave that for another posting if it is necessary. For now, assume that the date you want to use is: July 21, 2010
The AmiBroker equivalent is: 1100721

You can see the relationship: concatenate together: (Year-1900) in three digits, month in two digits, day in two digits.

One way is to assign the date to a variable
DateOfInterest = 1100721;

For ease of programming, store the date associated with each bar in a variable:
dn = datenum(); // do this once

The code to put a signal on that date is:
SignalDate = dn == DateOfInterest;

If you want to Buy on that date:
Buy = SignalDate;

If you want to plot showing that date:
shapes = ShapeUpArrow * SignalDate;
shapecolor = colorRed;
plotshapes(shapes,shapecolor);

Or have I misunderstood?

Thanks,
Howard

Hi howard,

I've pretty well stumbled to that point by myself(though have slightly less hair to show for it!)

Basically I want to have a look at the market for every NFP release going back to the mid 90's. I have the release dates at my disposal, I'm just not entirely sure on the best way to code up all of the dates into one AFL file so that I can start testing.

Is it simply a case of having a couple of hundred different "DatesOfInterest", as you put it, then having my buy= SignalDate OR SignalDate1 OR SignalDate2,etc,etc.

Or would there be a better way of doing it?

Hope I'm making sense here!
 
Hi howard,

I've pretty well stumbled to that point by myself(though have slightly less hair to show for it!)

Basically I want to have a look at the market for every NFP release going back to the mid 90's. I have the release dates at my disposal, I'm just not entirely sure on the best way to code up all of the dates into one AFL file so that I can start testing.

Is it simply a case of having a couple of hundred different "DatesOfInterest", as you put it, then having my buy= SignalDate OR SignalDate1 OR SignalDate2,etc,etc.

Or would there be a better way of doing it?

Hope I'm making sense here!

Hi Professor --

I think there are two reasonable solutions --

You could write the dates in a plain text file, save it to disk. The dates could be in natural format (2010/08/11) planning to write AmiBroker code to translate them, or in AmiBroker format (1100811).

Begin AmiBroker.

Open that file.
In a loop, read a date, translate as necessary, determine the index number of the data array that corresponds to that date, and set the array element of the array that keeps track of dates of interest to true for that date.
close that file.

Continue with the rest of your program, referring to that array as needed.

Or --------------

You could hard code all the dates into the afl program and use a series of logic tests to decide which array elements to set.

Then continue with the rest of your program, ...

Thanks,
Howard
 
Hi Professor --

I think there are two reasonable solutions --

You could write the dates in a plain text file, save it to disk. The dates could be in natural format (2010/08/11) planning to write AmiBroker code to translate them, or in AmiBroker format (1100811).

Begin AmiBroker.

Open that file.
In a loop, read a date, translate as necessary, determine the index number of the data array that corresponds to that date, and set the array element of the array that keeps track of dates of interest to true for that date.
close that file.

Continue with the rest of your program, referring to that array as needed.

Or --------------

You could hard code all the dates into the afl program and use a series of logic tests to decide which array elements to set.

Then continue with the rest of your program, ...

Thanks,
Howard

Hi Howard,

thanks for the reply:)

I figured it out in the end. I just used excel to convert the text file of dates into the format that ami would recognise and then just copied it into an afl file for future use.

I'm aure there are more elegant ways to do it, but I stumbled through in the end!
 
I am a noob to Amibroker, I have only been playing with it and reading the manual for a few days ( I do have a programming background). I have a few questions to ask regarding that software.

1. From what I have read it AB uses arrays to hold data and perform calculations. I was wondering if there was a feature where it can load previously calculated values from a previous run, rather than recalculating these values.
For example today I create a run to figure out the trend lines for a large number of stocks. Tomorrow I wish do a run that will see if any of the stocks are in close proximity to the trend lines calculated from the yesterday's run.

2.Using the trial version it is difficult to test out the scan feature as you are limited to 5 stocks. So I wish to buy the software, but as a noob it is difficult for me judge whether the standard version will be fine, or I should get the pro version. Many of you would have been in the same position in the past, would you be able to advice me on which version I should get.

3. Data costs, I am not interested in real time data, and only after data on daily volume and price for high, low, open, close ( for the past 5 years and just the close price for the past 20 years). Which are some reliable sources for these for Australian and US stocks and how much would this set me back?

4. I am not sure of the community around Amibroker whether it is proprietary, free, shareware etc., so finding code to detect patterns like Ascending Triangles, double bottoms is it easy, costly or is it simple to write the code?

Thanks, any insight would be appreciated
 
Hi Tminus --

Your questions --

1. AmiBroker calculations are very fast. It is easier to just let AmiBroker re-compute the earlier data than write it off to a file and read it back in.

2. There is a comparison of the features of standard and pro on the AmiBroker website. If you begin with standard and want to upgrade, it is an easy upgrade -- pay the additional fee and receive a new software key by return email.

3. High quality end of day data is available from Norgate Premium Data. http://www.premiumdata.net/

Instructions for installing AmiBroker and Norgate data are available as a free download from one of my websites:
http://www.introductiontoamibroker.com/book.html
Click the "installation" link.

4. There is an extensive library of functions contributed by customers. You need to be a subscriber to access it. That library contains both wheat and chaff -- be sure to check the code carefully.

There is a large AmiBroker forum hosted on Yahoo:
http://finance.groups.yahoo.com/group/amibroker/

There are vendors of add-on indicators -- some specifically look for patterns. Here is one reputable source:
http://codefortraders.com/AmiBroker/AmiBroker_Platform.htm

Thanks,
Howard
 
Timmius,

I'll expand a bit on Howard's answer:

1 - Although AmiBroker is quite fast, if necessary you can work with files. Take a look in the Users Guide for the discussion regarding File Input/Output functions. As one with programming experience you will not have a problem.

2 - The principal reason for getting the Professional version is the ability to work with intraday data. As an EOD user you should find the standard version meets your needs.

3 - For U.S. markets, the major financial websites (e.g., Yahoo, MSN) offer free historical EOD data that they obtain from very reliable sources (e.g., CSI). I have used such data for a very long time without a serious problem and in the rare instance that a problem arises users can contact the data supplier directly, resulting in a quick fix. In my case, I use the data in other programs (primarily for charting purposes) that require Metastock format and so do not use AmiBroker's downloader but rather MLDownloader. I suspect that similar arrangements exist for Australian markets.

Bottom line - you will probably be able to do most if not all of what you have in mind.
 
Thanks for your help howardbandt and colion.

I went with the standard edition. I am using Amiquote to download US data, once I am comfortable with the application I might use Norgate for Australian data.

---
I have come across a problem, I am using to two signals that are not inversely related to each other to generate buy and sell signals. So the sell signal is triggered even when I have not bought the stock.
I searched if there was a function that can be called to check if the stock has been bought to trigger a sell, and couldn't find one.
Is it common practice to create another array to hold information if the stock has been bought.

Thanks
 

Attachments

  • sell_buy.png
    sell_buy.png
    14.2 KB · Views: 156
I have come across a problem, I am using to two signals that are not inversely related to each other to generate buy and sell signals. So the sell signal is triggered even when I have not bought the stock.
I searched if there was a function that can be called to check if the stock has been bought to trigger a sell, and couldn't find one.

Exrem removes excess buy or sell signals.

http://www.amibroker.com/guide/afl/afl_view.php?id=49
 
Timmius,

1 - Although AmiBroker is quite fast, if necessary you can work with files. Take a look in the Users Guide for the discussion regarding File Input/Output functions. As one with programming experience you will not have a problem.

2 - The principal reason for getting the Professional version is the ability to work with intraday data. As an EOD user you should find the standard version meets your needs.

3 - For U.S. markets, the major financial websites (e.g., Yahoo, MSN) offer free historical EOD data that they obtain from very reliable sources (e.g., CSI). I have used such data for a very long time without a serious problem and in the rare instance that a problem arises users can contact the data supplier directly, resulting in a quick fix. In my case, I use the data in other programs (primarily for charting purposes) that require Metastock format and so do not use AmiBroker's downloader but rather MLDownloader. I suspect that similar arrangements exist for Australian markets.

Bottom line - you will probably be able to do most if not all of what you have in mind.

A couple of comments, if I may.

1. Whenever you can, work with the memory-based functions of AmiBroker (or any programming language). File access is very slow -- tasks that take milliseconds using variables will take seconds using files.

2. The standard version of AmiBroker works with intra-day data down to a resolution of one minute bars. The limitation that requires the professional version comes when you want to use very short (measured in seconds) time-based bars or tick bars. Here is the link to the AmiBroker site's comparison of the two versions:
http://www.amibroker.com/guide/versions.html

3. I'll make a few general comments about data:
A. Consistency is worth as much as accuracy. I recommend that you always use the same data source for trading that you use for system development. If you eventually plan to use high quality data (as in Norgate), you will want to revisit all your earlier development work using the high quality data before you begin trading those systems -- so consider starting with it.
B. Data from msn and Yahoo Finance are "free" in the sense that there is no subscription fee. They have many data errors and inconsistencies. There will be times when they do not agree with each other. Errors are resolved slowly or never. If you use msn or Yahoo data your new hobby will be data maintenance, it will take a lot of time, and you will often not know what the correct value is when you are trying to resolve some data issue. I use msn and / or Yahoo only when the data series I want to use is not provided by the subscription vendor -- which is very rare. In fact, I do not have a finished trading system that uses any data that comes from msn or Yahoo Finance. If you want to use data from CSI, and have it supported by CSI, subscribe to CSI.
C. AmiBroker has built-in interfaces for many high quality data vendors. I recommend using these whenever they are available. As you work with AmiBroker, you will progress from being new to the program and fiddling with the graphic interface to being a competent trading system developer working with statistical validation of your latest ideas. Use the tools provided to remove as much of the detail-level effort as you can and allow you to work on the ideas.

Thanks for listening,
Howard
 
A couple of comments, if I may.

1. Whenever you can, work with the memory-based functions of AmiBroker (or any programming language). File access is very slow -- tasks that take milliseconds using variables will take seconds using files.

2. The standard version of AmiBroker works with intra-day data down to a resolution of one minute bars. The limitation that requires the professional version comes when you want to use very short (measured in seconds) time-based bars or tick bars. Here is the link to the AmiBroker site's comparison of the two versions:
http://www.amibroker.com/guide/versions.html

3. I'll make a few general comments about data:
A. Consistency is worth as much as accuracy. I recommend that you always use the same data source for trading that you use for system development. If you eventually plan to use high quality data (as in Norgate), you will want to revisit all your earlier development work using the high quality data before you begin trading those systems -- so consider starting with it.
B. Data from msn and Yahoo Finance are "free" in the sense that there is no subscription fee. They have many data errors and inconsistencies. There will be times when they do not agree with each other. Errors are resolved slowly or never. If you use msn or Yahoo data your new hobby will be data maintenance, it will take a lot of time, and you will often not know what the correct value is when you are trying to resolve some data issue. I use msn and / or Yahoo only when the data series I want to use is not provided by the subscription vendor -- which is very rare. In fact, I do not have a finished trading system that uses any data that comes from msn or Yahoo Finance. If you want to use data from CSI, and have it supported by CSI, subscribe to CSI.
C. AmiBroker has built-in interfaces for many high quality data vendors. I recommend using these whenever they are available. As you work with AmiBroker, you will progress from being new to the program and fiddling with the graphic interface to being a competent trading system developer working with statistical validation of your latest ideas. Use the tools provided to remove as much of the detail-level effort as you can and allow you to work on the ideas.

Thanks for listening,
Howard

A few comments on your comments.

As noted, I certainly agree about the speed issue associated with using files. However, there are instances where that is desired and then the file input/output functions work quite well. Also, in general, the difference in speed between using files and memory for an EOD trader is often not of great importance. Likewise, based on my experience it is also not of great importance for discretionary, as opposed to mechanical system, traders.

Your comments suggest that you have not used the free data services. For an extended time before switching to Yahoo I used both CSI and Yahoo at the same time and did not find any inconsistencies. So, my experience is quite different from your description. In both cases, it was sometimes necessary to bring an error to CSI's attention and then it was fixed by the next update.

In addition, during the time that I obtained data from both errors in one were simultaneously corrected in the other. I assume that this is still the case although I now rely solely on Yahoo and have no more problems than I had with CSI. For this not to be the case, CSI would have to keep a database for CSI subscribers and one for 'mass' subscribers. I have not seen any evidence for this and doubt that is the case. I would be surprised if this did not apply also to other 'mass' subscriber data suppliers (e.g., Reuters, Morningstar, etc.).

To be sure, the pay-for-data sources often provide other services above and beyond Yahoo, MSN, Google, etc. However, after watching the rants on the AmiBroker board through the years has convinced me that those who claim that these sources are providing inferior data are (1) speaking without evidence and/or (2) simply trying to justify their subscription fees when all they need is quote data. Based on my experience, as well as the absence of a convincing argument to the contrary, it is hard for a 'simple data' type such as myself to justify leaving the 'mass' suppliers but I would be the first to cut them off if evidence for doing so was presented. Until that time I'll remain dumb and happy as long as my equity curve goes up without significant inconvenience.
 
Your comments suggest that you have not used the free data services.

Hi Colion --

I have used both msn and Yahoo free data extensively, and I do maintain databases with that data so that I can replicate results obtained by other people when I work on joint projects. It is precisely because of my experience with msn and Yahoo data that I made the comments I did.

That not withstanding, if those data sources work for you, by all means continue using them. I have no vested interest in any subscription data service, and am only trying to ease the learning curve for people new to technical analysis and trading system development.

Thanks,
Howard
 
Hi Colion --

I have used both msn and Yahoo free data extensively, and I do maintain databases with that data so that I can replicate results obtained by other people when I work on joint projects. It is precisely because of my experience with msn and Yahoo data that I made the comments I did.

That not withstanding, if those data sources work for you, by all means continue using them. I have no vested interest in any subscription data service, and am only trying to ease the learning curve for people new to technical analysis and trading system development.

Thanks,
Howard

I'd be interested in some examples of differences between Yahoo and your 'good' supplier. I use indices and ETFs so data within that group would be helpful.
 
I am new to Amibroker and programming language and need some help with a basic thing. I have the following code based on something from an amibroker newsletter. Its purpose is to automate importing data from a file with comsec data. It is saved as myimportscript.js in amibroker formats. The format file is what I use when I download the data through Import wizard. When I try to run it, the window Script host box says its a Jscript compilation error. Details line 4, char. 22 expected identfier. Can anyone tell me what it wants and why?
Any help will be greatly appreciated.

/* Create AmiBroker application object */
AmiBroker = new ActiveXObject( "Broker.Application" );

function Import( "C:\program files\amibroker\Comsec data\asxequitiesMetastock-20091028")
{

/* import the data using appropriate format definition file */
AmiBroker.Import( 0, "C:\program files\amibroker\Comsec data\asxequitiesMetastock-20091028", "My own format" );
/* refresh ticker list and windows */
AmiBroker.RefreshAll();


:confused:Andy
 
Colion, I suggest you have a look at the "Best Data for me?" thread:

https://www.aussiestockforums.com/forums/showthread.php?t=18057

Gav, that thread is just about Norgate and not a comparison of data quality between suppliers ('prime' or 'mass'). The only rating that I know of was done by Futures Magazine in 1999 in an article titled "How Clean is Your End-of-Day Data" in which they rate 'prime' data suppliers (e.g., CSI, Reuters, etc.), address some of the reasons for differences, and the effect of differences on a sample trading system (http://www.csidata.com/csi/reviews/reprintsep99.html). Ratings are, of course, somewhat of a moving target as technology and practices change and so the ratings might no longer be valid.

For purposes of this thread, however, it would be good if a comparison was made of the free end-of-day suppliers (e.g., Yahoo, MSN, Google, etc.) and their suppliers (e.g., CSI, Reuters, etc.). As I mentioned, my monitoring (informal by eye of indices and ETFs) of CSI and historical (as opposed to current) Yahoo data did not turn up any problems between the two. For my purposes, I am only interested in end-of-day O, H, L, C, V data and so the freebies appear to be OK and will remain so at least until I return from vacation :)
 
I have managed to create a link from Comseciress to an excel spreadsheet and then to Amibroker and am getting 1 minute bars with realtime data (without volume - volume isn't essential for the purpose in mind). Please disregard my previous question above as it would not help me much.

The problem now is naming the cells in the excel spreadsheet. There are about 1200 tickers each with a cell for open high low last and volume. Does anyone know how to automate the naming of cells in excel? The naming format I am using is eg. AAC_last. That is a combination of the ticker names (listed in column A) and open, high, low, last and volume (columns C, D, E, F and G) separated with an underscore.

Any help would be muchos appreciados.

Andy
 
I have managed to create a link from Comseciress to an excel spreadsheet and then to Amibroker and am getting 1 minute bars with realtime data (without volume - volume isn't essential for the purpose in mind). Please disregard my previous question above as it would not help me much.

The problem now is naming the cells in the excel spreadsheet. There are about 1200 tickers each with a cell for open high low last and volume. Does anyone know how to automate the naming of cells in excel? The naming format I am using is eg. AAC_last. That is a combination of the ticker names (listed in column A) and open, high, low, last and volume (columns C, D, E, F and G) separated with an underscore.

Any help would be muchos appreciados.

Andy

Is this what you are after?

Do a copy & paste special, values.
 

Attachments

  • ASF_ami_faq.JPG
    ASF_ami_faq.JPG
    101.6 KB · Views: 9
  • ASF_ami_faq.xls
    17.5 KB · Views: 7
Thanks Superglue but I am trying to name the cells eg. in your cell C3, you can name the cell by Insert>Name>Create and type aac_open. Easy enough to do for a few cells but not 6000 times.
 
Top