Skip to content

WithinRange Function

By Optuma Team · Updated 2020-04-01

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.

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.

Choose which categories of cookies you allow. Strictly-necessary cookies are always on. You can change this any time via the "Cookie Settings" link in the footer.

  • Functional

    Remember preferences like dismissed banners and your dark-mode choice.

  • Analytics

    Help us understand how the site is used so we can improve it.

  • Marketing

    Measure our advertising and help us reach people who may be interested in Optuma.