How To Add Column With Sector Name In Explore Results

#1
Hello Everyone,

I just discovered this sub-section of the TraderJI Forum by accident. I was looking for some place to post a question on specific code in AmiBroker.

First, let me say that I have been trading stocks from home for many years, and also using the AB product. Occasionally, I try to do some new analysis in the AB program to improve my trading. I am very interested in adding an additional column that shows the Sector Name in the results (Stock, Open, High, etc.) which I get when I run my 'Explore'. In that way I hope to see which exact sector the stock belongs to. This would be extremely useful to me.

Is this possible? I hope so.

Thank you all for any assistance in advance !!!

Josef
 

colion

Active Member
#2
From page 1035 of the Users Guide:

SectorID
- get sector ID / name

Information / Categories (AFL 1.8)

SYNTAX SectorID( mode = 0 )

RETURNS NUMBER/STRING

FUNCTION Retrieves current stock sector ID/name When mode = 0 (the default value ) this function returns numerical sector ID (consecutive
sector number)

When mode = 1 this function returns name of the sector.

EXAMPLE
Filter = SectorID() == 7 OR SectorID() == 9;
AddTextColumn( SectorID( 1 ), "Sector name" );
 
#3
Colion,

Thank you for your reply. How do I set the mode = 1? I tried to insert these 2 lines of code into the script but my Explore ran to completion and gave me no results:

Filter = SectorID() == 7 OR SectorID() == 9;
AddTextColumn( SectorID( 1 ), "Sector name" );

Am I missing something?

Thanks for your help

Josef
 

colion

Active Member
#4
Colion,

Thank you for your reply. How do I set the mode = 1? I tried to insert these 2 lines of code into the script but my Explore ran to completion and gave me no results:

Filter = SectorID() == 7 OR SectorID() == 9;
AddTextColumn( SectorID( 1 ), "Sector name" );

Am I missing something?

Thanks for your help

Josef
I don't know if you are missing something but those two lines of code work for me just as is. Mode 1 is set as shown by ( 1 ). Did you populate one or more industries in Sector 7 and Sector 9 (remember Sector numbering begins with 0)? Did you set the Filter in the Analysis Window appropriately (e.g., all symbols)? If this is all Greek to you then you need to read about what sectors/industries/analysis window are and how to work with them in the Users Guide. Here is a test with the two lines of code after putting ^FTSE into the Computer Hardware industry (Technology Sector#9) and ^AORD into the Healthcare Facilities (Healthcare Sector #7):