Issue 1/2004 (No. 23) |
AmiBroker Tips newsletter. Issue 1/2004. No 23. 20 September 2004. Copyright (C)2004 AmiBroker.com. All back issues available from: http://www.amibroker.com/newsletter/ |
Welcome to the 1st issue of AmiBroker Tips newsletter in the 2004. Well ...you have probably forgotten about newsletter at all, the last issue was back in 2001 but I think it is good idea to "re-incarnate" the newsletter. I think that this will be good place to introduce new features added in each beta and you will gain additional source of information (other than Read-Me files coming with beta versions).
Just a reminder: if you have any comments/suggestions or article ideas, please don't hesitate to drop a line to newsletter@amibroker.com
AmiBroker 4.62.1 allows you to easily create and modify your indicators with few moves of a mouse. From now on you can build sophisticated indicators without any programming knowledge at all. The available (ready-to-use) indicators are listed in Charts tab of the Workspace window.
There is a video tutorial at: http://www.amibroker.net/video/dragdrop1.html that shows basic usage of new drag and drop functionality.
To remove the indicator, press Close button from the menu on the top right-hand side of the indicator pane (the menu will be displayed if you place the mouse cursor in the nearby). This menu allows you also to move the indicator pane up/down or maximize the pane.
You can also use Close command from context menu that shows
up when you click on the chart pane with right mouse button.
How to overlay one indicator on another indicator.
_
Example:
The below indicator allows you to check how the parameters work in the custom code. You can change settings from Parameters dialog.
Buy = Cross(MACD(), Signal()
);
Sell = Cross(Signal(), MACD()
);
pricefield = ParamField("Price
Field", 2);
Color = ParamColor("color",colorRed);
style = ParamStyle("style",styleLine,maskAll);
arrows = ParamToggle("Display
arrows", "No|Yes",0);
Plot(pricefield,"My
Indicator",Color,style);
if(arrows)
{
PlotShapes(Buy*shapeUpArrow+Sell*shapeDownArrow,IIf(Buy,colorGreen,colorRed)
);
}
These are new functions that are used by drag & drop mechanism. The most important pair is _SECTION_BEGIN("name") and _SECTION_END().
When you drop the formula onto chart pane AmiBroker appends the formula you have dragged at the end of existing chart formula and wraps inserted code with _SECTION_BEGIN("name") and _SECTION_END() markers:
So, if original formula looks as follows:
P = ParamField("Price
field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA(
P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style")
);
it will be transformed by AmiBroker to:
_SECTION_BEGIN("MA");
P = ParamField("Price
field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA(
P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style")
);
_SECTION_END();
_SECTION_BEGIN/_SECTION_END markers allow AmiBroker to identify code parts and modify them later (for example remove individual sections). In addition to that sections provide the way to make sure that parameters having the same name in many code parts do not interfere each other. For example if you drop two moving averages the resulting code will look as follows:
_SECTION_BEGIN("MA");
P = ParamField("Price
field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA(
P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style")
);
_SECTION_END();
_SECTION_BEGIN("MA1");
P = ParamField("Price
field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA(
P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style")
);
_SECTION_END();
Note that code and is parameter names are identical in both parts. Without
sections the parameters with the same name will interfere. But thanks to uniquely
named sections there is no conflict. This is so because AmiBroker identifies
the parameter using section name AND parameter name, so if section names are
unique then parameters can be uniquely identified. When dropping indicator
AmiBroker automatically checks for already existing section names and auto-numbers
similarly named sections to avoid conflicts. Section name also appears in the
Parameter dialog:
Last but not least: you should NOT remove _SECTION_BEGIN / _SECTION_END markers from the formula. If you do, AmiBroker will not be able to recognize sections inside given formula any more and parameters with the same name will interfere with each other.
_SECTION_NAME is a function that just gives the name of the function (given in previous _SECTION_BEGIN call).
_DEFAULT_NAME is a function that returns the default name of plot. The default name consists of section name and comma separated list of values of numeric parameters defined in given section. For example in this code:
_SECTION_BEGIN("MA1");
P = ParamField("Price
field");
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA(
P, Periods ), _DEFAULT_NAME(), ParamColor( "Color",
colorCycle ), ParamStyle("Style")
);
_SECTION_END();
_DEFAULT_NAME will evaluate to "MA1(Close,15)" string.
_PARAM_VALUES works the same as _DEFAULT_NAME except that no section name is included (so only the list of parameter values is returned). So in above example _PARAM_VALUES will evaluate to "(Close, 15)" string.
Q. I can not see buy/sell arrows from my trading system
A.
Starting from version 4.62.1 trade arrows can be displayed on any chart
pane (not only one built-in price chart). However, by default, the arrow display
is turned OFF.
To turn it ON you have to open Indicator Builder or choose "Edit Formula" from
the chart context menu and check "Show Arrows" box.
Q. The read me says: "Automatic Analysis formula window is now drag&drop target too (you can drag formulas and AFL files onto it)". What does it mean?
A. It means that you can drag the formula from either Chart tree or .AFL file from Windows Explorer and drop it onto Automatic Analysis (AA) formula window and it will load the formula into AA window. This is an alternative to loading formula via "Load" button in AA window.
Q. I can see version 4.62.0 listed in the Read Me but I did not see the announcement on AmiBroker mailing list ?
A: Version 4.62.0 was an internal beta version not available to the public. 4.62.1 is the first public beta with new drag and drop features.
Q. Can I drop a shortcut onto the formula window ?
A: No you can't. You can only drag & drop files with .AFL extension (shortcuts in Windows have .lnk extension).
Q. Can I add my own formulas to the Chart tree ?
A. Yes you can. Simply save your .AFL formula into Formulas subfolder of AmiBroker
directory and it will appear under "Charts" tree (View->Refresh All may be
needed
to re-read the directory)
Q. I have added new file to the Formulas folder, but it does not show up in the Charts tree unless I restart AmiBroker? Is there a way to refresh Chart tree ?
A. You can refresh Chart tree by choosing View->Refresh All menu.
Q. If I modify the formula that ships with AmiBroker will it be overwritten by next upgrade?
A. Yes it will be overwritten. If you wish to make any modifications to the formulas provided with AmiBroker please save your modified versions under new name or (better) in your own custom subfolder.
Q. I can see Reset All button in Parameters dialog but it sets all parameters to default values. Is there a way to reset SINGLE parameter ?
A. No, there is no such option yet, but it will be added in upcoming betas.
Q. I dragged RSI to the price chart pane and got a straight red line at the bottom of the pane. What is wrong?
A. When you drop two indicators / plots that have drastically different values you have to use style OwnScale for one of it. You can turn on OwnScale style using Parameter dialog. This ensures that scales used for each are independent and you can see them properly. Otherwise they use one common scale that fits both value ranges that results in flattened plots.
Q. The light grey color of the new AFL special functions_SECTION_BEGIN etc makes them invisible in my bluegrey background IB color. How could I change the special functions color ?
A. Right now, you can't. But there will be a setting for coloring special
functions in the next version.
Q. When I drop the indicator the Parameter dialog does not show all
parameters.
Is this correct ?
A. Yes it works that way. The idea behind it is simple. When you drop new indicator AmiBroker displays a dialog with parameters ONLY for currently dropped indicator. This is to make sure that newly inserted indicator parameters are clearly visible (on top) and new user is not overwhelmed by tens of other parameters referring to previously dropped indicators. On the other hand when you choose "Parameters" item from context menu then ALL parameters will show up - allowing you to modify them all any time later.
Q. My indicator list is full of names like "#96 MACD". Where does #96 come from ?
A. When you double click the item in the chart tree AmiBroker creates new
chart pane and generates the formula for it. It also gives it a name in the
format
of
#Number
SectionName. #Number is the consecutive chart formula number (AmiBroker stores
custom formulas internally in the array that is numbered). Section name comes
from AFL file name used to generate this chart. The numbering allows to distinguish
between different formulas based on the same original indicator. Note that this
may change in the future versions.
AmiBroker Tips newsletter. Issue 1/2004. Copyright (C)2004 AmiBroker.com. All back issues available from: http://www.amibroker.com/newsletter/