ClearTP_ALL

Download script
Author: Copyright � 2008, Serega Lykov
ClearTP_ALL

This script is designed as a specialized utility for traders using the MetaTrader 4 platform to quickly manage their active market positions. Its primary purpose is to automate the removal of "Take Profit" levels from all currently open trades simultaneously.

How it Works

When you execute this script, it performs a systematic scan of your entire trading portfolio. It looks at every active order you have running and evaluates one specific criterion: Does this trade have a Take Profit price set?

If the script identifies a trade that has a Take Profit target, it immediately intervenes to modify that specific order. It updates the trade parameters to remove the profit target while keeping all other essential information—such as your entry price, current stop loss, and expiration settings—exactly as they are.

Key Features and Behavior

  • Comprehensive Sweep: The logic ensures that it checks every single open position in your account, rather than just focusing on one at a time.
  • Preservation of Data: It is "non-destructive" regarding your other risk management settings. It only touches the Take Profit field; it does not alter your entry price or move your Stop Loss levels.
  • Visual Feedback: Once activated, the script provides a simple on-screen notification to confirm that the process has been initiated, and it clears that notification once the task is complete.

Use Case

This tool is particularly useful for traders who prefer to manage their profits manually or who need to "free up" a trade from a predetermined exit point to let it run longer in the market without having to manually edit every single position one by one.

Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
7 Views
0 Downloads
0 Favorites
ClearTP_ALL
//+------------------------------------------------------------------+
//|                                                  ClearTP_ALL.mq4 |
//|                                   Copyright © 2008, Serega Lykov |
//|                                       http://mtexperts.narod.ru/ |
//+------------------------------------------------------------------+

#property copyright "Copyright © 2008, Serega Lykov"
#property link      "http://mtexperts.narod.ru/"

int start()
  {
   Comment("Script ClearTP_ALL is run...");
   int total = OrdersTotal() - 1;
   for(int i=total; i>=0; i--) if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true) if(OrderTakeProfit() != 0) bool err = OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),0,OrderExpiration(),CLR_NONE);
  }

int deinit()
  {
   Comment("");
  }

//+------------------------------------------------------------------+

Comments