Simple Editor
A paintbar, when it is created, is a "Simple" paintbar. That means that it is a collection of simple rules. Each rule is of the form
if (simple condition)
set color or shape, trigger alert or set scan result
[and stop]
otherwise
set color or shape, trigger alert or set scan result
[and stop]
(where the [and stop] is optional).
The Simple rules editor allows you to set up these rules without writing any code.
Example of a Simple Paintbar
Here is an example of a simple paintbar - all it does is checks if the Close of a candle is above all of the three EMAs (with periods of 7, 21 and 40) and if it is, sets the paintbar color. In the next section we will see how to do the same thing with an Advanced paintbar.
Sections of Simple Paintbar Editor
General Info
In this section, you enter the paintbar's ID, its name and short name (the short name shows up in legends on charts), and the description of the paintbar.
List of Rules
Here you manage the rules - you can add a rule, remove a rule and rearrange their order. The rules are executed from top to bottom, so the order of the rules is important. Click on a rule to edit it.
Individual Rule Editor
Each rule consists of a condition and two optional sets of actions - one to be taken if the condition is true, and the other if the condition is false.
Individual Rule Editor - Condition
There is a Left and a Right variable and an Operator between them. The condition expression is built from these three components.
Candles Ago
By default, when you specify an indicator or a candle value in the conditional expression, the values for them are implicitly taken from the current candle bar that is being calculated. If you would like to refer to the previous bars' values, you have to specify the candle ago number. A value of 1 means the candle before the current one, 2 - the second candle before the current one, etc.
Indicator Parameters
When you specify an indicator as the Left or Right variable, the question comes up what the parameters for the indicator should be. There are two ways to specify that in the editor:
•Any Parameters option - let the paintbar use the existing indicator on the chart
When Any Params is selected, the paintbar, for that indicator, will take the first existing indicator of that type in the chart on which it is placed. This allows the user of the paintbar to manipulate the values of the indicator's parameters and gives more flexibility to the paintbar. If the paintbar is placed on a chart that has no such indicator, the default values for the indicator will be used.
•Specify Parameters option - specify explicitly the parameters for the indicator
When Any Params is unchecked and the specific parameters are set, the paintbar, for that indicator, will create, internally, an indicator with these parameters, and use it in the calculations.
Indicators - Sub-values
Some indicators only have one value (for example, SMA). But a lot of indicators have several values (corresponding to several lines on the chart). For example, Bollinger Bands indicator has three values, corresponding to the top line, the bottom line and the center line.
Because of that, when you select an indicator as a variable in the Simple Rule Editor, you have to specify which sub-value of the indicator to use. Select it at the end of the line.
Action - Setting a Color
One of the actions you can do in the rule when the condition specified is true (or false for an Else action) is setting the bar's color.
•Naming the Color is optional. If you select to name the color, then that name will appear in the Parameter Editor for the paintbar when you place it on the chart and the Default color that you select will be assigned to it. The user will be able to change that color to his preference.
•Blank Name - If you leave the name blank, then the action will assign the color that you select and the user of the paintbar when it is placed on the chart will not be shown the color or be given a chance to change the color.
•Picking Color - the color-picker that is pops up when you click on the color box allows you to choose either an "absolute" color, or a color that represents an entry in the chart's color scheme - either one of the selected indicator colors or other colors in the scheme.
Action - Setting a Shape
The other action you can do in the rule is set a shape for the bar. If you don't set a shape (or set a Default shape), then whatever shape the user of the paintbar selects in the paintbar parameters on the charts will be displayed. Note that if the user chooses Candle Color as the paintbar's Placement, any shapes set will be ignored.
In general, it is a good idea to allow the user to select the shape. Set specific shapes in the paintbar only if you consider the particular shape very significant to the paintbar's meaning.
Action - Trigger an Alert
A paintbar can trigger an alert.
The alert should have a name and a message. The name shows up on the Paintbar Parameter Editor when the paintbar is applied to a chart, and the user will be able to specify the notification options for it there.
Action - Set Scan Result
When the code is used in a scan, a Scan Result can be set
The alert should have a name and a message. The name shows up on the Paintbar Parameter Editor when the paintbar is applied to a chart, and the user will be able to specify the notification options for it there.
Action - and Stop
The and Stop checkbox, if selected, stops the execution of all rules at this point.
Switching to Advanced
The Switch to Advanced button in the ribbon menu will switch the editing of the paintbar to the Advanced mode. This is not a reversible action, once the paintbar has been switched to Advanced mode, it can't go back to the Simple mode.