{"id":285,"date":"2007-06-15T03:46:36","date_gmt":"2007-06-15T03:46:36","guid":{"rendered":"http:\/\/www.amibroker.org\/userkb\/2007\/06\/15\/using-custom-colors-color-picking\/"},"modified":"2007-07-08T13:04:03","modified_gmt":"2007-07-08T13:04:03","slug":"using-custom-colors-color-picking","status":"publish","type":"post","link":"http:\/\/www.amibroker.org\/editable_userkb\/2007\/06\/15\/using-custom-colors-color-picking\/","title":{"rendered":"Color Picking"},"content":{"rendered":"

article 2\/5<\/EM><\/DIV>
\n
\nIn AmiBroker, the colors of many of the chart elements can be customized from within simple AFL formulas. The most common application of this feature is when plotting indicators, where the third parameter of the Plot() function allows users to set the color to their own preference e.g. Plot(C,"Close",colorRed<\/STRONG>, styleLine).

A short hand method, to specify the color, is to substitute colorRed with the number 32, which is the color index number for Red e.g. Plot(C,"Close",32<\/STRONG>, styleLine). It can, however, be difficult to remember the color names and the index numbers. (Refer to the AFL Reference Manual reserved variables table for the complete list).

The Color-Picker, on the Format Toolbar, is used as a graphical method for setting the color of drawing objects placed on the chart, as well as chart plots. It can also act as a handy reminder tool when stipulating color preferences in formulas. A prompt appears, when the mouse is hovered over the Color-Picker, and provides the correct name for each color. The name can then be appended to the color parameter within formulas.

To use the Color-Picker as a name prompt:
<\/STRONG>
a) open it from the drop-down on the Format Toolbar. <\/STRONG>(Note that the Color-Picker can be opened in the background, to act as a dynamic prompt, while working with the Formula Editor window open);

\"CP004\"

b) position the mouse over the color of choice.

\"CP011\"

c) replace Name<\/STRONG>, in colorName <\/STRONG>parameters, with the color title exactly as written e.g. colorName<\/STRONG> becomes colorRed. <\/STRONG>(Remove all gaps, hyphens and special characters e.g. Grey-50% becomes Grey50. Note that there are a few exceptions; Grey-80% becomes DarkGrey, Grey-25% becomes LightGrey, Light Green becomes PaleGreen and Light Turquoise becomes PaleTurquoise).

To use the Color-Picker as a color index prompt:
<\/STRONG>
a) open the Color-Picker<\/STRONG>;
b) choose the preferred color, and obtain it’s index number, by counting to the right from the first number in each row (the index is zero based, and the first sixteen colors are reserved for custom colors, so the first row starts with 16 and the second starts with 16 + 8 = = 24 etc. (The color index number for Red<\/STRONG>, as the first color in the third row, is therefore 32<\/STRONG>).

\"CP013\"

Color indexing is a better method of changing colors, at the formula level, than using colorNames, as it is quicker and there are no exceptions to remember. As an example, the formula in the Editor image above, which was originally used in the Users’ Knowledge Base post ’How Many Trading Days In A Calendar Year?’ with colorBlack and styleLine settings, has been changed to a colorRed styleHistogram chart using the shorthand color index 32 (text highlighted in yellow).

\"CP003\"
<\/STRONG>
The Color-Picker can be torn-off the toolbar if required:
<\/STRONG>
a) drop the Color-Picker <\/STRONG>down;
b) click and hold the mouse pointer on the tear-off line<\/STRONG>;

\"CP014\"

c) when a moving pointer appears the window can be dragged to the desired position.

\"CP015\"










<\/p>\n","protected":false},"excerpt":{"rendered":"

article 2\/5 In AmiBroker, the colors of many of the chart elements can be customized from within simple AFL formulas. The most common application of this feature is when plotting indicators, where the third parameter of the Plot() function allows users to set the color to their own preference e.g. Plot(C,"Close",colorRed, styleLine).A short hand method, […]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[90],"tags":[],"_links":{"self":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/285"}],"collection":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":0,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.amibroker.org\/editable_userkb\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}