_______ __________ ______

Download script
Author: mandorr@gmail.com
_______ __________ ______

This script serves as an automated trade management tool designed to monitor your open positions and automatically close them once a specific profit target is reached. It acts as a "take-profit" executor that scans your active trades in real-time to ensure you secure your gains according to your predefined criteria.

How the Logic Works

The script operates by continuously reviewing every active trade in your trading account. It processes these trades one by one, identifying whether you are currently in a "Buy" position or a "Sell" position.

For Buy Positions: The tool calculates the difference between the current market price and your original entry price. It converts these values into "points" (the smallest unit of price movement) to ensure accuracy. If the current price has risen enough to exceed the profit target you set in the settings, the script will automatically trigger a command to close that trade immediately.

For Sell Positions: Similarly, for positions where you are betting on a price decrease, the tool monitors the market. It compares your entry price against the current market price. If the price has dropped sufficiently to meet or exceed your specified profit goal, the script will automatically execute the closing order.

Key Features

  • Automated Monitoring: You do not need to manually watch the charts; the script scans your open orders for you.
  • Customizable Targets: The user can define exactly how many points of profit are required before a trade is considered "complete."
  • Precise Execution: By calculating movements based on the specific asset's price points, the script ensures that trades are closed accurately regardless of which currency pair or market you are trading.
  • Efficiency: The logic handles multiple trades simultaneously, checking each one independently to ensure that every winning position is captured as soon as it hits your target.
Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
12 Views
0 Downloads
0 Favorites
_______ __________ ______
// Çàêðûòü ïðèáûëüíûå îðäåðà.mq4
// Ñêðèïò
#property copyright "mandorr@gmail.com"
#property show_inputs
extern int Profit=5;
void start()
{
   int slippage=2;
   int ask, bid, open;
   double point;
   for (int i=OrdersTotal()-1; i>=0; i--)
   {
      if (!OrderSelect(i,SELECT_BY_POS,MODE_TRADES)) break;
      if (OrderType()==OP_BUY)
      {
         point=MarketInfo(OrderSymbol(),MODE_POINT);
         if (point==0) break;
         bid=MathRound(MarketInfo(OrderSymbol(),MODE_BID)/point);
         open=MathRound(OrderOpenPrice()/point);
         if (bid-open<Profit) continue;
         OrderClose(OrderTicket(),OrderLots(),bid*point,slippage);
      }
      if (OrderType()==OP_SELL)
      {
         point=MarketInfo(OrderSymbol(),MODE_POINT);
         if (point==0) break;
         ask=MathRound(MarketInfo(OrderSymbol(),MODE_ASK)/point);
         open=MathRound(OrderOpenPrice()/point);
         if (open-ask<Profit) continue;
         OrderClose (OrderTicket(),OrderLots(),ask*point,slippage);
      }
   }
}
// End

Comments