AssignNormGradientColor ( int length , CustomColor lowestColor , CustomColor highestColor );
Description
Fills a plot with a gradient using the current, the lowest, and the highest values of the last length
bars to define a specific color. If the current plot value is positive and the highest, then it is painted with the highestColor
. If the current plot value is negative and the lowest, then it is painted with the lowestColor
. The center color of the gradient is always situated on the zero level which means that the positive part of the plot uses the higher colors of the gradient, and the negative part uses the lower colors.
Note that Past Offset is not affected by length
parameter as the function assigns length = 1
to the first bar and then gradually increases it to the specified value.
Input parameters
Parameter | Default value | Description |
---|---|---|
length | - | Defines the period upon which the highest and lowest values are found. This parameter can be expressed as a dynamic value. |
lowestColor | - | Defines color corresponding to the lowest value. |
highestColor | - | Defines color corresponding to the highest value. |
Example
declare lower;
input colorNormLength = 14;
input fastLength = 9;
input slowLength = 18;
plot PriceOsc = Average(close, fastLength) - Average(close, slowLength);
PriceOsc.AssignNormGradientColor(colorNormLength, Color.LIGHT_RED, Color.YELLOW);
The example shows the Price Oscillator study which is a momentum study calculated as the difference between two moving averages. The biggest positive difference for the last colorNormLength
is painted yellow, the smallest is painted light red. The rest of the values are painted using intermediate colors depending on how far they are located from the two extreme points.