Category
General-Purpose Functions
Description
Maps a value from one scale to another
Syntax
Rescale(value, valmin, valmax, scalemin, scalemax, bound {0})
Parameters
value - the value to rescale
valmin - the bottom of the range that value comes from
valmax - the top of the range that value comes from
scalemin - the bottom of the range to scale value to
scalemax - the top of the range to scale value to
bound {0} - whether value < valmin or value > valmax should be adjusted before rescaling
Return Value
If bound is zero or omitted: (value - valmin) / (valmax - valmin) * (scalemax - scalemin) + scalemin
If bound is non-zero: (Bound(value, valmin, valmax) - valmin) / (valmax - valmin) * (scalemax - scalemin) + scalemin
Example
NormalizedTurnover: Rescale(Close * Volume, 1e5, 1e12, 1, 10, 1)
|