Zmiana kodu Jscript na moje potrzeby

0

Witam
Jestem kompletnie zielony jesli chodzi o Jscript, a na prawde nie mam czasu uczyc sie tego jezyka. Prosze Was o pomoc, mysle ze wezme tylko chwile Waszego czasu, bo sam problem nie jest zbyt skomplikowany.

Potrzebuje programu, ktory aktualizowal by moja baze danych w Amibrokerze (program do tradingu) automatycznie z pliku .csv i robil to nieprzerwanie co np. minute az do jego wylaczenie. Googlowalem jakis czas i znalazlem kodzik od tworcy programu .
Chcialbym was prosic o pomoc w przerobieniu go tak, by sie wykonywal co np. 1 minute , az go wylacze. I z racji ze nie mam za duzo doswiadczenia z tego typu plikami, chcialbym zeby mnie ktos nakierowal co ja w ogóle mam zrobic zeby ten skrypt "chodzil".

BTW: Wiem ze to wszystko jest banalne, ale mam mnostwo pracy i nie mam sil na kolejny problem :/

 

function ImportCSV( filename )
{
	var fso, f, r;
	var ForReading = 1;
	var AmiBroker;
	var ticker;
	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" );

	/* we use file name ( without extension ) as a ticker name */
	ticker = fso.GetBaseName( filename ).toUpperCase();

    	/* add a ticker - this is safe operation, in case that	 */
    	/* ticker already exists, AmiBroker returns existing one */
	/* we are doing this outside loop since the file contains */
	/* quotes of single stock only */
    	stock = AmiBroker.Stocks.Add( ticker ); 

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

    	/* notify the user */
	WScript.Echo( "Importing " + ticker );

	/* 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 comma as a separator */
		  fields = r.split(","); 
		  
		  /* split date at - separator */
		  var datefld = fields[ 0 ].split("-");

		  /* ensure Y2K compliance by converting year to 4 digit number */
		  var year = parseInt( datefld[ 2 ] );
		  year += ( year < 50 ) ? 2000 : 1900;
		  datefld[ 2 ] = year.toString();

		  /* put date back all together */
		  datefld.join(" ");

		  date = new Date( datefld );

		  /* add a new quotation */
		  quote = stock.Quotations.Add( date.getVarDate() );
		  
		  /* put data into it */
		  quote.Open = parseFloat( fields[ 1 ] );
		  quote.High  = parseFloat( fields[ 2 ] );
		  quote.Low   = parseFloat( fields[ 3 ] );
		  quote.Close = parseFloat( fields[ 4 ] );
		  quote.Volume = parseInt( fields[ 5 ] );
		  
	}

	/* refresh ticker list and windows */
	AmiBroker.RefreshAll();

	/* notify the user */
	WScript.Echo( "Finished" );

}




I tu jeszcze propozycja wywolania tej funkcji:

 
ImportCSV( "aapl.csv" );
0

Dobra, troche wykopie temat..
Sklecilem takie cos, co dziala

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

    function Import( filename )
    {

        /* import the data using appropriate format definition file - in our case (PRN files with Ticker) this is prnn.format file */
        AmiBroker.Import( 0, filename, "Datamt4.format" );
        /* refresh ticker list and windows */
        AmiBroker.RefreshAll();

    }
  Import("D:\\MetaTrader\\experts\\files\\Export_History\\USDCHF\\USDCHF_D1.csv");

I teraz mam pytanie.. zeby to sie wykonywalo co jaksi czas, mozna to wladowac w petle, i nakazac mu na koncu kazdego powtorzenia czekac? Czy ejst to efektywne?

1 użytkowników online, w tym zalogowanych: 0, gości: 1