Forex script placing pending orders instead of closed ones. Scripts for pending orders. An impromptu classification based on the materials of the Internet. Watch videos about special programs

02.08.2021

From the article you will learn:

Good afternoon, my dear readers and guests of the blog. Today our topic is a script, and the goal is to place all pending orders that we have. With one stroke. We will study the rules for placing orders, their components, consider the important features of orders. Let's recall the strategies within which these orders can be used.

Best Broker

It is absolutely necessary to know all this for beginners of the forex market. It is very important to grasp the basics before you start using this knowledge to enjoy the growth of profits. I will try to tell it in such a way that everyone understands what's what, without unnecessary words and heavy turns. I suppose you have already met my style and you like it.

Let's start.

Getting ready to open your pending orders

So, we got acquainted with forex, learned that, it turns out, couples change their quotes more than once a day, and now we are going to learn how to profit from this change. It is important to understand that opening a trade is both the end and the beginning. The end of your analysis, which can be endlessly long and incredibly difficult, or you can get it from another trader you trust. This knowledge can be transferred to, or invest in a service you are interested in, for example,.

A special place among the orders is occupied by those that are opened not by the market, but in the form of a pending order. An important feature such orders for a beginner is the opportunity to try the mechanism of opening transactions in the Metatrader 4 terminal without visible consequences for either a real or a demo account.

They just do not entail any consequences at the time of placement and the first time after installation. If you know how to take into account Greenwich Mean Time, then closer to the night there comes a moment when the calmest Pacific trading session opens. At this time, the market almost freezes. Right now I would start testing pending orders.

Simply, they entail consequences in the form of profit or loss, only when the price of the asset has reached the price of placing the order. Then the transaction becomes no longer deferred, but “according to the market”. Now he will either make a profit or leave you with a loss. And since the market is quiet at night, we can try to place an order and study how they work.

Do not do this on other people's real accounts! This can lead to unforeseen consequences, and most likely you will lose some money from the account. Those who are not lucky can completely empty the deposit.

Where can I get a script that will set all pending orders?

Luckily, I am attaching such a script. Let's quickly go over the built-in programs of the Metatrader 4 Terminal. So that you understand what place the scripts take.

There are indicators. These are programs from the navigator that perform additional plotting on the chart. They correspond to any mathematical formula. During the existence of trading, quite a lot of them have been invented.

There are advisers. Expert Advisors allow you to perform analysis and trading operations in automatic mode. It's easier not to say. In general, this is a whole world that will help you get rid of complex manual analysis and conduct trading operations in a fully automatic mode.

Finally, there are scripts, they allow you to perform the same actions as in the case with the adviser, but they do not work indefinitely, but only until the end of the code. To repeat the steps, you need to perform them again.

Watch an overview video about the script

Download the tutorial script and try placing pending orders.

If you haven't watched the video yet, I'll tell you more.

List all pending orders and set them using a script

So, there are four types of pending orders, two for purchases, that is, for working on the forecast that the price chart will go up. And two for selling, that is, for working on the forecast that the price chart will go down. We'll talk about how predictions are made a bit later.

Download

There are buy stop and buy limit orders for buying. The first one opens up current price, second below.

Each order can have an order to stop losses and an order to limit profit. About other details of orders another time.

There are sell stop and sell limit orders for selling. The first is set below the price, the second is set above.

An important feature of Stop Loss and Stop Profit orders is that Stop Loss orders in buy orders are below the order, while in sell orders they are above.

The opposite is true with orders to limit profits or take profit.

So, one more time. Pending orders are triggered only when the price reaches their level. Therefore, you can safely open them and see how it happens when we use a special script program.

How to use pending orders with or without a script

Now a word or two about where pending orders are used.

There are strategies that provide that we work on the countermove and wait for the market to go in the direction of the main trend. Such is, such is the method. However, in the first case, stop orders are used, and in the second, limit orders.

You need to understand that the orders themselves do not bring profit. That is, they cannot be opened wherever it comes into your head. The order must be opened clearly according to the system. Only in this case, and even then not with 100% probability, we can count on profit. Any other unsystematic approach to placing orders is doomed to failure. You will only receive losses, and then you will scold your broker for dishonesty towards you for a long time. Although in fact the fault will lie with you.

Today we got acquainted with the script, which very conveniently opens all pending orders, is study guide for beginner traders. You can download it from the link under the social buttons.

By the way, I used the Amarkets terminal for work, I recommend you today ...

The MetaTrader4 trading terminal provides the ability to place pending orders:

  • of the Stop type, in the parameters of which the trader specifies the value of the price above the market value for the purchase of a trading instrument and the value of the price below the market value for the sale of a trading instrument. Varieties of the protective order SellStop and BuyStop are intended for pending selling after a breakdown of a support level and pending buying after a breakdown of a resistance level. Protective orders of the Stop type are used by traders working on the strategy of breaking through significant levels and are placed after a competent analysis of the situation.
  • of the Limit type, in the settings of which the trader specifies a price below the market price - for buying a trading instrument, and a price above the market one - for selling a trading instrument. The so-called "limit" BuyLimit and SellLimit orders can be placed manually or with the help of an automated one-time action assistant - a script. An order of the BuyLimit type is placed slightly above a significant support level, since as a result of a price drop to the specified level, it may reverse, and the order will catch a good entry moment. Orders of the SellLimit type work in a similar way: they are placed slightly below the resistance level. When the price bounces off a significant level and reverses, an order will be opened at the optimal price.

In all cases, orders are triggered when the price reaches the level specified in the parameter settings.

Many traders, in order to avoid confusion with opening orders, prefer to use a Forex script for pending orders. To do this, enable the autotrading function in the terminal settings and set the necessary checkboxes. The above BuyLimit and BuyStop orders are set using the Setup_BUY_PendingOrder script by simply dragging them onto the price chart, to the level where they are planned to trigger according to the functionality. SellLimit and SellStop orders can be placed on the price chart using the Setup_SELL_PendingOrder script by analogy. In this case, the script itself calculates the type of order that must be placed at this level.

Trading with pending orders has the following advantages:

  • Strategy No. 2 - trading using a grid of orders in a flat

    If, subject to the presence of a trend, everything seems simple enough, then what to do when the market is experiencing a prolonged flat. In this case, it is recommended to use limit orders instead of stop pending orders. Let's consider a specific situation with an example. Suppose there is a flat on the market, then we place four Buy Limit orders below the current price and Sell Limit orders above the price.

    When one of the orders is triggered, the opposite series of positions should be deleted. Stop losses of all orders must be set at the same level, so if the price does not go in our direction, we can fix the losses and build a new grid of orders. The same applies to take profits. When the predetermined cumulative profit is reached, all orders must be deleted. If the first order worked and closed by take profit, then everything is clear here. If the price goes against us, then new trades will be opened, but to close trades at the total take profit, the price will need to travel a much shorter distance. This strategy works well for trading in calm markets with weak price movements and quick pullbacks, for example, during.

    Scripts for automatically placing a grid of orders

    In addition to manually placing pending orders, there are also special order grids, one of which is the SetGridOrders script. With it, you can place an unlimited number of pending orders. You just need to drag it from the "Navigator" to the chart, specifying the necessary settings for the following parameters in the window that opens:

      extern double Price – opening price of the first order;

      extern double Lot – lot size;

      extern int SetOrders – number of orders;

      extern int Step – distance between orders;

      extern int StopLoss – stop loss level;

      extern int TakeProfit – take profit level;

      extern bool GeneralProfit - total take profit, upon reaching which all orders will be closed;

      extern bool GeneralStop – total loss, upon reaching which all open positions and removal of failed pending orders.

    You can also turn on a sound signal that will notify you when the first order is triggered. Having specified all the necessary settings, you should click OK, as a result of which a new window will open in which you will need to select the type of pending orders - stop or limit. Thus, this script will be useful for anyone and will greatly simplify manual trading.

    As can be seen from the descriptions of the strategies, trading with pending orders requires the trader to have maximum concentration and attention. Need to constantly monitor current situation, add a new order in time if the strategy requires it, or delete the grid if the total take profit or loss is reached, and then add a new grid of orders to the chart. The script described above partially relieves you of the burden of placing orders, but this is just a script, not , it needs to be run manually each time a new grid of orders is built. We bring to your attention to consider one profitable Expert Advisor, which showed good work on the GBPUSD currency pair.

    This Expert Advisor is based on the principle of random walk of numbers - Brownian motion. When this Expert Advisor is installed on the chart, it splits the area around the price into two parts and places sell limit orders above the price, and buy limit orders below the price. The high profitability of the Expert Advisor is ensured by the use of , which is activated on non-recoil price movements. However, when losing trades appear, the lot does not double, as in most EAs based on the Martingale system, but by a certain coefficient specified in the PlusLot parameter, which makes the use of this EA less dangerous.

    Since the grid of orders is based on the difference in points between orders, it does not matter much, but it is best to install the adviser on M5 or M15. The Order Grid Expert Advisor can work in two directions at the same time. If multidirectional orders work, he will bring each of them to take profit, and if necessary, reopen the grid at new levels. The main disadvantage of this Expert Advisor is that in the event of a power or Internet outage, it does not “remember” which orders it has and which do not. Therefore, you have to delete the old grid of orders and restart the adviser. To prevent this from happening, we recommend installing the adviser on .

    The EA has the following settings:

      Orders - here you need to specify the maximum number of orders;

      lot1 – initial lot size for the first order in the grid;

      PlusLot – coefficient by which the initial lot will increase when losing trades appear;

      FirstStep - distance from the current price to the first order;

      Step - distance between orders;

      SLoss - stop loss size for each trade or for the entire grid;

      TProfit - take profit size for each trade or for the entire grid;

      ProfitClose - this parameter is responsible for closing all unidirectional orders when the total take profit is reached;

      TrailingPercent - the size of the total take profit that will be trailed, in percent;

      magic - unique number of the adviser;

      CloseEndWeek - when this parameter is activated, the adviser forcibly closes all orders at the end of the week;

      HourClose - this specifies the time to close all orders on Friday.

    As mentioned above, it is quite difficult to predict the direction of price movement, which is why gridders use a grid of orders to catch any price movement. However, in practice, a favorable scenario is extremely rare - which is the weakness of such strategies. The market is constantly changing, if yesterday one of currency pairs was 200 points, now it does not exceed 50 points. Perhaps the whole point is in the incorrect determination of levels for placing pending orders. And all because before placing orders, no analysis is carried out and the grid of orders is placed at random. If trading with pending orders was carried out from significant levels, then it would bring much more profit. We propose to consider the FractalGrid grid Expert Advisor, based on the use of fractal analysis.

    The trading of this Expert Advisor consists in placing pending orders at the level of breaking through fractal highs and lows. You can read about what fractals are and how to define them. It is recommended to use H1 as a working timeframe. There are two EA trading tactics:

      When a new fractal is formed, an unworked pending order is transferred from the old level to the new one;

      When a new fractal is formed, the old pending order is not deleted, but a new order is added to it.

    Let's move on to the description of the FractalGrid Expert Advisor settings:

      Lots – this parameter sets a fixed value of trading lots;

      Risk – if you put zero in front of the Lots parameter and specify the value of the Risk parameter, then the lot size for each new order will be calculated based on the current deposit size;

      RiskOnBalance – by setting this parameter to true, the lot size will be calculated based on the balance size, and by selecting the false mode, the amount of free margin will be taken as the basis;

      FractalPeriod - here you need to specify the period of the fractal, which must necessarily be odd;

      DeleteOldOrder - this parameter is responsible for choosing the tactics for placing pending orders, which was mentioned above. If you want to use the first tactic, then select true, and for the second tactic, specify false;

      The order grid strategy is not, but can be quite profitable. Depending on the state of the market, you can use a stop order grid - in the presence of a trend, or a limit grid - during a flat. To simplify the construction of a grid of orders, you can use scripts, as well as advisors. However, it is recommended to use gridded Expert Advisors only under the supervision of a trader in a semi-automatic mode. Good luck trading!

The MQL programming language, which is used to translate algorithms into functions understandable for MetaTrader, is used to write not only indicators and Expert Advisors, but also scripts. With their help, any one-time operation is performed, after which they are turned off. In this article you will be able download script to delete pending orders and learn how to use it correctly.

Recall that pending orders (OO) are a special type of orders given by a trader to the trading terminal, which leads to the opening of a position not immediately, but under specified conditions. Most often, these conditions are understood as a specific level, at which the quotes reach a transaction. Many trading strategies based solely on the use of pending orders.

For example, channel TS, the varieties of which involve trading on a pullback or a breakdown, involve placing pending orders at the boundaries of the channels. Another example of using pending orders is trading using the Martingale principle, according to which a position is sequentially opened when the quote passes a certain interval.

When a script is required to remove pending orders

When trading with the described methods, a very large number of pending orders can be placed (especially in short-term Martingale trading). At the same time, after the occurrence of certain events, it is required to quickly remove those that did not work. Doing it manually is quite laborious and time consuming. It is for such cases that the script for deleting pending orders is intended (download ) called Delete All Pending.

Best Broker

To use it, you must first place it in the Scripts folder, which can be found in the MQL4 section of the MT4 data directory (Fig. 1). Then you should mark all the items of the "Expert Advisors" tab of the "Settings" window, opened from the "Service" menu of the terminal. After that, in the "Scripts" section of the updated "Navigator" window (you can update it from the context menu or by restarting MT4), you need to find the required script (Fig. 2) and apply it to the required asset chart (this is done by dragging the script onto the chart or by double-clicking the left mouse button on the script name). As a result, all currently pending failed orders will be deleted.


Script for deleting pending orders by time

Some TS require pending orders to be active only for a specified period of time or until a certain moment (for example, until the end of a specific trading session or the current trading day). In this case, you should use the DelOrdersAfterVLine script (download ). Its activation leads to display on the chart at a distance of 10 candles from the current red vertical (Fig. 3). When it is reached, all pending orders will be canceled.


The moment of cancellation can be changed by moving the red vertical. This is done with the mouse - its pointer is directed to the vertical, the right button is pressed and the movement is made in the required direction. The script additionally calculates and displays the time (in seconds) at the top left of the chart window, after which the OO will close.

Other scripts for pending orders

In addition to the need to quickly delete pending orders, there is often a need for their quick placement (for example, to form a grid of pending orders). The following two scripts can be used for this purpose:

  1. LimitOrderGrid (download );
  2. StopOrderGrid (download ).

The first one ensures the formation of a grid of limit pending orders. In this case, if the script placement level is higher than the current price, then a grid of pending orders of the SellLimit type is built (Fig. 4), and if it is lower, BuyLimit is built (Fig. 5).


The second one ensures the formation of a grid of stop pending orders. If the script is placed above the current price level, then a grid of pending orders of the BuyStop type is formed (Fig. 4), and if it is placed below it, SellStop is formed (Fig. 5).

These two forex scripts have pending orders input parameters:

  • the number of created OOs;
  • distance in points between neighboring TOEs;
  • StopLoss and TakeProfit OO (if they are not needed, then their values ​​are set to 0);
  • the volume (in lots) of the initial TOE;
  • multiplier for calculating the volume when averaging (according to Martingale).

(( reviewsOverall )) / 5 User rating (0 votes)

Your browser does not support images upload. Please choose a modern one

Today I want to tell you about a useful tool. It is useful for those traders who have order grid is the basis trading system. Since this strategy involves opening a large number orders, doing the work with your hands is difficult. This requires a lot of time and attention. Using the script will greatly facilitate the work of the trader. , which applies order grid, does not require deep knowledge of the market. The behavior of the price in this case does not really matter. It is built on mathematical calculations that allow you to "catch" the price.

The essence of trading on a grid of orders

It is as follows. Pending orders are placed at a certain distance from each other (grid step). The direction of opening deals is chosen by the trader. It can only be BUY orders or only SELL orders. But in practice, pending orders are placed more often in both directions from the current price, that is, both for buying and for selling.

Now let's talk about a script that can successfully complete this task. In order to install it in trading terminal, we use the usual scheme of actions. The copied script file is placed in the MT4 "Scripts" folder. More detailed instructions can be read in the article.
And then, in the “Navigator” terminal menu, select “Scripts”, and in it “Grid” and drag the script onto the chart of the pair we are going to trade.

The success of trading is largely related to the correct selection of script parameter values.

First you need to specify the grid step in points - the Steps parameter. Another important parameter is Volume. This is the volume of each transaction. Then we tell the script the minimum deviation from the current price in points - the Price parameter. Next is the Slippage parameter. It defines the allowable slippage in points. Specify the size of the take profit and stop loss in the corresponding lines of the script settings. And the last parameter is Count Orders. In it, you need to put a number that will correspond to the number of orders to be opened. What should be kept in mind that if it is supposed to open trading orders in both directions (both SELL and BUY), then with the value of the parameter 5, the script will open five BUY orders and five SELL orders. You can choose the direction of transactions in the general settings of the script.

As you can see, there is nothing complicated in the settings of this script. Before using it in real trading, we will definitely try its operation on a demo account. There you can also choose the optimal parameters.

Script order grid download.