WithinRange Function

Author: Optuma Team Last updated: Apr 1, 2020 05:26

Overview

The WithinRange() script function allows you to find where a value is within x% of another value. For example, where the Closing price of a stock is within 5% of the All Time High.

Examples

The following script will show a True result when the Close is within 2% of a 150EMA.

V1 = CLOSE() ;
V2 = MA(BARS=150, STYLE=Exponential) ;
WITHINRANGE(V1,V2, PERCENT=2.00)

Shaded Zones indicate the scripted criteria is returning a True result.

The following script will show a True result when the High is within 5% of the All Time High value.

V1 = HIGH() ;
V2 = HIGHESTHIGH(RANGE=All Time) ;
WITHINRANGE(V1,V2, PERCENT=5.00)

Shaded Zones indicate the scripted criteria is returning a True result.

The following script will show a True result when the ADX + line is within a range of 10% of the ADX - line.

V1 = ADX().DMPlus ;
V2 = ADX().DMMinus ;
WITHINRANGE(V1,V2, PERCENT=10.00)

Shaded Zones indicate the scripted criteria is returning a True result.