__________ TakeProfit

Download script
Author:
__________ TakeProfit

This automated script is designed to manage your active trading positions by dynamically adjusting the "Take Profit" levels. Its primary purpose is to ensure that your profit targets stay at a specific, consistent distance from the current market price as the market moves in your favor.

How it Works

The script constantly monitors your open trades and performs the following logic:

Distance Management You can set a specific numerical value (the "Distance") representing how many points away from the current price you want your profit target to remain. The script uses this value to recalculate where your exit point should be at any given moment.

Dynamic Adjustment for Buy and Sell Orders The tool distinguishes between the two types of trades:

  • For Sell Positions: It tracks the market price and looks to place the Take Profit at a certain distance below the current price.
  • For Buy Positions: It tracks the market price and looks to place the Take Profit at a certain distance above the current price.

Operational Modes The script offers two different ways to handle these adjustments based on your preferences:

  1. Continuous Tracking (Default): When enabled, the script will continuously move your Take Profit level to maintain the exact distance you specified, regardless of which direction the price is moving. It essentially "trails" the profit target automatically.
  2. Selective Tracking: You can configure the script to be more conservative. In this mode, the script only moves the Take Profit when the market is moving in your favor (e.g., it will only adjust if the price is pushing further into profit), preventing the script from moving your target "backward" against a retracement.

Key Benefits for the User

  • Automation: It removes the need to manually move your TP orders as the price fluctuates, allowing for "hands-off" management of active trades.
  • Consistency: It ensures that your profit targets are always aligned with your intended strategy distance, maintaining a uniform risk/reward profile across different market conditions.
  • Error Handling: If the script encounters any issues while trying to modify an order (such as a connection glitch or a price gap), it will log the specific error message in the system diary for your review.
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
__________ TakeProfit
//+------------------------------------------------------------------+
//|                                             _TakeProfitMove.mq4  |
//|                                           "ÑÊÐÈÏÒÛ ÄËß ËÅÍÈÂÎÃÎ" |
//|                Ñêðèïò ïåðåìåùàåò TakeProfit íà Distance îò ðûíêà |
//|                           Bookkeeper, 2006, yuzefovich@gmail.com |
//+------------------------------------------------------------------+
#property copyright ""
#property link      ""
//#property show_inputs
//+------------------------------------------------------------------+
extern int Distance=5;            // Ðàññòîÿíèå îò ðûíêà            |
extern bool UpDoun=true; //äëÿ òîëüêî "ïîäòàñêèâàíèÿ" ê ðûíêó =false |
          //äëÿ è "ïîäòàñêèâàíèÿ" ê ðûíêó è "îòñêîêà" îò ðûíêà =true |
//+------------------------------------------------------------------+
void start() 
{
double NewPrice;
int    i,Total,Dist;
int    Dgts=MarketInfo(Symbol(),MODE_DIGITS);     
bool   GoGo;
//+------------------------------- ÓÇÍÀÒÜ ÎÃÐÀÍÈ×ÅÍÈÅ ÑÂÎÅÃÎ ÄÖ -----+
//  if(Distance<10) Dist=10;
//  else 
    Dist=Distance;
//+------------------------------------------------------------------+
  Total=OrdersTotal();
  if(Total>0)
  {
     for(i=Total-1; i>=0; i--) 
     {
        if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES)==true) 
        {
           if(OrderSymbol()==Symbol() && OrderType()==OP_SELL) 
           {
              NewPrice=Bid-Dist*Point;
              if(UpDoun==true) GoGo=true;
              else
              {
                 if(OrderTakeProfit()<NewPrice) GoGo=true;
                 else GoGo=false;
              }
              if(GoGo==true) if(OrderModify(OrderTicket(),
                             OrderOpenPrice(),
                             OrderStopLoss(),
                             NormalizeDouble(NewPrice,Dgts),
                             OrderExpiration(),
                             CLR_NONE)!=TRUE) 
                             Print("LastError = ", GetLastError());
           }
           if(OrderSymbol()==Symbol() && OrderType()==OP_BUY) 
           {
              NewPrice=Ask+Dist*Point;
              if(UpDoun==true) GoGo=true;
              else
              {
                 if(OrderTakeProfit()>NewPrice) GoGo=true;
                 else GoGo=false;
              }
              if(GoGo==true) if(OrderModify(OrderTicket(),
                             OrderOpenPrice(),
                             OrderStopLoss(),
                             NormalizeDouble(NewPrice,Dgts),
                             OrderExpiration(),
                             CLR_NONE)!=TRUE) 
                             Print("LastError = ", GetLastError());
           }
        }
     }
  }
}
//+------------------------------------------------------------------+

Comments