FUNCTION: STOPIF

STUB: STOPIF(VectorName,number_of_non_NA_points)


Function STOPIF will stop the execution of the formula if the named vector does not have enough non-missing points.

If you are running the formula for multiple companies, the execution will stop for the current company. The program will then proceed to evaluate the formula for the next company. Because of this and if you are planning to store any calculation results back to the Rank1 to Rank10 fields of the Summary table, you should initialize that value and store it in the Summary table before calling the STOPIF function.

Here is an example:

//
// Run this for all companies in the Summary table
//


RANGE(-200,_LASTDATE)
CLOSE=LOAD(_TICKER,CLOSE)
RANK1=INIT(_TICKER)
STOPIF(CLOSE,2)
RANK1=UPDAYS(CLOSE)

//
// Create a report called HIGH_ACHIEVERS where the number
// of up days (as stored in the field RANK1 of the Summary
// table) is greater than 20
//

FIELDS: TICKER,NAME,RANK1
CONDITION: (RANK1>20)
OUTPUT: HIGH_ACHIEVERS
ORDERBY: RANK1 DESC

As you see in the example, we call INIT first to set Rank1 to a NULL value and then we check for sufficient prices in the CLOSE vector.

How many values are sufficient?

This is all up to you. If your range consists of 200 values you may want to set the number of sufficient values to 100. It all depends on what calculations you are performing.