e-NightTrade

Author: ��� ����� �. aka KimIV
Profit factor:
0.80
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself
4 Views
0 Downloads
0 Favorites
e-NightTrade
//+------------------------------------------------------------------+
//|                                                 e-NightTrade.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//|  06.02.2006  Íî÷íàÿ òîðãîâëÿ.                                    |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"

//------- Âíåøíèå ïàðàìåòðû ñîâåòíèêà --------------------------------
extern string _Parameters_Trade = "----- Ïàðàìåòðû òîðãîâëè";
extern int  nDayOfWeek    = 1;      // Íîìåð äíÿ íåäåëè
extern int  HourOpenPos   = 23;     // ×àñ îòêðûòèÿ ïîçèöèè
extern int  MinuteOpenPos = 0;      // Ìèíóòû îòêðûòèÿ ïîçèöèè
extern int  DepthHistory  = 14;     // Ãëóáèíà â áàðàõ
extern int  RangeCutOff   = 19;     // Äèàïàçîí îòñå÷êè
extern int  StopLoss      = 68;     // Ðàçìåð ñòîïà
extern int  TakeProfit    = 25;     // Ðàçìåð òýéêà
extern bool UseClosePos   = True;   // Èñïîëüçîâàòü çàêðûòèå ïîçèöèè
extern int  HourClosePos  = 3;      // ×àñ çàêðûòèÿ ïîçèöèè

//---- Ãëîáàëüíûå ïåðåìåííûå ñîâåòíèêà -------------------------------
double Lots        = 0.1;
int    Slippage    = 3;
int    MAGIC       = 20060206;
color  clOpenBuy   = LightBlue;
color  clOpenSell  = LightCoral;
color  clCloseBuy  = Blue;
color  clCloseSell = Red;


//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  if (DayOfWeek()==nDayOfWeek && Hour()==HourOpenPos
  && Minute()>=MinuteOpenPos && Minute()<=MinuteOpenPos+4) OpenPositions();

  if (UseClosePos && Hour()==HourClosePos) CloseAllPositions();
}

//+------------------------------------------------------------------+
//| Îòêðûòèå ïîçèöèé                                                 |
//+------------------------------------------------------------------+
void OpenPositions() {
  double ldStop=0, ldTake=0;
  int    bs=GetTradeSignal();

  if (!ExistPosition()) {
    if (bs>0) {
      if (StopLoss!=0) ldStop=Ask-StopLoss*Point;
      if (TakeProfit!=0) ldTake=Ask+TakeProfit*Point;
      OpenPosition(OP_BUY, ldStop, ldTake);
    }
    if (bs<0) {
      if (StopLoss!=0) ldStop=Bid+StopLoss*Point;
      if (TakeProfit!=0) ldTake=Bid-TakeProfit*Point;
      OpenPosition(OP_SELL, ldStop, ldTake);
    }
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò òîðãîâûé ñèãíàë:                                      |
//|    1 - ïîêóïàé                                                   |
//|    0 - ñèäè, êóðè áàìáóê                                         |
//|   -1 - ïðîäàâàé                                                  |
//+------------------------------------------------------------------+
int GetTradeSignal() {
  int nb, bs=0;

  nb=Highest(NULL, 0, MODE_HIGH, DepthHistory, 1);
  if (High[nb]-Close[1]>RangeCutOff*Point) {
    bs=1;
  }
  nb=Lowest(NULL, 0, MODE_LOW, DepthHistory, 1);
  if (Close[1]-Low[nb]>RangeCutOff*Point) {
    bs=-1;
  }

  return(bs);
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò ôëàã ñóùåñòâîâàíèÿ ïîçèöèè                            |
//+------------------------------------------------------------------+
bool ExistPosition() {
  bool Exist=False;
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          Exist=True; break;
        }
      }
    }
  }
  return(Exist);
}

//+------------------------------------------------------------------+
//| Îòêðûòèå ïîçèöèè                                                 |
//| Ïàðàìåòðû:                                                       |
//|   op     - îïåðàöèÿ                                              |
//|   ldStop - óðîâåíü ñòîï                                          |
//|   ldTake - óðîâåíü òåéê                                          |
//+------------------------------------------------------------------+
void OpenPosition(int op, double ldStop, double ldTake) {
  color  clOpen;
  double pp;

  if (op==OP_BUY) {
    clOpen=clOpenBuy; pp=Ask;
  } else {
    clOpen=clOpenSell; pp=Bid;
  }
  pp=NormalizeDouble(pp, Digits);
  OrderSend(Symbol(),op,Lots,pp,Slippage,ldStop,ldTake,"",MAGIC,0,clOpen);
}

//+------------------------------------------------------------------+
//| Çàêðûòèå âñåõ ïîçèöèé ïî ðûíî÷íîé öåíå                           |
//+------------------------------------------------------------------+
void CloseAllPositions() {
  for (int i=OrdersTotal()-1; i>=0; i--) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==OP_BUY) {
          OrderClose(OrderTicket(), OrderLots(), Bid, Slippage, clCloseBuy);
        }
        if (OrderType()==OP_SELL) {
          OrderClose(OrderTicket(), OrderLots(), Ask, Slippage, clCloseSell);
        }
      }
    }
  }
}
//+------------------------------------------------------------------+

Profitability Reports

USD/CAD Jul 2025 - Sep 2025
0.73
Total Trades 12
Won Trades 8
Lost trades 4
Win Rate 66.67 %
Expected payoff -0.44
Gross Profit 14.51
Gross Loss -19.82
Total Net Profit -5.31
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
1.38
Total Trades 11
Won Trades 8
Lost trades 3
Win Rate 72.73 %
Expected payoff 0.50
Gross Profit 20.00
Gross Loss -14.50
Total Net Profit 5.50
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.32
Total Trades 15
Won Trades 7
Lost trades 8
Win Rate 46.67 %
Expected payoff -1.78
Gross Profit 12.65
Gross Loss -39.36
Total Net Profit -26.71
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.04
Total Trades 21
Won Trades 2
Lost trades 19
Win Rate 9.52 %
Expected payoff -3.90
Gross Profit 3.29
Gross Loss -85.12
Total Net Profit -81.83
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.64
Total Trades 11
Won Trades 7
Lost trades 4
Win Rate 63.64 %
Expected payoff -0.88
Gross Profit 17.50
Gross Loss -27.20
Total Net Profit -9.70
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
3.68
Total Trades 11
Won Trades 10
Lost trades 1
Win Rate 90.91 %
Expected payoff 1.65
Gross Profit 25.00
Gross Loss -6.80
Total Net Profit 18.20
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.32
Total Trades 43
Won Trades 20
Lost trades 23
Win Rate 46.51 %
Expected payoff -1.67
Gross Profit 33.69
Gross Loss -105.56
Total Net Profit -71.87
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
1.09
Total Trades 29
Won Trades 22
Lost trades 7
Win Rate 75.86 %
Expected payoff 0.18
Gross Profit 62.10
Gross Loss -56.78
Total Net Profit 5.32
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
0.60
Total Trades 37
Won Trades 23
Lost trades 14
Win Rate 62.16 %
Expected payoff -0.72
Gross Profit 40.72
Gross Loss -67.47
Total Net Profit -26.75
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
1.47
Total Trades 27
Won Trades 21
Lost trades 6
Win Rate 77.78 %
Expected payoff 0.62
Gross Profit 52.50
Gross Loss -35.80
Total Net Profit 16.70
-100%
-50%
0%
50%
100%

Comments