How to check particular ticker on backtest?

Hi All,

how to check particular ticker on backtest.

i try this code. but there is no result found. i know i am mistake. please help teach.

sectorlist = "GALAXYSURF.NSE,MAHLOG.NSE,NILKAMAL.NSE,KAJARIACER.NSE,KSCL.NSE,KALPATPOWR.NSE,CESC.NSE,GODFRYPHLP.NSE,SHANKARA.NSE,LUXIND.NSE,CEATLTD.NSE";

for( item = -1; ( sym = StrExtract( sectorlist, item ) ) != ""; item-- ) 
{ 
	if( Name()== sym )
	{
		Buy condition;
	}
	if( Name()== sym )
	{
		Sell condition;
	}
	if( Name()== sym )
	{
		Short condition;
	}
	if( Name()== sym )
	{
		Cover condition;
	}
}

@Ganesan,

Not sure what you are really looking for with your question.

My interpretation..... If you want to see what a particular ticker does in the backtest, limit your backtest to the one ticker you want.

If those symbols of your list are the only ones of a sector of AB categorization then simply set Filter in Analysis to include that sector name e.g.

8

If those symbols are just a partial group within that sector's entire symbol list then simply add those symbols of post #1 to WatchList and then set Filter in Analysis to include that Watchlist e.g.

9

Of course you can do filter symbols via code also e.g.
executing code only if symbols are part a particular sector (ID):

sector_ID = 1;

if ( SectorID(0) == sector_ID ) {
	m = MA( Close, 20 );
	Buy = Cross( Close, m ); 
	Sell = Cross( m, Close ); 
	Short = Cover = 0;
}

or filter by Sector name:

if ( SectorID(1) == "Basic Materials" ) {
	m = MA( Close, 20 );
	Buy = Cross( Close, m ); 
	Sell = Cross( m, Close ); 
	Short = Cover = 0;
}

Or only running code if symbols are part of particular watch list number:

wl_number = 0;

if ( InWatchList(wl_number) ) {
	m = MA( Close, 20 );
	Buy = Cross( Close, m ); 
	Sell = Cross( m, Close ); 
	Short = Cover = 0;
}

or by inserting existing watch list name:

if ( InWatchListName("My Sector WL") ) {
	m = MA( Close, 20 );
	Buy = Cross( Close, m ); 
	Sell = Cross( m, Close ); 
	Short = Cover = 0;
}

And if you want to apply portfolio backtest or multiple individual backtests over those number of symbols then choose one of the two available backtest options

9

2 Likes