Dear Group,
I am crating a composite to check number of stocks in a watchlist "NIFTY 500" which are above and below their 50 DMA. Possibility of C=MA50 is pretty remote. The afl is as follows:
_SECTION_BEGIN("Advance Decline Line 500");
MA20 = EMA(C,20);
MA50 = EMA(C,50);
MA100 = EMA(C,100);
MA200 = EMA(C,200);
if( InWatchListName("NSE - NIFTY 500") AND Name()!="NIFTY 500" ) AddToComposite(C>MA50,"~NSE - NIFTY 500 Above MA50","X",flags = atcFlagDefaults);
if( InWatchListName("NSE - NIFTY 500") AND Name()!="NIFTY 500" ) AddToComposite(C<MA50,"~NSE - NIFTY 500 Below MA50","X",flags = atcFlagDefaults);
//if( InWatchListName("NSE - NIFTY 500") AND Name()!="NIFTY 500" ) AddToComposite(C=MA50,"~NSE - NIFTY 500 At MA50","X",flags = atcFlagDefaults);
ScripF1="~NSE - NIFTY 500 Above MA50";
ScripF2="~NSE - NIFTY 500 Below MA50";
//ScripF3="~NSE - NIFTY 500 At MA50";
CloseF1=Foreign(ScripF1,"Close");
CloseF2=Foreign(ScripF2,"Close");
//CloseF3=Foreign(ScripF3,"Close");
CloseTotal = CloseF1 + CloseF2;
//CloseTotal = CloseF1 + CloseF2 +CloseF3;
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Graph0=Plot(CloseF1, "Adv Line", colorGreen, styleThick);
Graph1=Plot(CloseF2, "Dec Line", colorRed, styleThick);
Graph2=Plot(CloseTotal, "Adv-Dec Line", colorBlack, styleDots);
//Graph3=Plot(C,"Close",colorBlack,styleCandle);
Filter=1;
AddColumn(CloseF1,"Above50MA",1.0);
AddColumn(CloseF2,"Below50MA",1.0);
AddColumn(CloseTotal,"Total",1.0);
_SECTION_END();
Issue is the Total Number of stocks (CloseTotal = CloseF1 + CloseF2) seems to be varying with dates. The sample of Watchlist is list of Top 500 stocks in Indian Equities and therefore possibility of new listings within the space is that much difficult.
So there seems to be something wrong out there. Whether it has to do with the flags, am bit perplexed