Hi all,

I am trying to link an file of ascii datas with Amibroker.

I have downloaded, in Amibroker'sguide,  a jscript procedure which is capable 
to realize this, bur it does'not work with me.

Here is the source of this Jscript :   

/*
** AmiBroker/Win32 scripting Example
**
** File:  Import.js
** Created:  Tomasz Janeczko, January 30th, 2000
** Purpose:  Import quotes from Metastock ASCII file
** Language: JScript (Windows Scripting Host)
**
** The data is stored in lines with following format
** <ticker>,<per>,<date>,<high>,<low>,<close>,<volume>
**
*/
 ImportMsASCII( "C:\\ACCOR.Txt" );

function ImportMsASCII( filename )
{
 var fso, f, r;
 var ForReading = 1;
 var AmiBroker;
 var date;
 var quote;
 var fields;
 var stock;

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

 /* ... and file system object */
 fso = new ActiveXObject( "Scripting.FileSystemObject" );

 /* open ASCII file */
 f = fso.OpenTextFile( filename, ForReading);

 /* skip first line which contains format definition */
 f.SkipLine(); 

 /* read the file line by line */
 while ( !f.AtEndOfStream )
 {  
    r =  f.ReadLine();
    
    /* split the lines using semicolon as a separator */
    fields = r.split(";"); 
    
    /* add a ticker - this is safe operation, in case that  */
    /* ticker already exists, AmiBroker returns existing one */
    stock = AmiBroker.Stocks.Add( fields[ 0 ] ); 
    
    /* notify the user */
    WScript.Echo( "Importing " + fields[ 0 ] );

    /* parse the date from the text file */
    date = new Date( fields[ 1 ] );

    /* add a new quotation */
    quote = stock.Quotations.Add( date.getvarDate() );
    /* put data into it */
    quote.Open = parseFloat( fields[2]);
    quote.High  = parseFloat( fields[ 3 ] );
    quote.Low   = parseFloat( fields[ 4 ] );
    quote.Close = parseFloat( fields[ 5 ] );
    quote.Volume = parseInt( fields[ 6 ] );
   
 }
 /* refresh ticker list and windows */
 AmiBroker.RefreshAll();
 /* notify the user */
 WScript.Echo( "Finished" );
}
 and here is an example of datas file :

<Ticker>,<date_DMY>,<Open>,<High>,<Low>,<Close>,<Volume>
ACCOR;09/10/2009;      37.42;      38.12;      36.87;      37.10;    735891
ACCOR;12/10/2009;      37.25;      37.84;      37.13;      37.68;    673107
ACCOR;13/10/2009;      37.36;      38.02;      37.21;      37.34;    726353
ACCOR;14/10/2009;      37.71;      38.29;      37.59;      37.81;    850644
ACCOR;15/10/2009;      37.85;      38.10;      36.30;      36.50;   1445724
ACCOR;16/10/2009;      36.50;      36.88;      35.90;      36.08;   1541279
ACCOR;19/10/2009;      36.12;      36.65;      35.90;      36.28;   1036342
ACCOR;20/10/2009;      36.49;      36.63;      36.05;      36.20;    799961
ACCOR;21/10/2009;      36.31;      36.40;      35.57;      35.74;    889888
ACCOR;22/10/2009;      35.47;      35.47;      34.70;      35.02;    804990
ACCOR;23/10/2009;      35.50;      35.78;      34.26;      34.31;   1473307
ACCOR;26/10/2009;      34.49;      34.85;      33.75;      33.87;   1293311

I always have an error message : "cet objet ne gère pas cette propriété"

at the lnstruction "quote = stock.Quotations.Add( date.getvarDate() )"  (In red 
in the source code)

Can anyone help me ?

Best regards;

Reply via email to