//
// Find the 100 most active companies over the last 50 days
// using total volume
//
RANGE(-50,_LASTDATE)
CLOSE =LOAD(_TICKER,CLOSE)
VOLUME=LOAD(_TICKER,VOLUME)
RANK1 = INIT(_TICKER)
RANK2 = INIT(_TICKER)
//
// We only consider companies that do not have
// any missing days
//
STOPIF (CLOSE,45)
// Interpolate for missing values
ICLOSE =INTERPOLATE(CLOSE)
IVOLUME=INTERPOLATE(VOLUME)
CPP: double TotalVolume;
CPP: TotalVolume = 0.0;
CPP: for (int i=0;i<_SIZE;i++)
CPP: {
CPP: if (VOLUME(i) != 1e9) TotalVolume = TotalVolume + VOLUME(i);
CPP: }
CPP: DBSaveDouble("_TICKER","Rank1",TotalVolume);
RUNCODE()
RANK2 = UPDAYS(IVOLUME)
//
// The following commands are processed only
// when program is done applying formula to all stocks
//
FIELDS: TICKER,NAME,RANK1,RANK2
CONDITION: (RANK1>1000) AND (RANK2>22) AND (LastClose > 1.00)
OUTPUT: EARLY_RISERS
ORDERBY: RANK1 DESC
TOP: 100