| AmiBroker Tips weekly newsletter.
Copyright (C)2000 Tomasz Janeczko.
All back issues available from:
Welcome to the 5th issue of AmiBroker Tips newsletter.
The main topic of this issue is how to remove stocks that are no longer traded
from your database in automatic fashion. AFL corner features Aroon Up/Down indicator.
By the way: Do you find this newsletter useful? Have any comments/suggestions or article ideas. Please don't hesitate to drop a line to email@example.com
The Aroon indicator was developed by Tushar Chande. Aroon is Sanskrit word
meaning "dawn's early light" or the change from night to day. The
Aroon indicator allows you to anticipate changes in security prices from trending
to trading range. The indicator uses two lines: Aroon Up and Aroon Down. Aroon
Down is a measure of how close the current bar is to the most recent lowest
Low bar found in the last N bars. Aroon Up is a measure of how close the current
bar is to the most recent highest High bar found in the last N bars. Additionally
Aroon oscillator can be defined as the difference between the Aroon Up and Aroon
Down indicators. For more information on the Aroon indicator see the article
written by Tushar Chande in the September 1995 issue of Technical Analysis of
Stocks & Commodities magazine.
Aroon indicator ranges from 0 to 100 and it is drawn with additional 30/70 levels. The default period is 14 days. The indicator works as follows: if a security makes a new 14-day high, the Aroon Up = 100; when the security makes a new 14-day low, the Aroon Down = 100; when there was no new high in 14 days, the Aroon Up = 0; and consequently when there was no new low for 14 days, the Aroon Down = 0.
Aroon indicator is an another way (in addition to VHF and ADX indicators) of
detemining if market is trending or not. The AFL formula for the indicator is
L14 = LLV( Low, 14 );
H14 = HHV( High, 14 );
100* (14 - (( IIF(Ref(L,-1) == L14 ,1 , IIF( Ref(L ,-2 ) == L14 ,2 , IIF( Ref(L ,- 3 ) ==
L14 ,3 ,IIF( Ref(L ,-4 ) == L14 ,4 ,IIF(Ref( L ,-5 ) == L14 ,5 ,IIF(Ref(L ,-6 ) ==
L14 ,6 ,IIF( Ref(L ,-7 ) == L14 ,7 ,IIF(Ref( L ,-8 ) == L14 ,8 ,IIF(Ref( L ,-9 ) ==
L14 ,9 ,IIF( Ref(L,-10) == LLV(L,14 ) ,10 ,IIF(Ref(L ,-11) == L14 ,11 ,IIF(Ref(L,-12 ) ==
LLV(L ,14) ,12,IIF( Ref(L,-13) == LLV(L ,14 ) ,13 ,IIF( Ref( L,-14) == L14 ,14 ,0) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) / 14;
100 * ( 14 - ( ( IIF(Ref(H ,-1) == H14 ,1 ,IIF(Ref(H ,-2 ) == H14 ,2 ,IIF(Ref(H ,- 3 ) ==
H14 ,3, IIF(Ref(H ,-4 ) == H14 ,4 ,IIF(Ref(H ,-5 ) == H14 ,5 ,IIF(Ref(H ,-6 ) ==
H14 ,6 ,IIF(Ref(H,-7 ) == H14 ,7 ,IIF(Ref(H ,-8 ) == H14 ,8 , IIF(Ref(H ,-9 ) ==
H14 ,9 ,IIF(Ref(H ,-10 ) == H14 ,10 ,IIF(Ref(H ,-11 ) == H14 ,11 ,IIF(Ref(H ,-12 ) ==
H14 ,12 ,IIF(Ref(H ,-13) == H14 ,13 ,IIF(Ref(H ,-14 ) == H14 ,14 ,0 ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) / 14;
graph0 = AroonUp;
graph1 = AroonDown;
( Note: the formulas presented here are also available from http://www.amibroker.com/library.html )
3 Tip of the week: : Culling database - How to detect non trading stocks?
Note: This functionality is available only in Windows version of AmiBroker
In the first issue of AmiBroker Tips newsletter AmiBroker I discussed using of AmiBroker's OLE automation interface for accessing stock data. In this article I will give you another example of automation: detecting non trading stocks using simple JScript. For starters I recommend reading the first article before proceeding with this one.
As you already know keeping your database clean is not an easy task. Especially when you have several thousands stocks listed. Some new tickers appear, some are gone and you don't want to keep them listed when they are not used anymore. Now you can of course examine each stock by hand but it is a tedious task. This is the area where AmiBroker's scripting & automation capability may help a lot.
The main idea of a script is to automatically scan the database and check the latest quotation date. If it is old enough (say last quotation date was more than 30 days ago) the script will warn the user and give him/her a change to decide if the stock should be deleted or not. Additionally script can generate a list of "old" stocks and save it to the text file.
When I wrote the script I realized that it is just too complicated for non-programmer, so I won't dig into details here. Instead I will explain how to tune the script to suit your needs. I parametrized the script so it is easy now to change its behaviour. When you open the script with a text editor (such as Notepad) you will see the following lines at the beginning (after comments):
/* detection threshold (in days) */
var Threshold = 30; // one month for example
/* by default do not delete */
var DeleteByDefault = false;
/* ask the user for the decision */
var AskUser = true;
/* a timeout to
wait until default route (no deletion) is taken */
var Timeout = 5;
These four variables control the bahaviour of the script. The Threshold variable defines how many non-trading days are needed to consider given ticker as obsolete and to warn the user about it. DeleteByDefault variable decides if detected stocks should be deleted by default - when user does not response within given timeout. As you can see I assigned false to this variable so tickers are NOT deleted by default (they are deleted only if user confirms deletion). AskUser decides if script displays prompts asking user what to do with given stock, if you assign a false to this variable the script will quietly scan the whole database taking a default route (not deleting just saving the list). Otherwise it asks the user what to do with each ticker. The last parameter Timeout decides how many seconds the script should wait for user interaction. If a timeout is reached (by default 5 seconds) without a click scripts goes further taking default route (not deleting). One nice feature of this script is that that even if you say "Yes" to delete given stock the script just adds the ticker to "StockToDelete" list and you can later decide not to proceed with the deletion. Another nice feature is that all stocks that were not deleted but were detected as obsolete can be written to "nottraded.txt" file. Just answer "Yes" when the script asks for this.
A complete Cleanup.js script can be found here. You could safely save this file onto your hard disk, launch AmiBroker and double click on the script file (in Windows Explorer). The script will run detecting your old stocks, and it will not delete anything unless you confirm deletion manually. Advanced users can play with described parameters to make this script better suited for your personal purposes.
.... and that's all for this week - hope you enjoyed reading
AmiBroker Tips weekly newsletter. Issue 5/2000. Copyright (C)2000 Tomasz Janeczko. All back issues available from: http://www.amibroker.com/newsletter/