Author: Copyright � 2009, MetaQuotes Software Corp.
Profit factor:
3.77
Orders Execution
It Closes Orders by itself It automatically opens orders when conditions are reachedChecks for the total of open orders
Miscellaneous
It issuies visual alerts to the screen
3 Views
0 Downloads
0 Favorites
jpytest
//+------------------------------------------------------------------+
//|                                                      jpytest.mq4 |
//|                      Copyright © 2009, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2009, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"
extern double LotSize=0.1; //Ðàçìåð ëîòà äëÿ òîðãîâëè
int MagicNumber;
int OpenedOrder;

double ExtendPoint=1;   //äëÿ ÄÖ ñ äîïîëíèòåëüíûì çíàêîì ExtendPoint=10


int init()
  {
   return(0);
  }

int deinit()
  {
   return(0);
  }

int start()
 {
  MagicNumber=900;
  datetime curtime=iTime(NULL,PERIOD_M1,0);
  if (ExistPositions(Symbol(),-1 , MagicNumber)) {
   if ((TimeHour(curtime)==5 && TimeMinute(curtime)==55) || (TimeHour(curtime)==6 && TimeMinute(curtime)==0))
   OrderClose(OpenedOrder,LotSize,Ask,3);
  } 
  else {
   if (TimeHour(curtime)==4 && TimeMinute(curtime)==0) 
   iSetOrder(Symbol(), OP_SELL, 20*ExtendPoint,10000);
  }

  MagicNumber=901;
  if (ExistPositions(Symbol(),-1 , MagicNumber)) {
   if ((TimeHour(curtime)==12 && TimeMinute(curtime)==55) || (TimeHour(curtime)==13 && TimeMinute(curtime)==0))
   OrderClose(OpenedOrder,LotSize,Bid,3);
  } 
  else {
   if (TimeHour(curtime)==10 && TimeMinute(curtime)==0) 
   iSetOrder(Symbol(), OP_BUY, 15*ExtendPoint,10000);
  }

  return(0);
 }

bool iSetOrder(string symbol, int cmd, double stoploss, double takeprofit, string comment=""){
int Dist_SL =stoploss; // Çàäàííûé SL (pt)
  int Dist_TP =takeprofit; // Çàäàííûé TP (pt)
  double Prots=0.10; // Ïðîöåíò ñâîá. ñð.
  string Symb=symbol; // Ôèíàíñ. èíñòðóìåíò
  double i=0;
  double SL;
  double TP;
  color arr;
  double price;
   
   
//--------------------------------------------------------------- 2 --
  while(i<5) // Öèêë îòêðûòèÿ îðä.
  {
  if (cmd==OP_BUY) {
  SL=Bid - New_Stop(stoploss)*Point; // Âû÷èñëåíèå SL îòêð.
  TP=Bid + New_Stop(takeprofit)*Point; // Âû÷èñëåíèå TP îòêð.
  Alert("Ïîïûòêà îòêðûòü Buy. Îæèäàíèå îòâåòà..");
  price=Ask;
  arr=Maroon; 
  } else
  {
  SL=Ask + New_Stop(stoploss)*Point; // Âû÷èñëåíèå SL îòêð.
  TP=Ask - New_Stop(takeprofit)*Point; // Âû÷èñëåíèå TP îòêð.
  price=Bid;
  arr=Green; 
 
  }//if else
  if (stoploss==0) SL=0;
  if (takeprofit==0) TP=0;

  int ticket=OrderSend(symbol,cmd,LotSize,price,3,SL,TP,comment,MagicNumber,0,arr);//Îòêðûòèå Buy  
 
  //--------------------------------------------------------- 7 --
  if (ticket>0) // Ïîëó÷èëîñü :)
  {
  Alert ("Îòêðûò îðäåð Buy ",ticket);
  OpenedOrder=ticket;
  return(True);
  break; // Âûõîä èç öèêëà
  }
  //--------------------------------------------------------- 8 --
  int Error=GetLastError(); // Íå ïîëó÷èëîñü :(
  switch(Error) // Ïðåîäîëèìûå îøèáêè
  {
  case 135:Alert("Öåíà èçìåíèëàñü. Ïðîáóåì åù¸ ðàç..");
  RefreshRates(); // Îáíîâèì äàííûå
  i=i+1;
  continue; // Íà ñëåä. èòåðàöèþ
  case 136:Alert("Íåò öåí. Æä¸ì íîâûé òèê..");
  while(RefreshRates()==false) // Äî íîâîãî òèêà
  Sleep(1); // Çàäåðæêà â öèêëå
  continue; // Íà ñëåä. èòåðàöèþ
  case 146:Alert("Ïîäñèñòåìà òîðãîâëè çàíÿòà. Ïðîáóåì åù¸..");
  Sleep(500); // Ïðîñòîå ðåøåíèå
  i=i+0.3;
  RefreshRates(); // Îáíîâèì äàííûå
  continue; // Íà ñëåä. èòåðàöèþ
  }
  switch(Error) // Êðèòè÷åñêèå îøèáêè
  {
  case 2 : Alert("Îáùàÿ îøèáêà.");
  break; // Âûõîä èç switch
  case 5 : Alert("Ñòàðàÿ âåðñèÿ êëèåíòñêîãî òåðìèíàëà.");
  break; // Âûõîä èç switch
  case 64: Alert("Ñ÷åò çàáëîêèðîâàí.");
  break; // Âûõîä èç switch
  case 133:Alert("Òîðãîâëÿ çàïðåùåíà");
  break; // Âûõîä èç switch
  default: Alert("Âîçíèêëà îøèáêà ",Error);// Äðóãèå âàðèàíòû  
  }
  break; // Âûõîä èç öèêëà
  }
//--------------------------------------------------------------- 9 --
  return(False);  
}
int New_Stop(int Parametr) // Ïðîâåðêà ñòîï-ïðèê.
  {
  int Min_Dist=MarketInfo(Symbol(),MODE_STOPLEVEL);// Ìèíèì. äèñòàíöèÿ
  if (Parametr < Min_Dist) // Åñëè ìåíüøå äîïóñò.
  {
  Parametr=Min_Dist; // Óñòàíîâèì äîïóñò.
  Alert("Óâåëè÷åíà äèñòàíöèÿ ñòîï-ïðèêàçà.");
  }
  return(Parametr); // Âîçâðàò çíà÷åíèÿ
  }

bool ExistPositions(string sy="", int op=-1, int mn=-1, datetime ot=0) {
  int i, k=OrdersTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
  if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
  if (OrderSymbol()==sy || sy=="") {
  if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
  if (op<0 || OrderType()==op) {
  if (mn<0 || OrderMagicNumber()==mn) {
  if (ot<=OrderOpenTime()) return(True);
  }
  }
  }
  }
  }
  }
  return(False);
}

Profitability Reports

USD/CAD Jul 2025 - Sep 2025
0.18
Total Trades 14
Won Trades 1
Lost trades 13
Win Rate 7.14 %
Expected payoff -2.13
Gross Profit 6.48
Gross Loss -36.25
Total Net Profit -29.77
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.07
Total Trades 19
Won Trades 2
Lost trades 17
Win Rate 10.53 %
Expected payoff -2.94
Gross Profit 4.20
Gross Loss -60.10
Total Net Profit -55.90
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.35
Total Trades 13
Won Trades 1
Lost trades 12
Win Rate 7.69 %
Expected payoff -1.83
Gross Profit 13.00
Gross Loss -36.80
Total Net Profit -23.80
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
1.02
Total Trades 18
Won Trades 3
Lost trades 15
Win Rate 16.67 %
Expected payoff 0.08
Gross Profit 58.87
Gross Loss -57.47
Total Net Profit 1.40
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.37
Total Trades 124
Won Trades 8
Lost trades 116
Win Rate 6.45 %
Expected payoff -2.39
Gross Profit 172.02
Gross Loss -467.83
Total Net Profit -295.81
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
53.00
Total Trades 23
Won Trades 4
Lost trades 19
Win Rate 17.39 %
Expected payoff 128.20
Gross Profit 3005.20
Gross Loss -56.70
Total Net Profit 2948.50
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.44
Total Trades 4
Won Trades 1
Lost trades 3
Win Rate 25.00 %
Expected payoff 1.05
Gross Profit 13.70
Gross Loss -9.50
Total Net Profit 4.20
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.38
Total Trades 253
Won Trades 12
Lost trades 241
Win Rate 4.74 %
Expected payoff -1.24
Gross Profit 191.89
Gross Loss -504.85
Total Net Profit -312.96
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.48
Total Trades 326
Won Trades 36
Lost trades 290
Win Rate 11.04 %
Expected payoff -1.76
Gross Profit 530.51
Gross Loss -1105.08
Total Net Profit -574.57
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.44
Total Trades 277
Won Trades 25
Lost trades 252
Win Rate 9.03 %
Expected payoff -1.30
Gross Profit 282.01
Gross Loss -643.26
Total Net Profit -361.25
-100%
-50%
0%
50%
100%

Comments