- Desktop
- Scripting
- Formulas and Scripting Functions
- WithinRange Function
WithinRange Function
Overview
Section titled “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
Section titled “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.
Your privacy choices
We use cookies and similar technologies to make the site work, see how it's used, and improve it. Analytics and advertising cookies only run with your consent — see our Privacy Policy for details.