Author Topic: AFL for Oraganize Assignments  (Read 6856 times)

tujthevux

  • Newbie
  • *
  • Posts: 11
    • View Profile
AFL for Oraganize Assignments
« on: April 20, 2011, 10:12:51 pm »
Hi sir,
I am re-organising my symbols using Organize Assignments in menu Symbols. It's a hard work with thousand of symbols from two stock markets in our country. Anyway to use AFL (programming) to do this work?
Thanks

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 200
    • View Profile
Re: AFL for Oraganize Assignments
« Reply #1 on: April 21, 2011, 09:29:10 pm »
Hello

I think you can do this through javascript and Amibroker's OLE. You can read up on it in the Amibroker help file. That's probably the easiest way of doing it.

tujthevux

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: AFL for Oraganize Assignments
« Reply #2 on: April 26, 2011, 10:00:49 pm »
Thanks,
As you advice, I found this helps me.
 
Code: [Select]
   /* change this line according to your data file name */
    var filename = "industry_data.txt";

    var fso, f, r;
    var ForReading = 1;
    var AmiBroker;
    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);

    /* read the file line by line */
    while ( !f.AtEndOfStream )
    {

        r = f.ReadLine();

        /* split the lines using comma 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 ] );

        stock.FullName = fields[ 1 ];
        stock.IndustryID = parseInt( fields[ 2 ] );

    }

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

Stock Jock

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: AFL for Oraganize Assignments
« Reply #3 on: October 23, 2014, 04:48:33 pm »
I saw that code too and I was wondering how to re-code it in order to import data from a Finviz csv file containing Ticker, FullName, SectorName, IndustryName, Country?