nModify Orders - MetaTrader 5 Library | Forex Indicators Download - MT4/MT5 Resources


Modify_Order.mqh provides two powerful functions for managing open positions and pending orders in Expert Advisor and indicators on the MetaTrader 5 platform. It is designed to automate the daily operations of modifying stop loss, take profit levels and order prices.
Modification of stop loss and take profit for open positions
Modify pending order price
Flexible filtering by position type, profitability and symbol
Supports different modes of value calculation (in points or absolute price).
Designed to modify the Stop Loss and Take Profit levels of open positions.
blankmodify_position ( string tp_and_sl, // "SL" or "TP" - what we change. String price and value, // "Value" or "Price" - type of value string type position, // filtering of double prices _tp_ and _sl by position type , // value to set string symbol, // trading instrument symbol long magic number // magic number expert. );
// Set the stop loss of all positions to 1000 pips modify_position( "SL" , "Value" , "All" , 1000 , _symbol , 0 ); // Set the target price of the profitable buy position to 1.2345 modify_position( "TP" , "Price" , "Buy Profit" , 1.2345 , _symbol , 12345 ); // For an unprofitable sell position, set the stop loss to 500 pips MODIFY_POSITION( "SL" , "Value" , "Sell Loss" , 500 , "EURUSD" , 98765 );
Designed to modify pending orders (stop and limit orders).
Blank Modify Order ( string tp_sl_price, // "price", "stop loss" or "take profit". string_type_order , // Order type used for filtering double_tp_sl_price , // New meaning. String Symbol, // Trading Tool Symbol Long Magic Number // Magic Number Expert. );
"Buy Stop" - pending buy stop order
" Limit" - Pending buy limit order.
" Sell Stop" - Pending stop-loss sell order.
" Sell Limit" - Pending sell limit orders.
// Change the price modification order for the Buy Stop order ( "Price" , "Buy Stop" , 1.2345 , _symbol , 0 ); // Set the Stop Loss modification order for the Sell Limit order ( "SL" , "Sell Limit" , 1.2350 , "GBP/USD" , 12345 ); // Change the Take Profit modification order for the Buy Limit order ( "TP" , "Buy Limit" , 1.2300 , "EUR/USD" , 98765 );
Search all vacancies in reverse order
Positions filtered by symbols and magic numbers
Check additional conditions ( position type, profitability)
New calculated stop loss/stop loss values :
For "Value" mode : Price ± (Value × Points)
For "price" mode : direct assignment
Send modification command via OrderSend()
Enumerate all pending orders
Filter by symbol, magic number and order type
Modify specified parameters ( price, stop loss or take profit)
Save unchanged parameters
Send modification command
Double check the order type - string parameter and actual type via system
Complex filtering - ensures only target positions/orders are affected
Preserve unchanged parameters - when SL changes, TP is preserved and vice versa
For a buy position :
Stop loss : current price - (value × points)
Take profit : current price + (value × points)
To sell a position :
Stop loss : current price + (value × points)
Take profit : current price - (value × points)
#Include <modify_order.mqh> // In the OnTick() function or by condition: If (Условие_для_трейлинга) { // When moving in the desired direction, pull the stop loss to the price modify_position( "SL" , "Value" , "Total Profit" , 500 , _symbol , expert magic); }
// Quick stop loss script for all positions blank start () { modify_position( "SL" , "value" , "all" , 1000 , _symbol , 0 ); }
Approximate time : any (function has nothing to do with time range)
Instrumentation : any currency pair, metal, index.
Magic Number : It is recommended to use a unique value for each Expert Advisor.
Versatility - suitable for any trading instrument
Flexibility - 18 different location filtering modes
Easy to use - intuitive interface
Reliability - full inspection before modification
Efficiency - minimal consumption of computing resources
Position profit and loss calculator (open orders)
Monitor trends in different time ranges within one time range
Modern Time Panel for MT5 The Modern Time Panel is a stylish, minimalist custom indicator for MetaTrader 5 that helps you track time accurately. It's neatly pinned to the top right corner of the chart and displays the current broker time, local time, and a live countdown to the next candlestick (new bar). Built-in independent 1-second timer, the countdown will continue to run even if the market is slow or there are no incoming quotes. Fully customizable and suitable for dark mode, it's the perfect non-intrusive tool to ensure you never miss a candle closing.
A simple trading strategy based on breakouts of previous highs and lows.
Attachment download
📎 Modify_Orders.mq5 (65.76 KB)
📎 Modify_Orders.mqh (59.57 KB)
Source: MQL5 #68540
💡 Featured Recommendations
✍️ Latest by the author
- •
- •
- •
- •
- •
- •
📌 Popular topics
- •
- •
- •
- •
- •
- •
- •
- •
🔗 You May Be Interested In
- •
- •
- •
- •
- •
- •