StopLoss Mover

Download script
Author: Apostol-Aristotel
StopLoss Mover

This automated script is designed to actively manage open trades by dynamically adjusting the "Stop Loss" levels based on real-time market movement. Its primary goal is to protect your capital by ensuring that your protection barrier stays in line with current price action.

How the Logic Works

The tool continuously scans your active trading account to identify specific positions that meet two criteria: they must belong to the correct currency pair (chart) and carry a specific identification number (Magic Number). This ensures the script only interacts with the trades you intend for it to manage, leaving other manual or unrelated trades untouched.

Once it identifies a relevant trade, it applies different logic depending on whether you are in a "Buy" or "Sell" position:

For Buy Positions: The script monitors the current market price. If the price rises significantly above your original Stop Loss level, the script automatically moves the Stop Loss upward. It essentially "trails" the price, ensuring that as the market moves in your favor, your safety net moves with it to lock in potential profits.

For Sell Positions: The logic works in the opposite direction. If the market price drops below your current Stop Loss level, the script automatically moves the Stop Loss downward. This follows the downward trend of a successful sell trade, protecting your gains as the price falls.

Key Features

  • Automated Protection: It removes the need for manual monitoring; the script reacts instantly to price fluctuations.
  • Precision Movement: The adjustments are made based on specific point increments, ensuring consistent and disciplined movement of your risk levels.
  • Selective Management: By using a "Magic Number," the tool can distinguish between different sets of trades, allowing you to use it specifically for automated strategies without affecting your manual trading.
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
14 Views
0 Downloads
0 Favorites
StopLoss Mover
//+------------------------------------------------------------------+
//|                                               StopLoss Mover.mq4 |
//|                                                Apostol-Aristotel |
//|                                  http://www.apostol-aristotel.ru |
//+------------------------------------------------------------------+
#property copyright "Apostol-Aristotel"
#property link      "http://www.apostol-aristotel.ru"
extern int MAGIC;

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
   for(int i=0;i<OrdersTotal();i++) // åñëè åñòü îòêðûòûå ïîçèöèè
    {
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
     if(OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) // Åñëè ñèìâîë ãðàôèêà = ñèìâîëó ñäåëêè
      {
       if(OrderType()==OP_BUY) // Åñëè ìû êóïèëè
         if(Bid-Point*10>OrderStopLoss()) OrderModify(OrderTicket(),0,Bid-Point*10,OrderTakeProfit(),0,Blue); // Åñëè óðîâåíü íàñòîÿùåãî ñòîïà áîëüøå óñòàíîâëåííîãî, òî äâèãàåì ñòîï
       if(OrderType()==OP_SELL) // Åñëè ìû ïðîäàëè
         if(Ask+Point*10<OrderStopLoss()) OrderModify(OrderTicket(),0,Ask+Point*10,OrderTakeProfit(),0,Blue); // Åñëè óðîâåíü íàñòîÿùåãî ñòîïà ìåíüøå óñòàíîâëåííîãîã, òî äâèãàåì ñòîï
      }
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments