The tools Pull up object by object and Pull down object by object

В AutoGraf 4 application There are order tools Pull Up (9) and Pull Down (10) designed for modifying orders. These tools can change the price of the order line depending on the position of one of the standard terminal objects MetaTrader 4. These tools have the same execution algorithms; the only difference is the direction of modification of the order line. Let's consider their properties on the example of the Pull Up by Object tool.

Authorizations

The Pull Up behind object tool can be set on order lines:
- StopLoss and TakeProfit of a market order of any type;
- OpenPrice of a pending order of any type.

Limitations

The tool is installed (column):

If the Object Pull Up tool is placed on an order line that already has any tools placed on it:

1 - Upward pull-up,
2 - Downward pull-up,
3 - Price following,
6 - Tuck is not higher,
7 - Tuck no lower,
10- Downward pull-up behind the object,
11 - Following the object,

then the specified tools are automatically deleted.

The Pull Up by Object tool cannot be set on the StopLoss of a Sell market order if the 5 Stop 0 Sell tool is set on the order.

The tool is installed (line):

If one of the tools is installed on an order line that already has the Pull Up by Object tool installed:

1 - Upward pull-up,
2 - Downward pull-up,
3 - Price following,
10- Downward pull-up behind the object,
11 - Following the object,

then the Pull Up Object tool is automatically deleted.

If the Pull Up Object tool is set on the StopLoss of a Sell market order, the 5 Stop 0 Sell tool cannot be set on this order.

Requirements

No other tools are required to install the Object Pull Up tool.

To set the Pull Up Object tool, a graphical object of one of the following types is required to be set on the price chart:

- OBJ_REGRESSION - linear regression channel;
- OBJ_STDDDEVCHANNEL - standard deviation channel;
- OBJ_TREND - trend line;
- OBJ_CHANNEL - equidistant channel;
- OBJ_FIBOFAN is a Fibonacci fan;
- OBJ_FIBOCHANNEL - Fibonacci channel;
- OBJ_PITCHFORK - Andrews Fork.

Installing Tool Pull-up behind the object upwards satisfies the requirements for installing Tool 6 Pull-up not above.

Installing

The installation of the Upward Pull tool is performed in two stages - first the tool is fixed on the order line, and then its binding to the chart object is performed.

1 step. Preparing the instrument Pull up behind the object.

To fix a tool on an order line, it is necessary to grab the tool icon on the Toolbar, bring it to the order line on which the tool is to be set, and release the mouse button. If the order line is selected according to the resolution rules, the tool icon will be displayed near the order line on the bar () on which the user released the icon. At that, the icon is displayed in "passive" color (white for black background and black for white background); the message that the instrument is prepared for adjustment is displayed.

Step 2. Binding of the Pull up tool behind the object to the graphical object.

To bind a tool to a graphical object, it is necessary to take the icon of the tool fixed on the order line with the mouse and move it to the desired line of the graphical object. When the tool icon is in close proximity to the object line, the line starts "blinking" - its color changes. It means that the selected line can be used as a snap object. Binding of the tool to the object is performed if the user releases the tool near the blinking line.

If the installation of the Pull Up by Object tool is performed without errors, the icon will be displayed near the order line on the bar on which the user released the icon near the blinking line. To confirm the fact of setting the tool, the icon is colored in its own color (as on the toolbar) and a message about successful completion of setting is displayed, accompanied by a confirmation sound.


Figure 1. Setting the Pull Up tool by the object up on the TakeProfit of the Sell order.

1. Tool preparation - the tool is fixed on the order line. The color of the icon is black. 2. Binding the tool to the object line - the line blinks, i.e. binding is allowed. The user released the tool icon near the line - the icon returned to the order line. The color of the icon is blue. 3. Parameter values to the left and right of the icon indicate the end of the installation (after clicking on the image you will go to the site to view the video).

If an invalid order line is selected for setting an instrument, the instrument will not be set. In this case a message about an erroneous user action is displayed, accompanied by an error sound. If in the process of binding to a graphical object the user moves the fixed icon to an object of an invalid type, the object will not respond with a blink. It means that binding of the tool to this object is impossible. An attempt to snap a tool to such an object will cause the icon to return to the order line. In this case, the tool will remain attached to the order line, but it is not attached to any object, i.e. it is not set.

It is not allowed to rearrange an installed instrument, i.e. fixed on an order line and bound to a chart object. This means that the installed tool cannot be assigned to another order line or another chart object. If you need to set up a different trade management scenario, you must remove the installed tool Pull Up by Object and install a new one.

Parameters

The Pull up tool behind the object is characterized by parameters:

Index 0 1 2 3 4 5 6
Parameter 0/1 d_T Ds St i_O i_Ln
For example: 1.0 1230.0 0.0 50.0 3.0 7.0 32.0

The indices of the instrument parameters correspond to the indices of these parameters in the Instrument [or][ol][9][j] array, where:
or - the current index of the order in the Order[][] array;
ol - order line number (1 - OpenPrice, 2 - StopLoss, 3 - TakeProfit);
9 - number of the tool Pulling upwards behind the object;
j is the index of the tool parameter Pulling upward behind the object.
- the fact that the tool is inserted; the parameter is changed in manual mode by inserting and removing the tool;
- time offset from the moment of instrument setting in seconds; the parameter is changed in manual mode by moving the instrument icon within the price chart (horizontally).

The tool icon is displayed on the bar that corresponds to the calculated time To + dT, where To is the current time, dT is the time offset (the parameter in question). Unlike most other tools displayed on a particular bar, the icon of the Pull Up by Object tool will change its horizontal position depending on the timeframe.

For example. В timeframe On M1, two tools are set on the same TakeProfit order line on the same 20m bar - Trade reversal Buy and Pull up behind the object. For the Pull Up tool, the time offset can be 1201 to 1259 sec (20 bars = 20*60 = 1200, + time from the beginning of the zero bar from 1 to 59 sec); let's assume that the offset is 1230 sec. When switching to the M5 timeframe, the Trading reversal Buy tool will still be displayed on the 20th bar. And the Pull Up tool will be displayed at the 5m bar. In this case, the 5th bar corresponds to the displacement of the tool relative to the current time by 1230 sec (4e bars = 4*300=1200; 30 is the time of staying on the 5th bar). Thus, the Pull Up by Object tool changes its position in time depending on the timeframe.

Moving the tool icon horizontally allows you to change the time offset of the tool in steps equal to the timeframe. If you need the value of the parameter with accuracy up to a minute, you should specify the desired value in the tool settings panel. To call the panel, select the tool icon and use the right mouse button to call the context menu (select Properties). In the appeared object properties panel (Parameters - Time) you can specify the desired tool setting time. After changing the setting parameter, the tool icon will be displayed on the bar corresponding to the specified time. The time offset (the parameter dT under consideration) will be calculated as the difference between the current time and the time specified in the settings panel of the tool icon.

Sometimes there is a shift of the object to the right at a time that does not coincide with the moment of opening bar. This is a normal phenomenon, indicating only that the offset time dT is not a multiple of the timeframe.

- distance in points between the object reference line and the order line (pursuit distance for order lines below the object line and fleeing distance for order lines above the object line).

At the moment of setting the instrument, the parameter takes a value equal to the actual distance between the order line and the object line. The parameter can take both positive and negative values. A positive value of the parameter means that the object line is above the order line (in the place where the tool icon is set). Negative value means that the object line is below the order line.

Changing the parameter in the manual mode is performed by moving the tool icon with the mouse within the price chart (vertically) and on the parameter value scale.

Moving the tool icon toward the object line decreases the distance, moving away from the line increases it. The parameter changes proportionally to the distance between the current position of the tool icon (moved by the user) and the object line. The current value of the parameter is displayed to the left of the tool icon. The new parameter value is accepted for execution when the user releases the left mouse button; the tool icon returns to the order line.

The parameter value can be changed by selecting a new value on the parameter value scale. To display the scale, move the parameter digit icon to the left of the tool icon by a small distance. The value selected by the user on the scale is accepted as the new parameter value.

The Ds parameter is also changed when the order line is modified downwards. For order lines above the object line, the parameter value decreases if the actual distance is less than Ds - St. For order lines below the object line, the parameter value increases if the actual distance is greater than Ds + St. In these cases, the parameter value is set equal to the actual distance between the order line and the object line.

- step of modification of the order line in points.

When the tool is set, the parameter assumes the St setting value specified in the subwindow.

The parameter value can be changed by selecting a new value on the parameter scale. To display the scale, move the parameter digit icon to the right of the tool icon by a small distance. The value selected by the user on the scale is accepted as the new parameter value.

- index of the binding object in the Object[] array.

All objects of the types supported for the Pull Up Behind Object tool are accounted for in the Object[] array.

The use of object indexes in manual order management is not required - when the tool is set by the user using the mouse, the application AutoGraf 4 will automatically determine the object index. The user only needs to make sure that the total number of supported objects does not exceed 100.

During operation, the user can change the number of installed objects considered by AutoGraf 4. This causes AutoGraf 4 to reorder the Object[] array to remove empty rows.

For example, there are three objects of supported types with names: Channal_1, Channal_2 and My_TrandLine. These objects are accounted for in the Object[] array with indexes Object[1], Object[2] and Object[3] respectively. Suppose that the Object Pull Up tool is bound to the My_TrandLine object. In this case, the value of the i_O parameter is 3.0.

If an object with index 2 is deleted, the Object[] array is reordered - the value of Object[1] remains unchanged, the value of Object[3] is overwritten into the vacated Object[2] element, and then the values of all elements below Object[2] are reset to zero. As a result, the object previously accounted for with index 3 will now have index 2. At the same time, the value of the i_O parameter in the Instrument [or][ol][9][5] array is automatically changed.

The specified ordering is performed automatically, without the user's participation. The necessary calculations are performed immediately before transferring control to the user function AG_AT(), i.e. updated arrays are transferred to the user function at each new iteration.

- object line index.

Enclosed AutoGraf 4 The classification of object lines of supported types is adopted, which is close to the method of line indexing in MQL 4. The use of object line indices in manual order management is not required - AutoGraf 4 application will automatically determine the object line index when the user sets the tool with the mouse.


Figure 2. Changing the distance Ds of the tool Pull up behind the object by moving the tool icon. 1. From the moment the icon starts moving, the anchor line marks itself with a blink. 2. Moving the icon toward the object line causes the Ds parameter to decrease (after clicking on the image you will go to the website to view the video).


Fig. 3. Moving the order line up does not change the Ds parameter of the instrument. Moving the order line downward leads to a change in the Ds parameter of the instrument (true for order lines both above and below the object line) (after clicking on the image you will go to the site to view the video).

To display a scale of values for the distance setting parameter Ds of the Object pull up tool, the user moved the number icon slightly to the left of the tool. The value selected on the scale that appears is accepted as the new distance Ds value.

Execution

To enable execution of instruments in the AutoGraf 4 application, you must enable the semi-automatic or automatic order management mode (move the AG or AT control icon to the top position).

Tool algorithm A tuck behind the facility upwards is aimed at modification of the order line upwards. Modification in the opposite direction is not provided. The installed tool tracks the change of distance between the order line and the selected object line in the place where the tool icon is installed.

The instrument execution conditions for order lines above and below the object line are different. For order lines located below the object line, the tool execution condition occurs if the pursuit distance is equal to or exceeds the value Ds + St. For order lines located above the object line, the tool execution condition occurs if the pursuit distance is less than or equal to the value Ds - St. When the execution condition is reached, the tool generates an indication - a new price value of the order line, which is distant from the object line by the value Ds (points). All calculations are performed for the distance between the lines on the barYou can use the Pull Up by Object tool on which you currently have the Pull Up by Object tool installed.

When working with the Pull Up Object tool, you should be very careful when moving the tool's anchor line. Any change in the coordinates or angle of the object line may result in the formation of a trade order. If it is necessary to rebuild the order management scenario, it is recommended to disable semi-automatic or automatic management, rebuild objects and reconfigure tools, and then re-enable semi-automatic or automatic mode.

Execution of the Pull Up tool for pending orders provides for modification of the whole order. This means that StopLoss and TakeProfit orders are modified simultaneously with the order. In this case, the distance from OpenPrice to each of the stop orders of the order is preserved. The exception is the case when the tool 13 Lock on price is set on the stop order line.


Figure 4. When changing the position of the object line, the distance between the object line and the order line changes. When the semi-automatic mode is enabled (AG icon at the top), this leads to the execution of the Pull Up behind object tool according to the settings (after clicking on the image you will go to the website to view the video).

On a new bar the icon of the instrument is shifted to the right. At the new place of the icon, the distance between the object line and the order line is greater than the critical distance. When the semi-automatic order management mode is enabled (AG icon at the top), this leads to the execution of the instrument. When forming a trade order to execute an instrument instruction, AutoGraf 4 takes into account the requirements and restrictions for trading operations, as well as instructions of other instruments set for the order. If there are instructions of other instruments, the application generates a single trade order that takes into account all instructions (AutoGraf 4 does not allow setting instruments that could form contradictory instructions).

Deletion

All tools in AutoGraf 4 will execute as long as they are installed. To stop executing an installed tool, it must be deleted. A tool can be deleted manually or programmatically by the user.

To manually delete the Pull Up by Object tool, select the tool icon and press the Delete key. Such a control action is executed by AutoGraf 4 application always, without bounce (unlike trade orders executed on the server side). When deleting instruments manually, make sure that no other instruments or order lines are selected. If other objects are deleted simultaneously with the deletion of the icon of a set instrument, then (depending on what kind of objects they are) this may lead to the deletion of other instruments, as well as the formation of unplanned trade orders - deletion and modification of orders.

Tool removal Lift behind the object upward also occurs automatically when the tool 6 Pull Up Not Above is executed. If the execution price of the order line reaches the execution price of the Pull Up tool, the need for further use of the Pull Up tool is considered exhausted. In this case, the Pull Up Not Above tool deletes the Pull Up Behind Object tool and deletes itself.

The Pull Up behind Object tool is automatically deleted by AutoGraf 4 also if the snap line of a graphic object or the object itself is deleted.


Figure 5. Deleting an anchor line (object) leads to automatic deletion of the tool (after clicking on the image you will go to the site to view the video).

The following example discusses a programmatic way to manage tools:

- Pull up behind the object (9),
- Tuck behind the object down (10),
- Pull object (12).

The presented example uses functions imported from the file AG_Lib.ex4. This file contains functions serving the execution of the automatic trade function AG_AT(). In general, the use of these functions is not mandatory, but it is strongly recommended.

The AG_Magic_Number() function is used to calculate the MagicNumber. The AutoGraf 4 application has a rule that only a unique value can be assigned to each order MagicNumber. This is necessary for successful identification of orders at reopening and partial closing.

The AG_Message() function is used to record message texts into the Message[] array. The AG_Set_Instr() function is used to record the parameters of the tools to be set into the Manager[][] array. The AG_Delete_Instr() function is used to record deleted tools into the Manager[][] array.

Leave a Reply

Back to top button