StockWiz 5 formulas allow for segments of C++ code to be inserted into a formula. That code is then interpreted. Here is an example:

 

 


//
// Find companies with rising prices and rising volume
// using UPDAYS as a meaure
//

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)

STOPIF2(CLOSE(-1)<1.0)
STOPIF2( CLOSE(-1) == 1e9 )
STOPIF2( CLOSE(SIZE-1) == 1e9)

// 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 AS "Total Volume Last 50 Days",RANK2 AS "Number of up days" 
CONDITION: (RANK1>1000) AND (RANK2>22) AND (LastClose > 1.00)
OUTPUT: EARLY_RISERS
ORDERBY: RANK1 DESC
TOP: 100

The CPP: commands essentially store the C++ code and the RUNCODE() gives the message to process it.

The _SIZE variable is a built-in variable that represents the size of the matrix and therefore the size of each vector, since all vectors are of the same length.