Navigation: Study Formulas > Utility

Utility

Top  Previous  Next

The study formulas included in the Utility section are:

 

 

correlation()

 

This function correlates two input streams and returns the coefficient of determination. There are 3 available calculation types. Calculation Type 1 will correlate on the actual  values, Calculation Type 2 will correlate on the percent change of the values, and Calculation Type 3 will correlate strictly on relative change (i.e., whether a value is greater than the prior value or less than the prior value). The input streams can be standard data points or other studies.

 

Parameters

 

period

the input length

calc

the calculation type

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

currentTrend()

 

This function calculates the difference between input source #2 and input source #1 and returns a positive value if input source #1 is greater than input source #2 or a negative value if input source #1 is less than input source #2. The input streams can be standard data points or other studies.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

isWithin()

 

Returns 1.0 if source #2 is within percent distance from source #1 (either above or below), otherwise returns 0. For example, if we assume that Study01 is a moving average then isWithin(0.05,Study01,Symbol.close) would return 1.0 if the close is within 5% (i.e., within 5% above or within 5% below) of the moving average, otherwise it would return 0. The input streams can be standard data points or other studies.

 

Parameters

 

percent

max allowable distance. you would enter 5% as 0.05.

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study. the distance, as a percentage, is measured from this stream.

source2

the second input stream. the values in this stream are compared to the first stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

normalizeDynamic()

 

This function will normalize an input stream (typically an oscillator) to a value between 0.0 and 1.0 based on an analysis of the values over the period specified. You would use this function when you don't know in advance what the range will be. The normalizeDynamic formula will determine the highest and lowest values over the period specified and will use those values to normalize the current value to a range between 0.0 and 1.0. Use the direction parameter to reverse the polarity of the calculation. The input stream can be a standard data point or it can be another study.

 

Parameters

 

period

the input length

direction

1=normal, 2=reverse

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

normalizeFixed()

 

This function will normalize an input stream (typically an oscillator) to a value between 0.0 and 1.0 based on the range specified. You would use this function when you know in advance what the range will be. Use the direction parameter to reverse the polarity of the calculation. The input stream can be a standard data point or it can be another study.

 

Parameters

 

lorange

the lower range for normalization

hirange

the upper range for normalization

direction

1=normal, 2=reverse

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

standardDeviation()

 

This function calculates the standard deviation of the input stream over the length specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

period

the input length

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

standardError()

 

This function calculates the standard error of the input stream over the length specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

period

the input length

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamABS()

 

This function returns the absolute value of the values in the input stream. The input stream can be a standard data point or it can be another study.

 

Parameters

 

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamCrossAbove()

 

This function returns the number of bars elapsed since source1 crossed over source2 on bar close. So it returns 0 on the opening of the bar following the close of the bar where the cross over occurs. On the next bar, it would return 1 and on the next bar after that it would return 2, etc.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamCrossBelow()

 

This function returns the number of bars elapsed since source1 crossed under source2 on bar close. So it returns 0 on the opening of the bar following the close of the bar where the cross under occurs. On the next bar, it would return 1 and on the next bar after that it would return 2, etc.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamDaysAgo()

 

For use with intraday timeframes. Retrieves a value from source1 from daysback days ago at the timestamp of the bar referenced by offset. If offset is 0 and daysback is 1, and if the bar at offset 0 has a timestamp of 09:30, then the function will attempt to retrieve the value of the 09:30 bar from source1 1 day ago. The inv parameter is not used by this function (function will always operate on the stream that is passed as source1). The input stream can be a standard data point or it can be another study.

 

When using this function you need to be aware of the number of bars of data that are available. The default number of bars to download is 300, and that value can be adjusted up to 600 on the Symbols page in Configuration Manager. If you are using, for example, 1-min bars of 24-hour data it would require at least 1440 bars of data to be available in order to lookup the value of a 1-min bar from 1 day ago, which would exceed the number of bars that could possibly be available. However if you were using 60-min bars of 24-hour data then only 24 bars would be required to lookup the value from 1 day ago.

 

Parameters

 

offset

the bar offset at which to start the calculation

daysback

the number of days back for which to retrieve the value (1 or greater)

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamDif()

 

This function returns the difference between the values in two input streams. Subtracts the value of input stream #2 from that of input stream #1. The input streams can be standard data points or other studies.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. the values in this stream are subtracted from the first stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamDifValue()

 

This function subtracts the values in input stream by the value specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

value

the value to subtract from the input stream

source1

the input stream. the values in this stream are reduced by value. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamDiv()

 

This function divides the values in input stream #1 by the values in input stream #2. The input streams can be standard data points or other studies.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. the values in this stream are divided into the first stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamDivValue()

 

This function divides the values in input stream by the value specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

value

the value to divide into the input stream

source1

the input stream. the values in this stream are divided by value. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamHighest()

 

This function will return the highest value in the input stream over the specified lookback period, using the offset specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

offset

the bar offset at which to start the calculation

lookback

the number of bars over which to perform the calculation

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamIntraHighest()

 

Intraday Only. This function will return the highest value in the input stream for the current day. The input stream can be a standard data point or it can be another study. When using this function you must be certain that you have enough bars available in ScanExpert to account for 1 full day. For 1-min bars with a session from 9:30 to 16:00 you would need to request at least 390 bars. Because ScanExpert is restricted to loading a maximum of 600 bars per symbol, this function cannot be used in conjunction with 24-hour 1-min bars (which would require a minimum of 1440 bars).

 

Parameters

 

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamLowest()

 

This function will return the lowest value in the input stream over the specified lookback period, using the offset specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

offset

the bar offset at which to start the calculation

lookback

the number of bars over which to perform the calculation

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamIntraLowest()

 

Intraday Only. This function will return the lowest value in the input stream for the current day. The input stream can be a standard data point or it can be another study. When using this function you must be certain that you have enough bars available in ScanExpert to account for 1 full day. For 1-min bars with a session from 9:30 to 16:00 you would need to request at least 390 bars. Because ScanExpert is restricted to loading a maximum of 600 bars per symbol, this function cannot be used in conjunction with 24-hour 1-min bars (which would require a minimum of 1440 bars).

 

Parameters

 

source1

the input stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamMult()

 

This function multiplies the values in input stream #1 by the values in input stream #2. The input streams can be standard data points or other studies.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. the values in this stream are multiplied by the values in the first stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamMultValue()

 

This function multiplies the values in input stream by the value specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

value

the value by which to multiply the input stream

source1

the input stream. the values in this stream are multiplied by value. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamOffset()

 

This function offsets the input stream back by the number of bars specified.. The input stream can be a standard data point or it can be another study.

 

Parameters

 

offset

the number of bars by which to offset the input stream

source1

the input stream. the values in this stream are offset by the number of bars specified. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamPercentDif()

 

This function returns the distance of source #2 from source #1 as a percentage.  For example, streamPercentDif(Symbol.hl2,Symbol.high) would return the distance from the high of the bar to the midpoint of the bar as a percentage of the midpoint. 2% would be returned as 0.02. -2% would be returned as -0.02. The input streams can be standard data points or other studies.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study. the distance, as a percentage, is measured from this stream.

source2

the second input stream. the values in this stream are compared to the first stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamRegression()

 

This function calculates the linear regression in input stream over the period specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

period

the input period

source1

the input stream from which the regression is calculated. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamRegressionSlope()

 

This function calculates the slope of the linear regression in input stream over the period specified. The input stream can be a standard data point or it can be another study. streamRegressionSlope() is a good tool to use for trend determination (i.e., positive slope, trend is up and negative slope, trend is down).

 

Parameters

 

period

the input period

source1

the input stream from which the regression is calculated. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamRSquared()

 

This function calculates the R-Squared value for input stream over the period specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

period

the input period

source1

the input stream from which r-squared is calculated. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamSlope()

 

This function calculates the slope of the input stream over the period specified. The input stream can be a standard data point or it can be another study. streamSlope() is a good tool to use for trend determination (i.e., positive slope, trend is up and negative slope, trend is down).

 

Parameters

 

period

the input period

source1

the input stream from which the regression is calculated. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamSum()

 

This function adds the values in input stream #1 to the values in input stream #2. The input streams can be standard data points or other studies.

 

Parameters

 

source1

the first input stream. select from one of the standard data points or select the output of another study as input for this study

source2

the second input stream. the values in this stream are added to the values in the first stream. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

streamSumValue()

 

This function adds the values in input stream by the value specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

value

the value to add into the input stream

source1

the input stream. the values in this stream are added to value. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval

 

 

 

summation()

 

This function calculates the sum of values in input stream over the period specified. The input stream can be a standard data point or it can be another study.

 

Parameters

 

period

the input period

source1

the input stream. the values in this stream are summed together over the period specified. select from one of the standard data points or select the output of another study as input for this study

inv

select the bar interval on which this study should be calculated or leave blank to calculate on the default bar interval