Extending The Range

article 4/5

The custom colors in the Color-Picker are like a collection of color favorites; they are available to use within the program wherever graphical color choices are made, however the choice is limited to sixteen. There may be situations, when plotting, where an extended range of colors is required. This is provided for by the Parameters Color-Picker, where additional custom colors can be selected, from a wide range, for any parametrical plot.

The following formula will be used to demonstrate how to apply an extended custom color to a plot.

1
2
3
4
5
6
7
/*P_Foreign*/ 
 
//Color = ParamColor("Color",colorRed); 
//Plot(C,"Close",Color,styleLine); 
 
Plot(C,"Close",colorBlack,styleLine);
PlotForeign("GM","GM",colorCustom2, styleLine);


To apply the formula as a dynamic indicator chart:

a) save the code as P_Foreign,
b) right click on it and select Edit from the context menu (the Formula Editor window will open),
c) click on Apply from the Formula Editor Standard Toolbar. (The indicator will open in a new dynamic pane, however, the dynamics will only hold for the initial instance, while the Formula Editor remains open ).

CustomColorExtensions002

(Note that for this example the DJIA example database installed with AmiBroker has been used. AA, the first stock symbol in that database, is the current chart, and GM has been chosen as the foreign symbol, because, at the time of writing it’s price was close to that of AA. This provides a more compact view in the chart. Readers who are following this tutorial can substitute any other symbols as required).

The ParamColor function then needs to be added to the formula, to add a graphical Color-Picker interface to the chart.

To add color parameters to the current symbol:

a) uncomment line 3 (this assigns the ParamColor function output to the variable Color),
b) uncomment line 5 (this substitutes the ’contents’ of the variable Color, for the reserved variable colorBlack, in the standard plot code),
c) comment out the standard plot code in line7 (it has been replaced by line 5),
c) Save the formula to apply the new settings.

CustomColorExtensions004

The plot color for AA is now the default color of the ParamColor function i.e. colorRed. This can be changed to a custom color, that is not available in the color favorites group, from within the Properties window.

To apply an extended custom color to the current plot:

a) right click in the chart,
b) select Parameters from the context menu (the Properties window will open with the Parameters [tabbed] page in view),
c) use the dropdown on that page to open the Color-Picker,

CustomColorExtensions005

d) click on More at the bottom of the Color-Picker table (the Palette Editor opens),
e) check the second box on the top row of Custom colors (for this example only Custom color box two will be set),
f) then pick a Basic color (the check marks on Custom color box2 will not be retained but it is still the active box),
g) click on the desired base color variation in the Luminescence bar, or, click/hold and drag the arrow head for fine control,
h) in addition, or alternatively, click on the desired color variation in the Color Matrix, or click/hold and drag the moving pointer for fine control, (to allow for ease of replication, this example was created using option ’g’ alone).

CustomColorExtensions006

i) when the desired color is displayed in the Color/Solid box select Add to Custom Colors > OK. (The new color will be applied to the Parameters color setting and appear in the chart).

CustomColorExtensions007

Notice that the foreign plot is still referencing colorCustom2 (Black), from the favorites collection, while the current symbol color is referencing the color selected from the extended range. (The extended Palette Editor does not overwrite the favorites collection!).

CustomColorExtensions009

When using extended custom colors, it is not necessary to set them in the Custom colors table, as per the example, unless two or more will be used and interchanged in the one session. (If that is the case Custom colors can be set, to allow for an easy return to the same color, but they will not be available in a new session). The method used was chosen purely to demonstrate the differences between color favorites and extended custom colors . The easiest way to set extended colors, for one off use, is simply to click OK once the desired color has been produced by manipulating the matrix pointer.

While the Custom color settings are not retained between sessions any preferred Parameter color settings are e.g. the current view will be reinstated after closing and reopening AmiBroker. (In the installed version the current chart is automatically saved, as the default, at the end of the session).

The current view can also be saved for recycling, as a template, so that it will not be overwritten if the default is changed.

To save the current view as a template:

a) right click in the chart and select Template > Save from the available options, (the Save As window will open),

CustomColorExtensions015

b) Name the file and Save it. (The current data folder is the default view in the installed version. Thereafter it will change to the last folder used in this window).

CustomColorExtensions024

The saved template operates globally, as well as with the local database, so, if it is going to be used with other databases it is more convenient to save it in a generic Templates folder.

To create a Template folder and save a template file (continuing from step ’a’ above):

a) click on the Up One Level icon to access the AmiBroker folder list,

CustomColorExtensions016

b) create a new folder under AmiBroker, (a New Folder will appear with the name highlighted in blue),

CustomColorExtensions025

c) hit the Delete key to clear the text and rename the folder by typing Templates into the folder text box,
d) open the Templates folder, after naming it, and save the template file there as P_Foreign.

CustomColorExtensions020

The template, complete with the parameter color settings, can be reinstated anytime, and for any database. (In this case the database would need to contain the symbol used in the formula.).

To open the saved template:

(As preparation for this example, and to demonstrate the functionality of templates, the chart window was closed and AmiBroker was shutdown. After reopening AmiBroker a New > Blank Chart was installed from the File menu. In normal use it is not necessary to do this as the template will overwrite any chart when it is opened).

a) right click in the chart window where the template is to be installed,

CustomColorExtensions021

b) browse the file list and open P_Foreign.ALY that is in the Templates folder,

CustomColorExtensions023

P_Foreign will open using the first symbol in the All symbols list. (This example was created using the DJIA example database installed with AmiBroker. ^DJI is the first symbol in that database, so, in the example it is the current symbol).

c) select AA from the All symbols list to restore the view to the saved version.

Additional foreign plots can be added to the chart, each with their own customized color.

To add additional customized plots:

a) copy/paste line 3 & 8 into the Formula Editor page, as line 10 & 12 respectively, then edit them as shown to add Color2 as a Parameter option, (after saving, dual options will become available in the Properties window),

1
2
3
4
5
6
7
8
9
10
11
12
/*P_Foreign*/
 
Color = ParamColor("Color",colorRed);
 
Plot(C,"Close",Color,styleLine);
 
//Plot(C,"Close",colorBlack,styleLine);
PlotForeign("GM","GM",colorCustom2, styleLine);
 
Color2 = ParamColor("Color2",colorRed);
 
PlotForeign("DIS","DIS",Color2, styleLine);


b) use the Color-Picker to set Color2.

CustomColorExtensions010


All three plots will now be displayed with their own colors. (The first and third symbols are using unique colors that are not included in the Color-Picker or color favorites).


CustomColorExtensions011














1 Star2 Stars3 Stars4 Stars5 Stars (3 votes, average: 4.33 out of 5)
Loading ... Loading ...

No comments yet. Be the first.

Leave a reply