We recommend:

  1. Home
  2. Scripts
  3. Script for modifying order targets Take Profit and Stop Loss

Script for modifying order targets Take Profit and Stop Loss

скрипт для модификации ордеров

This script was created to help a trader modify his open orders faster than it can be done manually.

The script has a number of settings, with the help of which you can modify the targets of all orders in general that you have in trade, and only certain ones that fit the given conditions. You can choose two targets at once: Take Profit and Stop Loss.

This script is convenient both when working with single orders and when working with grids of orders or a number of orders using the pyramid method.

Script settings:

New Take Profit New Take Profit to be placed for orders. If 0 – the current TP is deleted
New Stop Loss New Stop Loss to be placed for orders. If 0 – the current SL is deleted
Choose Order Direction Choosing the direction of open order: buy or sell
Magic Number Include a magic number for closed orders. If the value is -1 all the magic will be taken into account.
Orders Symbol Which one to modify: the current one on which the script is installed, or everything in the market.
Orders Comment Include a well-known comment of the order on which the search will be carried out (you can specify only part). Or leave the field blank, then the comment will not be taken into account.
Orders Ticket Include a specific order ticket that needs to be modified or leave a value of 0 for all tickets. If the ticket is found, the rest of the filters will not be counted.

An example of how the script works:

Suppose that we have 4 orders in the market, three of which are open with the known magic number.

To set the desired magic for manual orders, use our DaVinci Open order with given Magic Number script:

script for mt4

We need to modify Take Profit by making it equal to 1.3850 and Stop Loss equal to 1.201 for all Buy orders in the market, for which the Magic Number is “1111”. In this case, set these settings and run the script:

script for mt4

As you can see in the screenshot below, these targets were adjusted, our TP and SL were modified, the script interacted only with those orders for which the Magic Number was known.

script for mt4

The log entry indicates that there were three modifications.

script for mt4

If you need to modify only a specific order – no problem, just specify its Ticket in the settings, then other filters will not be taken into account.

Simplicity is the key to success!

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed