WeeklyBreakout_v1.0

Author: Copyright ?2007, Arui
Profit factor:
0.43

The script is designed to automate trading based on a weekly breakout strategy. Here's how it works:

  1. Weekly Setup: The script looks for specific days and times of the week to initiate trades. You can define the 'start day' (like Tuesday) and 'end day' (like Friday), along with corresponding 'start time' and 'end time' in Greenwich Mean Time (GMT). This establishes a window of time for trading activity.

  2. Order Placement: At the beginning of the defined weekly trading window (specified start day and time), the script checks if it has already placed orders. If not, it places two pending orders:

    • A "Buy Stop" order, which is an order to buy if the price rises to a certain level above the current market price. The script calculates this price by adding a small amount (50 "Points," a unit of price movement) to the current ask price (the price you would pay to buy). A stop loss order is also defined for this trade which would execute if price starts to move in the wrong direction.

    • A "Sell Stop" order, which is an order to sell if the price falls to a certain level below the current market price. The script calculates this price by subtracting a small amount (50 Points) from the current bid price (the price you would receive to sell). A stop loss order is also defined for this trade which would execute if price starts to move in the wrong direction.

    The key idea is that if the price "breaks out" of its recent range during the week, one of these orders will be triggered, initiating a trade.

  3. Break-Even Adjustment: The script includes an optional feature to move the stop-loss order of an open trade to the "break-even" point. This means that if the price moves favorably by a certain amount (defined by the 'breakEven' parameter), the stop loss is adjusted to the original entry price. This reduces the risk of the trade by ensuring that, at worst, you won't lose money on the trade (excluding any potential broker fees or slippage).

  4. Weekly Closure: At the end of the defined weekly trading window (specified end day and time), the script closes all open orders associated with it. This ensures that any remaining trades are exited before the weekend, regardless of their current profit or loss.

Price Data Components
Series array that contains open time of each bar
Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open ordersIt Closes Orders by itself It can change open orders parameters, due to possible stepping strategy
11 Views
0 Downloads
0 Favorites
WeeklyBreakout_v1.0
//+------------------------------------------------------------------+
//|                                               WeeklyBreakout.mq4 |
//|                                            Copyright ?2007, Arui |
//|                                    http://www.ea-performance.com |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2007, Arui"
#property link      "http://www.ea-performance.com"
// This ea is based on SIBKIS's weekly breakout system


extern int    startTime = 0; // GMT time
extern int    startDay = 2;  // Tuesday
extern int    endTime = 19;  
extern int    endDay = 5;    //  Close all orders at the end of Friday


extern int    stopLoss = 100;
extern double lots = 0.1;
extern int    breakEven = 0;
extern int    magicNumber= 2007411;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {
//----
    
    if(DayOfWeek()==startDay && TimeCurrent() > StrToTime(startTime+":00")
      && TimeCurrent()< StrToTime(startTime+":10")
      )
    {
    
     if(currentOrders_By_Type(OP_BUYSTOP)==0)  // Send BuyStop order
     {


   double sellPrice = NormalizeDouble(Bid - 50*Point,Digits);
        double sellStopPrice = NormalizeDouble(sellPrice + stopLoss*Point,Digits);
     
         OrderSend(Symbol(),OP_SELLSTOP,lots,sellPrice,3,sellStopPrice,0,"weekly breakout 1.0",magicNumber,0,Yellow);        
   /*     
        double buyPrice  =  NormalizeDouble(Ask + 50*Point,Digits);
        double buyStopPrice =  NormalizeDouble(buyPrice - stopLoss*Point,Digits);
        
        
        OrderSend(Symbol(),OP_BUYSTOP,lots,buyPrice,3,buyStopPrice,0,"weekly breakout 1.0",magicNumber,0,Green);
        
     */   
        
        
     }
     if(currentOrders_By_Type(OP_SELLSTOP)==0) 
     {
     
        double buyPrice  =  NormalizeDouble(Ask + 50*Point,Digits);
        double buyStopPrice =  NormalizeDouble(buyPrice - stopLoss*Point,Digits);
        
        
        OrderSend(Symbol(),OP_BUYSTOP,lots,buyPrice,3,buyStopPrice,0,"weekly breakout 1.0",magicNumber,0,Green);
     
     
     
    /*   
        double sellPrice = NormalizeDouble(Bid - 50*Point,Digits);
        double sellStopPrice = NormalizeDouble(sellPrice + stopLoss*Point,Digits);
     
         OrderSend(Symbol(),OP_SELLSTOP,lots,sellPrice,3,sellStopPrice,0,"weekly breakout 1.0",magicNumber,0,Yellow);
     */
     }
     
    
    }
    
    
    if(breakEven > 0)  moveToBreakeven();
    
    if(DayOfWeek()==endDay && TimeCurrent()>=StrToTime(endTime+":00")&& TimeCurrent()<=StrToTime(endTime+":10")) 
    {
    
     closeAll();
    
    }
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

int currentOrders_By_Type(int type)
  {
   int cur_orders = 0;

   for(int i=0;i<OrdersTotal();i++)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
      if(OrderSymbol()==Symbol() && OrderMagicNumber()==magicNumber && OrderType()==type)
        {
          cur_orders++;
        }
     }
    
    return(cur_orders);
}


void closeAll(){


    for(int i=0; i<OrdersTotal();i++)
    {
    
     if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
     if(OrderSymbol() == Symbol() && OrderMagicNumber() == magicNumber)
     {
        
           
           
           if(OrderType()==OP_BUY)  
           {
            OrderClose(OrderTicket(),OrderLots(),Bid,3,White);
           }
           else if(OrderType()==OP_SELL) 
           { 
            OrderClose(OrderTicket(),OrderLots(),Ask,3,White);
           }
           else
           {
            OrderDelete(OrderTicket());
           }    
           
     }
    
   }//end for

}// end closeAll

void moveToBreakeven()
{
   for (int i=0;i<OrdersTotal();i++)
   { 
   if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
  
      if ( OrderSymbol()==Symbol() && OrderMagicNumber()==magicNumber) 
      {
         if (OrderType()==OP_BUY) 
         {
		
			 if ( breakEven > 0 && Bid-OrderOpenPrice()> breakEven*Point && OrderOpenPrice()!= OrderStopLoss() )    
			 {
			    OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Orange);
			 }
         
         }//end buy   

         if (OrderType()==OP_SELL)
         {
          if ( breakEven > 0 && OrderOpenPrice()-Ask>breakEven*Point && OrderOpenPrice()!= OrderStopLoss())  
          {
              OrderModify(OrderTicket(), OrderOpenPrice(),OrderOpenPrice(),OrderTakeProfit(),0,Orange);
          } 
            
         }//end sell
      }
   
   
   }//end for     



}// end trailing

Profitability Reports

USD/JPY Jul 2025 - Sep 2025
0.00
Total Trades 945
Won Trades 0
Lost trades 945
Win Rate 0.00 %
Expected payoff -6.79
Gross Profit 0.00
Gross Loss -6419.19
Total Net Profit -6419.19
-100%
-50%
0%
50%
100%
USD/CHF Jul 2025 - Sep 2025
0.00
Total Trades 437
Won Trades 0
Lost trades 437
Win Rate 0.00 %
Expected payoff -9.64
Gross Profit 0.00
Gross Loss -4211.30
Total Net Profit -4211.30
-100%
-50%
0%
50%
100%
USD/CAD Jul 2025 - Sep 2025
0.00
Total Trades 1003
Won Trades 33
Lost trades 970
Win Rate 3.29 %
Expected payoff -6.29
Gross Profit 7.71
Gross Loss -6318.18
Total Net Profit -6310.47
-100%
-50%
0%
50%
100%
NZD/USD Jul 2025 - Sep 2025
0.00
Total Trades 815
Won Trades 0
Lost trades 815
Win Rate 0.00 %
Expected payoff -9.39
Gross Profit 0.00
Gross Loss -7649.90
Total Net Profit -7649.90
-100%
-50%
0%
50%
100%
GBP/USD Jul 2025 - Sep 2025
0.12
Total Trades 392
Won Trades 189
Lost trades 203
Win Rate 48.21 %
Expected payoff -3.72
Gross Profit 207.80
Gross Loss -1666.40
Total Net Profit -1458.60
-100%
-50%
0%
50%
100%
GBP/AUD Jul 2025 - Sep 2025
0.00
Total Trades 1479
Won Trades 0
Lost trades 1479
Win Rate 0.00 %
Expected payoff -6.61
Gross Profit 0.00
Gross Loss -9779.61
Total Net Profit -9779.61
-100%
-50%
0%
50%
100%
EUR/USD Jul 2025 - Sep 2025
0.22
Total Trades 993
Won Trades 69
Lost trades 924
Win Rate 6.95 %
Expected payoff -6.44
Gross Profit 1855.60
Gross Loss -8254.30
Total Net Profit -6398.70
-100%
-50%
0%
50%
100%
AUD/USD Jul 2025 - Sep 2025
0.00
Total Trades 791
Won Trades 0
Lost trades 791
Win Rate 0.00 %
Expected payoff -7.92
Gross Profit 0.00
Gross Loss -6262.20
Total Net Profit -6262.20
-100%
-50%
0%
50%
100%
USD/JPY Jan 2025 - Jul 2025
0.00
Total Trades 802
Won Trades 0
Lost trades 802
Win Rate 0.00 %
Expected payoff -4.96
Gross Profit 0.00
Gross Loss -3980.70
Total Net Profit -3980.70
-100%
-50%
0%
50%
100%
USD/CHF Jan 2025 - Jul 2025
0.68
Total Trades 936
Won Trades 165
Lost trades 771
Win Rate 17.63 %
Expected payoff -2.95
Gross Profit 5974.61
Gross Loss -8732.29
Total Net Profit -2757.68
-100%
-50%
0%
50%
100%

Comments