Profit factor:
2.05
Orders Execution
Checks for the total of open orders
5 Views
1 Downloads
0 Favorites
NailShort
//+------------------------------------------------------------------+
//|                                                        Gerat.mq4 |
//|                                      Copyright © 2009, Nail_Saby |
//|                                            http://gerat.ucoz.ru/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, http://gerat.ucoz.ru/"
#property link      "gerat.ru@mailru"

#define MAGICNUM  20084379

extern double OpenT = -50;
extern double Lot = 0.1;
extern int    N_MaxBar = 10;
extern double TakeProfit = 400;
extern double Delta = 1000;

//ïîäñ÷åò òåêóùåãî êîëè÷åñòâà îòêðûòûõ ïîçèöèé íà ïðîäàæó
int CalcNumShorts()
{
   int nShorts = 0;
   for (int i = 0; i < OrdersTotal(); i++) {
      int res = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (res == 0) {
         Print ("Îøèáêà ïðè âûáîðå îðäåðà: ", GetLastError()); 
         return;
      }
      if (OrderSymbol() == Symbol() && OrderMagicNumber() == MAGICNUM 
            && OrderType() == OP_SELL) nShorts++;
   }
   return (nShorts);
}

//ïîïûòêà îòêðûòü íîâûé îðäåð
void CheckForOpen()
{  
   bool found = false;
   //ïîèñê ïîñëåäíåãî îòêðûòîãî îðäåðà íà ïðîäàæó   
   
   for (int i = OrdersTotal() - 1; i >= 0; i--) {
      int res = OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
      if (res == 0) {
         Print ("Îøèáêà ïðè âûáîðå îðäåðà: ", GetLastError()); 
         return;
      }
      if (OrderMagicNumber() == MAGICNUM && 
            OrderSymbol() == Symbol() && OrderType() == OP_SELL) {                                      
         found = true; //...íàøëè ïîñëåäíèé îòêðûòûé îðäåð íà ïðîäàæó      
         break;
      }
   }
    
   if (!found) {
      Print ("Îøèáêà: íå ñìîãëè íàéòè îæèäàåìîãî îòêðûòîãî îðäåðà íà ïðîäàæó: ", GetLastError()); 
      return;   
   }
        
   //åñëè óáûòîê ïðåâûøàåò çíà÷åíèå ïåðåìåííîé OpenT, îòêðûâàåì îðäåð íà ïðîäàæó
   if (OrderProfit() <= OpenT) {
      //Print (OrderProfit());
      double Max = Close[ArrayMaximum(Close, N_MaxBar, 1)]; 
      Print (Bid, " ", Max + Delta * Point);
      res = OrderSend (Symbol(), OP_SELL, Lot, Bid, 3, Max + Delta * Point, Bid - TakeProfit * Point, "", MAGICNUM, 0, Red);
      if (res == 0) {         
         Print ("Îøèáêà îòêðûòèÿ îðäåðà íà ïðîäàæó: ",GetLastError()); 
         return;
      }        
   }        
}

void start()
{
   //ïðîâåðêà íåîáõîäèìûõ óñëîâèé äëÿ òîðãîâëè
   if (Bars < N_MaxBar || IsTradeAllowed() == false) return;
   
   //åñëè íåò îòêðûòûõ ïîçèöèé, îòêðûâààåì ïîçèöèþ íà ïðîäàæó
   if (CalcNumShorts() == 0) {
      double Max = Close[ArrayMaximum(Close, N_MaxBar, 1)]; 
      Print (Bid, " ", Max + Delta * Point);
      int res = OrderSend (Symbol(), OP_SELL, Lot, Bid, 3, Max + Delta * Point, Bid - TakeProfit * Point, "", MAGICNUM, 0, Red);
      if (res == 0) {         
         Print ("Îøèáêà îòêðûòèÿ îðäåðà íà ïðîäàæó: ",GetLastError()); 
         return;
      }      
   }
   else CheckForOpen();
   return;
}

Profitability Reports

NZD/USD Jul 2025 - Sep 2025
1.18
Total Trades 21
Won Trades 15
Lost trades 6
Win Rate 71.43 %
Expected payoff 4.42
Gross Profit 600.00
Gross Loss -507.10
Total Net Profit 92.90
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.95
Total Trades 73
Won Trades 48
Lost trades 25
Win Rate 65.75 %
Expected payoff -1.42
Gross Profit 1920.00
Gross Loss -2023.40
Total Net Profit -103.40
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.86
Total Trades 54
Won Trades 37
Lost trades 17
Win Rate 68.52 %
Expected payoff -3.22
Gross Profit 1056.86
Gross Loss -1230.47
Total Net Profit -173.61
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.17
Total Trades 81
Won Trades 60
Lost trades 21
Win Rate 74.07 %
Expected payoff 2.78
Gross Profit 1562.81
Gross Loss -1337.57
Total Net Profit 225.24
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.01
Total Trades 98
Won Trades 3
Lost trades 95
Win Rate 3.06 %
Expected payoff -102.59
Gross Profit 120.00
Gross Loss -10173.60
Total Net Profit -10053.60
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.79
Total Trades 24
Won Trades 16
Lost trades 8
Win Rate 66.67 %
Expected payoff -7.06
Gross Profit 626.20
Gross Loss -795.60
Total Net Profit -169.40
-100%
-50%
0%
50%
100%
USD/JPY Jul 2025 - Sep 2025
0.82
Total Trades 101
Won Trades 66
Lost trades 35
Win Rate 65.35 %
Expected payoff -4.01
Gross Profit 1795.20
Gross Loss -2200.68
Total Net Profit -405.48
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.02
Total Trades 35
Won Trades 25
Lost trades 10
Win Rate 71.43 %
Expected payoff 0.72
Gross Profit 1213.24
Gross Loss -1187.90
Total Net Profit 25.34
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.59
Total Trades 24
Won Trades 15
Lost trades 9
Win Rate 62.50 %
Expected payoff -12.39
Gross Profit 437.00
Gross Loss -734.46
Total Net Profit -297.46
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.79
Total Trades 84
Won Trades 47
Lost trades 37
Win Rate 55.95 %
Expected payoff -6.11
Gross Profit 1880.00
Gross Loss -2393.40
Total Net Profit -513.40
-100%
-50%
0%
50%
100%

Comments