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

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

Color Formulas

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

Extending The Range

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.50 out of 5)
Loading...Loading...

Colored Plots

article 1/5

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