This post refers to idea to EXCLUDE symbols from multiple watchlists while calculating the AddToComposites.
Just to explain, the database has Underlying, First Month, Second Month & Third Month futures. The futures are available only for limited stocks. I wish not to include the First Month, Second Month & Third Month futures for calculations so that data is clean for only the underlying alone.
- For ease of work, I have put the 3 months futures in a separate watchlist let’s say “2 - NSE FO Exclude”, but how do I exclude it in the code? I tried the following stuff:
if(!InWatchListName(“2 - NSE FO Exclude”)) AddToComposite(C>Ref(C,-1),"~NSE - Total Advances",“X”);
astonishingly there is no syntax error till the time the scan is RUN. But the calculated data is wrong.
The test code is as follows:
_SECTION_BEGIN("Composites");
// Advance / Decline Composite Index
AddToComposite(C>Ref(C,-1),"~Advances","X");
AddToComposite(C<Ref(C,-1),"~Declines","X");
AddToComposite(C==Ref(C,-1),"~NoChange","X");
AddToComposite ( IIf( C>Ref(C,-1), V, 0),"~Advance Volumes","C");
AddToComposite ( IIf( C<Ref(C,-1), V, 0),"~Decline Volumes","C");
AddToComposite ( IIf( C==Ref(C,-1), V, 0),"~Unchanged Volumes","C");
/*
ValChg = ROC(C,1) * V;
AddToComposite( IIf( C>Ref(C,-1), Valchg , 0), "~Advancing Value", "C");
AddToComposite( IIf( C<Ref(C,-1), -Valchg , 0), "~Declining Value", "C");
//NSE - NIFTY 50 SPECIFIC
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite(C>Ref(C,-1),"~NSE - NIFTY 50 Advances","X");
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite(C<Ref(C,-1),"~NSE - NIFTY 50 Declines","X");
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite(C==Ref(C,-1),"~NSE - NIFTY 50 NoChange","X");
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite ( IIf( C>Ref(C,-1), V, 0),"~NSE - NIFTY 50 Advance Volumes","C");
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite ( IIf( C<Ref(C,-1), V, 0),"~NSE - NIFTY 50 Decline Volumes","C");
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite ( IIf( C==Ref(C,-1), V, 0),"~NSE - NIFTY 50 Unchanged Volumes","C");
ValChg = ROC(C,1) * V;
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite( IIf( C>Ref(C,-1), Valchg , 0), "~NSE - NIFTY 50 Advancing Value", "C");
if( InWatchListName("NSE - NIFTY 50") ) AddToComposite( IIf( C<Ref(C,-1), -Valchg , 0), "~NSE - NIFTY 50 Declining Value", "C");
Buy = 0;
//NSE - NIFTY MIDCAP100 SPECIFIC
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite(C>Ref(C,-1),"~NSE - NIFTY MIDCAP100 Advances","X");
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite(C<Ref(C,-1),"~NSE - NIFTY MIDCAP100 Declines","X");
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite(C==Ref(C,-1),"~NSE - NIFTY MIDCAP100 NoChange","X");
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite ( IIf( C>Ref(C,-1), V, 0),"~NSE - NIFTY MIDCAP100 Advance Volumes","C");
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite ( IIf( C<Ref(C,-1), V, 0),"~NSE - NIFTY MIDCAP100 Decline Volumes","C");
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite ( IIf( C==Ref(C,-1), V, 0),"~NSE - NIFTY MIDCAP100 Unchanged Volumes","C");
ValChg = ROC(C,1) * V;
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite( IIf( C>Ref(C,-1), Valchg , 0), "~NSE - NIFTY MIDCAP100 Advancing Value", "C");
if( InWatchListName("NSE - NIFTY MIDCAP100") ) AddToComposite( IIf( C<Ref(C,-1), -Valchg , 0), "~NSE - NIFTY MIDCAP100 Declining Value", "C");
*/
Buy = 0;
_SECTION_END();