Australian (ASX) Stock Market Forum

Amibroker FAQ

Dear Amibrokers
is anyone using the Account in amibroker?
I found it awkward to populate/update and then what can we do with it?
I expected the ability to graph the perf of the account, etc
but I gave up last week and went back to my spreadsheet for my account management.
Am I missing something there?:confused:
 
Hey,

I have just purchased amibroker and am going through howard bandy's 'introduction to amibroker'. I am stuck with an issue in chapter 2 unfortunately. I downloaded data through amiquote and am trying to direct that specific data to a certain database in amibroker. I downloaded the nasdaq 100 and it went into my NYSE section. Does anyone know how I can direct data into a specific section?

cheers
 
thanks superglue i will have a play with that. I have imported the nasdaq 100 already and for some reason they go straight to the NYSE "markets" group. I may have to delete them all because i obviously only want NYSE stocks in that file.
 
Hey,

I have just purchased amibroker and am going through howard bandy's 'introduction to amibroker'. I am stuck with an issue in chapter 2 unfortunately. I downloaded data through amiquote and am trying to direct that specific data to a certain database in amibroker. I downloaded the nasdaq 100 and it went into my NYSE section. Does anyone know how I can direct data into a specific section?

cheers

You can also do it automatically.

For example using Finviz.com (it uses Morningstar Industry Classification system just like Yahoo)

For example to download
Nasdaq use this link http://finviz.com/export.ashx?v=111&f=exch_nasd
NYSE use this one http://finviz.com/export.ashx?v=111&f=exch_nyse
AMEX use this one http://finviz.com/export.ashx?v=111&f=exch_amex

There are some other finviz lists possible. Just use the filter options there on their website.

( Of course there are some other websites where you can get symbol lists from including category assignments like from here http://www.nasdaq.com/screening/company-list.aspx )

Move that downloaded Finviz files to C:\\. Name them AMEX.csv, NASDAQ.csv and NYSE.csv.

Then you could create format files for each of the three markets ( the format file codes below work in most recent AB 5.60 only!)

like

for Nasdaq

Code:
$FORMAT Skip,Ticker,FullName,SectorName,IndustryName,Country,Skip,Skip,Skip,Skip,Skip
$SKIPLINES 1
$SEPARATOR ,
$AUTOADD 1
$NOQUOTES 1
$OVERWRITE 1
$SORTSECTORS 1
$GROUP 1
$MARKET 1

for NYSE

Code:
$FORMAT Skip,Ticker,FullName,SectorName,IndustryName,Country,Skip,Skip,Skip,Skip,Skip
$SKIPLINES 1
$SEPARATOR ,
$AUTOADD 1
$NOQUOTES 1
$OVERWRITE 1
$SORTSECTORS 1
$GROUP 1
$MARKET 0

for AMEX

Code:
$FORMAT Skip,Ticker,FullName,SectorName,IndustryName,Country,Skip,Skip,Skip,Skip,Skip
$SKIPLINES 1
$SEPARATOR ,
$AUTOADD 1
$NOQUOTES 1
$OVERWRITE 1
$SORTSECTORS 1
$GROUP 1
$MARKET 2

Before importing the separately downloaded Finviz files the old sector and industry names (if there are any) better needs to be cleaned. The content of the format file that cleans the sectors after creating a data base or if using an already in use data base would be just one line

Code:
$CLEANSECTORS 1

We call that format file e.g. CLEANSECTORS.format
So since we add three independent Finviz csv files we would need to create an empty dummy file named CleanSectors.csv. Otherwise we could add $CLEANSECTORS 1 to the symbols format file.

In regards to Ascii formats see here www.amibroker.com/guide/d_ascii.html

Then we create a jscript file that automates all that

Code:
var Amibroker, Mydatabase, Shell;

AmiBroker  = new ActiveXObject("Broker.Application");

// save current Database before open the new one
AmiBroker.SaveDatabase();

// Amibroker database
//Mydatabase = "C:\\Program Files\\AmiBroker\\Data\\";   //your Amibroker database

// Open database 
//AmiBroker.LoadDatabase(Mydatabase);

// Import 
if (!AmiBroker.Import(0, "C:\\CLEANSECTORS.csv", "CLEANSECTORS.format"));
if (!AmiBroker.Import(0, "C:\\AMEX.csv", "FinVizAMEX.format"));
if (!AmiBroker.Import(0, "C:\\NYSE.csv", "FinVizNYSE.format"));
if (!AmiBroker.Import(0, "C:\\NASDAQ.csv", "FinVizNASDAQ.format"));
//if (!AmiBroker.Import(0, "C:\\SP500.csv", "FinVizSP500.format"));
//if (!AmiBroker.Import(0, "C:\\\DJ30.csv", "FinVizDJ30.format"));
//if (!AmiBroker.Import(0, "C:\\Other.csv", "FinVizOther.format"));

AmiBroker.RefreshAll();
AmiBroker.SaveDatabase();
//AmiBroker.Visible = true;  // Opens Amibroker if is closed

//notify user when import is finished 
Shell = new ActiveXObject("WScript.Shell");
Shell.Popup("Symbols Import Completed", 1.5);

I have uploaded all files to here http://www.datafilehost.com/download-552f71e0.html You just need to move the files to the according Amibroker folder on your PC.

Create a new data base. Then download the files of the three Finviz links. Download them to C:\\. Name them AMEX.csv, NASDAQ.csv and NYSE.csv. Then start Amibroker and excecute the jscript file of my uploaded zip archive.

I have made a comfortable AFL (it's not in the zip file) that does all that half-automatically without any manual user interference (except for clicking GFX buttons). See here http://www.youtube.com/watch?v=FDqnqN2z7I0&hd=1 The video is just supposed to show what you can do and what AB is capable of. So actually you can do anything that comes into your mind. That AFL of the video is an older version that I have recently updated to use the new ASCII capabilities provided in AB 5.60. See changes for 5.58 here http://www.amibroker.com/devlog/2012/09/29/amibroker-5-60-1-release-candidate-1/

My AFL programmatically creates folders to download the files to. It uses Urlget to download the files from Finviz or any other website providing symbol lists with category assignments (you can additionally choose individual Markets to download via Parameters dialog). It moves the files to the created folders, of course. It creates names for categories and moves the imported symbols to market, group, sector, industry, watchlist

In regards to setting category names it's all there in AFL, e.g.

Code:
                            CategorySetName( "NYSE", categoryMarket, 0 );
                            CategorySetName( "Nasdaq", categoryMarket, 1 );
                            CategorySetName( "Amex", categoryMarket, 2 );
                            CategorySetName( "World Indices", categoryGroup, 0 );
                            CategorySetName( "US Stocks", categoryGroup, 1 );
                            CategorySetName( "European Stocks", categoryGroup, 2 );
                            CategorySetName( "DJ INDU 30", categoryWatchlist, 0 );
                            CategorySetName( "S&P 500", categoryWatchlist, 1 );
                            CategorySetName( "NASDAQ 100", categoryWatchlist, 2 );
                            CategorySetName( "Symbols not updated", categoryWatchlist, 62 );
                            CategorySetName( "Symbols probably dead", categoryWatchlist, 63 );
 
Issue with NumToStr function:


// The NumToStr function appears to be changing the number

num1 = 77244687 ;
num1_str = NumToStr( num1, 1.0, False );

GfxTextOut( num1_str, 100, 100 ); // displays 77244688

num2 = StrToNum( num1_str );
Plot(num2,"num2",colorRed ); // plots 77244688


??any ideas??
 
Issue with NumToStr function:


// The NumToStr function appears to be changing the number

num1 = 77244687 ;
num1_str = NumToStr( num1, 1.0, False );

GfxTextOut( num1_str, 100, 100 ); // displays 77244688

num2 = StrToNum( num1_str );
Plot(num2,"num2",colorRed ); // plots 77244688


??any ideas??


It's not a bug.

Hello,

Check the archives before starting again and again the same thread.
Was discussed already many many times here.

The floating precision is determined by INTERNATIONAL STANDARD
IEEE-754 standard for 32-bit floating point: 7 significant digits:
http://en.wikipedia.org/wiki/IEEE_floating-point_standard
http://babbage.cs.qc.edu/courses/cs341/IEEE-754hex32.html
http://babbage.cs.qc.edu/courses/cs341/IEEE-754references.html

.
.
.
.

Best regards,
Tomasz Janeczko
amibroker.com

Hello,

There is no error.

As discussed hundreds of times on this list - there is no *integer* arithmetic in AFL.

All numbers are represented in FLOATING POINT, Standard Single Precision IEEE754 standard format.

MUST READ:
http://en.wikipedia.org/wiki/IEEE_754

There single precision format is 32 bit with 23 bit for mantissa and 8 bits for fraction and 1 bit for sign.
Single precision IEEE offers 7+ significant digit precision.

So technically there is NO error. You are just displaying the numbers past the significant digits.

That is the reason why AB uses DateNum format of YYYMMDD (where YYY is (year-1900))..

For dates you should use DATETIME format !

AddColumn( DateTime(), "DateTime", formatDateTime );

Best regards,
Tomasz Janeczko
amibroker.com

Hello,

1. No, the bitness of AmiBroker does not matter as AFL always uses single
precision floating point

2. Yes you can use double in DLL but as long as you output data they are still
returned as float.

You should first answer yourself a question WHY you need those "long" digits. 7+
digit accuracy is perfectly enough for display (you don't have a screen with more
than 10 million pixels of width or height, do you?) and perfectly enough for any
T/A analysis (1 cent difference on million dollar account).

First and foremost, if you just want to print such number you may simply use
strings to output numbers of any length:

printf( "123456789.123456789" );

Say you want year/month/date serial you can do this that way:

printf("%4.0f%04.0f%04.0f", Year(), Month(), Day() );

and the result will be say: 20120123

But, if you for some reason do some astronomic calculations involving
galaxy-sized numbers, you can do your calculations in JScript or VBScript
parts. JScript/VBScript would give you double precision
http://www.amibroker.com/guide/a_aflcom.html

But again, unless you are counting atoms while working in cosmic scale, you
don't need doubles.

Best regards,
Tomasz Janeczko
amibroker.com

Hello,

Some reading:
http://docs.sun.com/source/806-3568/ncg_goldberg.html

1. Precision is 7 significant digits.
2. No PRICE information on ANY market is provided with greater accurracy
than 7 digits.
3. Because of (2), all major software packages including Tradestation, Metastock
and others use 32 bit floating point IEEE standard and
there are NO problems using it assuming that you code properly.
4. Round() function does not change anything because certain decimal fractions
(like 0.1) can not be represented as binary fraction (because 1/10 can not be
expressed as finite sum of binary fractions 1/2, 1/4, 1/8, 1/16, 1/32, 1/64,
1/128, and so on ......)
And all computers work with binary numbers only (except some ancient machines
that were using BCD codes).

This is as plain obvious fact like the fact that 1/3 can not be represented
as decimal fraction. And if you round 1/3 expressed in decimal system
0.333333333 to any number of places you won't get accurate result no matter
what.

Actually in EVERY encoding system (using any base) there are fractions not
representable by finite number of digits)

Sorry guys but this is elementary school math.

Best regards,
Tomasz Janeczko
amibroker.com

Go to the AB Yahoo message board http://finance.groups.yahoo.com/group/amibroker/msearch_adv and search for more using digit accuracy or digit precision as key words
 
Hi Trash,

I did not mean to suggest the presence of a bug......TJ does not have such in his work.

If I've got an eight-digit number that needs to be represented as a string, what are my options?

Thanks,
RutheezKey
 
Hi Trash,

I did not mean to suggest the presence of a bug......TJ does not have such in his work.

If I've got an eight-digit number that needs to be represented as a string, what are my options?

Thanks,
RutheezKey

Greetings --

Where did the eight digits come from? Not a calculation done in traditional fashion, because only seven are available.

If they come from an outside source, can you capture them as they are read from their source?

If they come from a calculation, you can use numerical analysis techniques to do double precision calculation using single precision storage. It will require sophisticated coding. Refer to numerical analysis texts.

Or you can do the calculations that produce your result in a different order that retains significance more efficiently.

How will the result be used? Financial prices are seldom more precise than five or six digits. If the eight digit number will be used in a subsequent calculation, is the eighth digit necessary?

If the most significant digits are known, store them separately, adjust the operands, then compute the least significant digits. Do the subsequent arithmetic in two pieces -- the first using the most significant digits, the second using the least significant digits, then combine the results (which are still limited to seven digits).

Regards,
Howard
 
Hi Trash,

I did not mean to suggest the presence of a bug......TJ does not have such in his work.

If I've got an eight-digit number that needs to be represented as a string, what are my options?

Thanks,
RutheezKey

Try this one

Code:
EnableScript("jscript");
<%
x1 = 77244687;
x = x1.toString();
AFL.Var("num1") = x;
%>

GfxTextOut( num1, 100, 100 );

or

Code:
EnableScript("jscript");
<%
x1 = 77244687;
x = x1 + '';
AFL.Var("num1") = x;
%>

GfxTextOut( num1, 100, 100 );

or using vbscript

Code:
EnableScript("vbscript");
<%
x1 = 77244687
x = CStr(x1)
AFL.Var("num1") = x
%>

GfxTextOut( num1, 100, 100 );
 
Many thanks to both Howard and trash,

The number that I was using, when this issue first became known to me, was an "order-ID#". Not unlike a zip code, I typically handle such items as a string. With a string, I can include some flow-control----I do like to have that option. This is kinda new to me, so bear with me going forward. I greatly appreciate the help that I receive at this site. Hopefully, one day I'll be able to return the favor.

Later,
RutheezKey
 
Hi,

I have a composite indicator that looks reasonably promising as a way of trading the Aus index with a cfd.

How would I go about assigning buy and sell signals based upon the turning of the composite squiggle, and thereby back testing it?

Thanks.
 
Hi GB,

Does one treat the one-bar "turn" equally to the swing where the indicator does not reverse polarity for several more bars? Plus, does one consider the usage of a numerical-horizontal (such as the famous zero-line), before considering the movement of the indicator line as significant?

Just thinking out loud,
RutheezKey
 
Hi GB,

Does one treat the one-bar "turn" equally to the swing where the indicator does not reverse polarity for several more bars? Plus, does one consider the usage of a numerical-horizontal (such as the famous zero-line), before considering the movement of the indicator line as significant?

Just thinking out loud,
RutheezKey

Yes, every upturn is counted rather than using a zero line or similar. Well it looks best that way - which is why i want to test it. Any thoughts?
 
Hi GB,

See if this will work.

IV = your indicator-value ;

xx = IIf( IV > Ref( IV, -1 ), 1, IIf( IV < Ref( IV, -1 ), -1, IIf( IV == Ref( IV, -1 ), 0, 0 )));
yy = ValueWhen( ( xx == 0 ) AND ( Ref( xx, -1 ) != 0 ), Ref( xx, -1), 1 );
zz = ValueWhen( ( xx != 0 ) AND ( Ref( xx,-1) == 0 ), Ref( yy, -1 ), 1 );

TurnDN = ( ( xx < 0 ) AND ( Ref( xx, -1 ) > 0 ) ) OR ( ( xx < 0 ) AND ( Ref( xx, -1 ) == 0 ) AND ( zz != xx ) );
TurnUP = ( ( xx > 0 ) AND ( Ref( xx, -1 ) < 0 ) ) OR ( ( xx > 0 ) AND ( Ref( xx, -1 ) == 0 ) AND ( zz != xx ) );
 
Hi GB,

See if this will work.

IV = your indicator-value ;

xx = IIf( IV > Ref( IV, -1 ), 1, IIf( IV < Ref( IV, -1 ), -1, IIf( IV == Ref( IV, -1 ), 0, 0 )));
yy = ValueWhen( ( xx == 0 ) AND ( Ref( xx, -1 ) != 0 ), Ref( xx, -1), 1 );
zz = ValueWhen( ( xx != 0 ) AND ( Ref( xx,-1) == 0 ), Ref( yy, -1 ), 1 );

TurnDN = ( ( xx < 0 ) AND ( Ref( xx, -1 ) > 0 ) ) OR ( ( xx < 0 ) AND ( Ref( xx, -1 ) == 0 ) AND ( zz != xx ) );
TurnUP = ( ( xx > 0 ) AND ( Ref( xx, -1 ) < 0 ) ) OR ( ( xx > 0 ) AND ( Ref( xx, -1 ) == 0 ) AND ( zz != xx ) );
Thanks for your coding there Ruth. Appreciated.

My difficulty is that in order to generate the composite, Buy = 0;

So I can't later re-define the buy signal to trigger when the squiggle turns.
 
Hi GB,

Can you first run the scan----saving the indicator array as a static. Then change the formula (with the new formula "getting" the static) and run the backtest.

Later,
RutheezKey
 
Hi GB,

Can you first run the scan----saving the indicator array as a static. Then change the formula (with the new formula "getting" the static) and run the backtest.

Later,
RutheezKey

RK, I ran the scan, which creates a symbol called "~MyComposite". Then I tried the following as a backtest on ^AORD, but no cigar.

SetForeign("~MyComposite",True,True);
y = C>Ref(C,-1) AND Ref(C,-1)<Ref(C,-2);
RestorePriceArrays( True );
Buy = y ;
Sell = !y;

Any further ideas appreciated.
 
Top