Author: Copyright � 2008, ������ ������� ����������
Profit factor:
0.76
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
4 Views
1 Downloads
0 Favorites
Locker
//+------------------------------------------------------------------+
//|                                                       Locker.mq4 |
//|                     Copyright © 2008, Äåì¸õèí Âèòàëèé Åâãåíüåâè÷ |
//|                                             vitalya_1983@list.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Äåì¸õèí Âèòàëèé Åâãåíüåâè÷"
#property link      "vitalya_1983@list.ru"
extern double  NeedProfit  = 0.001,   //Íà ñêîëüêî ïðîöåíòîâ Ìû óâåëè÷èâàåì áàëàíñ?
               StepLot     = 0.2,   //Âòîðè÷íûå ëîòû
               Lot         = 0.5;   //Ñòàðòîâûé ëîò
extern int     Step        = 50;    //Øàãè ìåæäó ëîêèðîâàíèåì
extern bool    spasenie    = true;
string text = "Locker.mq4";
int  i,ticket1,ticket2;
double ChekPoint,Profit1,Profit2,HighBuy,LowSell;
bool mode_buy,mode_sell,Stop=false;

//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
  double buy_profit=0;
  double sell_profit=0;
//----
   for (i=OrdersTotal();i>=1;i--)                        //Ñþäà ìû âòûêàå èíäèêàòîðà
      {
      OrderSelect(i-1, SELECT_BY_POS, MODE_TRADES);
      if(OrderType() == OP_SELL && OrderSymbol () ==Symbol())  
         {
         sell_profit=sell_profit+OrderProfit();
         Lot=OrderLots();
         StepLot = NormalizeDouble (Lot/1.2,2);
         }
      if(OrderType() == OP_BUY && OrderSymbol () ==Symbol())  
         {
         buy_profit=buy_profit+OrderProfit();
         Lot=OrderLots();
         StepLot = NormalizeDouble (Lot/1.2,2);
         }
      if (sell_profit<buy_profit)
      mode_buy=true;
      if (sell_profit>buy_profit)
      mode_sell=true;
      }
      
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
  
//----
   if ((spasenie&&!Stop)||!spasenie)
      {
      int orders=0;
      bool Otkryt_orders = false;
      for (i=OrdersTotal();i>=1;i--)                        //Ñþäà ìû âòûêàå èíäèêàòîðà
         {
         OrderSelect(i-1, SELECT_BY_POS, MODE_TRADES);
         if((OrderType() == OP_SELL||OrderType() == OP_BUY) && OrderSymbol () ==Symbol())  
         Otkryt_orders = true;
         orders++;
         }
      if (!Otkryt_orders||mode_buy||mode_sell)
         {
         if (!Otkryt_orders&&(!mode_buy&&!mode_sell))
            {
            RefreshRates();
            OrderSend(Symbol(),OP_BUY,Lot,Ask,5,0,0,text,0,Blue);
            }
         if (mode_buy&&!mode_sell)
            {
            mode_buy = false;
            RefreshRates();
            OrderSend(Symbol(),OP_BUY,StepLot,Ask,5,0,0,text,0,Blue);
            }
         if (!mode_buy&&mode_sell)
            {
            mode_sell=false;
            RefreshRates();
            OrderSend(Symbol(),OP_SELL,StepLot,Bid,5,0,0,text,0,Blue);
            }
      
         ChekPoint = Ask;
         HighBuy=Ask;
         LowSell=Bid;
         }
      if (Otkryt_orders)
         {
         double CurrentProfit=0;                                        //Ïîäñ÷èòûâàåì äîõîäíîñòü ñåðèè
         for (i=OrdersTotal();i>=1;i--)
            {
            OrderSelect(i-1, SELECT_BY_POS, MODE_TRADES);
            if((OrderType() == OP_SELL||OrderType() == OP_BUY) && OrderSymbol () ==Symbol())  
            CurrentProfit=CurrentProfit+OrderProfit();
            }
         if (orders>=8)                                                 //Åñëè îðäåðîâ ìíîãî, çàêðûâàåì ïåðåêðûòûå îðäåðà
            {
            for (i=OrdersTotal();i>=1;i--)
               {
               ticket1 = 0;
               Profit1 = 0;
               OrderSelect(i-1, SELECT_BY_POS, MODE_TRADES);
               if(OrderType() == OP_SELL&& OrderSymbol () ==Symbol())  
                  {
                  ticket1 = OrderTicket();
                  Profit1 = OrderProfit();
                  }
               for (int n=OrdersTotal();n>=1;n--)
                  {
                  ticket2 = 0;
                  Profit2 = 0;
                  OrderSelect(n-1, SELECT_BY_POS, MODE_TRADES);
                  if(OrderType() == OP_BUY&& OrderSymbol () ==Symbol()&&(ticket1!=0&&ticket2!=0))
                     {
                     ticket2 = OrderTicket();
                     Profit2 = OrderProfit();
                     if (Profit1==Profit2*(-1))
                        {
                        RefreshRates();
                        OrderSelect(ticket1, SELECT_BY_TICKET);
                        OrderClose(OrderTicket() ,OrderLots(),Ask,5,Blue);
                        RefreshRates();
                        OrderSelect(ticket2, SELECT_BY_TICKET);
                        OrderClose(OrderTicket() ,OrderLots(),Bid,5,Blue);
                        break;
                        }
                     }
                  }
               }
            }
         if (CurrentProfit>=NeedProfit*AccountBalance())                   //Åñëè íàø ïðîôèò ó íàñ â êàðìàíå, çàêðûâàåìñÿ
            {
            for (i=OrdersTotal();i>=1;i--)
               {
               OrderSelect(i-1, SELECT_BY_POS, MODE_TRADES);
               if(OrderType() == OP_SELL && OrderSymbol () ==Symbol())  
                  {
                  RefreshRates ();
                  OrderClose(OrderTicket() ,OrderLots(),Ask,5,Blue);
                  }
               if(OrderType() == OP_BUY && OrderSymbol () ==Symbol())  
                  {
                  RefreshRates ();
                  OrderClose(OrderTicket() ,OrderLots(),Bid,5,Red);
                  }
               }
            if (spasenie)
            Stop=false;
            }
         if (CurrentProfit<-1*NeedProfit*AccountBalance())                            //Åñëè â ìèíóñå, ñòàâèì Ëîêè. 
            {
            if (Ask>ChekPoint+(Step*Point)&&Ask>HighBuy)
               {
               Alert (ChekPoint+(Step*Point));
               RefreshRates();
               OrderSend(Symbol(),OP_BUY,StepLot,Ask,5,0,0,text,0,Blue);
               ChekPoint = Ask;
               HighBuy=Ask;
               }
            if (Bid<ChekPoint-(Step*Point)&&Bid<LowSell)
               {
               RefreshRates();
               OrderSend(Symbol(),OP_SELL,StepLot,Bid,5,0,0,text,0,Blue);
               ChekPoint = Bid;
               LowSell=Bid;
               }
            }
         }
      }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Profitability Reports

USD/CHF Jul 2025 - Sep 2025
0.56
Total Trades 243
Won Trades 154
Lost trades 89
Win Rate 63.37 %
Expected payoff -27.38
Gross Profit 8396.66
Gross Loss -15048.96
Total Net Profit -6652.30
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.40
Total Trades 252
Won Trades 146
Lost trades 106
Win Rate 57.94 %
Expected payoff -29.66
Gross Profit 4994.90
Gross Loss -12470.31
Total Net Profit -7475.41
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.93
Total Trades 438
Won Trades 315
Lost trades 123
Win Rate 71.92 %
Expected payoff -3.24
Gross Profit 18314.00
Gross Loss -19732.50
Total Net Profit -1418.50
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
1.06
Total Trades 1056
Won Trades 791
Lost trades 265
Win Rate 74.91 %
Expected payoff 2.47
Gross Profit 48865.40
Gross Loss -46259.90
Total Net Profit 2605.50
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.80
Total Trades 369
Won Trades 228
Lost trades 141
Win Rate 61.79 %
Expected payoff -18.87
Gross Profit 28014.77
Gross Loss -34977.66
Total Net Profit -6962.89
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.73
Total Trades 715
Won Trades 476
Lost trades 239
Win Rate 66.57 %
Expected payoff -9.80
Gross Profit 19418.00
Gross Loss -26426.37
Total Net Profit -7008.37
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.47
Total Trades 80
Won Trades 48
Lost trades 32
Win Rate 60.00 %
Expected payoff -27703.35
Gross Profit 2004613.60
Gross Loss -4220881.40
Total Net Profit -2216267.80
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.51
Total Trades 178
Won Trades 103
Lost trades 75
Win Rate 57.87 %
Expected payoff -34.92
Gross Profit 6414.70
Gross Loss -12630.80
Total Net Profit -6216.10
-100%
-50%
0%
50%
100%
USD/CAD Oct 2024 - Jan 2025
0.97
Total Trades 1030
Won Trades 699
Lost trades 331
Win Rate 67.86 %
Expected payoff -0.86
Gross Profit 28276.48
Gross Loss -29158.03
Total Net Profit -881.55
-100%
-50%
0%
50%
100%
NZD/USD Oct 2024 - Jan 2025
0.94
Total Trades 341
Won Trades 224
Lost trades 117
Win Rate 65.69 %
Expected payoff -3.39
Gross Profit 19021.00
Gross Loss -20176.20
Total Net Profit -1155.20
-100%
-50%
0%
50%
100%

Comments