COLORIZE CLOSING PRICE IN TITLE

Is it possible to have the closing price IN THE TITLE SECTION OF CHARTS, displayed in APPROPRIATE COLOR (brightgreen or red)?

Thanks,
Gary

@GCSami welcome to this AmiBroker Community.

Try to apply this snippet to a new blank chart or pane:

roc1Bar = ROC(C, 1);
upBar = roc1Bar > 0;
downBar = roc1Bar < 0;
// create an array of colors - a color for each bar based on its state (positive: green, negative: red, flat: yellow)
closeColors = IIf(upBar, colorBrightGreen, IIf(downBar, colorRed, colorYellow));
// use EncodeColor() to set the color using the SelectedValue() function
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close " + EncodeColor(SelectedValue(closeColors)) + " %g (%.1f%%) " + EncodeColor(colorDefault) +
"{{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

Plot( C, "Close", ParamColor("Color", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );

A good overview of title customization is found here.

P.S. Please, avoid sending duplicate posts!

1 Like

Thank you. I will check out the title customization overview.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.