locked
Amibroker JScript RRS feed

  • Question

  • I need help with some JScript code that I found on the internet.  I don't remember where I found it, but as far as I know no one has claimed ownership to it.  The code is used in the Amibroker trading platform for importing data into it and I don't get any syntax errors from Amibroker.  Still the code seems to start and then never return or end with the completion message.  Can someone help me?

    /*
    ** AmiBroker/Win32 scripting 
    **
    ** File:  importFinviz.js
    ** Created:     
    ** Purpose:  Import finviz symbols from a text file into a AmiBroker DataBase
    ** Language: JScript
     
     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
     
    Mydatabase = "C:\\Program Files\\Finance\\AmiBroker\\Intraday\\";
     
    // Open database  AmiBroker.LoadDatabase( Mydatabase ) ;
    Import 
    if (!AmiBroker.Import(0, "C:\\Program Files\\AmiBroker\\MyFiles\\CLEANSECTORS.csv", "CLEANSECTORS.format"));
    if (!AmiBroker.Import(0, "C:\\Program Files\\AmiBroker\\MyFiles\\AllUSStocks.csv",  "FinVizDATA.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);

    The data is imported into Amibroker by using the following format contained in the "FinVizDATA.format" file as shown in the code above.

    $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

    Here are a few lines of data that are contained in the data file that was downloaded from the Finviz.com website.

    "No.","Ticker","Company","Sector","Industry","Country","Market Cap","P/E","Price","Change","Volume"
    1,"A","Agilent Technologies Inc.","Healthcare","Medical Laboratories & Research","USA",17459.25,25.54,53.49,2.18%,1159189
    2,"AA","Alcoa Inc.","Basic Materials","Aluminum","USA",18477.64,,16.19,3.19%,10751677
    3,"AAC","AAC Holdings, Inc.","Healthcare","Specialized Health Services","USA",393.35,634.33,19.50,2.47%,65618



    Regards, PC User



    • Edited by PC_User Tuesday, October 28, 2014 3:23 PM
    Tuesday, October 28, 2014 3:09 PM