Author: transport_david , David W Honeywell
Modify All

This tool is designed to automate the management of your active trading positions by ensuring that every trade has a predefined safety net and profit target. If you frequently find yourself opening trades but forgetting to set specific exit points, this script acts as an automated assistant that handles that task for you instantly.

How the Logic Works

The script continuously monitors your open trading account. Every time it runs, it scans through all your active positions to identify "incomplete" trades—specifically those where a Stop Loss (the price at which a trade closes to prevent further loss) or a Take Profit (the price at which a trade closes to lock in gains) has not been set.

Key Functional Behaviors

  • Automatic Identification: The tool filters your open positions to focus only on the specific currency pair you are currently viewing. It ignores other unrelated trades, ensuring that it only modifies what is necessary for your current focus.
  • Smart Modification: For every active trade that is missing a profit goal or a loss limit, the script automatically calculates and applies the correct levels based on the settings you provide.
  • Buy Position Handling: When the script detects an open "Buy" order without a target, it automatically places the Stop Loss below the entry price and the Take Profit above the entry price.
  • Sell Position Handling: Conversely, for "Sell" orders, it intelligently places the Stop Loss above the entry price and the Take Profit below the entry price.
  • Customizable Parameters: You have full control over the safety margins. Through the input settings, you can define exactly how many points away from your entry price the script should place these protective limits.

Summary of Benefits

Essentially, this script serves as a fail-safe for disciplined trading. It eliminates the manual effort of calculating and clicking into every individual trade to set exit points, ensuring that no position is left "hanging" without a clear plan for risk management or profit realization.

Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
13 Views
0 Downloads
0 Favorites
Modify All
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                   Modify All.mq4 |
//|                              transport_david , David W Honeywell |
//|                                        transport.david@gmail.com |
//+------------------------------------------------------------------+
#property copyright "transport_david , David W Honeywell"
#property link      "transport.david@gmail.com"

extern int stploss = 100;
extern int tkprft = 100;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
 int i;
  for (i = OrdersTotal()-1; i >=0 ; i--)
  {
      if ((OrderStopLoss()==0 || OrderTakeProfit() == 0)&&(OrderSymbol()==OrderSymbol()))
      {
      OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if ((OrderType() == OP_BUY)&&(OrderTakeProfit() == 0))
      {
         OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()-(stploss*Point), OrderOpenPrice()+(tkprft*Point),0, White);
      }
      if ((OrderType() == OP_SELL)&&(OrderTakeProfit() == 0))
      {
         OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice()+(stploss*Point), OrderOpenPrice()-(tkprft*Point),0, White);
      }
      }
  }

  
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments