Profit factor:
2.51
Orders Execution
Checks for the total of open orders
3 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

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%
GBP/CAD Jul 2025 - Sep 2025
0.96
Total Trades 53
Won Trades 38
Lost trades 15
Win Rate 71.70 %
Expected payoff -0.75
Gross Profit 1079.21
Gross Loss -1119.01
Total Net Profit -39.80
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
1.13
Total Trades 81
Won Trades 61
Lost trades 20
Win Rate 75.31 %
Expected payoff 2.23
Gross Profit 1610.23
Gross Loss -1429.42
Total Net Profit 180.81
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.01
Total Trades 99
Won Trades 3
Lost trades 96
Win Rate 3.03 %
Expected payoff -101.10
Gross Profit 120.00
Gross Loss -10129.30
Total Net Profit -10009.30
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.77
Total Trades 25
Won Trades 17
Lost trades 8
Win Rate 68.00 %
Expected payoff -8.06
Gross Profit 657.10
Gross Loss -858.70
Total Net Profit -201.60
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
1.18
Total Trades 351
Won Trades 249
Lost trades 102
Win Rate 70.94 %
Expected payoff 2.98
Gross Profit 6721.61
Gross Loss -5676.56
Total Net Profit 1045.05
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.69
Total Trades 169
Won Trades 114
Lost trades 55
Win Rate 67.46 %
Expected payoff 12.89
Gross Profit 5353.14
Gross Loss -3175.15
Total Net Profit 2177.99
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
1.32
Total Trades 143
Won Trades 110
Lost trades 33
Win Rate 76.92 %
Expected payoff 5.20
Gross Profit 3084.51
Gross Loss -2340.78
Total Net Profit 743.73
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.69
Total Trades 80
Won Trades 51
Lost trades 29
Win Rate 63.75 %
Expected payoff -11.68
Gross Profit 2040.00
Gross Loss -2974.10
Total Net Profit -934.10
-100%
-50%
0%
50%
100%

Comments