Profit factor:
0.77
Orders Execution
Checks for the total of open orders
7 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/CAD Jul 2025 - Sep 2025
1.28
Total Trades 25
Won Trades 19
Lost trades 6
Win Rate 76.00 %
Expected payoff 4.76
Gross Profit 551.89
Gross Loss -432.77
Total Net Profit 119.12
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.64
Total Trades 23
Won Trades 14
Lost trades 9
Win Rate 60.87 %
Expected payoff -13.69
Gross Profit 560.00
Gross Loss -874.80
Total Net Profit -314.80
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.74
Total Trades 67
Won Trades 43
Lost trades 24
Win Rate 64.18 %
Expected payoff -9.14
Gross Profit 1720.00
Gross Loss -2332.60
Total Net Profit -612.60
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.63
Total Trades 54
Won Trades 34
Lost trades 20
Win Rate 62.96 %
Expected payoff -10.45
Gross Profit 971.37
Gross Loss -1535.71
Total Net Profit -564.34
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.77
Total Trades 82
Won Trades 50
Lost trades 32
Win Rate 60.98 %
Expected payoff -4.85
Gross Profit 1299.80
Gross Loss -1697.65
Total Net Profit -397.85
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.00
Total Trades 7
Won Trades 5
Lost trades 2
Win Rate 71.43 %
Expected payoff -15055.96
Gross Profit 200.00
Gross Loss -105591.70
Total Net Profit -105391.70
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.92
Total Trades 21
Won Trades 14
Lost trades 7
Win Rate 66.67 %
Expected payoff -2.27
Gross Profit 560.00
Gross Loss -607.60
Total Net Profit -47.60
-100%
-50%
0%
50%
100%
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%

Comments