FastKCustom

FastKCustom ( int length);

Default values:

length: 14

Description

Returns values from 0 through 100 depending on a price. If the price is the lowest for the last length bars then 0 is returned. If the price is the highest for the last length bars then 100 is returned.

The function is calculated according to the following algorithm:

FastKCustom = if Highest(close, 12) - Lowest(close, 12) > 0 then (close - Lowest(close, 12)) / (Highest(close, 12) - Lowest(close, 12))*100 else 0

Input parameters

Parameter Default value Description
data - Defines data for which the FastK is found.
length 14 Defines the period on which the prices are translated into 0..100 range.

Example

declare lower;
input colorNormLength = 14;
plot Price = close;
def abs = AbsValue(Price);
def normVal = FastKCustom(abs, colorNormLength);
Price.AssignValueColor( CreateColor(255, 2.55 * normVal, 0) );

The example plots the EMA using the manual thinkScript® implementation and the built-in function. The resulting plots coincide forming a single curve.

The FastKCustom function is used to assign a normVal value to each bar depending on its price. Zero value is assigned if the current closing price is the lowest on the last 14 bars, 100 is assigned if the current closing price is the highest on the last 14 bars. The normVal is used in the AssignValueColor function to paint a plot with colors ranging from red (255, 0,0) to yellow (255, 255, 0). The green component of the color varies depending on the current value of normVal.