 LoopDev

Description
Type Function

Category MISC

Short Description LoopDev(''formula'',iterations[,start,increment]) Executes the formula a number of times and returns the standard deviation. A special variable CTR (short for counter) is available for the formula that is incremented each time.

Full Description

Parameters:
formula: the formula to be executed in the loop. The special CTR variable must be used here.
iterations: the number of times to execute the formula (2-50)
start: the starting value of CTR (default 0)
increment: how much CTR is incremented for each iteration (default 1)

Example 1 You can recreate PctDev(50, 5) like this:

LoopDev("Close(CTR)", 50, 0, 5) / (LoopSum("Close(CTR)", 50, 0, 5) / 50) * 100

Example 2 Calculate net margin volatility over 10 years, perhaps as a risk measure:

LoopDev("IAC(CTR, ANN) / Sales(CTR, ANN)", 10)

Example 3 Calculate the number of standard deviations the P/B ratio is above or below its historical mean, perhaps for relative valuation purposes:

((Close(0) / BookVal(0, QTR)) - LoopSum("Close(CTR*252) / BookVal(CTR*4, QTR)", 5) / 5) / LoopDev("Close(CTR*252) / BookVal(CTR*4, QTR)", 5)

This is a historical z-score. Breaking it down:

Close(0) / BookVal(0, QTR) is the current P/B ratio.

LoopSum("Close(CTR*252) / BookVal(CTR*4, QTR)", 5) / 5 is the average P/B ratio over 5 years.

LoopDev("Close(CTR*252) / BookVal(CTR*4, QTR)", 5) is the standard deviation of the P/B ratio over 5 years.

The amount by which the P/B ratio deviates from its historical value is normalized against the standard deviation.
Results: Total score: 15 , # of Votes: 4 , Average: 3.8
You will be able to view details once you have voted.
Requested by: acamus
On date: 07/30/12
Category: Factors and Functions

1 comment