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)

<CPLUSPLUS:START>

 double TotalVolume;
 TotalVolume = 0.0;
 for (int i=0;i<_SIZE;i++)
 {
     if (VOLUME(i) != 1e9) TotalVolume = TotalVolume + VOLUME(i);
 }
 DBSaveDouble("_TICKER","Rank1",TotalVolume); 

<CPLUSPLUS:STOP>

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 <CPLUSPLUS:START> and <CPLUSPLUS:STOP> 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.

The C++ interpreted portion of the formulas can also make use of built-in functions.


These are:

DATABASE ACCESS FUNCTIONS

int DBFirst(); 
// Set the database pointer to the first record, 
// returns 0 if all went well, returns 1 if database is empty

int DBNext();  
// Moves the database pointer to the next record
// returns 0 if all went well, returns 1 if database is empty
// or if we reached the end of the database records

int DBPrevious(); 
// Moves the database pointer to the previous record
// returns 0 if all went well, returns 1 if database is empty
// or if we reached the top of the database records

int DBLast();  
// Set the database pointer to the last record, 
// returns 0 if all went well, returns 1 if database is empty

int DBSize();  
// returns the number of records in the database
// which also corresponds to the number of companies in the database

String DBGetTicker(); 
// returns the ticker symbol for the current record

Integer DBGetLastTradingDay(); 
// returns the last date for which there were trades
// the format is YYYYMMDD

Double DBGetDouble(String FieldName);
// gets the value for a database field of type double from the current record

String DBGetString(String FieldName);
// gets the value for a database field of type string from the current record

Integer DBGetLong(String FieldName);
// gets the value for a database field of type integer from the current record

DBSaveDouble(String Ticker,String FieldName,Double Value);
// Saves a pair of FieldName/FloatingPointNumericValue that corresponds 
// to Ticker

DBSaveString(String Ticker,String FieldName,String Value);
// Saves a pair of FieldName/StringValue that corresponds to Ticker

DBSaveLong(String Ticker,String FieldName,Integer Value);
// Saves a pair of FieldName/IntegerValue that corresponds to Ticker


COMPANY OBJECT ACCESS

Although data are stored in an efficient database that consists of
multiple tables (some of which are relational and some of which are not),
the data for a specific company are accessed via a special object 
we call COMPANY.

What follows is a list of methods (functions) that interact with that object.

Integer CompanyLoad(String Ticker);
// It initializes the COMPANY object and loads data for the
// date range defined previously with the use of the RANGE command.
// It returns 0 when succesful.

Integer CompanyApplySplitFactors();
// It applies any split factors for the current company to the range
// of the already loaded data. It returns 0 when successful.

Integer CompanyInterpolate();
// It calculates values for missing data. For example, since holidays that
// happen on weekdays do not have data, we need to provide some approximation
// for the missing data. This then allows us to perform calculations without
// always worrying about the incomplete data. It returns 0 when successful.

Integer CompanyGetBegDate();
// It returns the starting date for the stored data in the COMPANY object.
// The format of the date is YYYYMMDD.

Integer CompanyGetEndDate();
// It returns the Ending date for the stored data in the COMPANY object.
// The format of the date is YYYYMMDD.

Integer CompanyGetSize();
// It returns the number of days that are represented in the stored data
// in the COMPANY object.


Double CompanyGetPriceByDate(String FieldName, Integer YYYYMMDD);
// Returns for value from the collection of historical daily prices 
// (also known as a 'time series') for the defined date and series name.
// The supplied date must be an integer in the format YYYYMMDD.

Double CompanyGetPriceByIndex(String FieldName,Integer Index);
// Returns for value from the collection of historical daily prices 
// (also known as a 'time series') for the defined entry and series name.
// The first entry is referred as entry 0, whereas the last one is referred
// as _SIZE-1 (where -SIZE is the built-in variable that represents the length
// of each time series - since all time series are forced to have the same length).

Integer CompanyCreateNewColumn(String Ticker,String ColumnName);
// Creates a new empty time series. The resulting time series has
// the same range as all the other time series (which was originally defined
// by the RANGE function). Each time series has the ticker with which is
// associated and a unique name. For example, if the series is to store a 10
// day moving average for IBM, it can have the coluumn name "MA10" and the
// ticker "IBM".

SetCELL(String ColumnName,Integer RowID,Double Value);
// Sets the value for an individual entry in a time series

Double GetCELL(String ColumnName,Integer RowID);
// Reads the value from an individul entry in a time series

CalculateMOVAVG(String SourceVector,String ResultVector,Integer Step);
// Calculates a moving average. It expects the name of the existing vector
// with the data to use, the step of the moving average and the name of the
// new vector to be created.

CalculateEMA(String SourceVector,String ResultVector,Integer Step);
// Calculates an exponention moving average. It expects the name of the
// existing vector with the data to use, the step of the moving average 
// and the name of the new vector to be created.

GRAPH FUNCTIONS

Although any vector that is loaded from the database or it is calculated
can be displayed in a graph using formula functions such as GRAPHAREA, it can
also be added to a graph directly from your C++ script using the following
C++ script built-in functions:

GRAPHAREA(double Area1,
          double Area2,
          double Area3,
          double Area4,
          double Area5,
          double Area6);
// StockWiz 5 provides an easy way to display any vector that has been calculated 
//by the current formula to be displayed on a chart. The chart can actually have 
//up to 6 areas "stacked up" on each other. The function GRAPHAREA allows you 
//to define how many of those 6 areas to use and how much "real estate" 
//each graph should use.For example, GRAPHAREA(75,25,0,0,0,0) means that you
// only want to use two "stacked up" graphs and that the first one should 
// use 75% of the chart area and the second one should use %25 of the area.
//The 6 values passed as parameters to GRAPHAREA() must add to a hundred.

GRAPHOHLC(String Axis,
          String OPEN,
          String HIGH,
          String LOW,
          String CLOSE,
          String COLOR);
// Displays the named data as an OHLC chart

GRAPHBAR(String Axis,String VectorName,String COLOR);
// Displays the data for the named vector as a bar

GRAPHLINE(String Axis,String VectorName,String COLOR);
// Displays the data for the named vector as a line