AFL Templates v2

Templates can be used, to reduce typing time, when writing formulas.

Formulas, that contain frequently used code, can be pre-written for the various modes (back-testing, plotting indicators, scanning, functions, explorations, optimization) and saved in a Templates folder.

Write your own to suit your use-age patterns.

When starting a new formula, open the relevant template, save it under a new name and comment/un-comment or cut and paste the starter snippets where needed.

AFLT001

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Organizing Formula Files

New formulas are saved into the Custom folder, in the Workspace Charts Tree, by default. The tree can get pretty messy after a while, especially if Unnamed formulas start to accumulate (new formulas that are not named are automatically saved as Unnamed).

A little organization goes a long way.

New folders can be created by right clicking on the Custom folder and selecting Folder from the context menu that opens.

OFF001 

Folders can be moved by right clicking on the folder, holding down the right mouse button and dragging it to the new location.

OFF005

If the ‘dragged’ folder is ‘dropped’ over the Databases folder, for example, New Folder will be entered under Databases as a sub-folder.

OFF006

In the Charts Tree, folders and formulas are arranged alphabetically .

OFF009

An alternative sort order can be forced by adding a ‘character hack’ to the folder names.

To re-order folders:

1) Right click on the folder and select Rename from the context menu that opens.

OFF003

2) Position the cursor at the start of the name and enter a single space, or a character e.g. tilde “~”, to the beginning of the name.

OFF004

Next time the Chart Tree is refreshed the folders will have moved to the top and they will be ordered alphabetically.

Note: In this example a single space was used.

OFF007

In the authors opinion, this is a much better view. Unassigned formulas are grouped together at the bottom of the Custom hierarchy, which prompts the user to move them to a folder, and Unnamed formulas are grouped together, once again prompting the user to clean them up.

Experimental, or temporary formulas, can be ‘kept’ in the formula list and more permanent formulas moved to folders.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Naming Formula Files

The formula name, as it is entered in the Formula Editor title box, is also the file name that the formula is saved under.

NFF003

To help make it easier to find formulas prefix the name with:

  • X_ for Exploration,
  • P_ for Plot,
  • S_ for Scan and
  • B_ for Backtest.

The formulas will automatically be arranged, by functionality, in AmiBroker’s Workspace Chart Tree.

NFF004

The order will be replicated in file browsers, like Windows Explorer, when the file list at C:\Program Files\AmiBroker\Formulas\Custom is sorted by Name.

NFF005

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Modifying Built-in Formulas

Any indicator, or formula, can be easily changed while at the same time preserving the original version.

To create another version of a formula:

1) Right click on the formula, or indicator, in the Workspace >> Charts Tree and pick Edit from the context menu that opens.

MBF001

The Formula Editor window will open with the code for the selected formula in place.

2) Click inside the Formula name input box, to position the cursor, and over-type to change the name of the formula, or add a version number (if the name is a long one use the arrow keys to move the cursor to the end of the box).

MBF002

3) Click on Save and the ‘new’ formula will be entered into the same folder as the original (the Formula Editor will remain open).

MBF005

4) Once the formula has been saved under a different name the code can be changed.

Modify the code and Save the changes.

MBF006

5) When the changes to the formula are complete Save and close.

Bob’s your uncle (as we say in Orstralia).

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

Naming Formulas

For sharing formulas, or where the owner keeps notes on formulas outside of AmiBroker, it can be useful to copy the name of the formula into the code. That way, when the formula is copied and pasted back into AmiBroker the name will be ’shipped’ with the formula. It also helps with version control by recording the version number in the formula.

Note: This helps avoid naming mishaps since changing the version number in the formula requires a deliberate effort that goes hand in hand with formula modifications. 

To copy formula names into the code:

1) Select the formula name by clicking in the name box.

2) Right click in the selected area and pick Copy from the context menu that opens.

NamingFormulaFiles002

3) Right click inside the Formula Editor ‘page’ and select Paste from the context menu that opens.

NamingFormulaFiles001

4) Delineate the formula name, as a comment, by adding the symbol pair /* and */ before and after the name.

NF001

5) When the formula is exported, in any format, the name travels with the formula.

/*P_PriceFields*/

field = ParamField(”PriceField”,3);
Color = ParamColor(”Color”,colorBlack);
Plot(field,”(”PriceField”,Color,styleLine);

6) When the formula is ’imported’ back into AmiBroker the name can be copied, from the formula, and pasted back into the Formula Editor name box. 

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Combination Charts

Combining bar and line plots can produce some interesting charts.

As a starting point a simple bar chart needs to be setup (for demonstration purposes some of the toolbars have been ‘turned off’ and all chart-sheets closed prior to starting this demo).

To insert a chart-sheet with the price displayed in bar style:

1) Open a new Blank Chart from the File menu (a blank chart window will open).

CombinationCharts001

2) Left click, and hold, on Price in the Charts > Basic Charts formula list and drag and drop the formula onto the blank chart.

CombinationCharts002

3) Accept the defaults from the Properties window that pops-up.

CombinationCharts004

The price will be automatically displayed in bar style (assuming that the selected symbol has OHLC data available). Alternatively the Price chart style can be set to Bars from the View menu.

CombinationCharts005

Starting with a bar style chart, plots can be overlaid to create some unusual, and sometimes useful, chart styles.

To overlay a single line plot:

1) Copy and paste the following formula into a blank Formula Editor page and Save As under the title P_CombinationCharts (the formula will automatically be saved as an .afl file in the Charts > Custom list).

Note: It can also be downloaded as an .afl file from a link at the bottom of this page.

1
2
3
4
5
/*P_CombinationCharts*/ 
 
field = ParamField("PriceField",3);
Color = ParamColor("Color",colorBlack);
Plot(field,"PriceField",Color,styleLine);

2) Drag and drop the file onto the bar chart and accept the Properties defaults (a black close line style plot will be overlaid onto the bar chart).

CombinationCharts006

To overlay multiple single line plots:

Either 1) Drag and drop a second copy of the P_CombinationCharts formula onto the chart (successive copies will automatically be assigned a serial numeric identifier).

CombinationCharts007

or 2) Use copy and paste in Formula Editor to replicate the formula and modify it to produce copy 1,2,3 etc.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*P_CombinationCharts*/ 
 
field1 = ParamField("PriceField1",3);
Color1 = ParamColor("Color1",colorBlack);
Plot(field1,"PriceField1",Color1,styleLine); 
 
field2 = ParamField("PriceField2",3);
Color2 = ParamColor("Color2",colorBlack);
Plot(field2,"PriceField2",Color2,styleLine); 
 
field3 = ParamField("PriceField3",3);
Color3 = ParamColor("Color3",colorBlack);
Plot(field3,"PriceField3",Color3,styleLine); 
 
field4 = ParamField("PriceField4",3);
Color4 = ParamColor("Color4",colorBlack);
Plot(field4,"PriceField4",Color4,styleLine);

Once the modified formula has been added to the chart a number of color and field combinations can be used. (Delete the original file first by right clicking inside the chart and picking Delete Indicator > P_CombinationCharts from the context menu that opens).

To use multiple combinations:

  • 1) Right click inside the chart and select Parameters to open the Properties window.
  • 2) Scroll down the Parameters list and use the drop-down arrows to set the color and the field for each plot e.g. PriceField1 and Color1.

CombinationCharts009 

The plots in the background chart will automatically change as soon as the Parameter settings are changed. Various combinations can be experimented with while the Properties window is still open.

EXAMPLE COMBINATION CHARTS

Western Candlestick Style

CombinationCharts010

OK, so you have to use your imagination, but that is good for you!

If you’re unlucky enough to be lacking in imagination here’s a candlestick equivalent to help with ’seeing the picture’.

CombinationCharts013

Which leads into the next style very nicely…….

OC Ribbon Style

CombinationCharts014

Of course trending markets, like this one, always look good to a trader, no matter what the chart style!

Bar Range Style

CombinationCharts011

This is a very good style for highlighting support and resistance points!

Note: In this example PriceFields1&2/3&4 have the same settings, as only two plots are required (this ‘hides’ the extra plots but they can just as easily be commented out of the code according to user preference).

Stochastic Bar Range Style

CombinationCharts012

It’s another first for AmiBroker!

For practical application the “PriceField” chart titles can be removed and unused plots commented out.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*P_CombinationCharts*/ 
 
field1 = ParamField("PriceField1",3);
Color1 = ParamColor("Color1",colorBlack);
Plot(field1,"",Color1,styleLine); 
 
field2 = ParamField("PriceField2",3);
Color2 = ParamColor("Color2",colorBlack);
Plot(field2,"",Color2,styleLine); 
 
field3 = ParamField("PriceField3",3);
Color3 = ParamColor("Color3",colorBlack);
Plot(field3,"",Color3,styleLine); 
 
//field4 = ParamField("PriceField4",3);
//Color4 = ParamColor("Color4",colorBlack);
//Plot(field4,"PriceField4",Color4,styleLine);

 

Perhaps you can dream up some new styles and maybe even name them after your-self!

ATTACHED FORMULA FILE: p_combinationcharts.afl

  • To download .afl files right click on the link and pick Save Target As. Then enter Program Files/AmiBroker/Formulas/Custom as the path to access them from within AmiBroker > View > Charts. 
  • Written using AmiBroker Standard Edition v4.9 and Yahoo!Finance EOD data.
1 Star2 Stars3 Stars4 Stars5 Stars (6 votes, average: 4.17 out of 5)
Loading ... Loading ...

Color Formulas

article 5/5

When a formula, containing the ParamColor function, is inserted into a new chart the ParamColor default will apply.

Save the following code as P_ForeignRGB and apply it as an indicator to demonstrate this point.

1
2
3
4
5
6
7
8
9
/*P_ForeignRGB*/ 
 
Color = ParamColor("Color",colorCustom2);
//Color = ParamColor("Color",ColorRGB(204,0,204));
 
Plot(C,"Close",Color,styleLine|styleThick);
 
PlotForeign("GM","GM",colorCustom2, styleLine|styleThick);
//PlotForeign("GM","GM",ColorRGB(204,0,204), styleLine|styleThick);



(Note that for this example the style has been changed to a thick line, by adding styleThick to the code, to make it easier to see the color of the plots in a screenshot).

CustomColorsAdvanced008

Any one of the 40 colors in the Color-Picker, or the 16 color favorites can be set as the ParamColor default. This can be extended to the full range of colors available in the 24 bit palette i.e. 255 * 255 * 255, which is approximately equal to 16 million colors, by the use of color functions within formulas.

To do this it is necessary to obtain the Red Green Blue numerical code for the color of choice.

To record the Color Matrix numerical code for an extended color:

a) open the ParamColor extended Color Palette (refer to the Users’ Knowledge Base Article ’Custom Colors - Extending The Range’ for instructions),
b) create the color of choice by maneuvering the pointer, either on the Luminescence Bar or within the Color Matrix and make a note of the numerical code for the chosen color e.g. Red 204, Green 0, Blue 204.

CustomColorsAdvanced001


c) click on OK and the Properties window will open with the custom color settings displayed e.g. RGB (204,0,204).

CustomColorsAdvanced002

The plot color, for the current symbol will change to reflect the parameter setting.

CustomColorsAdvanced006

The plot color can be set to use any color in the extended palette as the default.
There are two ways to do this; first by replacing color with a ColorFunction within the standard plot (or plotForeign code) or alternatively by using a ColorFunction within ParamColor arguments.

To change the foreign plot to an extended color:

a) comment out line 8 in the formula and uncomment line 9,
b) type the Red Green Blue (RGB) numerical code into the ColorRGB function arguments exactly as they were written in the Properties box (refer to the example text highlighted in yellow),
c) Save the formula to enact the changes.

CustomColorsAdvanced012

To change the current (parametrical) plot to use an extended color as the default (and demonstrate the functionality):

a) comment out line 3,
b) uncomment line 4,
c) Save the formula and then close the Formula Editor,
d) close the lower chart pane by clicking on the cross that appears when the mouse is hovered over the top right hand corner,

CustomColorsAdvanced013

e) right click on P_Foreign in the Charts list and then Insert it (this will install a new chart in the lower pane with RGB(204,0,204) as the default color, along with the option of changing the color settings via the Palette Editor, in case you have changed your mind about the color in the few seconds it took to insert the formula).

With the following three lines of code the result in the chart below was produced.

1
2
3
Color = ParamColor("Color",ColorRGB(204,0,204));
Plot(C,"Close",Color,styleLine|styleThick); 
PlotForeign("GM","GM",ColorRGB(204,0,204), styleLine|styleThick);



CustomColorsAdvanced015

Notice that the colors are identical.

The good news is, that if you have changed your mind about the current color, you still have the choice of 56 colors in the Picker, or the rest of the 16 million colors in the extended palette up your sleeve.

And now for a little fun let’s type 255, 255, 255 into the Color Matrix and see what we get.

CustomColorsAdvanced009

No sense in doing things by half. Let’s try 000.

CustomColorsAdvanced010


Finally the ’piece de resistance’.

Try the following code by Tomasz Janeczko (from the AFL Function Reference; ColorHSB examples).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Example 1: 
// 3-d multicolor multiple moving average cloud chart 
side = 1;
increment = Param("Increment",2, 1, 10, 1 );
for( i = 10; i < 80; i = i + increment ) 
{ 
up = MA( C, i );
down = MA( C, i + increment ); 
 
if( ParamToggle("3D effect?", "No|Yes" ) ) 
side = IIf(up<=down AND Ref( up<=down, 1 ), 1, 0.6 ); 
 
PlotOHLC( up,up,down,down, "MA"+i, ColorHSB( 3*(i - 10),
Param("Saturation", 128, 0, 255 ), 
side * Param("Brightness", 255, 0, 255 ) ), styleCloud | styleNoLabel );
}



CustomColorsAdvanced016




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

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 ...

Palette Editing

article 3/5



The majority of indicators use a limited number of plots, so a few basic colors can accommodate most charting requirements. Combining this with the fact that the primary colors are easier to distinguish apart, compared to graduations of any one color, makes the colors of the rainbow a stand-out choice for everyday color preferences. Conveniently, ROYGBIV is a mnemonic that makes the rainbow numbers easy to remember when using color indexing for quick code writing.

The first sixteen numbers of the color index are reserved for custom colors, so this provides an opportunity to apply this system. (The color index is based on a zero count system so the available numbers are 0 - 15).

WARNING - THE FOLOWING PROCEDURE WILL CHANGE ALL THE DEFAULT CUSTOM COLOR INDEX NUMBERS, EXCEPT FOR BLACK, WHICH IS ONE. THIS WILL AFFECT ALL SAVED INDICATORS THAT USE CUSTOM COLOR INDEXES, OTHER THAN ONE FOR BLACK.

To match the colors of the rainbow to number 2 - 8 of the color index:

a) go to Tools > Preferences > Colors [TAB] and click on the Palette editor button ( the Color window will open);
b) select the first box in the top row of Custom colors;

CustomColors001

c) click on White, in the Basic colors table;

CustomColors002

d) click on the Add to Custom Colors button (White will become colorCustom1 or index number 0).

CustomColors003

e) select the second box in the top row of Custom colors;
f) click on Black, in the Basic colors table;
g) click on the Add to Custom Colors button (Black will become colorCustom2 or index number 1, which is the installed default for black).
e) Repeat the three stop process for Red, Orange, Yellow, Green, Blue, Indigo and Violet using boxes 3 - 9 inclusive.
f) Use the same procedure to set the remaining seven to any preferred color.
g) Close the Color window and click on Apply on the Preferences window before closing it (this will confirm the new color settings).

To use a color that is not in the Basic color table:

a) select the Custom color box to be changed, followed by the Basic color;
b) then modify the selected Basic color’s Luminescence by dragging the arrow head up and down the vertical scale. (In this example the graduated shades of grey were added to Custom Colors 13 - 16 using this technique).

CustomColors009

c) Additionally the Hue or the Saturation can be changed by clicking and holding on the moving cursor, inside the color matrix panel, and dragging it up/down (Saturation) or left/right (Hue).
d) When the desired color is produced in the large Color/Solid box click the Add button.
e) Click on Apply on the way out.

CustomColors006

(In this example the Basic color Medium Grey has been changed slightly by the addition of a little Blue and a slight reduction in Red (Saturation), as well as changes to the Hue settings, while the Luminescence is constant).

The new Custom Color settings will now be available in the Color Picker, or within formulas via color index numbers 0 - 7 and 8 - 15, or colorCustom1-16.

CustomColors007

(Note that for maximum contrast between the colors it is better to use only six colors, along with black and white, as there are only three primary colors (RYB) with three possible primary combinations between them (O,G,V). Indigo is an exceptional color, not being derived solely from the Primary Colors. For this reason it is hard to distinguish between Indigo and Blue or Violet, so for clarity Indigo can be left out if desired).


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

Colored Plots

article 1/5

The most used color, for chart plotting, is black, but this can be changed using simple AFL formulas.
This will be demonstrated in this article using the following code as a template.

(The template can be downloaded from the file attached to the end of this post and the lines commented/uncommented as required. Note that the attached file has been stripped of it’s capitals, and the underscore character, by the editing software used by the author. After downloading and saving the file rename it as written in this post).

1
2
3
4
5
6
7
/*P_PriceFields*/
 
Plot(C,"Close",colorBlack,styleLine);
//Plot(C,"Close",colorBlack);
//Plot(C,"Close",colorRed);
//color = ParamColor("color",colorRed); 
//Plot(C,"Close",color);


At the most fundamental level colors are customized from within formulas.

To create a black line price chart in a new pane:

a) open Formula Editor from the Tools Toolbar,

CustomColorsBasic003

b) copy/paste or type line 3 of the code into a new Formula Editor page,
c) check the syntax using the Verify Syntax tool from the Formula Editor Standard Toolbar before saving it as P_PriceFields,


CustomColorsBasic007


d) apply it as an indicator using the icon on the Formula Editor Standard Toolbar, (the chart will be opened in a new pane in the current window),


CustomColorsBasic005


Line view is the default for all charts, so it isn’t necessary to stipulate the styleName on every occasion.
The code can be shortened by leaving out the style setting, if Line is the preferred view.

To change the formula to line view as the default:

a) copy/paste line 3 of the code into line 4,
b) comment out line 3 by putting two forward slashes before the line (this line will then be ignored when the formula is processed),
c) delete styleLine from the line 4 code and save the new version (the result will be visible in the chart).


CustomColorsBasic008


(Note that when an indicator is applied from the Formula Editor toolbar the chart it opens interacts dynamically with the formula, so that the effect of changes to the formula can be immediately seen in the chart, once the formula has to be saved).

To change the color of chart plots:

a) copy line 4 of the code and paste it into line 5,
b) comment out line 4,
c) change colorBlack to colorRed in line 5.


CustomColorsBasic009


For convenience the color parameter can be accessed graphically by adding the Parameter function to the formula.

To add color to the Parameter options list:

a) comment out line 5,
b) add line 6 and 7 to the formula and Save,
c) right click inside the Chart and select Parameters from the context menu that appears, (the Properties window will open with the Parameter tabbed page in view),


CustomColorsBasic010


d) select a color from the Color-Picker that drops down, (the plot will then change color to match).


CustomColorsBasic013

(Note that whenever a formula, with the color parameter included, is inserted into a chart, the Parameter Window will open automatically and offer the user the choice of colors, for plotting, before proceeding).


Attached Files:


right click .afl files and Save Target As to download to the desktop at Program Files/AmiBroker/Formulas/Custom then access them as a formulas within AmiBroker Charts.

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 3 out of 5)
Loading ... Loading ...
Next Page »