AssignPriceColor

AssignPriceColor ( CustomColor color);

Default values:

Input parameters

Parameter Default value Description
color - Defines color to be assigned to the price bar.

Description

Sets a color of the price bar.

Example

declare lower;

plot MFI = MoneyFlowIndex();
plot OverBought = 80;
plot OverSold = 20;

MFI.DefineColor("OverBought", Color.ORANGE);
MFI.DefineColor("OverSold", Color.BLUE);

OverBought.SetDefaultColor(Color.GRAY);
OverSold.SetDefaultColor(Color.GRAY);

AssignPriceColor(if MFI >= OverBought then MFI.color("OverBought") else if MFI <= OverSold then MFI.color("OverSold") else Color.CURRENT);

In this example price bars are colored depending on the MFI plot which refers to the MoneyFlowIndex study. If the MFI is greater or equals 80 then the price plot is colored orange, if the MFI is lower or equals 20 then it is colored blue. In the rest of cases the color will not change and will remain grey which is defined by the Color.CURRENT constant. In order to be able to change colors for the AssignPriceColor function without actually changing the code, the example refers to colors of the MFI plot.

Note that you cannot paint the same price bar using multiple studies simultaneously.