Welcome Forex EA downloads & MT4/MT5 auto-trading resources — EAs, Gold EAs, quant tools and real-world automation.
Sign In Sign Up

PlannedPendingOrders - MetaTrader 4 Script - MT4/MT5 Resources

author EAcpu | 3 reads | 0 comments |

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

PlannedPendingOrders - script for MetaTrader 4

This script will open a limit pending order based on the specified horizontal line in the chart you drew previously. Once you've finished plotting, drag and drop the script onto the chart. You can change the expected risk before the order is executed. Before executing, you will see an information dialog with the calculated risk asking you if you really want to execute the order.

The code under version control is here: https://github.com/dirkmql/planned-pending-orders

You can define up to 4 order lines.

Always starts at 1, with subsequent orders increasing the number. If you create lines for multiple orders, remember that the entry price or stop loss will be taken over from the first order if not set in the current order. For example, you can only set Take Profit for Order 2, since Entry and Stop Loss will be taken over from Order 1.

In the example, we will have the script execute two sell limit orders with the same entry and stop loss, but different take profit. In the screenshot below, you can see the horizontal line created for the entry, named entry_1. In order not to be confused with the lines, I gave them different colors in the screenshot.

PlannedPendingOrders - script for MetaTrader 4

Now we set a stop loss line named sl_1 for order 1:

PlannedPendingOrders - script for MetaTrader 4

Take profit for order 1:

PlannedPendingOrders - script for MetaTrader 4

Take profit for order 2 (below tp_1):

PlannedPendingOrders - script for MetaTrader 4

After drawing the line, drag and drop the script onto the chart.

PlannedPendingOrders - script for MetaTrader 4

When setting the expected risk (default: 0.005 = 0.5%), if you set it to a value lower than 0.1, it will be considered a factor in your account balance. Example: If your current account balance is €10,000 and you wish to trade with an expected risk of 0.01, the expected risk is €100 of currency (1% of the account). If you set the expected risk to 0.1 or higher, it will be treated as a monetary amount. Calculated approximate risk differs from expected risk based on account size and trade setup. You will see it printed in the message box and you must confirm it to execute the transaction.

For the example, we set 0.01, which is 1%:

PlannedPendingOrders - script for MetaTrader 4

After clicking "OK" in the parameters dialog, the following dialog appears with a brief conclusion of the transaction:

PlannedPendingOrders - script for MetaTrader 4

After clicking OK to confirm the dialog box, the order will be created:

PlannedPendingOrders - script for MetaTrader 4

If any problems occur, check the Expert tab below the terminal window for any error messages (automated trading needs to be allowed).


Attachment download

📎 plannedpendingorders.mq4 (21.39 KB)

Source: MQL5 #21804

Verification code Refresh