e-Friday_v2

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

This script is designed to automate trading, specifically on Fridays, with some customizable rules. It aims to open and potentially close trades based on conditions at specific times. Here's the breakdown:

  1. Overall Goal: The script watches the market and automatically executes trades, with the primary focus being on trading activity specifically on Fridays.

  2. Time-Based Trading: The core strategy revolves around time. The script is configured to only operate on Fridays, and it's set to open a trade around a specified hour. It can also automatically close all open trades at another specified hour on Friday.

  3. Trade Logic: When the specified opening hour on Friday arrives, the script checks what happened on the price chart the day before.

    • If the price on the previous day went down overall (the closing price was lower than the opening price), the script will automatically place a "buy" order. It's essentially betting the price will go back up.
    • If the price on the previous day went up overall, the script will automatically place a "sell" order, betting that the price will go back down.
  4. Risk Management: The script includes some built-in safety features:

    • Stop Loss: If a trade starts losing money, the script will automatically close the trade at a certain loss level (Stop Loss), preventing further losses.
    • Take Profit: If a trade is making money, the script can automatically close the trade at a certain profit level (Take Profit), securing the gains.
    • Trailing Stop: This is a more advanced feature. As the price moves in a profitable direction, the Stop Loss level is automatically adjusted to "trail" behind the price. This helps to lock in profits and protect the trade from a sudden reversal.
  5. Customization: The script is designed to be customizable through a set of input parameters that can be changed inside Metatrader:

    • Trade volume
    • Stop Loss and Take Profit levels
    • Opening and closing hours
    • Trailing Stop settings
    • Sound alerts
  6. Account Restrictions: There's an option to restrict the script to only trade on a specific account. This can be helpful if you want to dedicate a particular trading account to this strategy.

  7. Order Management The script provides functionality to close all open positions at a specific time and also to check if there's already an open order to not open two same orders.

In summary, this script is an automated trading system that attempts to capitalize on price fluctuations after big up or down movements on the day before Friday, while providing risk management and customization options.

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
7 Views
0 Downloads
0 Favorites
e-Friday_v2
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                     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

GBP/CAD Jul 2025 - Sep 2025
0.27
Total Trades 24
Won Trades 6
Lost trades 18
Win Rate 25.00 %
Expected payoff -2.96
Gross Profit 26.68
Gross Loss -97.63
Total Net Profit -70.95
-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.64
Gross Loss -173.24
Total Net Profit -99.60
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.91
Total Trades 16
Won Trades 7
Lost trades 9
Win Rate 43.75 %
Expected payoff -0.39
Gross Profit 61.30
Gross Loss -67.50
Total Net Profit -6.20
-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.61
Total Trades 99
Won Trades 33
Lost trades 66
Win Rate 33.33 %
Expected payoff -1.32
Gross Profit 204.13
Gross Loss -335.25
Total Net Profit -131.12
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.86
Total Trades 41
Won Trades 20
Lost trades 21
Win Rate 48.78 %
Expected payoff -0.61
Gross Profit 159.80
Gross Loss -184.94
Total Net Profit -25.14
-100%
-50%
0%
50%
100%
USD/CAD Jan 2025 - Jul 2025
1.41
Total Trades 32
Won Trades 18
Lost trades 14
Win Rate 56.25 %
Expected payoff 0.95
Gross Profit 104.89
Gross Loss -74.48
Total Net Profit 30.41
-100%
-50%
0%
50%
100%
NZD/USD Jan 2025 - Jul 2025
0.66
Total Trades 44
Won Trades 19
Lost trades 25
Win Rate 43.18 %
Expected payoff -1.44
Gross Profit 124.30
Gross Loss -187.50
Total Net Profit -63.20
-100%
-50%
0%
50%
100%
GBP/USD Jan 2025 - Jul 2025
0.48
Total Trades 54
Won Trades 18
Lost trades 36
Win Rate 33.33 %
Expected payoff -2.60
Gross Profit 129.60
Gross Loss -270.00
Total Net Profit -140.40
-100%
-50%
0%
50%
100%
GBP/CAD Jan 2025 - Jul 2025
0.29
Total Trades 66
Won Trades 20
Lost trades 46
Win Rate 30.30 %
Expected payoff -2.68
Gross Profit 72.63
Gross Loss -249.30
Total Net Profit -176.67
-100%
-50%
0%
50%
100%

Comments