e-MovingInWL

Download script
Author: ��� ����� �. aka KimIV
e-MovingInWL

This automated trading tool is designed to manage your open positions by dynamically adjusting your Stop Loss levels based on real-time market profitability. Its primary goal is to protect your capital while ensuring that trades move into a "locked" profit state as the price progresses in your favor.

How it Works

The script continuously monitors all of your active trades. For every open position, it performs the following logic:

1. Monitoring for Safety (Stop Loss Check) The tool looks at how close your current Stop Loss is to your entry price. It specifically identifies trades where the "risk" is currently narrow—meaning the distance between where you entered the trade and where you would lose money is small.

2. Identifying Profitable Movement If a trade meets that safety criteria, the script then checks if the market has moved sufficiently in your favor. It looks for a specific threshold of profit (which you can define in the settings).

3. Dynamic Adjustment (Moving to Break-Even) Once both conditions are met—the risk is small enough and the price has reached a desired profit level—the script automatically modifies your trade. It moves your Stop Loss to a point where you are guaranteed a specific amount of profit (or your original entry price), effectively "locking in" your gains. This prevents a winning trade from suddenly turning into a losing one due to market fluctuations.

Key Features for the User

  • Automated Protection: You don't have to manually watch every trade; the script identifies when it is safe to move your Stop Loss and does it automatically.
  • Customizable Thresholds: You can easily adjust how much profit is required before the adjustment happens and how much "buffer" profit you want to secure.
  • Visual Feedback: The tool provides a real-time on-screen summary of your open positions, showing the symbol, entry price, current Stop Loss, and the calculated distance for each.
  • Audio Notifications: It includes an optional alert sound that triggers every time the script successfully modifies a trade, letting you know your profit is secured.
  • Clean Interface: When you remove the tool from a chart, it automatically clears the on-screen comments to keep your workspace tidy.
Orders Execution
Checks for the total of open ordersIt can change open orders parameters, due to possible stepping strategy
Miscellaneous
It plays sound alerts
8 Views
0 Downloads
0 Favorites
e-MovingInWL
//+------------------------------------------------------------------+
//|                                                 e-MovingInWL.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//| Äâèãàåò ñòîï â áåçóáûòîê                                         |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern int  LevelWLoss  = 1;       // Óðîâåíü áåçóáûòêà
extern int  LevelProfit = 10;      // Óðîâåíü ïðîôèòà
extern bool ShowComment = True;    // Ïîêàçûâàòü êîììåíòàðèè
extern bool SoundAlert  = True;    // Çâóê

//+------------------------------------------------------------------+
//| Custor expert deinitialization function                          |
//+------------------------------------------------------------------+
void deinit() {
  Comment("");
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  bool   fm;
  double pBid, pAsk, pp;
  int    nd;
  string comm = "";

  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      nd = MarketInfo(OrderSymbol(), MODE_DIGITS);
      pp = MarketInfo(OrderSymbol(), MODE_POINT);
      comm = comm+OrderSymbol()+"  Öåíà: "+DoubleToStr(OrderOpenPrice(),nd)+
             "  SL=" + DoubleToStr(OrderStopLoss(),nd);
      if (OrderType()==OP_BUY) {
        comm = comm + "(" + DoubleToStr((OrderStopLoss()-OrderOpenPrice())/pp,0) + ")\n";
        if (OrderStopLoss()-OrderOpenPrice()<LevelWLoss*pp) {
          pBid = MarketInfo(OrderSymbol(), MODE_BID);
          if (pBid-OrderOpenPrice()>LevelProfit*pp) {
            fm=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+LevelWLoss*pp,OrderTakeProfit(),CLR_NONE);
          }
        }
      }
      if (OrderType()==OP_SELL) {
        comm = comm + "(" + DoubleToStr((OrderOpenPrice()-OrderStopLoss())/pp,0) + ")\n";
        if (OrderStopLoss()==0 || OrderOpenPrice()-OrderStopLoss()<LevelWLoss*pp) {
          pAsk = MarketInfo(OrderSymbol(), MODE_ASK);
          if (OrderOpenPrice()-pAsk>LevelProfit*pp) {
            fm=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-LevelWLoss*pp,OrderTakeProfit(),CLR_NONE);
          }
        }
      }
      if (fm) {
        if (SoundAlert) PlaySound("alert2");
        break;
      }
    }
  }
  if (ShowComment) Comment(comm);
}
//+------------------------------------------------------------------+

Comments