Author: Copyright � 2008, ������ ������� ����������
Profit factor:
0.85
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
1 Views
0 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/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%
GBP/USD Oct 2024 - Jan 2025
0.84
Total Trades 720
Won Trades 504
Lost trades 216
Win Rate 70.00 %
Expected payoff -8.79
Gross Profit 33225.40
Gross Loss -39554.00
Total Net Profit -6328.60
-100%
-50%
0%
50%
100%
AUD/USD Oct 2024 - Jan 2025
0.66
Total Trades 224
Won Trades 0
Lost trades 0
Win Rate 0.00 %
Expected payoff -25.77
Gross Profit 11003.30
Gross Loss -16776.40
Total Net Profit -5773.10
-100%
-50%
0%
50%
100%

Comments