- Joined
- 13 June 2007
- Posts
- 838
- Reactions
- 136
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 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
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.
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
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
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.
Colion, I suggest you have a look at the "Best Data for me?" thread:
https://www.aussiestockforums.com/forums/showthread.php?t=18057
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
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?