- Joined
- 8 June 2008
- Posts
- 13,203
- Reactions
- 19,457
Hey,
Does anyone know how I can direct data into a specific section?
cheers
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
$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
$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
$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
$CLEANSECTORS 1
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);
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??
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
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
EnableScript("jscript");
<%
x1 = 77244687;
x = x1.toString();
AFL.Var("num1") = x;
%>
GfxTextOut( num1, 100, 100 );
EnableScript("jscript");
<%
x1 = 77244687;
x = x1 + '';
AFL.Var("num1") = x;
%>
GfxTextOut( num1, 100, 100 );
EnableScript("vbscript");
<%
x1 = 77244687
x = CStr(x1)
AFL.Var("num1") = x
%>
GfxTextOut( num1, 100, 100 );
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
Thanks for your coding there Ruth. Appreciated.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,
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
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?