e-Friday-3172552

Author: ��� ����� �. aka KimIV
Profit factor:
0.66
Orders Execution
Checks for the total of open ordersIt automatically opens orders when conditions are reachedIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
7 Views
0 Downloads
0 Favorites
e-Friday-3172552
//+------------------------------------------------------------------+
//|                                             e-Friday-3172552.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 23.10.2005  Ýôôåêò ïÿòíèöû. Âàðèàöèÿ 3172552.                    |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
#define   MAGIC     20051023

//------- Âíåøíèå ïàðàìåòðû ñîâåòíèêà --------------------------------
extern string _Parameters_Trade = "----- Ïàðàìåòðû òîðãîâëè";
extern double Lots           = 0.1;    // Ðàçìåð òîðãóåìîãî ëîòà
extern int    StopLoss       = 50;     // Ðàçìåð ôèêñèðîâàííîãî ñòîïà
extern int    HourOpenPos    = 9;      // Âðåìÿ îòêðûòèÿ ïîçèöèè
extern bool   UseClosePos    = True;   // Èñïîëüçîâàòü çàêðûòèå ïîçèöèè
extern int    HourClosePos   = 20;     // Âðåìÿ çàêðûòèÿ ïîçèöèè
extern bool   UseTrailing    = False;  // Èñïîëüçîâàòü òðàë
extern bool   ProfitTrailing = True;   // Òðàëèòü òîëüêî ïðîôèò
extern int    TrailingStop   = 60;     // Ôèêñèðîâàííûé ðàçìåð òðàëà
extern int    TrailingStep   = 5;      // Øàã òðàëà
extern int    Slippage       = 3;      // Ïðîñêàëüçûâàíèå öåíû

extern string _Parameters_Expert = "----- Ïàðàìåòðû ñîâåòíèêà";
extern color clOpenBuy    = LightBlue;    // Öâåò îòêðûòèÿ ïîêóïêè
extern color clOpenSell   = LightCoral;   // Öâåò îòêðûòèÿ ïðîäàæè
extern color clModifyBuy  = Aqua;         // Öâåò ìîäèôèêàöèè ïîêóïêè
extern color clModifySell = Tomato;       // Öâåò ìîäèôèêàöèè ïðîäàæè
extern color clCloseBuy   = Blue;         // Öâåò çàêðûòèÿ ïîêóïêè
extern color clCloseSell  = Red;          // Öâåò çàêðûòèÿ ïðîäàæè

//---- Ãëîáàëüíûå ïåðåìåííûå ñîâåòíèêà -------------------------------
int prevDay;

//------- Ïîäêëþ÷åíèå âíåøíèõ ìîäóëåé --------------------------------

//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
void deinit() {
  Comment("");
}

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  double Op1=0, Cl1=0;
  int    i=0;

  if (DayOfWeek()==5 && Hour()==HourOpenPos) {
    while (TimeHour(Time[i])!=6) i++;
    Cl1=Close[i];
    while (TimeHour(Time[i])!=14) i++;
    Op1=Close[i];
    if (Op1>Cl1+20*Point) OpenPosition(1);
    if (Op1<Cl1-20*Point) OpenPosition(0);
  }
  if (UseClosePos) {
    if (Hour()>=HourClosePos || prevDay!=Day()) CloseAllPositions();
  }
  if (UseTrailing) TrailingPositions();
  prevDay=Day();
}

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

  if (!ExistPosition()) {
    if (op==1) {
      if (StopLoss!=0) ldStop=Ask-StopLoss*Point;
      SetOrder(OP_BUY, Ask, ldStop, ldTake);
    }
    if (op==0) {
      if (StopLoss!=0) ldStop=Bid+StopLoss*Point;
      SetOrder(OP_SELL, Bid, ldStop, ldTake);
    }
  }
}

//+------------------------------------------------------------------+
//| Âîçâðàùàåò ôëàã ñóùåñòâîâàíèÿ ïîçèöèè                            |
//+------------------------------------------------------------------+
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     - îïåðàöèÿ                                              |
//|   pp     - öåíà                                                  |
//|   ldStop - óðîâåíü ñòîï                                          |
//|   ldTake - óðîâåíü òåéê                                          |
//+------------------------------------------------------------------+
void SetOrder(int op, double pp, double ldStop, double ldTake) {
  color clOpen;

  if (op==OP_BUY) clOpen=clOpenBuy;
  else clOpen=clOpenSell;
  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);
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Ñîïðîâîæäåíèå ïîçèöèè ïðîñòûì òðàëîì                             |
//+------------------------------------------------------------------+
void TrailingPositions() {
  for (int i=0; i<OrdersTotal(); i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
      if (OrderSymbol()==Symbol() && OrderMagicNumber()==MAGIC) {
        if (OrderType()==OP_BUY) {
          if (!ProfitTrailing || (Bid-OrderOpenPrice())>TrailingStop*Point) {
            if (OrderStopLoss()<Bid-(TrailingStop+TrailingStep-1)*Point) {
              ModifyStopLoss(Bid-TrailingStop*Point, clModifyBuy);
            }
          }
        }
        if (OrderType()==OP_SELL) {
          if (!ProfitTrailing || OrderOpenPrice()-Ask>TrailingStop*Point) {
            if (OrderStopLoss()>Ask+(TrailingStop+TrailingStep-1)*Point || OrderStopLoss()==0) {
              ModifyStopLoss(Ask+TrailingStop*Point, clModifySell);
            }
          }
        }
      }
    }
  }
}

//+------------------------------------------------------------------+
//| Ïåðåíîñ óðîâíÿ StopLoss                                          |
//| Ïàðàìåòðû:                                                       |
//|   ldStopLoss - óðîâåíü StopLoss                                  |
//|   clModify   - öâåò ìîäèôèêàöèè                                  |
//+------------------------------------------------------------------+
void ModifyStopLoss(double ldStop, color clModify) {
  double ldOpen=OrderOpenPrice();
  double ldTake=OrderTakeProfit();

  OrderModify(OrderTicket(), ldOpen, ldStop, ldTake, 0, clModify);
}
//+------------------------------------------------------------------+

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
2.82
Total Trades 36
Won Trades 2
Lost trades 34
Win Rate 5.56 %
Expected payoff 5.83
Gross Profit 325.03
Gross Loss -115.20
Total Net Profit 209.83
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
1.32
Total Trades 19
Won Trades 3
Lost trades 16
Win Rate 15.79 %
Expected payoff 1.70
Gross Profit 131.98
Gross Loss -99.68
Total Net Profit 32.30
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.49
Total Trades 23
Won Trades 2
Lost trades 21
Win Rate 8.70 %
Expected payoff -1.70
Gross Profit 37.32
Gross Loss -76.31
Total Net Profit -38.99
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.70
Total Trades 22
Won Trades 2
Lost trades 20
Win Rate 9.09 %
Expected payoff -1.35
Gross Profit 70.20
Gross Loss -100.00
Total Net Profit -29.80
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.84
Total Trades 36
Won Trades 2
Lost trades 34
Win Rate 5.56 %
Expected payoff -0.78
Gross Profit 142.00
Gross Loss -170.00
Total Net Profit -28.00
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.09
Total Trades 159
Won Trades 1
Lost trades 158
Win Rate 0.63 %
Expected payoff -3.27
Gross Profit 50.37
Gross Loss -570.92
Total Net Profit -520.55
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
1.63
Total Trades 26
Won Trades 3
Lost trades 23
Win Rate 11.54 %
Expected payoff 2.81
Gross Profit 188.00
Gross Loss -115.00
Total Net Profit 73.00
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.15
Total Trades 15
Won Trades 1
Lost trades 14
Win Rate 6.67 %
Expected payoff -3.98
Gross Profit 10.30
Gross Loss -70.00
Total Net Profit -59.70
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.81
Total Trades 107
Won Trades 6
Lost trades 101
Win Rate 5.61 %
Expected payoff -0.60
Gross Profit 276.38
Gross Loss -340.91
Total Net Profit -64.53
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.58
Total Trades 70
Won Trades 8
Lost trades 62
Win Rate 11.43 %
Expected payoff -2.16
Gross Profit 209.95
Gross Loss -361.03
Total Net Profit -151.08
-100%
-50%
0%
50%
100%

Comments