Print Page  
Advanced Functions / Relative vs. History
LoopRel("formula(CTR)", iterations[, start=0, increment=0, NA_value=NA, NA_pct=20])
Full Description

These functions compare the most recent value vs. historical values and calculate a relative statistic. They can be used, for example, to find stocks that are trading at lower valuations than historically. These "Loop" functions evaluate a loop formula multiple times using an offset dynamically updated using a CTR variable.

LoopZScore("formula(CTR)", iterations[, start, increment, clip, NA_value, NA_pct])
Calculates the Z-Score of the latest value vs. all the values.

LoopRank("formula(CTR)", iterations[, start, increment, sort, sort_style, NA_value, NA_pct])
Calculates the percentile rank of the latest value vs. all the values.

LoopRel("formula(CTR)",iterations [, start=0, increment, NA_value, NA_pct])
Calculates the relative value vs. the minimum and the maximum of the samples. The range of values is from 0 to 1.

Parameters

formula(CTR): the loop expressions you want evaluated using the CTR iterator
iterations: how many samples will be used
start: the starting value for CTR. Default is 0.
increment: how much to increment CTR by. Default is 1.
clip: z-score clip. Defaults to 3.5 which clips to either -3.5 or +3.5
sort: how the values are sorted. Can be either #ASC or #DESC (default)
sort_style: how the ranks are distributed. Can be either #Top (default) or #Neutral
NA_value: value for NAs. Defaults to NA
NA_pct: the max percentage of values that can be NA (0-80, default 20)

Example

Screen for stocks that have reported a Gross Margin in the top 90th percentile when compared to the last 20 previously reported values.

LoopRank("GMgn%(CTR, TTM)",20) >= 90