Deleting Tickers and Composites

Creating composites is a lot of fun and can provide useful information about market and sector movements. However, when creating many composites, you will sooner or later find that your database is bloated with obsolete composites. The first requirement is to create a function to delete composites. Dingo kindly provided the following example code, which will be used to provide a variety of other useful functions. Note that the functions below can be used to delete both tickers and composites; the procedure is the same. The formula is designed to be run as an indicator but can be adapted to run in a scan, etc.

Deleting a list of Tickers or Composites

1
2
3
4
5
6
7
8
9
10
11
12
DeleteTickers = ParamTrigger("Delete Tickers", "Click Here To Delete Tickers"); 
TickerList = ParamStr("Tickers to Delete","ALY,CALM,FCX,GLF,PNCL,RS,SCHN,STLD,WNR,X"); 
if ( DeleteTickers ) 
{ 
oAB = CreateObject( "Broker.Application" ); 
oStocks = oAB.Stocks(); 
for( n=0; (Ticker=StrExtract( TickerList, n))!= ""; n++) 
{ 
oStocks.Remove( Ticker ); 
} 
oAB.RefreshAll(); 
}

When testing this code be sure to use a test database to prevent deleting important tickers. It is always best to develop code that creates and deletes tickers on a test database. To test the above code create a new test database and copy-n-paste the TickerList into a Watchlist using Symbol -> Watchlist -> Type in Symbols. There is no need to backfill the tickers with data. Next open your workspace and display the Watchlist. Next, if you click Click Here To Delete Tickers, you’ll see the ticker disappearing from your Symbol Workspace.

Deleting a Single Ticker or Composite

The above code can easily be trimmed to provide a function to delete a single ticker:

1
2
3
4
5
6
7
8
9
10
11
function DeleteComposite( CompositeName ) 
{ 
oAB = CreateObject( "Broker.Application" ); 
oStocks = oAB.Stocks(); 
oStocks.Remove( CompositeName ); 
oAB.RefreshAll(); 
} 
 
DeleteTicker = ParamTrigger("Delete Ticker", "Click Here To Delete Ticker"); 
Ticker = ParamStr("Ticker to Delete","ALY"); 
if( DeleteTicker ) DeleteComposite( Ticker );

Deleting All Tickers in a Watchlist

A slight modification of the above code will let you delete all tickers in a Watchlist:

1
2
3
4
5
6
7
8
9
10
11
12
13
WatchListNum = Param("Watchlist Number",0,0,64,1); 
DeleteTickers = ParamTrigger("Delete Tickers in Watchlist", "Delete Tickers"); 
TickerList = GetCategorySymbols( categoryWatchlist, WatchListNum ); 
if ( DeleteTickers ) 
{ 
oAB = CreateObject( "Broker.Application" ); 
oStocks = oAB.Stocks(); 
for( n=0; (Ticker=StrExtract( TickerList, n))!= ""; n++) 
{ 
oStocks.Remove( Ticker ); 
} 
oAB.RefreshAll(); 
}

Deleting all Composites in Group 253

Composites are normally stored in Group 253. To delete all composites in this group replace the categorywatchlist with categorygroup:

1
2
3
4
5
6
7
8
9
10
11
12
13
GroupNum = Param("Group Nbr",253,0,255,1); 
DeleteTickers = ParamTrigger("Delete Composites", "Click Here To Delete Composites"); 
TickerList = GetCategorySymbols( categoryGroup, GroupNum ); 
if ( DeleteTickers ) 
{ 
oAB = CreateObject( "Broker.Application" ); 
oStocks = oAB.Stocks(); 
for( n=0; (Ticker=StrExtract( TickerList, n))!= ""; n++) 
{ 
oStocks.Remove( Ticker ); 
} 
oAB.RefreshAll(); 
}

OLE Code written by dingo.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Introduction to the ATC

The AddToComposite() (ATC) is an extremely powerful function. Topics in this category will not repeat ATC topics covered elsewhere, so be sure to follow the following links for more information and applications:

The AmiBroker AFL Reference: ADDTOCOMPOSITE
Calculating multiple-security statistics with AddToComposite function
Introduction to AddToComposite
Multiple time-frame indicators
Search this users’ Knowledge Base for applications

Also be sure to browse the applications listed at the bottom of the AFL Reference for the ATC.

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 5 out of 5)
Loading ... Loading ...