Profit factor:
0.81
Orders Execution
Checks for the total of open orders
6 Views
0 Downloads
0 Favorites
NailLong
//+------------------------------------------------------------------+
//|                                                        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  20081723

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

//ïîäñ÷åò òåêóùåãî êîëè÷åñòâà îòêðûòûõ ïîçèöèé íà ïîêóïêó
int CalcNumLongs()
{
   int nLongs = 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_BUY) nLongs++;
   }
   return (nLongs);
}

//ïîïûòêà îòêðûòü íîâûé îðäåð
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_BUY) {                                      
         found = true; //...íàøëè ïîñëåäíèé îòêðûòûé îðäåð íà ïîêóïêó     
         break;
      }
   }
    
   if (!found) {
      Print ("Îøèáêà: íå ñìîãëè íàéòè îæèäàåìîãî îòêðûòîãî îðäåðà íà ïîêóïêó: ", GetLastError()); 
      return;   
   }
        
   //åñëè óáûòîê ïðåâûøàåò çíà÷åíèå ïåðåìåííîé OpenT, îòêðûâàåì îðäåð íà ïîêóïêó
   if (OrderProfit() <= OpenT) {      
      double Min = Close[ArrayMinimum(Close, N_MaxBar, 1)]; 
      Print (Bid, " ", Min - Delta * Point);
      res = OrderSend (Symbol(), OP_BUY, Lot, Ask, 3, Min - Delta * Point, Ask + TakeProfit * Point, "", MAGICNUM, 0, Blue);
      if (res == 0) {         
         Print ("Îøèáêà îòêðûòèÿ îðäåðà íà ïîêóïêó: ",GetLastError()); 
         return;
      }        
   }        
}

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

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
1.04
Total Trades 129
Won Trades 71
Lost trades 58
Win Rate 55.04 %
Expected payoff 0.52
Gross Profit 1924.38
Gross Loss -1856.97
Total Net Profit 67.41
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.08
Total Trades 33
Won Trades 24
Lost trades 9
Win Rate 72.73 %
Expected payoff 2.71
Gross Profit 1164.75
Gross Loss -1075.32
Total Net Profit 89.43
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
1.37
Total Trades 22
Won Trades 18
Lost trades 4
Win Rate 81.82 %
Expected payoff 6.04
Gross Profit 494.83
Gross Loss -361.95
Total Net Profit 132.88
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.62
Total Trades 23
Won Trades 14
Lost trades 9
Win Rate 60.87 %
Expected payoff -14.93
Gross Profit 560.00
Gross Loss -903.50
Total Net Profit -343.50
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.75
Total Trades 73
Won Trades 46
Lost trades 27
Win Rate 63.01 %
Expected payoff -8.09
Gross Profit 1808.40
Gross Loss -2398.70
Total Net Profit -590.30
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.91
Total Trades 60
Won Trades 41
Lost trades 19
Win Rate 68.33 %
Expected payoff -2.02
Gross Profit 1163.30
Gross Loss -1284.69
Total Net Profit -121.39
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.76
Total Trades 85
Won Trades 57
Lost trades 28
Win Rate 67.06 %
Expected payoff -5.71
Gross Profit 1504.65
Gross Loss -1990.38
Total Net Profit -485.73
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 7
Won Trades 6
Lost trades 1
Win Rate 85.71 %
Expected payoff -15037.60
Gross Profit 240.00
Gross Loss -105503.20
Total Net Profit -105263.20
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.84
Total Trades 22
Won Trades 15
Lost trades 7
Win Rate 68.18 %
Expected payoff -4.99
Gross Profit 562.90
Gross Loss -672.70
Total Net Profit -109.80
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.72
Total Trades 340
Won Trades 228
Lost trades 112
Win Rate 67.06 %
Expected payoff -7.00
Gross Profit 6171.11
Gross Loss -8550.46
Total Net Profit -2379.35
-100%
-50%
0%
50%
100%

Comments