Author: ��� ����� �. aka KimIV
Profit factor:
1983.74

This script, named "e-Friday.mq4", is designed to automatically trade on the MetaTrader platform based on a strategy related to Fridays.

Here's a breakdown of what it does, without getting technical:

1. Setup & Configuration:

  • The script has a set of settings you, as the user, can adjust. These include:
    • Trading Parameters: How much to trade (Lots), how much risk to take (Stop Loss), and how much profit to target (Take Profit). It also sets the specific hour of Friday to open the positions.
    • Friday Trading Logic: It will open a BUY order if the previous day closed higher than it opened, and vice versa for SELL orders.
    • Position Management: Settings that determine when and how the script closes the position including a specific hour on Friday and if profit protection (Trailing Stop) should be used.
    • Script Settings: This covers whether the script only trades on a specific account, the name of the script (for identification), if sound alerts are enabled, and color settings for visual cues on the chart.

2. Trading Hours:

  • The script only operates on Fridays. It checks the current day and time to make sure it's within the hours you've defined as the trading period.

3. Opening a Position (Buy or Sell):

  • At the set opening hour on Friday, the script does the following:
    • If there are no open positions already, it looks at the price movement of the previous day.
    • If the previous day's closing price was higher than its opening price, it places a Buy order (betting the price will go up).
    • If the previous day's closing price was lower than its opening price, it places a Sell order (betting the price will go down).
    • It sets a "Stop Loss" (an automatic closing price to limit potential losses) and a "Take Profit" (an automatic closing price to secure profits).

4. Closing Positions:

  • If you've enabled it, at the set closing hour on Friday, the script will automatically close any open positions. It closes them at the current market price.

5. Trailing Stop (Profit Protection):

  • If you've enabled the "Trailing Stop" feature, the script will automatically adjust the "Stop Loss" level as the price moves in your favor. This helps to lock in profits and protect against sudden price reversals. The amount of movement required to adjust the Stop Loss, the 'Trailing Stop', is also set in the parameters. The Profit Trailing parameter determines if this only occurs when the trade is in profit.

6. Important Checks:

  • Before doing anything, the script checks if it's allowed to trade on the current account (if you've specified a specific account number). It also checks if it's running in a testing mode versus real trading mode, and adjusts its messages accordingly.

In simple terms: This script is an automated system that aims to exploit potential price tendencies that might occur on Fridays. It enters trades at a specific time of day on Friday based on the prior day's price direction, tries to protect the trading positions as they move into profit, and automatically closes the positions at a later specified time on Friday. You control the risk level, the potential profit target, the times for entering and exiting, and other aspects through the script's settings.

Price Data Components
Series array that contains close prices for each bar
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
Miscellaneous
It plays sound alerts
8 Views
0 Downloads
0 Favorites
e-Friday
//+------------------------------------------------------------------+
//|                                                     e-Friday.mq4 |
//|                                           Êèì Èãîðü Â. aka KimIV |
//|                                              http://www.kimiv.ru |
//|                                                                  |
//| 08.10.2005  Ýôôåêò ïÿòíèöû                                       |
//+------------------------------------------------------------------+
#property copyright "Êèì Èãîðü Â. aka KimIV"
#property link      "http://www.kimiv.ru"
#define   MAGIC     20051008

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

extern string _Parameters_Expert = "----- Ïàðàìåòðû ñîâåòíèêà";
extern bool   UseOneAccount = False;        // Òîðãîâàòü òîëüêî íà îäíîì ñ÷¸òå
extern int    NumberAccount = 11111;        // Íîìåð òîðãîâîãî ñ÷¸òà
extern string Name_Expert   = "e-Friday.mq4";
extern bool   UseSound      = True;         // Èñïîëüçîâàòü çâóêîâîé ñèãíàë
extern string NameFileSound = "expert.wav"; // Íàèìåíîâàíèå çâóêîâîãî ôàéëà
extern color  clOpenBuy     = LightBlue;    // Öâåò îòêðûòèÿ ïîêóïêè
extern color  clOpenSell    = LightCoral;   // Öâåò îòêðûòèÿ ïðîäàæè
extern color  clModifyBuy   = Aqua;         // Öâåò ìîäèôèêàöèè ïîêóïêè
extern color  clModifySell  = Tomato;       // Öâåò ìîäèôèêàöèè ïðîäàæè
extern color  clCloseBuy    = Blue;         // Öâåò çàêðûòèÿ ïîêóïêè
extern color  clCloseSell   = Red;          // Öâåò çàêðûòèÿ ïðîäàæè

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

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

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

//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
void start() {
  if (UseOneAccount && AccountNumber()!=NumberAccount) {
    if (!IsTesting()) Comment("Òîðãîâëÿ íà ñ÷¸òå: "+AccountNumber()+" ÇÀÏÐÅÙÅÍÀ!");
    return;
  } else if (!IsTesting()) Comment("");

  if (DayOfWeek()!=5 || Hour()<HourOpenPos || Hour()>HourClosePos) {
    if (!IsTesting()) Comment("Âðåìÿ òîðãîâëè åù¸ íå íàñòóïèëî!");
    return;
  } else if (!IsTesting()) Comment("");

  if (Hour()==HourOpenPos) OpenPosition();
  if (Hour()>=HourClosePos && UseClosePos) CloseAllPositions();
  if (UseTrailing) TrailingPositions();
}

//+------------------------------------------------------------------+
//| Óñòàíîâêà îðäåðîâ                                                |
//+------------------------------------------------------------------+
void OpenPosition() {
  double ldStop=0, ldTake=0;
  double Op1=iOpen (NULL, PERIOD_D1, 1);
  double Cl1=iClose(NULL, PERIOD_D1, 1);

  if (!ExistPosition()) {
    if (Op1>Cl1) {
      if (StopLoss!=0) ldStop=Ask-StopLoss*Point;
      if (TakeProfit!=0) ldTake=Ask+TakeProfit*Point;
      SetOrder(OP_BUY, Ask, ldStop, ldTake);
    }
    if (Op1<Cl1) {
      if (StopLoss!=0) ldStop=Bid+StopLoss*Point;
      if (TakeProfit!=0) ldTake=Bid-TakeProfit*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;
  string lsComm=GetCommentForOrder();

  if (op==OP_BUYLIMIT || op==OP_BUYSTOP) clOpen=clOpenBuy;
  else clOpen=clOpenSell;
//  Lots=MathCeil(AccountFreeMargin()/10000*10)/10;
  OrderSend(Symbol(),op,Lots,pp,Slippage,ldStop,ldTake,lsComm,MAGIC,0,clOpen);
  if (UseSound) PlaySound(NameFileSound);
}

//+------------------------------------------------------------------+
//| Ãåíåðèðóåò è âîçâðàùàåò ñòðîêó êîìåíòàðèÿ äëÿ îðäåðà èëè ïîçèöèè |
//+------------------------------------------------------------------+
string GetCommentForOrder() {
  return(Name_Expert);
}

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

//+------------------------------------------------------------------+
//| Ñîïðîâîæäåíèå ïîçèöèè ïðîñòûì òðàëîì                             |
//+------------------------------------------------------------------+
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) {
  bool   fm;
  double ldOpen=OrderOpenPrice();
  double ldTake=OrderTakeProfit();

  fm=OrderModify(OrderTicket(), ldOpen, ldStop, ldTake, 0, clModify);
  if (fm && UseSound) PlaySound(NameFileSound);
}
//+------------------------------------------------------------------+

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
2.34
Total Trades 18
Won Trades 11
Lost trades 7
Win Rate 61.11 %
Expected payoff 2.63
Gross Profit 82.73
Gross Loss -35.42
Total Net Profit 47.31
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.52
Total Trades 13
Won Trades 5
Lost trades 8
Win Rate 38.46 %
Expected payoff -1.63
Gross Profit 22.49
Gross Loss -43.65
Total Net Profit -21.16
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.07
Total Trades 35
Won Trades 4
Lost trades 31
Win Rate 11.43 %
Expected payoff -6.21
Gross Profit 15.20
Gross Loss -232.50
Total Net Profit -217.30
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.96
Total Trades 18
Won Trades 9
Lost trades 9
Win Rate 50.00 %
Expected payoff -0.14
Gross Profit 65.00
Gross Loss -67.50
Total Net Profit -2.50
-100%
-50%
0%
50%
100%
GBP/CAD Jul 2025 - Sep 2025
0.24
Total Trades 28
Won Trades 6
Lost trades 22
Win Rate 21.43 %
Expected payoff -3.26
Gross Profit 28.12
Gross Loss -119.27
Total Net Profit -91.15
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.43
Total Trades 45
Won Trades 10
Lost trades 35
Win Rate 22.22 %
Expected payoff -2.21
Gross Profit 73.62
Gross Loss -173.14
Total Net Profit -99.52
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.88
Total Trades 16
Won Trades 7
Lost trades 9
Win Rate 43.75 %
Expected payoff -0.49
Gross Profit 59.60
Gross Loss -67.50
Total Net Profit -7.90
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
1.24
Total Trades 14
Won Trades 8
Lost trades 6
Win Rate 57.14 %
Expected payoff 0.79
Gross Profit 56.00
Gross Loss -45.00
Total Net Profit 11.00
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.62
Total Trades 97
Won Trades 32
Lost trades 65
Win Rate 32.99 %
Expected payoff -1.30
Gross Profit 203.82
Gross Loss -330.26
Total Net Profit -126.44
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.55
Total Trades 40
Won Trades 17
Lost trades 23
Win Rate 42.50 %
Expected payoff -2.27
Gross Profit 111.71
Gross Loss -202.70
Total Net Profit -90.99
-100%
-50%
0%
50%
100%

Comments