Formula Editor
AFL Formula Editor features user-definable syntax highlighting,
context-sensitive formula reference help, enhanced error reporting,
automatic statement completion and parameter information
technology (similar to Intellisense(tm) featured in Microsoft Developer studio),
support for editing multiple files at once, and is multi-monitor friendly.
These features greatly simplifies writing formula and provides
instant help so time needed to write formula decreases significantly.

Menu
Formula Editor menu options are described in detail in Menus:
Formula Editor chapter of the guide.
Toolbar

The Formula Editor toolbar provides the following buttons:
- New - clears the formula editor window
- Open - opens the formula file
- Save - saves the formula under current name
- Print - prints the formula
- Cut - cuts the selection and copies to the clipboard
- Copy - copies the selection to the clipboard
- Paste - pastes current clipboard content in the current cursor position
- Undo - un-does recent action (multiple-level)
- Redo - re-does recent action (multiple-level)
- Formula Name - an EDIT field that allows to modify the formula file name,
once you change the name here and press Save button the formula will be
saved under new name and the change will be refleced in editor CAPTION
BAR.
- Check syntax - checks current formula for errors
- Apply indicator - saves the formula and applies current formula as a
chart/indicator ONCE
- Analysis - saves the formula and selects it as current formula
in Automatic Analysis window and repeat most recently used Analysis operation
(i.e. Scan or Exploration or Backtest or Optimization)
Usage
Typical use of Formula Editor is as follows:
-
open Formula Editor
- type the formula
- type meaningful name that describes the purpose of you code into Formula
Name field
- click Apply indicator button (if you have written indicator
code)
..
or..
click Analysis button
to display Automatic Analysis window (when you have written exploration/scan
or trading system)
Syntax highlighting
AmiBroker's AFL editor features user-definable syntax highlighting
that automatically applies user-defined colors and styles to different
language elements like functions and reserved variable names, strings,
numbers, comments, etc. This feature greatly simplifies code writing. You
can modify coloring scheme in Preferences
window.
Enhanced error reporting
When you make an error in your formula, AmiBroker's enhanced
error reporting will help you to locate and fix an error by highlighting
the place where error occured and displaying extended error description with
the examples of common mistakes and advice how to fix them.

Context help
You can quickly display relevant AFL function reference page if you press
F1 key or choose "Function reference" from the context menu while
the caret is inside or right after function name as shown in the picture
below:

Automatic statement completion
The automatic completion feature (available when you press CTRL+SPACE key
combination) finishes typing your functions and reserved variables for you,
or displays a list of candidates if what you've typed has more than one possible
match. You can select the item from the list using up/down arrow keys or your
mouse. To accept selection press RETURN (ENTER). You can also type immediately
space (for variables) or opening brace (for function) and AmiBroker will
auto-complete currently selected word and close the list. To dismiss the list
press ESC key.
Parameter Information
When you are typing a function, you can display a Tool Tip containing the
complete function prototype, including parameters. The Parameter Info Tool
Tip is also displayed for nested functions.
With your insertion point next to a function, type an open parenthesis
as you normally would to enclose the parameter list.
AmiBroker displays the complete declaration for the function
in a pop-up window just under the insertion point.
Typing the closing parenthesis dismisses the parameter list.
You can also dismiss the list if you press arrow up/down key,
click with the mouse or press RETURN.
